You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2014/06/03 08:21:15 UTC
svn commit: r1599422 - in /lucene/dev/trunk/solr/core/src:
java/org/apache/solr/handler/SnapShooter.java
test/org/apache/solr/handler/TestReplicationHandler.java
Author: dweiss
Date: Tue Jun 3 06:21:14 2014
New Revision: 1599422
URL: http://svn.apache.org/r1599422
Log:
SOLR-6119: TestReplicationHandler attempts to remove open folders (and other fixes).
Modified:
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/SnapShooter.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/SnapShooter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/SnapShooter.java?rev=1599422&r1=1599421&r2=1599422&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/SnapShooter.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/SnapShooter.java Tue Jun 3 06:21:14 2014
@@ -118,13 +118,12 @@ public class SnapShooter {
}
void validateCreateSnapshot() throws IOException {
-
Lock lock = lockFactory.makeLock(directoryName + ".lock");
+ snapShotDir = new File(snapDir, directoryName);
if (lock.isLocked()) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Unable to acquire lock for snapshot directory: " + snapShotDir.getAbsolutePath());
}
- snapShotDir = new File(snapDir, directoryName);
if (snapShotDir.exists()) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Snapshot directory already exists: " + snapShotDir.getAbsolutePath());
@@ -198,7 +197,7 @@ public class SnapShooter {
LOG.info("Deleting snapshot: " + snapshotName);
NamedList<Object> details = new NamedList<>();
- boolean isSuccess = false;
+ boolean isSuccess;
File f = new File(snapDir, "snapshot." + snapshotName);
isSuccess = SnapPuller.delTree(f);
@@ -236,7 +235,6 @@ public class SnapShooter {
}
}
- public static final String SNAP_DIR = "snapDir";
public static final String DATE_FMT = "yyyyMMddHHmmssSSS";
@@ -271,6 +269,4 @@ public class SnapShooter {
sourceDir.copy(destDir, indexFile, indexFile, DirectoryFactory.IOCONTEXT_NO_CACHE);
}
}
-
-
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java?rev=1599422&r1=1599421&r2=1599422&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java Tue Jun 3 06:21:14 2014
@@ -1444,9 +1444,10 @@ public class TestReplicationHandler exte
};
File[] snapDir = new File[2];
+ boolean namedBackup = random().nextBoolean();
try {
String firstBackupTimestamp = null;
- boolean namedBackup = true;
+
String[] backupNames = null;
if (namedBackup) {
backupNames = new String[2];
@@ -1503,7 +1504,7 @@ public class TestReplicationHandler exte
files = dataDir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
- if (name.startsWith("snapshot." + backupName)) {
+ if (name.equals("snapshot." + backupName)) {
return true;
}
return false;
@@ -1520,49 +1521,46 @@ public class TestReplicationHandler exte
reader.close();
dir.close();
- if (!namedBackup && snapDir[0].exists()) {
- fail("The first backup should have been cleaned up because " + backupKeepParamName + " was set to 1.");
- }
}
- for (int i = 0; i < 2; i++) {
- //Test Deletion of named backup
- BackupThread deleteBackupThread = new BackupThread(backupNames[i], ReplicationHandler.CMD_DELETE_BACKUP);
- deleteBackupThread.start();
- int waitCnt = 0;
- CheckDeleteBackupStatus checkDeleteBackupStatus = new CheckDeleteBackupStatus();
- while (true) {
- checkDeleteBackupStatus.fetchStatus();
- if (checkDeleteBackupStatus.fail != null) {
- fail(checkDeleteBackupStatus.fail);
- }
- if (checkDeleteBackupStatus.success) {
- break;
- }
- Thread.sleep(200);
- if (waitCnt == 20) {
- fail("Delete Backup success not detected:" + checkDeleteBackupStatus.response);
+ if (!namedBackup && snapDir[0].exists()) {
+ fail("The first backup should have been cleaned up because " + backupKeepParamName + " was set to 1.");
+ }
+
+ //Test Deletion of named backup
+ if(namedBackup) {
+ for (int i = 0; i < 2; i++) {
+ BackupThread deleteBackupThread = new BackupThread(backupNames[i], ReplicationHandler.CMD_DELETE_BACKUP);
+ deleteBackupThread.start();
+ int waitCnt = 0;
+ CheckDeleteBackupStatus checkDeleteBackupStatus = new CheckDeleteBackupStatus();
+ while (true) {
+ checkDeleteBackupStatus.fetchStatus();
+ if (checkDeleteBackupStatus.fail != null) {
+ fail(checkDeleteBackupStatus.fail);
+ }
+ if (checkDeleteBackupStatus.success) {
+ break;
+ }
+ Thread.sleep(200);
+ if (waitCnt == 20) {
+ fail("Delete Backup success not detected:" + checkDeleteBackupStatus.response);
+ }
+ waitCnt++;
}
- waitCnt++;
- }
- if (deleteBackupThread.fail != null) {
- fail(deleteBackupThread.fail);
+ if (deleteBackupThread.fail != null) {
+ fail(deleteBackupThread.fail);
+ }
}
}
+
} finally {
- // FIXME: SOLR-6119 This is a test bug in that it tries to remove snapDirs that are still open.
- try {
+ if(!namedBackup) {
TestUtil.rm(snapDir);
- } catch (IOException e) {
- // Ignore failures.
}
- }
- }
- /* character copy of file using UTF-8 */
- private static void copyFile(File src, File dst) throws IOException {
- copyFile(src, dst, null, false);
+ }
}
/**