apply review comments

This commit is contained in:
Simon Willnauer 2015-10-08 14:22:21 +02:00
parent dee94c798c
commit 50907d5b7d
3 changed files with 14 additions and 19 deletions

View File

@ -166,7 +166,7 @@ public class MetaDataIndexUpgradeService extends AbstractComponent {
/**
* Elasticsearch 3.0 no longer supports indices with pre Lucene v5.0 (Elasticsearch v2.0.0.beta1) segments. All indices
* that were created before Elasticsearch v2.0.0.beta1 should be upgraded using upgrade plugin before they can
* that were created before Elasticsearch v2.0.0.beta1 should be upgraded using upgrade API before they can
* be open by this version of elasticsearch.
*/
private void checkSupportedVersion(IndexMetaData indexMetaData) {
@ -185,10 +185,6 @@ public class MetaDataIndexUpgradeService extends AbstractComponent {
// The index was created with elasticsearch that was using Lucene 5.2.1
return true;
}
if (indexMetaData.getUpgradeVersion().onOrAfter(Version.V_2_0_0_beta1) == false) {
// early terminate if we are not upgrade - we don't even need to look at the segment version
return false;
}
if (indexMetaData.getMinimumCompatibleVersion() != null &&
indexMetaData.getMinimumCompatibleVersion().onOrAfter(org.apache.lucene.util.Version.LUCENE_5_0_0)) {
//The index was upgraded we can work with it

View File

@ -172,21 +172,12 @@ public class InternalEngine extends Engine {
}
private Translog openTranslog(EngineConfig engineConfig, IndexWriter writer, boolean createNew) throws IOException {
final Translog.TranslogGeneration generation = loadTranslogIdFromCommit(writer);
final Translog.TranslogGeneration generation = loadTranslogIdFromCommit(writer, createNew);
final TranslogConfig translogConfig = engineConfig.getTranslogConfig();
if (createNew == false) {
// We expect that this shard already exists, so it must already have an existing translog else something is badly wrong!
if (generation == null) {
throw new IllegalStateException("no translog generation present in commit data but translog is expected to exist");
}
translogConfig.setTranslogGeneration(generation);
if (generation != null && generation.translogUUID == null) {
throw new IndexFormatTooOldException("trasnlog", "translog has no generation nor a UUID - this might be an index from a previous version consider upgrading to N-1 first");
}
}
translogConfig.setTranslogGeneration(generation);
final Translog translog = new Translog(translogConfig);
if (generation == null || generation.translogUUID == null) {
assert createNew;
if (generation == null) {
logger.debug("no translog ID present in the current generation - creating one");
} else if (generation.translogUUID == null) {
@ -249,7 +240,7 @@ public class InternalEngine extends Engine {
* translog id into lucene and returns null.
*/
@Nullable
private Translog.TranslogGeneration loadTranslogIdFromCommit(IndexWriter writer) throws IOException {
private Translog.TranslogGeneration loadTranslogIdFromCommit(IndexWriter writer, boolean createNew) throws IOException {
// commit on a just opened writer will commit even if there are no changes done to it
// we rely on that for the commit data translog id key
final Map<String, String> commitUserData = writer.getCommitData();
@ -262,8 +253,16 @@ public class InternalEngine extends Engine {
}
final String translogUUID = commitUserData.get(Translog.TRANSLOG_UUID_KEY);
final long translogGen = Long.parseLong(commitUserData.get(Translog.TRANSLOG_GENERATION_KEY));
if (createNew == false && translogUUID == null) {
throw new IndexFormatTooOldException("translog", "translog has no generation nor a UUID - this might be an index from a previous version consider upgrading to N-1 first");
}
return new Translog.TranslogGeneration(translogUUID, translogGen);
}
if (createNew == false) {
// We expect that this shard already exists, so it must already have an existing translog else something is badly wrong!
throw new IllegalStateException("no translog generation present in commit data but translog is expected to exist");
}
return null;
}

View File

@ -705,7 +705,7 @@ public class ExceptionSerializationTests extends ESTestCase {
ids.put(61, org.elasticsearch.cluster.routing.RoutingValidationException.class);
ids.put(62, org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper.class);
ids.put(63, org.elasticsearch.indices.AliasFilterParsingException.class);
ids.put(64, org.elasticsearch.index.engine.DeleteByQueryFailedEngineException.class);
ids.put(64, null); // DeleteByQueryFailedEngineException was removed in 3.0
ids.put(65, org.elasticsearch.gateway.GatewayException.class);
ids.put(66, org.elasticsearch.index.shard.IndexShardNotRecoveringException.class);
ids.put(67, org.elasticsearch.http.HttpException.class);