Skip to content

Commit

Permalink
Remove Obsolete BwC Serialization Logic (#39883)
Browse files Browse the repository at this point in the history
* Remove Obsolete BwC Serialization Logic

* Same as #39879, all Bwc logic related to pre-7.0 versions is obsolete in master (8.0) now
  • Loading branch information
original-brownbear authored Mar 13, 2019
1 parent 97562a8 commit 2d6c462
Show file tree
Hide file tree
Showing 70 changed files with 201 additions and 1,070 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,10 @@ public void testReindexRequest() throws IOException {
ReindexRequest tripped = new ReindexRequest(toInputByteStream(reindex));
assertRequestEquals(reindex, tripped);

// Try slices=auto with a version that doesn't support it, which should fail
reindex.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES);
Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, reindex));
assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage());

// Try regular slices with a version that doesn't support slices=auto, which should succeed
reindex.setSlices(between(1, Integer.MAX_VALUE));
tripped = new ReindexRequest(toInputByteStream(reindex));
assertRequestEquals(Version.V_6_0_0_alpha1, reindex, tripped);
assertRequestEquals(reindex, tripped);
}

public void testUpdateByQueryRequest() throws IOException {
Expand All @@ -89,11 +84,6 @@ public void testUpdateByQueryRequest() throws IOException {
assertRequestEquals(update, tripped);
assertEquals(update.getPipeline(), tripped.getPipeline());

// Try slices=auto with a version that doesn't support it, which should fail
update.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES);
Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, update));
assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage());

// Try regular slices with a version that doesn't support slices=auto, which should succeed
update.setSlices(between(1, Integer.MAX_VALUE));
tripped = new UpdateByQueryRequest(toInputByteStream(update));
Expand All @@ -107,11 +97,6 @@ public void testDeleteByQueryRequest() throws IOException {
DeleteByQueryRequest tripped = new DeleteByQueryRequest(toInputByteStream(delete));
assertRequestEquals(delete, tripped);

// Try slices=auto with a version that doesn't support it, which should fail
delete.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES);
Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, delete));
assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage());

// Try regular slices with a version that doesn't support slices=auto, which should succeed
delete.setSlices(between(1, Integer.MAX_VALUE));
tripped = new DeleteByQueryRequest(toInputByteStream(delete));
Expand Down Expand Up @@ -139,7 +124,7 @@ private void randomRequest(AbstractBulkIndexByScrollRequest<?> request) {
request.setScript(random().nextBoolean() ? null : randomScript());
}

private void assertRequestEquals(Version version, ReindexRequest request, ReindexRequest tripped) {
private void assertRequestEquals(ReindexRequest request, ReindexRequest tripped) {
assertRequestEquals((AbstractBulkIndexByScrollRequest<?>) request, (AbstractBulkIndexByScrollRequest<?>) tripped);
assertEquals(request.getDestination().version(), tripped.getDestination().version());
assertEquals(request.getDestination().index(), tripped.getDestination().index());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.elasticsearch.action;

import org.elasticsearch.Version;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
import org.elasticsearch.action.support.WriteResponse;
Expand Down Expand Up @@ -264,13 +263,8 @@ public void readFrom(StreamInput in) throws IOException {
type = in.readString();
id = in.readString();
version = in.readZLong();
if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
seqNo = in.readZLong();
primaryTerm = in.readVLong();
} else {
seqNo = UNASSIGNED_SEQ_NO;
primaryTerm = UNASSIGNED_PRIMARY_TERM;
}
seqNo = in.readZLong();
primaryTerm = in.readVLong();
forcedRefresh = in.readBoolean();
result = Result.readFrom(in);
}
Expand All @@ -282,10 +276,8 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(type);
out.writeString(id);
out.writeZLong(version);
if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
out.writeZLong(seqNo);
out.writeVLong(primaryTerm);
}
out.writeZLong(seqNo);
out.writeVLong(primaryTerm);
out.writeBoolean(forcedRefresh);
result.writeTo(out);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ public ClusterHealthRequest(StreamInput in) throws IOException {
if (in.readBoolean()) {
waitForEvents = Priority.readFrom(in);
}
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
waitForNoInitializingShards = in.readBoolean();
}
waitForNoInitializingShards = in.readBoolean();
if (in.getVersion().onOrAfter(Version.V_7_1_0)) {
indicesOptions = IndicesOptions.readIndicesOptions(in);
} else {
Expand Down Expand Up @@ -118,9 +116,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(true);
Priority.writeTo(waitForEvents, out);
}
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
out.writeBoolean(waitForNoInitializingShards);
}
out.writeBoolean(waitForNoInitializingShards);
if (out.getVersion().onOrAfter(Version.V_7_1_0)) {
indicesOptions.writeIndicesOptions(out);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@

package org.elasticsearch.action.admin.cluster.node.stats;

import org.elasticsearch.Version;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.discovery.DiscoveryStats;
Expand Down Expand Up @@ -235,11 +233,7 @@ public void readFrom(StreamInput in) throws IOException {
scriptStats = in.readOptionalWriteable(ScriptStats::new);
discoveryStats = in.readOptionalWriteable(DiscoveryStats::new);
ingestStats = in.readOptionalWriteable(IngestStats::new);
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new);
} else {
adaptiveSelectionStats = null;
}
adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new);
}

@Override
Expand All @@ -263,9 +257,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(scriptStats);
out.writeOptionalWriteable(discoveryStats);
out.writeOptionalWriteable(ingestStats);
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
out.writeOptionalWriteable(adaptiveSelectionStats);
}
out.writeOptionalWriteable(adaptiveSelectionStats);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.action.admin.cluster.node.stats;

import org.elasticsearch.Version;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -296,11 +295,7 @@ public void readFrom(StreamInput in) throws IOException {
script = in.readBoolean();
discovery = in.readBoolean();
ingest = in.readBoolean();
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
adaptiveSelection = in.readBoolean();
} else {
adaptiveSelection = false;
}
adaptiveSelection = in.readBoolean();
}

@Override
Expand All @@ -318,8 +313,6 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(script);
out.writeBoolean(discovery);
out.writeBoolean(ingest);
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
out.writeBoolean(adaptiveSelection);
}
out.writeBoolean(adaptiveSelection);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

package org.elasticsearch.action.admin.cluster.reroute;

import org.elasticsearch.Version;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.cluster.ClusterModule;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.routing.allocation.RoutingExplanations;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -63,32 +61,16 @@ public RoutingExplanations getExplanations() {

@Override
public void readFrom(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
super.readFrom(in);
state = ClusterState.readFrom(in, null);
explanations = RoutingExplanations.readFrom(in);
} else {
state = ClusterState.readFrom(in, null);
acknowledged = in.readBoolean();
explanations = RoutingExplanations.readFrom(in);
}
super.readFrom(in);
state = ClusterState.readFrom(in, null);
explanations = RoutingExplanations.readFrom(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
super.writeTo(out);
state.writeTo(out);
RoutingExplanations.writeTo(explanations, out);
} else {
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
state.writeTo(out);
} else {
ClusterModule.filterCustomsForPre63Clients(state).writeTo(out);
}
out.writeBoolean(acknowledged);
RoutingExplanations.writeTo(explanations, out);
}
super.writeTo(out);
state.writeTo(out);
RoutingExplanations.writeTo(explanations, out);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.action.admin.cluster.settings;

import org.elasticsearch.Version;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -68,15 +67,9 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse {

@Override
public void readFrom(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
super.readFrom(in);
transientSettings = Settings.readSettingsFromStream(in);
persistentSettings = Settings.readSettingsFromStream(in);
} else {
transientSettings = Settings.readSettingsFromStream(in);
persistentSettings = Settings.readSettingsFromStream(in);
acknowledged = in.readBoolean();
}
super.readFrom(in);
transientSettings = Settings.readSettingsFromStream(in);
persistentSettings = Settings.readSettingsFromStream(in);
}

public Settings getTransientSettings() {
Expand All @@ -89,15 +82,9 @@ public Settings getPersistentSettings() {

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
super.writeTo(out);
Settings.writeSettingsToStream(transientSettings, out);
Settings.writeSettingsToStream(persistentSettings, out);
} else {
Settings.writeSettingsToStream(transientSettings, out);
Settings.writeSettingsToStream(persistentSettings, out);
out.writeBoolean(acknowledged);
}
super.writeTo(out);
Settings.writeSettingsToStream(transientSettings, out);
Settings.writeSettingsToStream(persistentSettings, out);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.action.admin.cluster.snapshots.status;

import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
Expand Down Expand Up @@ -134,10 +133,8 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(incrementalSize);
out.writeVLong(processedSize);

if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
out.writeVInt(totalFileCount);
out.writeVLong(totalSize);
}
out.writeVInt(totalFileCount);
out.writeVLong(totalSize);
}

@Override
Expand All @@ -151,13 +148,8 @@ public void readFrom(StreamInput in) throws IOException {
incrementalSize = in.readVLong();
processedSize = in.readVLong();

if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
totalFileCount = in.readVInt();
totalSize = in.readVLong();
} else {
totalFileCount = incrementalFileCount;
totalSize = incrementalSize;
}
totalFileCount = in.readVInt();
totalSize = in.readVLong();
}

static final class Fields {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.action.admin.cluster.snapshots.status;

import org.elasticsearch.Version;
import org.elasticsearch.cluster.SnapshotsInProgress;
import org.elasticsearch.cluster.SnapshotsInProgress.State;
import org.elasticsearch.common.ParseField;
Expand Down Expand Up @@ -169,9 +168,7 @@ public void readFrom(StreamInput in) throws IOException {
builder.add(SnapshotIndexShardStatus.readShardSnapshotStatus(in));
}
shards = Collections.unmodifiableList(builder);
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
includeGlobalState = in.readOptionalBoolean();
}
includeGlobalState = in.readOptionalBoolean();
updateShardStats();
}

Expand All @@ -183,9 +180,7 @@ public void writeTo(StreamOutput out) throws IOException {
for (SnapshotIndexShardStatus shard : shards) {
shard.writeTo(out);
}
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
out.writeOptionalBoolean(includeGlobalState);
}
out.writeOptionalBoolean(includeGlobalState);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.action.admin.cluster.state;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.support.IndicesOptions;
Expand Down Expand Up @@ -57,10 +56,8 @@ public ClusterStateRequest(StreamInput in) throws IOException {
customs = in.readBoolean();
indices = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
waitForTimeout = in.readTimeValue();
waitForMetaDataVersion = in.readOptionalLong();
}
waitForTimeout = in.readTimeValue();
waitForMetaDataVersion = in.readOptionalLong();
}

@Override
Expand All @@ -73,10 +70,8 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(customs);
out.writeStringArray(indices);
indicesOptions.writeIndicesOptions(out);
if (out.getVersion().onOrAfter(Version.V_6_6_0)) {
out.writeTimeValue(waitForTimeout);
out.writeOptionalLong(waitForMetaDataVersion);
}
out.writeTimeValue(waitForTimeout);
out.writeOptionalLong(waitForMetaDataVersion);
}

@Override
Expand Down
Loading

0 comments on commit 2d6c462

Please sign in to comment.