|
@@ -85,10 +85,6 @@ public class RemoveCorruptedShardDataCommand extends EnvironmentAwareCommand {
|
|
|
private final NamedXContentRegistry namedXContentRegistry;
|
|
|
|
|
|
public RemoveCorruptedShardDataCommand() {
|
|
|
- this(false);
|
|
|
- }
|
|
|
-
|
|
|
- public RemoveCorruptedShardDataCommand(boolean translogOnly) {
|
|
|
super("Removes corrupted shard files");
|
|
|
|
|
|
folderOption = parser.acceptsAll(Arrays.asList("d", "dir"),
|
|
@@ -104,18 +100,13 @@ public class RemoveCorruptedShardDataCommand extends EnvironmentAwareCommand {
|
|
|
|
|
|
namedXContentRegistry = new NamedXContentRegistry(ClusterModule.getNamedXWriteables());
|
|
|
|
|
|
- removeCorruptedLuceneSegmentsAction = translogOnly ? null : new RemoveCorruptedLuceneSegmentsAction();
|
|
|
+ removeCorruptedLuceneSegmentsAction = new RemoveCorruptedLuceneSegmentsAction();
|
|
|
truncateTranslogAction = new TruncateTranslogAction(namedXContentRegistry);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void printAdditionalHelp(Terminal terminal) {
|
|
|
- if (removeCorruptedLuceneSegmentsAction == null) {
|
|
|
- // that's only for 6.x branch for bwc with elasticsearch-translog
|
|
|
- terminal.println("This tool truncates the translog and translog checkpoint files to create a new translog");
|
|
|
- } else {
|
|
|
- terminal.println("This tool attempts to detect and remove unrecoverable corrupted data in a shard.");
|
|
|
- }
|
|
|
+ terminal.println("This tool attempts to detect and remove unrecoverable corrupted data in a shard.");
|
|
|
}
|
|
|
|
|
|
// Visible for testing
|
|
@@ -277,12 +268,6 @@ public class RemoveCorruptedShardDataCommand extends EnvironmentAwareCommand {
|
|
|
terminal.println("");
|
|
|
terminal.println(" WARNING: Elasticsearch MUST be stopped before running this tool.");
|
|
|
terminal.println("");
|
|
|
- // that's only for 6.x branch for bwc with elasticsearch-translog
|
|
|
- if (removeCorruptedLuceneSegmentsAction == null) {
|
|
|
- terminal.println(" This tool is deprecated and will be completely removed in 7.0.");
|
|
|
- terminal.println(" It is replaced by the elasticsearch-shard tool. ");
|
|
|
- terminal.println("");
|
|
|
- }
|
|
|
terminal.println(" Please make a complete backup of your index before using this tool.");
|
|
|
terminal.println("");
|
|
|
terminal.println("-----------------------------------------------------------------------");
|
|
@@ -318,26 +303,21 @@ public class RemoveCorruptedShardDataCommand extends EnvironmentAwareCommand {
|
|
|
// keep the index lock to block any runs of older versions of this tool
|
|
|
try (Lock writeIndexLock = indexDir.obtainLock(IndexWriter.WRITE_LOCK_NAME)) {
|
|
|
////////// Index
|
|
|
- // that's only for 6.x branch for bwc with elasticsearch-translog
|
|
|
- if (removeCorruptedLuceneSegmentsAction != null) {
|
|
|
- terminal.println("");
|
|
|
- terminal.println("Opening Lucene index at " + indexPath);
|
|
|
- terminal.println("");
|
|
|
- try {
|
|
|
- indexCleanStatus = removeCorruptedLuceneSegmentsAction.getCleanStatus(shardPath, indexDir,
|
|
|
- writeIndexLock, printStream, verbose);
|
|
|
- } catch (Exception e) {
|
|
|
- terminal.println(e.getMessage());
|
|
|
- throw e;
|
|
|
- }
|
|
|
-
|
|
|
- terminal.println("");
|
|
|
- terminal.println(" >> Lucene index is " + indexCleanStatus.v1().getMessage() + " at " + indexPath);
|
|
|
- terminal.println("");
|
|
|
- } else {
|
|
|
- indexCleanStatus = Tuple.tuple(CleanStatus.CLEAN, null);
|
|
|
+ terminal.println("");
|
|
|
+ terminal.println("Opening Lucene index at " + indexPath);
|
|
|
+ terminal.println("");
|
|
|
+ try {
|
|
|
+ indexCleanStatus = removeCorruptedLuceneSegmentsAction.getCleanStatus(shardPath, indexDir,
|
|
|
+ writeIndexLock, printStream, verbose);
|
|
|
+ } catch (Exception e) {
|
|
|
+ terminal.println(e.getMessage());
|
|
|
+ throw e;
|
|
|
}
|
|
|
|
|
|
+ terminal.println("");
|
|
|
+ terminal.println(" >> Lucene index is " + indexCleanStatus.v1().getMessage() + " at " + indexPath);
|
|
|
+ terminal.println("");
|
|
|
+
|
|
|
////////// Translog
|
|
|
// as translog relies on data stored in an index commit - we have to have non unrecoverable index to truncate translog
|
|
|
if (indexCleanStatus.v1() != CleanStatus.UNRECOVERABLE) {
|