Delegate write.lock to primary directory

This commit is contained in:
Simon Willnauer 2014-10-27 20:03:36 +01:00
parent f5b2dfd052
commit d6ae832c90
2 changed files with 3 additions and 2 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.index.store; package org.elasticsearch.index.store;
import org.apache.lucene.index.IndexFileNames; import org.apache.lucene.index.IndexFileNames;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.*; import org.apache.lucene.store.*;
import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IOUtils;
import org.elasticsearch.common.math.MathUtils; import org.elasticsearch.common.math.MathUtils;
@ -148,7 +149,7 @@ public final class DistributorDirectory extends BaseDirectory {
* Returns true if the primary directory should be used for the given file. * Returns true if the primary directory should be used for the given file.
*/ */
private boolean usePrimary(String name) { private boolean usePrimary(String name) {
return IndexFileNames.SEGMENTS_GEN.equals(name) || Store.isChecksum(name); return IndexFileNames.SEGMENTS_GEN.equals(name) || Store.isChecksum(name) || IndexWriter.WRITE_LOCK_NAME.equals(name);
} }
/** /**

View File

@ -507,7 +507,7 @@ public class StoreTest extends ElasticsearchLuceneTestCase {
} }
public void assertDeleteContent(Store store,DirectoryService service) throws IOException { public void assertDeleteContent(Store store, DirectoryService service) throws IOException {
store.deleteContent(); store.deleteContent();
assertThat(Arrays.toString(store.directory().listAll()), store.directory().listAll().length, equalTo(0)); assertThat(Arrays.toString(store.directory().listAll()), store.directory().listAll().length, equalTo(0));
assertThat(store.stats().sizeInBytes(), equalTo(0l)); assertThat(store.stats().sizeInBytes(), equalTo(0l));