speed up directory wrapping

This commit is contained in:
Robert Muir 2015-04-17 17:12:55 -04:00
parent a985c972f2
commit c7c4045e19
1 changed files with 7 additions and 4 deletions

View File

@ -45,7 +45,6 @@ import java.util.Set;
public class MockDirectoryHelper {
public static final String RANDOM_IO_EXCEPTION_RATE = "index.store.mock.random.io_exception_rate";
public static final String RANDOM_IO_EXCEPTION_RATE_ON_OPEN = "index.store.mock.random.io_exception_rate_on_open";
public static final String RANDOM_THROTTLE = "index.store.mock.random.throttle";
public static final String RANDOM_PREVENT_DOUBLE_WRITE = "index.store.mock.random.prevent_double_write";
public static final String RANDOM_NO_DELETE_OPEN_FILE = "index.store.mock.random.no_delete_open_file";
public static final String CRASH_INDEX = "index.store.mock.random.crash_index";
@ -70,7 +69,7 @@ public class MockDirectoryHelper {
preventDoubleWrite = indexSettings.getAsBoolean(RANDOM_PREVENT_DOUBLE_WRITE, true); // true is default in MDW
noDeleteOpenFile = indexSettings.getAsBoolean(RANDOM_NO_DELETE_OPEN_FILE, random.nextBoolean()); // true is default in MDW
random.nextInt(shardId.getId() + 1); // some randomness per shard
throttle = Throttling.valueOf(indexSettings.get(RANDOM_THROTTLE, random.nextDouble() < 0.1 ? "SOMETIMES" : "NEVER"));
throttle = Throttling.NEVER;
crashIndex = indexSettings.getAsBoolean(CRASH_INDEX, true);
if (logger.isDebugEnabled()) {
@ -92,6 +91,7 @@ public class MockDirectoryHelper {
// TODO: make this test robust to virus scanner
w.setEnableVirusScanner(false);
w.setNoDeleteOpenFile(noDeleteOpenFile);
w.setUseSlowOpenClosers(false);
wrappers.add(w);
return w;
}
@ -115,7 +115,10 @@ public class MockDirectoryHelper {
case 1:
return new MmapFsDirectoryService(shardId, indexSettings, indexStore);
case 0:
if (random.nextInt(10) == 0) {
// use simplefs less, it synchronizes all threads reads
return new SimpleFsDirectoryService(shardId, indexSettings, indexStore);
}
default:
return new NioFsDirectoryService(shardId, indexSettings, indexStore);
}
@ -184,7 +187,7 @@ public class MockDirectoryHelper {
@Override
public synchronized void sync(Collection<String> names) throws IOException {
// don't wear out our hardware so much in tests.
if (LuceneTestCase.rarely(superRandomState) || mustSync()) {
if (superRandomState.nextInt(100) == 0 || mustSync()) {
super.sync(names);
} else {
superUnSyncedFiles.removeAll(names);