delete files that are no longer used from the fs gateway
This commit is contained in:
parent
729baa6859
commit
290ecd4c95
|
@ -70,11 +70,11 @@ public class FsIndexShardGateway extends AbstractIndexShardComponent implements
|
||||||
|
|
||||||
private final File locationTranslog;
|
private final File locationTranslog;
|
||||||
|
|
||||||
private long lastIndexVersion;
|
private volatile long lastIndexVersion;
|
||||||
|
|
||||||
private long lastTranslogId = -1;
|
private volatile long lastTranslogId = -1;
|
||||||
|
|
||||||
private int lastTranslogSize;
|
private volatile int lastTranslogSize;
|
||||||
|
|
||||||
private RandomAccessFile translogFile;
|
private RandomAccessFile translogFile;
|
||||||
|
|
||||||
|
@ -237,6 +237,23 @@ public class FsIndexShardGateway extends AbstractIndexShardComponent implements
|
||||||
new File(locationTranslog, "translog-" + lastTranslogId).delete();
|
new File(locationTranslog, "translog-" + lastTranslogId).delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete files that no longer exists in the index
|
||||||
|
if (indexDirty) {
|
||||||
|
File[] existingFiles = locationIndex.listFiles();
|
||||||
|
for (File existingFile : existingFiles) {
|
||||||
|
boolean found = false;
|
||||||
|
for (final String fileName : snapshotIndexCommit.getFiles()) {
|
||||||
|
if (existingFile.getName().equals(fileName)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
existingFile.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
lastIndexVersion = snapshotIndexCommit.getVersion();
|
lastIndexVersion = snapshotIndexCommit.getVersion();
|
||||||
lastTranslogId = translogSnapshot.translogId();
|
lastTranslogId = translogSnapshot.translogId();
|
||||||
|
|
Loading…
Reference in New Issue