mirror of https://github.com/apache/lucene.git
SOLR-6119: TestReplicationHandler attempts to remove open folders (and other fixes).
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1599422 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
151033cdc1
commit
bb9116c485
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1444,9 +1444,10 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
|
|||
};
|
||||
|
||||
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 extends SolrTestCaseJ4 {
|
|||
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,13 +1521,15 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
|
|||
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
|
||||
if(namedBackup) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
BackupThread deleteBackupThread = new BackupThread(backupNames[i], ReplicationHandler.CMD_DELETE_BACKUP);
|
||||
deleteBackupThread.start();
|
||||
int waitCnt = 0;
|
||||
|
@ -1550,19 +1553,14 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
|
|||
fail(deleteBackupThread.fail);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
// FIXME: SOLR-6119 This is a test bug in that it tries to remove snapDirs that are still open.
|
||||
try {
|
||||
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);
|
||||
} finally {
|
||||
if(!namedBackup) {
|
||||
TestUtil.rm(snapDir);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue