|
35 | 35 | import org.elasticsearch.cluster.routing.UnassignedInfo;
|
36 | 36 | import org.elasticsearch.cluster.service.ClusterService;
|
37 | 37 | import org.elasticsearch.common.Strings;
|
38 |
| -import org.elasticsearch.common.UUIDs; |
39 | 38 | import org.elasticsearch.common.settings.Settings;
|
40 | 39 | import org.elasticsearch.common.xcontent.XContentFactory;
|
41 | 40 | import org.elasticsearch.env.NodeEnvironment;
|
|
47 | 46 | import org.elasticsearch.index.query.QueryBuilders;
|
48 | 47 | import org.elasticsearch.index.shard.ShardId;
|
49 | 48 | import org.elasticsearch.index.shard.ShardPath;
|
50 |
| -import org.elasticsearch.index.store.Store; |
51 | 49 | import org.elasticsearch.indices.IndicesService;
|
52 | 50 | import org.elasticsearch.indices.recovery.RecoveryState;
|
53 | 51 | import org.elasticsearch.plugins.Plugin;
|
|
58 | 56 | import org.elasticsearch.test.InternalTestCluster.RestartCallback;
|
59 | 57 | import org.elasticsearch.test.store.MockFSIndexStore;
|
60 | 58 |
|
| 59 | +import java.nio.file.DirectoryStream; |
61 | 60 | import java.nio.file.Files;
|
62 | 61 | import java.nio.file.Path;
|
63 |
| -import java.nio.file.StandardOpenOption; |
64 | 62 | import java.util.Arrays;
|
65 | 63 | import java.util.Collection;
|
66 | 64 | import java.util.Collections;
|
@@ -560,14 +558,19 @@ public Settings onNodeStopped(String nodeName) throws Exception {
|
560 | 558 | });
|
561 | 559 |
|
562 | 560 | if (corrupt) {
|
563 |
| - // TODO NORELEASE revert this change when Store#tryOpenIndex is fixed |
564 | 561 | for (Path path : internalCluster().getInstance(NodeEnvironment.class, nodeName).availableShardPaths(shardId)) {
|
565 | 562 | final Path indexPath = path.resolve(ShardPath.INDEX_FOLDER_NAME);
|
566 | 563 | if (Files.exists(indexPath)) { // multi data path might only have one path in use
|
567 |
| - final Path markerPath = indexPath.resolve(Store.CORRUPTED_MARKER_NAME_PREFIX + UUIDs.randomBase64UUID(random())); |
568 |
| - logger.info("writing corruption marker at [{}]", markerPath); |
569 |
| - Files.write(markerPath, new byte[0], StandardOpenOption.CREATE_NEW); |
| 564 | + try (DirectoryStream<Path> stream = Files.newDirectoryStream(indexPath)) { |
| 565 | + for (Path item : stream) { |
| 566 | + if (item.getFileName().toString().startsWith("segments_")) { |
| 567 | + logger.debug("--> deleting [{}]", item); |
| 568 | + Files.delete(item); |
| 569 | + } |
| 570 | + } |
| 571 | + } |
570 | 572 | }
|
| 573 | + |
571 | 574 | }
|
572 | 575 | }
|
573 | 576 |
|
|
0 commit comments