Skip to content

Commit c311574

Browse files
author
Christoph Büscher
committed
Remove version 6 pre-release constants
1 parent bc95794 commit c311574

File tree

36 files changed

+114
-244
lines changed

36 files changed

+114
-244
lines changed

server/src/main/java/org/elasticsearch/Version.java

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,6 @@ public class Version implements Comparable<Version>, ToXContentFragment {
4646
*/
4747
public static final int V_EMPTY_ID = 0;
4848
public static final Version V_EMPTY = new Version(V_EMPTY_ID, org.apache.lucene.util.Version.LATEST);
49-
public static final int V_6_0_0_alpha1_ID = 6000001;
50-
public static final Version V_6_0_0_alpha1 =
51-
new Version(V_6_0_0_alpha1_ID, org.apache.lucene.util.Version.LUCENE_7_0_0);
52-
public static final int V_6_0_0_alpha2_ID = 6000002;
53-
public static final Version V_6_0_0_alpha2 =
54-
new Version(V_6_0_0_alpha2_ID, org.apache.lucene.util.Version.LUCENE_7_0_0);
55-
public static final int V_6_0_0_beta1_ID = 6000026;
56-
public static final Version V_6_0_0_beta1 =
57-
new Version(V_6_0_0_beta1_ID, org.apache.lucene.util.Version.LUCENE_7_0_0);
58-
public static final int V_6_0_0_beta2_ID = 6000027;
59-
public static final Version V_6_0_0_beta2 =
60-
new Version(V_6_0_0_beta2_ID, org.apache.lucene.util.Version.LUCENE_7_0_0);
61-
public static final int V_6_0_0_rc1_ID = 6000051;
62-
public static final Version V_6_0_0_rc1 =
63-
new Version(V_6_0_0_rc1_ID, org.apache.lucene.util.Version.LUCENE_7_0_0);
64-
public static final int V_6_0_0_rc2_ID = 6000052;
65-
public static final Version V_6_0_0_rc2 =
66-
new Version(V_6_0_0_rc2_ID, org.apache.lucene.util.Version.LUCENE_7_0_1);
6749
public static final int V_6_0_0_ID = 6000099;
6850
public static final Version V_6_0_0 =
6951
new Version(V_6_0_0_ID, org.apache.lucene.util.Version.LUCENE_7_0_1);
@@ -218,18 +200,6 @@ public static Version fromId(int id) {
218200
return V_6_0_1;
219201
case V_6_0_0_ID:
220202
return V_6_0_0;
221-
case V_6_0_0_rc2_ID:
222-
return V_6_0_0_rc2;
223-
case V_6_0_0_beta2_ID:
224-
return V_6_0_0_beta2;
225-
case V_6_0_0_rc1_ID:
226-
return V_6_0_0_rc1;
227-
case V_6_0_0_beta1_ID:
228-
return V_6_0_0_beta1;
229-
case V_6_0_0_alpha2_ID:
230-
return V_6_0_0_alpha2;
231-
case V_6_0_0_alpha1_ID:
232-
return V_6_0_0_alpha1;
233203
case V_EMPTY_ID:
234204
return V_EMPTY;
235205
default:
@@ -429,7 +399,7 @@ public Version minimumCompatibilityVersion() {
429399
return bwcVersion == null ? this : bwcVersion;
430400
}
431401

432-
return Version.min(this, fromId((int) major * 1000000 + 0 * 10000 + 99));
402+
return Version.min(this, fromId(major * 1000000 + 0 * 10000 + 99));
433403
}
434404

435405
/**
@@ -442,7 +412,9 @@ public Version minimumIndexCompatibilityVersion() {
442412
if (major == 5) {
443413
bwcMajor = 2; // we jumped from 2 to 5
444414
} else if (major == 7) {
445-
return V_6_0_0_beta1;
415+
bwcMajor = 6;
416+
} else if (major == 8) {
417+
bwcMajor = 7;
446418
} else {
447419
bwcMajor = major - 1;
448420
}

server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
package org.elasticsearch.cluster.metadata;
2121

2222
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
23-
import org.apache.logging.log4j.Logger;
23+
2424
import org.apache.logging.log4j.LogManager;
25+
import org.apache.logging.log4j.Logger;
2526
import org.apache.logging.log4j.message.ParameterizedMessage;
2627
import org.elasticsearch.ElasticsearchException;
2728
import org.elasticsearch.ResourceAlreadyExistsException;
@@ -714,13 +715,6 @@ static void validateSplitIndex(ClusterState state, String sourceIndex,
714715
Settings targetIndexSettings) {
715716
IndexMetaData sourceMetaData = validateResize(state, sourceIndex, targetIndexMappingsTypes, targetIndexName, targetIndexSettings);
716717
IndexMetaData.selectSplitShard(0, sourceMetaData, IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.get(targetIndexSettings));
717-
if (sourceMetaData.getCreationVersion().before(Version.V_6_0_0_alpha1)) {
718-
// ensure we have a single type since this would make the splitting code considerably more complex
719-
// and a 5.x index would not be splittable unless it has been shrunk before so rather opt out of the complexity
720-
// since in 5.x we don't have a setting to artificially set the number of routing shards
721-
throw new IllegalStateException("source index created version is too old to apply a split operation");
722-
}
723-
724718
}
725719

726720
static IndexMetaData validateResize(ClusterState state, String sourceIndex,

server/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.cluster.routing;
2121

22-
import org.elasticsearch.Version;
2322
import org.elasticsearch.cluster.ClusterState;
2423
import org.elasticsearch.cluster.metadata.IndexMetaData;
2524
import org.elasticsearch.cluster.node.DiscoveryNodes;
@@ -194,16 +193,7 @@ private ShardIterator preferenceActiveShardIterator(IndexShardRoutingTable index
194193
}
195194
}
196195
// if not, then use it as the index
197-
int routingHash = Murmur3HashFunction.hash(preference);
198-
if (nodes.getMinNodeVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
199-
// The AllocationService lists shards in a fixed order based on nodes
200-
// so earlier versions of this class would have a tendency to
201-
// select the same node across different shardIds.
202-
// Better overall balancing can be achieved if each shardId opts
203-
// for a different element in the list by also incorporating the
204-
// shard ID into the hash of the user-supplied preference key.
205-
routingHash = 31 * routingHash + indexShard.shardId.hashCode();
206-
}
196+
int routingHash = 31 * Murmur3HashFunction.hash(preference) + indexShard.shardId.hashCode();
207197
if (awarenessAttributes.isEmpty()) {
208198
return indexShard.activeInitializingShardsIt(routingHash);
209199
} else {

server/src/main/java/org/elasticsearch/index/IndexSortConfig.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.apache.lucene.search.SortField;
2424
import org.apache.lucene.search.SortedNumericSortField;
2525
import org.apache.lucene.search.SortedSetSortField;
26-
import org.elasticsearch.Version;
2726
import org.elasticsearch.common.settings.Setting;
2827
import org.elasticsearch.common.settings.Settings;
2928
import org.elasticsearch.index.fielddata.IndexFieldData;
@@ -120,15 +119,6 @@ public IndexSortConfig(IndexSettings indexSettings) {
120119
.map((name) -> new FieldSortSpec(name))
121120
.toArray(FieldSortSpec[]::new);
122121

123-
if (sortSpecs.length > 0 && indexSettings.getIndexVersionCreated().before(Version.V_6_0_0_alpha1)) {
124-
/**
125-
* This index might be assigned to a node where the index sorting feature is not available
126-
* (ie. versions prior to {@link Version.V_6_0_0_alpha1_UNRELEASED}) so we must fail here rather than later.
127-
*/
128-
throw new IllegalArgumentException("unsupported index.version.created:" + indexSettings.getIndexVersionCreated() +
129-
", can't set index.sort on versions prior to " + Version.V_6_0_0_alpha1);
130-
}
131-
132122
if (INDEX_SORT_ORDER_SETTING.exists(settings)) {
133123
List<SortOrder> orders = INDEX_SORT_ORDER_SETTING.get(settings);
134124
if (orders.size() != sortSpecs.length) {

server/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,7 @@ public static DynamicTemplate parse(String name, Map<String, Object> conf,
205205
try {
206206
xcontentFieldType = XContentFieldType.fromString(matchMappingType);
207207
} catch (IllegalArgumentException e) {
208-
if (indexVersionCreated.onOrAfter(Version.V_6_0_0_alpha1)) {
209-
throw e;
210-
} else {
211-
deprecationLogger.deprecated("match_mapping_type [" + matchMappingType + "] is invalid and will be ignored: "
212-
+ e.getMessage());
213-
// this template is on an unknown type so it will never match anything
214-
// null indicates that the template should be ignored
215-
return null;
216-
}
208+
throw e;
217209
}
218210
}
219211

server/src/main/java/org/elasticsearch/index/seqno/ReplicationTracker.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.carrotsearch.hppc.ObjectLongHashMap;
2323
import com.carrotsearch.hppc.ObjectLongMap;
24+
2425
import org.elasticsearch.Version;
2526
import org.elasticsearch.action.ActionListener;
2627
import org.elasticsearch.action.support.replication.ReplicationResponse;
@@ -758,10 +759,9 @@ public synchronized void activatePrimaryMode(final long localCheckpoint) {
758759
* @param applyingClusterStateVersion the cluster state version being applied when updating the allocation IDs from the master
759760
* @param inSyncAllocationIds the allocation IDs of the currently in-sync shard copies
760761
* @param routingTable the shard routing table
761-
* @param pre60AllocationIds the allocation IDs of shards that are allocated to pre-6.0 nodes
762762
*/
763763
public synchronized void updateFromMaster(final long applyingClusterStateVersion, final Set<String> inSyncAllocationIds,
764-
final IndexShardRoutingTable routingTable, final Set<String> pre60AllocationIds) {
764+
final IndexShardRoutingTable routingTable) {
765765
assert invariant();
766766
if (applyingClusterStateVersion > appliedClusterStateVersion) {
767767
// check that the master does not fabricate new in-sync entries out of thin air once we are in primary mode
@@ -782,8 +782,7 @@ public synchronized void updateFromMaster(final long applyingClusterStateVersion
782782
final boolean inSync = inSyncAllocationIds.contains(initializingId);
783783
assert inSync == false : "update from master in primary mode has " + initializingId +
784784
" as in-sync but it does not exist locally";
785-
final long localCheckpoint = pre60AllocationIds.contains(initializingId) ?
786-
SequenceNumbers.PRE_60_NODE_CHECKPOINT : SequenceNumbers.UNASSIGNED_SEQ_NO;
785+
final long localCheckpoint = SequenceNumbers.UNASSIGNED_SEQ_NO;
787786
final long globalCheckpoint = localCheckpoint;
788787
checkpoints.put(initializingId, new CheckpointState(localCheckpoint, globalCheckpoint, inSync, inSync));
789788
}
@@ -794,8 +793,7 @@ public synchronized void updateFromMaster(final long applyingClusterStateVersion
794793
} else {
795794
for (String initializingId : initializingAllocationIds) {
796795
if (shardAllocationId.equals(initializingId) == false) {
797-
final long localCheckpoint = pre60AllocationIds.contains(initializingId) ?
798-
SequenceNumbers.PRE_60_NODE_CHECKPOINT : SequenceNumbers.UNASSIGNED_SEQ_NO;
796+
final long localCheckpoint = SequenceNumbers.UNASSIGNED_SEQ_NO;
799797
final long globalCheckpoint = localCheckpoint;
800798
checkpoints.put(initializingId, new CheckpointState(localCheckpoint, globalCheckpoint, false, false));
801799
}
@@ -807,8 +805,7 @@ public synchronized void updateFromMaster(final long applyingClusterStateVersion
807805
checkpointState.inSync = true;
808806
checkpointState.tracked = true;
809807
} else {
810-
final long localCheckpoint = pre60AllocationIds.contains(inSyncId) ?
811-
SequenceNumbers.PRE_60_NODE_CHECKPOINT : SequenceNumbers.UNASSIGNED_SEQ_NO;
808+
final long localCheckpoint = SequenceNumbers.UNASSIGNED_SEQ_NO;
812809
final long globalCheckpoint = localCheckpoint;
813810
checkpoints.put(inSyncId, new CheckpointState(localCheckpoint, globalCheckpoint, true, true));
814811
}
@@ -1082,17 +1079,13 @@ private Runnable getMasterUpdateOperationFromCurrentState() {
10821079
assert primaryMode == false;
10831080
final long lastAppliedClusterStateVersion = appliedClusterStateVersion;
10841081
final Set<String> inSyncAllocationIds = new HashSet<>();
1085-
final Set<String> pre60AllocationIds = new HashSet<>();
10861082
checkpoints.entrySet().forEach(entry -> {
10871083
if (entry.getValue().inSync) {
10881084
inSyncAllocationIds.add(entry.getKey());
10891085
}
1090-
if (entry.getValue().getLocalCheckpoint() == SequenceNumbers.PRE_60_NODE_CHECKPOINT) {
1091-
pre60AllocationIds.add(entry.getKey());
1092-
}
10931086
});
10941087
final IndexShardRoutingTable lastAppliedRoutingTable = routingTable;
1095-
return () -> updateFromMaster(lastAppliedClusterStateVersion, inSyncAllocationIds, lastAppliedRoutingTable, pre60AllocationIds);
1088+
return () -> updateFromMaster(lastAppliedClusterStateVersion, inSyncAllocationIds, lastAppliedRoutingTable);
10961089
}
10971090

10981091
/**

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.index.shard;
2121

2222
import com.carrotsearch.hppc.ObjectLongMap;
23+
2324
import org.apache.logging.log4j.Logger;
2425
import org.apache.logging.log4j.message.ParameterizedMessage;
2526
import org.apache.lucene.index.CheckIndex;
@@ -432,8 +433,7 @@ public void updateShardState(final ShardRouting newRouting,
432433
final BiConsumer<IndexShard, ActionListener<ResyncTask>> primaryReplicaSyncer,
433434
final long applyingClusterStateVersion,
434435
final Set<String> inSyncAllocationIds,
435-
final IndexShardRoutingTable routingTable,
436-
final Set<String> pre60AllocationIds) throws IOException {
436+
final IndexShardRoutingTable routingTable) throws IOException {
437437
final ShardRouting currentRouting;
438438
synchronized (mutex) {
439439
currentRouting = this.shardRouting;
@@ -452,7 +452,7 @@ public void updateShardState(final ShardRouting newRouting,
452452
}
453453

454454
if (newRouting.primary()) {
455-
replicationTracker.updateFromMaster(applyingClusterStateVersion, inSyncAllocationIds, routingTable, pre60AllocationIds);
455+
replicationTracker.updateFromMaster(applyingClusterStateVersion, inSyncAllocationIds, routingTable);
456456
}
457457

458458
if (state == IndexShardState.POST_RECOVERY && newRouting.active()) {

server/src/main/java/org/elasticsearch/index/shard/ShardSplittingQuery.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ final class ShardSplittingQuery extends Query {
6565
private final BitSetProducer nestedParentBitSetProducer;
6666

6767
ShardSplittingQuery(IndexMetaData indexMetaData, int shardId, boolean hasNested) {
68-
if (indexMetaData.getCreationVersion().before(Version.V_6_0_0_rc2)) {
69-
throw new IllegalArgumentException("Splitting query can only be executed on an index created with version "
70-
+ Version.V_6_0_0_rc2 + " or higher");
71-
}
7268
this.indexMetaData = indexMetaData;
7369
this.shardId = shardId;
7470
this.nestedParentBitSetProducer = hasNested ? newParentDocBitSetProducer(indexMetaData.getCreationVersion()) : null;

server/src/main/java/org/elasticsearch/index/shard/StoreRecovery.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.index.shard;
2121

2222
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
23+
2324
import org.apache.logging.log4j.Logger;
2425
import org.apache.lucene.index.IndexWriter;
2526
import org.apache.lucene.index.IndexWriterConfig;
@@ -31,7 +32,6 @@
3132
import org.apache.lucene.store.IOContext;
3233
import org.apache.lucene.store.IndexInput;
3334
import org.elasticsearch.ExceptionsHelper;
34-
import org.elasticsearch.Version;
3535
import org.elasticsearch.cluster.metadata.IndexMetaData;
3636
import org.elasticsearch.cluster.metadata.MappingMetaData;
3737
import org.elasticsearch.cluster.routing.RecoverySource;
@@ -119,8 +119,6 @@ boolean recoverFromLocalShards(BiConsumer<String, MappingMetaData> mappingUpdate
119119
Sort indexSort = indexShard.getIndexSort();
120120
final boolean hasNested = indexShard.mapperService().hasNested();
121121
final boolean isSplit = sourceMetaData.getNumberOfShards() < indexShard.indexSettings().getNumberOfShards();
122-
assert isSplit == false || sourceMetaData.getCreationVersion().onOrAfter(Version.V_6_0_0_alpha1) : "for split we require a " +
123-
"single type but the index is created before 6.0.0";
124122
return executeRecovery(indexShard, () -> {
125123
logger.debug("starting recovery from local shards {}", shards);
126124
try {

server/src/main/java/org/elasticsearch/index/translog/Translog.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.logging.log4j.message.ParameterizedMessage;
2323
import org.apache.lucene.index.Term;
2424
import org.apache.lucene.store.AlreadyClosedException;
25-
import org.elasticsearch.Version;
2625
import org.elasticsearch.common.UUIDs;
2726
import org.elasticsearch.common.bytes.BytesArray;
2827
import org.elasticsearch.common.bytes.BytesReference;
@@ -217,14 +216,9 @@ private ArrayList<TranslogReader> recoverFromFiles(Checkpoint checkpoint) throws
217216
logger.debug("open uncommitted translog checkpoint {}", checkpoint);
218217

219218
final long minGenerationToRecoverFrom;
220-
if (checkpoint.minTranslogGeneration < 0) {
221-
final Version indexVersionCreated = indexSettings().getIndexVersionCreated();
222-
assert indexVersionCreated.before(Version.V_6_0_0_beta1) :
223-
"no minTranslogGeneration in checkpoint, but index was created with version [" + indexVersionCreated + "]";
224-
minGenerationToRecoverFrom = deletionPolicy.getMinTranslogGenerationForRecovery();
225-
} else {
226-
minGenerationToRecoverFrom = checkpoint.minTranslogGeneration;
227-
}
219+
assert checkpoint.minTranslogGeneration > 0 : "minTranslogGeneration < 0 should not happen if index was created with version"
220+
+ " > 7.0, but version created was [" + indexSettings().getIndexVersionCreated() + "]";
221+
minGenerationToRecoverFrom = checkpoint.minTranslogGeneration;
228222

229223
final String checkpointTranslogFile = getFilename(checkpoint.generation);
230224
// we open files in reverse order in order to validate tranlsog uuid before we start traversing the translog based on
@@ -882,6 +876,7 @@ public Location(long generation, long translogLocation, int size) {
882876
this.size = size;
883877
}
884878

879+
@Override
885880
public String toString() {
886881
return "[generation: " + generation + ", location: " + translogLocation + ", size: " + size + "]";
887882
}

0 commit comments

Comments
 (0)