|
25 | 25 | import org.apache.lucene.document.SortedDocValuesField; |
26 | 26 | import org.apache.lucene.document.StringField; |
27 | 27 | import org.apache.lucene.document.TextField; |
28 | | -import org.apache.lucene.index.CheckIndex; |
29 | 28 | import org.apache.lucene.index.CorruptIndexException; |
30 | 29 | import org.apache.lucene.index.DirectoryReader; |
31 | 30 | import org.apache.lucene.index.IndexFileNames; |
|
47 | 46 | import org.apache.lucene.store.IOContext; |
48 | 47 | import org.apache.lucene.store.IndexInput; |
49 | 48 | import org.apache.lucene.store.IndexOutput; |
50 | | -import org.apache.lucene.store.Lock; |
51 | | -import org.apache.lucene.store.LockObtainFailedException; |
52 | 49 | import org.apache.lucene.store.RAMDirectory; |
53 | 50 | import org.apache.lucene.util.BytesRef; |
54 | 51 | import org.apache.lucene.util.IOUtils; |
|
57 | 54 | import org.elasticsearch.ExceptionsHelper; |
58 | 55 | import org.elasticsearch.cluster.metadata.IndexMetaData; |
59 | 56 | import org.elasticsearch.common.UUIDs; |
60 | | -import org.elasticsearch.common.io.stream.BytesStreamOutput; |
61 | 57 | import org.elasticsearch.common.io.stream.InputStreamStreamInput; |
62 | 58 | import org.elasticsearch.common.io.stream.OutputStreamStreamOutput; |
63 | 59 | import org.elasticsearch.common.lucene.Lucene; |
|
79 | 75 | import java.io.ByteArrayOutputStream; |
80 | 76 | import java.io.FileNotFoundException; |
81 | 77 | import java.io.IOException; |
82 | | -import java.io.PrintStream; |
83 | | -import java.nio.charset.StandardCharsets; |
84 | 78 | import java.nio.file.NoSuchFileException; |
85 | 79 | import java.nio.file.Path; |
86 | 80 | import java.util.ArrayList; |
@@ -1077,32 +1071,4 @@ public Directory newDirectory() throws IOException { |
1077 | 1071 | store.close(); |
1078 | 1072 | } |
1079 | 1073 |
|
1080 | | - public void testCheckIndex() throws Exception { |
1081 | | - final ShardId shardId = new ShardId("index", "_na_", 1); |
1082 | | - final Store store = new Store(shardId, INDEX_SETTINGS, new LuceneManagedDirectoryService(random()), new DummyShardLock(shardId)); |
1083 | | - try (IndexWriter writer = new IndexWriter(store.directory(), newIndexWriterConfig())) { |
1084 | | - writer.commit(); |
1085 | | - } |
1086 | | - // Check index does not need to lock the store directory |
1087 | | - try (Lock directoryLock = store.directory().obtainLock(IndexWriter.WRITE_LOCK_NAME)) { |
1088 | | - BytesStreamOutput os = new BytesStreamOutput(); |
1089 | | - PrintStream out = new PrintStream(os, false, StandardCharsets.UTF_8.name()); |
1090 | | - assertThat(store.checkIndex(out).clean, equalTo(true)); |
1091 | | - } |
1092 | | - // exorciseIndex requires directory lock |
1093 | | - try (Lock directoryLock = store.directory().obtainLock(IndexWriter.WRITE_LOCK_NAME)) { |
1094 | | - BytesStreamOutput os = new BytesStreamOutput(); |
1095 | | - PrintStream out = new PrintStream(os, false, StandardCharsets.UTF_8.name()); |
1096 | | - assertThat(store.checkIndex(out).clean, equalTo(true)); |
1097 | | - final CheckIndex.Status status = store.checkIndex(out); |
1098 | | - try { |
1099 | | - store.exorciseIndex(status); |
1100 | | - fail("exorciseIndex should acquire directory lock"); |
1101 | | - } catch (LockObtainFailedException ignore) { |
1102 | | - |
1103 | | - } |
1104 | | - } |
1105 | | - store.close(); |
1106 | | - } |
1107 | | - |
1108 | 1074 | } |
0 commit comments