Skip to content

Commit

Permalink
adding fixIndex() method
Browse files Browse the repository at this point in the history
  • Loading branch information
jprante authored and kimchy committed Apr 27, 2012
1 parent cd79f03 commit 9555759
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -114,6 +114,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I


private final boolean checkIndexOnStartup;

private final boolean fixIndexOnStartup;

private long checkIndexTook = 0;

Expand Down Expand Up @@ -163,6 +165,7 @@ public InternalIndexShard(ShardId shardId, @IndexSettings Settings indexSettings
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() {
Expand Down Expand Up @@ -866,6 +869,15 @@ private void checkIndex(boolean throwException) throws IndexShardException {
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) {
Expand Down

0 comments on commit 9555759

Please sign in to comment.