Permalink
Browse files

adding fixIndex() method

  • Loading branch information...
jprante committed Apr 27, 2012
1 parent cd79f03 commit 8ca83860ee093cf20a9ca74ff6d8ad72237ddf02
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java
@@ -114,6 +114,8 @@
private final boolean checkIndexOnStartup;
+
+ private final boolean fixIndexOnStartup;
private long checkIndexTook = 0;
@@ -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() {
@@ -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) {

0 comments on commit 8ca8386

Please sign in to comment.