mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-13 08:25:26 +00:00
adding fixIndex() method
This commit is contained in:
parent
cd79f03977
commit
9555759d33
@ -114,6 +114,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||
|
||||
|
||||
private final boolean checkIndexOnStartup;
|
||||
|
||||
private final boolean fixIndexOnStartup;
|
||||
|
||||
private long checkIndexTook = 0;
|
||||
|
||||
@ -163,6 +165,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||
logger.debug("state: [CREATED]");
|
||||
|
||||
this.checkIndexOnStartup = indexSettings.getAsBoolean("index.shard.check_on_startup", false);
|
||||
this.fixIndexOnStartup = indexSettings.getAsBoolean("index.shard.check_on_startup_and_fix", false);
|
||||
}
|
||||
|
||||
public MergeSchedulerProvider mergeScheduler() {
|
||||
@ -866,6 +869,15 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("check index [success]\n{}", new String(os.underlyingBytes(), 0, os.size()));
|
||||
}
|
||||
if (fixIndexOnStartup) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("fixing index, writing new segments file ...");
|
||||
}
|
||||
checkIndex.fixIndex(status);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("index fixed, wrote new segments file \"{}\"", status.segmentsFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkIndexTook = System.currentTimeMillis() - time;
|
||||
} catch (Exception e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user