Skip to content

Commit

Permalink
Use Version.indexCreated instead of manually parsing version
Browse files Browse the repository at this point in the history
  • Loading branch information
dakrone committed May 28, 2015
1 parent a8543d3 commit e154495
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/main/java/org/elasticsearch/index/engine/InternalEngine.java
Expand Up @@ -31,6 +31,7 @@
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchIllegalStateException;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.routing.operation.hash.djb.DjbHashFunction;
import org.elasticsearch.common.Nullable;
Expand Down Expand Up @@ -119,17 +120,13 @@ public InternalEngine(EngineConfig engineConfig) throws EngineException {
boolean success = false;
try {
try {
String version = engineConfig.getIndexSettings().get("index.version.created");
boolean autoUpgrade = true;
if (version != null) {
try {
// If the index was created on 0.20.7 (Lucene 3.x) or earlier,
// it needs to be upgraded
try {
int versionNum = Integer.parseInt(version);
autoUpgrade = Version.fromId(versionNum).onOrBefore(Version.V_0_20_7);
} catch (NumberFormatException e) {
// we weren't able to parse the version, that's fine
}
autoUpgrade = Version.indexCreated(engineConfig.getIndexSettings()).onOrBefore(Version.V_0_20_7);
} catch (ElasticsearchIllegalStateException e) {
// we weren't able to parse the version, that's fine
}
if (autoUpgrade) {
logger.debug("[{}] checking for 3x segments to upgrade", shardId);
Expand Down

0 comments on commit e154495

Please sign in to comment.