Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the 6.7 version constants. #42039

Merged
merged 6 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.elasticsearch.index.reindex;

import org.apache.logging.log4j.Logger;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.support.ActionFilters;
Expand Down Expand Up @@ -82,18 +81,13 @@ protected void doExecute(Task task, UpdateByQueryRequest request, ActionListener
*/
static class AsyncIndexBySearchAction extends AbstractAsyncBulkByScrollAction<UpdateByQueryRequest, TransportUpdateByQueryAction> {

private final boolean useSeqNoForCAS;

AsyncIndexBySearchAction(BulkByScrollTask task, Logger logger, ParentTaskAssigningClient client,
ThreadPool threadPool, TransportUpdateByQueryAction action, UpdateByQueryRequest request, ClusterState clusterState,
ActionListener<BulkByScrollResponse> listener) {
super(task,
// not all nodes support sequence number powered optimistic concurrency control, we fall back to version
clusterState.nodes().getMinNodeVersion().onOrAfter(Version.V_6_7_0) == false,
// all nodes support sequence number powered optimistic concurrency control and we can use it
clusterState.nodes().getMinNodeVersion().onOrAfter(Version.V_6_7_0),
// use sequence number powered optimistic concurrency control
false, true,
logger, client, threadPool, action, request, listener);
useSeqNoForCAS = clusterState.nodes().getMinNodeVersion().onOrAfter(Version.V_6_7_0);
}

@Override
Expand Down
7 changes: 1 addition & 6 deletions server/src/main/java/org/elasticsearch/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,7 @@ public static void writeBuild(Build build, StreamOutput out) throws IOException
out.writeString(build.flavor().displayName());
}
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
final Type buildType;
if (out.getVersion().before(Version.V_6_7_0) && build.type() == Type.DOCKER) {
buildType = Type.TAR;
} else {
buildType = build.type();
}
final Type buildType = build.type();
out.writeString(buildType.displayName());
}
out.writeString(build.shortHash());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1010,19 +1010,19 @@ private enum ElasticsearchExceptionHandle {
COORDINATION_STATE_REJECTED_EXCEPTION(org.elasticsearch.cluster.coordination.CoordinationStateRejectedException.class,
org.elasticsearch.cluster.coordination.CoordinationStateRejectedException::new, 150, Version.V_7_0_0),
SNAPSHOT_IN_PROGRESS_EXCEPTION(org.elasticsearch.snapshots.SnapshotInProgressException.class,
org.elasticsearch.snapshots.SnapshotInProgressException::new, 151, Version.V_6_7_0),
org.elasticsearch.snapshots.SnapshotInProgressException::new, 151, UNKNOWN_VERSION_ADDED),
NO_SUCH_REMOTE_CLUSTER_EXCEPTION(org.elasticsearch.transport.NoSuchRemoteClusterException.class,
org.elasticsearch.transport.NoSuchRemoteClusterException::new, 152, Version.V_6_7_0),
org.elasticsearch.transport.NoSuchRemoteClusterException::new, 152, UNKNOWN_VERSION_ADDED),
RETENTION_LEASE_ALREADY_EXISTS_EXCEPTION(
org.elasticsearch.index.seqno.RetentionLeaseAlreadyExistsException.class,
org.elasticsearch.index.seqno.RetentionLeaseAlreadyExistsException::new,
153,
Version.V_6_7_0),
UNKNOWN_VERSION_ADDED),
RETENTION_LEASE_NOT_FOUND_EXCEPTION(
org.elasticsearch.index.seqno.RetentionLeaseNotFoundException.class,
org.elasticsearch.index.seqno.RetentionLeaseNotFoundException::new,
154,
Version.V_6_7_0);
UNKNOWN_VERSION_ADDED);

final Class<? extends ElasticsearchException> exceptionClass;
final CheckedFunction<StreamInput, ? extends ElasticsearchException, IOException> constructor;
Expand Down
16 changes: 0 additions & 16 deletions server/src/main/java/org/elasticsearch/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@ public class Version implements Comparable<Version>, ToXContentFragment {
public static final Version V_6_6_1 = new Version(V_6_6_1_ID, org.apache.lucene.util.Version.LUCENE_7_6_0);
public static final int V_6_6_2_ID = 6060299;
public static final Version V_6_6_2 = new Version(V_6_6_2_ID, org.apache.lucene.util.Version.LUCENE_7_6_0);
public static final int V_6_7_0_ID = 6070099;
public static final Version V_6_7_0 = new Version(V_6_7_0_ID, org.apache.lucene.util.Version.LUCENE_7_7_0);
public static final int V_6_7_1_ID = 6070199;
public static final Version V_6_7_1 = new Version(V_6_7_1_ID, org.apache.lucene.util.Version.LUCENE_7_7_0);
public static final int V_6_7_2_ID = 6070299;
public static final Version V_6_7_2 = new Version(V_6_7_2_ID, org.apache.lucene.util.Version.LUCENE_7_7_0);
public static final int V_6_7_3_ID = 6070399;
public static final Version V_6_7_3 = new Version(V_6_7_3_ID, org.apache.lucene.util.Version.LUCENE_7_7_0);
public static final int V_6_8_0_ID = 6080099;
public static final Version V_6_8_0 = new Version(V_6_8_0_ID, org.apache.lucene.util.Version.LUCENE_7_7_0);
public static final int V_7_0_0_ID = 7000099;
Expand Down Expand Up @@ -154,14 +146,6 @@ public static Version fromId(int id) {
return V_7_0_0;
case V_6_8_0_ID:
return V_6_8_0;
case V_6_7_3_ID:
return V_6_7_3;
case V_6_7_1_ID:
return V_6_7_1;
case V_6_7_2_ID:
return V_6_7_2;
case V_6_7_0_ID:
return V_6_7_0;
case V_6_6_2_ID:
return V_6_6_2;
case V_6_6_1_ID:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected void ensureMaxSeqNoEqualsToGlobalCheckpoint(final SeqNoStats seqNoStat
// that guarantee that all operations have been flushed to Lucene.
final Version indexVersionCreated = engineConfig.getIndexSettings().getIndexVersionCreated();
if (indexVersionCreated.onOrAfter(Version.V_7_2_0) ||
(seqNoStats.getGlobalCheckpoint() != SequenceNumbers.UNASSIGNED_SEQ_NO && indexVersionCreated.onOrAfter(Version.V_6_7_0))) {
(seqNoStats.getGlobalCheckpoint() != SequenceNumbers.UNASSIGNED_SEQ_NO)) {
if (seqNoStats.getMaxSeqNo() != seqNoStats.getGlobalCheckpoint()) {
throw new IllegalStateException("Maximum sequence number [" + seqNoStats.getMaxSeqNo()
+ "] from last commit does not match global checkpoint [" + seqNoStats.getGlobalCheckpoint() + "]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.lucene.store.RateLimiter;
import org.apache.lucene.util.ArrayUtil;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.StepListener;
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
Expand Down Expand Up @@ -112,8 +111,7 @@ public RecoverySourceHandler(final IndexShard shard, RecoveryTargetHandler recov
this.shardId = this.request.shardId().id();
this.logger = Loggers.getLogger(getClass(), request.shardId(), "recover to " + request.targetNode().getName());
this.chunkSizeInBytes = fileChunkSizeInBytes;
// if the target is on an old version, it won't be able to handle out-of-order file chunks.
this.maxConcurrentFileChunks = request.targetNode().getVersion().onOrAfter(Version.V_6_7_0) ? maxConcurrentFileChunks : 1;
this.maxConcurrentFileChunks = maxConcurrentFileChunks;
}

public StartRecoveryRequest getRequest() {
Expand Down
34 changes: 0 additions & 34 deletions server/src/test/java/org/elasticsearch/BuildTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -194,39 +193,6 @@ public void testSerialization() {
});
}

public void testSerializationBWC() throws IOException {
final WriteableBuild dockerBuild = new WriteableBuild(new Build(randomFrom(Build.Flavor.values()), Build.Type.DOCKER,
randomAlphaOfLength(6), randomAlphaOfLength(6), randomBoolean(), randomAlphaOfLength(6)));

final List<Version> versions = Version.getDeclaredVersions(Version.class);
final Version pre63Version = randomFrom(versions.stream().filter(v -> v.before(Version.V_6_3_0)).collect(Collectors.toList()));
final Version post63Pre67Version = randomFrom(versions.stream()
.filter(v -> v.onOrAfter(Version.V_6_3_0) && v.before(Version.V_6_7_0)).collect(Collectors.toList()));
final Version post67Pre70Version = randomFrom(versions.stream()
.filter(v -> v.onOrAfter(Version.V_6_7_0) && v.before(Version.V_7_0_0)).collect(Collectors.toList()));
final Version post70Version = randomFrom(versions.stream().filter(v -> v.onOrAfter(Version.V_7_0_0)).collect(Collectors.toList()));

final WriteableBuild pre63 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, pre63Version);
final WriteableBuild post63pre67 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post63Pre67Version);
final WriteableBuild post67pre70 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post67Pre70Version);
final WriteableBuild post70 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post70Version);

assertThat(pre63.build.flavor(), equalTo(Build.Flavor.OSS));
assertThat(post63pre67.build.flavor(), equalTo(dockerBuild.build.flavor()));
assertThat(post67pre70.build.flavor(), equalTo(dockerBuild.build.flavor()));
assertThat(post70.build.flavor(), equalTo(dockerBuild.build.flavor()));

assertThat(pre63.build.type(), equalTo(Build.Type.UNKNOWN));
assertThat(post63pre67.build.type(), equalTo(Build.Type.TAR));
assertThat(post67pre70.build.type(), equalTo(dockerBuild.build.type()));
assertThat(post70.build.type(), equalTo(dockerBuild.build.type()));

assertThat(pre63.build.getQualifiedVersion(), equalTo(pre63Version.toString()));
assertThat(post63pre67.build.getQualifiedVersion(), equalTo(post63Pre67Version.toString()));
assertThat(post67pre70.build.getQualifiedVersion(), equalTo(post67Pre70Version.toString()));
assertThat(post70.build.getQualifiedVersion(), equalTo(dockerBuild.build.getQualifiedVersion()));
}

public void testFlavorParsing() {
for (final Build.Flavor flavor : Build.Flavor.values()) {
// strict or not should not impact parsing at all here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ public void testShardLockObtainFailedException() throws IOException {

public void testSnapshotInProgressException() throws IOException {
SnapshotInProgressException orig = new SnapshotInProgressException("boom");
Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_7_0, Version.CURRENT);
Version version = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to do here, but we could probably replace this so that we do not need to worry about it in the big 7.x refactor.

to something like

Version version = Versionutils.randomVersion()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be VersionUtils.randomIndexCompatibleVersion(random())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'll make this change in the current PR.

SnapshotInProgressException ex = serialize(orig, version);
assertEquals(orig.getMessage(), ex.getMessage());
}
Expand Down
1 change: 0 additions & 1 deletion server/src/test/java/org/elasticsearch/VersionTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ public static void assertUnknownVersion(Version version) {
public void testIsCompatible() {
assertTrue(isCompatible(Version.CURRENT, Version.CURRENT.minimumCompatibilityVersion()));
assertFalse(isCompatible(Version.V_6_6_0, Version.V_7_0_0));
assertFalse(isCompatible(Version.V_6_7_0, Version.V_7_0_0));
assertTrue(isCompatible(Version.V_6_8_0, Version.V_7_0_0));
assertFalse(isCompatible(Version.fromId(2000099), Version.V_7_0_0));
assertFalse(isCompatible(Version.fromId(2000099), Version.V_6_5_0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,7 @@ public void testStartedShardEntrySerialization() throws Exception {
final StartedShardEntry deserialized = new StartedShardEntry(in);
assertThat(deserialized.shardId, equalTo(shardId));
assertThat(deserialized.allocationId, equalTo(allocationId));
if (version.onOrAfter(Version.V_6_7_0)) {
assertThat(deserialized.primaryTerm, equalTo(primaryTerm));
} else {
assertThat(deserialized.primaryTerm, equalTo(0L));
}
assertThat(deserialized.primaryTerm, equalTo(primaryTerm));
assertThat(deserialized.message, equalTo(message));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
import java.util.List;

import static java.util.EnumSet.copyOf;
import static org.elasticsearch.test.VersionUtils.getPreviousVersion;
import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.elasticsearch.test.VersionUtils.randomVersionBetween;
import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
Expand Down Expand Up @@ -62,45 +60,6 @@ public void testSerialization() throws Exception {
}
}

public void testBwcSerialization() throws Exception {
for (int runs = 0; runs < randomIntBetween(5, 20); runs++) {
// Generate a random cluster block in version < 7.0.0
final Version version = randomVersionBetween(random(), Version.V_6_0_0, getPreviousVersion(Version.V_6_7_0));
final ClusterBlock expected = randomClusterBlock(version);
assertNull(expected.uuid());

// Serialize to node in current version
final BytesStreamOutput out = new BytesStreamOutput();
expected.writeTo(out);

// Deserialize and check the cluster block
final ClusterBlock actual = new ClusterBlock(out.bytes().streamInput());
assertClusterBlockEquals(expected, actual);
}

for (int runs = 0; runs < randomIntBetween(5, 20); runs++) {
// Generate a random cluster block in current version
final ClusterBlock expected = randomClusterBlock(Version.CURRENT);

// Serialize to node in version < 7.0.0
final BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(randomVersionBetween(random(), Version.V_6_0_0, getPreviousVersion(Version.V_6_7_0)));
expected.writeTo(out);

// Deserialize and check the cluster block
final StreamInput in = out.bytes().streamInput();
in.setVersion(out.getVersion());
final ClusterBlock actual = new ClusterBlock(in);

assertThat(actual.id(), equalTo(expected.id()));
assertThat(actual.status(), equalTo(expected.status()));
assertThat(actual.description(), equalTo(expected.description()));
assertThat(actual.retryable(), equalTo(expected.retryable()));
assertThat(actual.disableStatePersistence(), equalTo(expected.disableStatePersistence()));
assertArrayEquals(actual.levels().toArray(), expected.levels().toArray());
}
}

public void testToStringDanglingComma() {
final ClusterBlock clusterBlock = randomClusterBlock();
assertThat(clusterBlock.toString(), not(endsWith(",")));
Expand Down Expand Up @@ -171,7 +130,7 @@ private ClusterBlock randomClusterBlock() {
}

private ClusterBlock randomClusterBlock(final Version version) {
final String uuid = (version.onOrAfter(Version.V_6_7_0) && randomBoolean()) ? UUIDs.randomBase64UUID() : null;
final String uuid = randomBoolean() ? UUIDs.randomBase64UUID() : null;
final List<ClusterBlockLevel> levels = Arrays.asList(ClusterBlockLevel.values());
return new ClusterBlock(randomInt(), uuid, "cluster block #" + randomInt(), randomBoolean(), randomBoolean(), randomBoolean(),
randomFrom(RestStatus.values()), copyOf(randomSubsetOf(randomIntBetween(1, levels.size()), levels)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,9 @@ public AutoFollowStats(StreamInput in) throws IOException {
numberOfFailedFollowIndices = in.readVLong();
numberOfFailedRemoteClusterStateRequests = in.readVLong();
numberOfSuccessfulFollowIndices = in.readVLong();
if (in.getVersion().onOrAfter(Version.V_6_7_0)) {
// note: the casts to the following Writeable.Reader<T> instances are needed by some IDEs (e.g. Eclipse 4.8) as a compiler help
recentAutoFollowErrors = new TreeMap<>(in.readMap((Writeable.Reader<String>) StreamInput::readString,
(Writeable.Reader<Tuple<Long, ElasticsearchException>>) in1 -> new Tuple<>(in1.readZLong(), in1.readException())));
} else {
// note: the casts to the following Writeable.Reader<T> instances are needed by some IDEs (e.g. Eclipse 4.8) as a compiler help
recentAutoFollowErrors = new TreeMap<>(in.readMap((Writeable.Reader<String>) StreamInput::readString,
(Writeable.Reader<Tuple<Long, ElasticsearchException>>) in1 -> new Tuple<>(-1L, in1.readException())));
}
// note: the casts to the following Writeable.Reader<T> instances are needed by some IDEs (e.g. Eclipse 4.8) as a compiler help
recentAutoFollowErrors = new TreeMap<>(in.readMap((Writeable.Reader<String>) StreamInput::readString,
(Writeable.Reader<Tuple<Long, ElasticsearchException>>) in1 -> new Tuple<>(in1.readZLong(), in1.readException())));
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
autoFollowedClusters = new TreeMap<>(in.readMap(StreamInput::readString, AutoFollowedCluster::new));
} else {
Expand All @@ -137,14 +131,11 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(numberOfFailedFollowIndices);
out.writeVLong(numberOfFailedRemoteClusterStateRequests);
out.writeVLong(numberOfSuccessfulFollowIndices);
if (out.getVersion().onOrAfter(Version.V_6_7_0)) {
out.writeMap(recentAutoFollowErrors, StreamOutput::writeString, (out1, value) -> {
out1.writeZLong(value.v1());
out1.writeException(value.v2());
});
} else {
out.writeMap(recentAutoFollowErrors, StreamOutput::writeString, (out1, value) -> out1.writeException(value.v2()));
}
out.writeMap(recentAutoFollowErrors, StreamOutput::writeString, (out1, value) -> {
out1.writeZLong(value.v1());
out1.writeException(value.v2());
});

if (out.getVersion().onOrAfter(Version.V_6_6_0)) {
out.writeMap(autoFollowedClusters, StreamOutput::writeString, (out1, value) -> value.writeTo(out1));
}
Expand Down
Loading