Remove now unused Store.renameFile, and obsolete commented out code

This commit is contained in:
Mike McCandless 2016-08-24 18:20:30 -04:00
parent 0ccfe69789
commit 7492300544
4 changed files with 2 additions and 51 deletions

View File

@ -298,12 +298,6 @@ public class Store extends AbstractIndexShardComponent implements Closeable, Ref
return statsCache.getOrRefresh();
}
public void renameFile(String from, String to) throws IOException {
ensureOpen();
// TODO: switch to directory.rename? but caller needs to syncMetaData!
directory.renameFile(from, to);
}
/**
* Increments the refCount of this Store instance. RefCounts are used to determine when a
* Store can be closed safely, i.e. as soon as there are no more references. Be sure to always call a

View File

@ -1638,7 +1638,8 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
stream = new RateLimitingInputStream(partSliceStream, restoreRateLimiter, restoreRateLimitingTimeInNanos::inc);
}
// TODO: why does the target file sometimes already exist?
// TODO: why does the target file sometimes already exist? Simon says: I think, this can happen if you fail a shard and
// it's not cleaned up yet, the restore process tries to reuse files
IOUtils.deleteFilesIgnoringExceptions(store.directory(), fileInfo.physicalName());
try (final IndexOutput indexOutput = store.createVerifyingOutput(fileInfo.physicalName(), fileInfo.metadata(), IOContext.DEFAULT)) {

View File

@ -354,49 +354,6 @@ public class StoreTests extends ESTestCase {
IOUtils.close(store);
}
public void testRenameFile() throws IOException {
final ShardId shardId = new ShardId("index", "_na_", 1);
DirectoryService directoryService = new LuceneManagedDirectoryService(random(), false);
Store store = new Store(shardId, INDEX_SETTINGS, directoryService, new DummyShardLock(shardId));
{
IndexOutput output = store.directory().createOutput("foo.bar", IOContext.DEFAULT);
int iters = scaledRandomIntBetween(10, 100);
for (int i = 0; i < iters; i++) {
BytesRef bytesRef = new BytesRef(TestUtil.randomRealisticUnicodeString(random(), 10, 1024));
output.writeBytes(bytesRef.bytes, bytesRef.offset, bytesRef.length);
}
CodecUtil.writeFooter(output);
output.close();
}
store.renameFile("foo.bar", "bar.foo");
assertThat(numNonExtraFiles(store), is(1));
final long lastChecksum;
try (IndexInput input = store.directory().openInput("bar.foo", IOContext.DEFAULT)) {
lastChecksum = CodecUtil.checksumEntireFile(input);
}
try {
store.directory().openInput("foo.bar", IOContext.DEFAULT);
fail("file was renamed");
} catch (FileNotFoundException | NoSuchFileException ex) {
// expected
}
{
IndexOutput output = store.directory().createOutput("foo.bar", IOContext.DEFAULT);
int iters = scaledRandomIntBetween(10, 100);
for (int i = 0; i < iters; i++) {
BytesRef bytesRef = new BytesRef(TestUtil.randomRealisticUnicodeString(random(), 10, 1024));
output.writeBytes(bytesRef.bytes, bytesRef.offset, bytesRef.length);
}
CodecUtil.writeFooter(output);
output.close();
}
store.renameFile("foo.bar", "bar2.foo");
assertThat(numNonExtraFiles(store), is(2));
assertDeleteContent(store, directoryService);
IOUtils.close(store);
}
public void testCheckIntegrity() throws IOException {
Directory dir = newDirectory();
long luceneFileLength = 0;

View File

@ -172,7 +172,6 @@ public class MockFSDirectoryService extends FsDirectoryService {
w.setRandomIOExceptionRateOnOpen(randomIOExceptionRateOnOpen);
w.setThrottling(throttle);
w.setCheckIndexOnClose(false); // we do this on the index level
//w.setPreventDoubleWrite(preventDoubleWrite);
// TODO: make this test robust to virus scanner
w.setAssertNoDeleteOpenFile(false);
w.setUseSlowOpenClosers(false);