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 Obsolete BWC Serialization Logic #39879

Merged
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 @@ -18,7 +18,6 @@
*/
package org.elasticsearch.action.admin.indices.analyze;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.single.shard.SingleShardRequest;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -252,9 +251,7 @@ public void readFrom(StreamInput in) throws IOException {
field = in.readOptionalString();
explain = in.readBoolean();
attributes = in.readStringArray();
if (in.getVersion().onOrAfter(Version.V_6_0_0_beta1)) {
normalizer = in.readOptionalString();
}
normalizer = in.readOptionalString();
}

@Override
Expand All @@ -268,9 +265,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(field);
out.writeBoolean(explain);
out.writeStringArray(attributes);
if (out.getVersion().onOrAfter(Version.V_6_0_0_beta1)) {
out.writeOptionalString(normalizer);
}
out.writeOptionalString(normalizer);
}

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

package org.elasticsearch.action.admin.indices.cache.clear;

import org.elasticsearch.Version;
import org.elasticsearch.action.support.broadcast.BroadcastRequest;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -83,9 +82,6 @@ public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
queryCache = in.readBoolean();
fieldDataCache = in.readBoolean();
if (in.getVersion().before(Version.V_6_0_0_beta1)) {
in.readBoolean(); // recycler
}
fields = in.readStringArray();
requestCache = in.readBoolean();
}
Expand All @@ -95,9 +91,6 @@ public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeBoolean(queryCache);
out.writeBoolean(fieldDataCache);
if (out.getVersion().before(Version.V_6_0_0_beta1)) {
out.writeBoolean(false); // recycler
}
out.writeStringArrayNullable(fields);
out.writeBoolean(requestCache);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import org.elasticsearch.ElasticsearchGenerationException;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.admin.indices.alias.Alias;
Expand Down Expand Up @@ -442,27 +441,12 @@ public void readFrom(StreamInput in) throws IOException {
for (int i = 0; i < size; i++) {
final String type = in.readString();
String source = in.readString();
if (in.getVersion().before(Version.V_6_0_0_alpha1)) { // TODO change to 5.3.0 after backport
// we do not know the content type that comes from earlier versions so we autodetect and convert
source = XContentHelper.convertToJson(new BytesArray(source), false, false, XContentFactory.xContentType(source));
}
mappings.put(type, source);
}
if (in.getVersion().before(Version.V_6_5_0)) {
// This used to be the size of custom metadata classes
int customSize = in.readVInt();
assert customSize == 0 : "unexpected custom metadata when none is supported";
if (customSize > 0) {
throw new IllegalStateException("unexpected custom metadata when none is supported");
}
}
int aliasesSize = in.readVInt();
for (int i = 0; i < aliasesSize; i++) {
aliases.add(Alias.read(in));
}
if (in.getVersion().before(Version.V_7_0_0)) {
in.readBoolean(); // updateAllTypes
}
waitForActiveShards = ActiveShardCount.readFrom(in);
}

Expand All @@ -477,17 +461,10 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(entry.getKey());
out.writeString(entry.getValue());
}
if (out.getVersion().before(Version.V_6_5_0)) {
// Size of custom index metadata, which is removed
out.writeVInt(0);
}
out.writeVInt(aliases.size());
for (Alias alias : aliases) {
alias.writeTo(out);
}
if (out.getVersion().before(Version.V_7_0_0)) {
out.writeBoolean(true); // updateAllTypes
}
waitForActiveShards.writeTo(out);
}

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

package org.elasticsearch.action.admin.indices.get;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.master.info.ClusterInfoRequest;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -81,9 +80,7 @@ public GetIndexRequest(StreamInput in) throws IOException {
features[i] = Feature.fromId(in.readByte());
}
humanReadable = in.readBoolean();
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
includeDefaults = in.readBoolean();
}
includeDefaults = in.readBoolean();
}

public GetIndexRequest features(Feature... features) {
Expand Down Expand Up @@ -155,9 +152,6 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeByte(feature.id);
}
out.writeBoolean(humanReadable);
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
out.writeBoolean(includeDefaults);
}
out.writeBoolean(includeDefaults);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;

import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.cluster.metadata.MappingMetaData;
Expand Down Expand Up @@ -193,11 +192,9 @@ public void readFrom(StreamInput in) throws IOException {
settings = settingsMapBuilder.build();

ImmutableOpenMap.Builder<String, Settings> defaultSettingsMapBuilder = ImmutableOpenMap.builder();
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
int defaultSettingsSize = in.readVInt();
for (int i = 0; i < defaultSettingsSize ; i++) {
defaultSettingsMapBuilder.put(in.readString(), Settings.readSettingsFromStream(in));
}
int defaultSettingsSize = in.readVInt();
for (int i = 0; i < defaultSettingsSize; i++) {
defaultSettingsMapBuilder.put(in.readString(), Settings.readSettingsFromStream(in));
}
defaultSettings = defaultSettingsMapBuilder.build();
}
Expand Down Expand Up @@ -228,12 +225,10 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(indexEntry.key);
Settings.writeSettingsToStream(indexEntry.value, out);
}
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
out.writeVInt(defaultSettings.size());
for (ObjectObjectCursor<String, Settings> indexEntry : defaultSettings) {
out.writeString(indexEntry.key);
Settings.writeSettingsToStream(indexEntry.value, out);
}
out.writeVInt(defaultSettings.size());
for (ObjectObjectCursor<String, Settings> indexEntry : defaultSettings) {
out.writeString(indexEntry.key);
Settings.writeSettingsToStream(indexEntry.value, out);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.carrotsearch.hppc.ObjectHashSet;

import org.elasticsearch.ElasticsearchGenerationException;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.support.IndicesOptions;
Expand Down Expand Up @@ -308,15 +307,8 @@ public void readFrom(StreamInput in) throws IOException {
indicesOptions = IndicesOptions.readIndicesOptions(in);
type = in.readOptionalString();
source = in.readString();
if (in.getVersion().before(Version.V_7_0_0)) {
in.readBoolean(); // updateAllTypes
}
concreteIndex = in.readOptionalWriteable(Index::new);
if (in.getVersion().onOrAfter(Version.V_6_7_0)) {
origin = in.readOptionalString();
} else {
origin = null;
}
origin = in.readOptionalString();
}

@Override
Expand All @@ -326,13 +318,8 @@ public void writeTo(StreamOutput out) throws IOException {
indicesOptions.writeIndicesOptions(out);
out.writeOptionalString(type);
out.writeString(source);
if (out.getVersion().before(Version.V_7_0_0)) {
out.writeBoolean(true); // updateAllTypes
}
out.writeOptionalWriteable(concreteIndex);
if (out.getVersion().onOrAfter(Version.V_6_7_0)) {
out.writeOptionalString(origin);
}
out.writeOptionalString(origin);
}

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

package org.elasticsearch.action.admin.indices.open;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.support.ActiveShardCount;
Expand Down Expand Up @@ -141,18 +140,14 @@ public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
indices = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
waitForActiveShards = ActiveShardCount.readFrom(in);
}
waitForActiveShards = ActiveShardCount.readFrom(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeStringArray(indices);
indicesOptions.writeIndicesOptions(out);
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
waitForActiveShards.writeTo(out);
}
waitForActiveShards.writeTo(out);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.carrotsearch.hppc.cursors.IntObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
import org.elasticsearch.cluster.node.DiscoveryNode;
Expand Down Expand Up @@ -163,10 +162,6 @@ public static StoreStatus readStoreStatus(StreamInput in) throws IOException {
@Override
public void readFrom(StreamInput in) throws IOException {
node = new DiscoveryNode(in);
if (in.getVersion().before(Version.V_6_0_0_alpha1)) {
// legacy version
in.readLong();
}
allocationId = in.readOptionalString();
allocationStatus = AllocationStatus.readFrom(in);
if (in.readBoolean()) {
Expand All @@ -177,10 +172,6 @@ public void readFrom(StreamInput in) throws IOException {
@Override
public void writeTo(StreamOutput out) throws IOException {
node.writeTo(out);
if (out.getVersion().before(Version.V_6_0_0_alpha1)) {
// legacy version
out.writeLong(-1L);
}
out.writeOptionalString(allocationId);
allocationStatus.writeTo(out);
if (storeException != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@

package org.elasticsearch.action.admin.indices.shrink;

import org.elasticsearch.Version;
import org.elasticsearch.action.Action;

public class ResizeAction extends Action<ResizeResponse> {

public static final ResizeAction INSTANCE = new ResizeAction();
public static final String NAME = "indices:admin/resize";
public static final Version COMPATIBILITY_VERSION = Version.V_6_1_0; // TODO remove this once it's backported

private ResizeAction() {
super(NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.elasticsearch.action.admin.indices.shrink;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.admin.indices.alias.Alias;
Expand Down Expand Up @@ -94,32 +93,17 @@ public void readFrom(StreamInput in) throws IOException {
targetIndexRequest = new CreateIndexRequest();
targetIndexRequest.readFrom(in);
sourceIndex = in.readString();
if (in.getVersion().onOrAfter(ResizeAction.COMPATIBILITY_VERSION)) {
type = in.readEnum(ResizeType.class);
} else {
type = ResizeType.SHRINK; // BWC this used to be shrink only
}
if (in.getVersion().before(Version.V_6_4_0)) {
copySettings = null;
} else {
copySettings = in.readOptionalBoolean();
}
type = in.readEnum(ResizeType.class);
copySettings = in.readOptionalBoolean();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
targetIndexRequest.writeTo(out);
out.writeString(sourceIndex);
if (out.getVersion().onOrAfter(ResizeAction.COMPATIBILITY_VERSION)) {
out.writeEnum(type);
}
// noinspection StatementWithEmptyBody
if (out.getVersion().before(Version.V_6_4_0)) {

} else {
out.writeOptionalBoolean(copySettings);
}
out.writeEnum(type);
out.writeOptionalBoolean(copySettings);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -193,15 +192,4 @@ static CreateIndexClusterStateUpdateRequest prepareCreateIndexRequest(final Resi
.resizeType(resizeRequest.getResizeType())
.copySettings(resizeRequest.getCopySettings() == null ? false : resizeRequest.getCopySettings());
}

@Override
protected String getMasterActionName(DiscoveryNode node) {
if (node.getVersion().onOrAfter(ResizeAction.COMPATIBILITY_VERSION)){
return super.getMasterActionName(node);
} else {
// this is for BWC - when we send this to version that doesn't have ResizeAction.NAME registered
// we have to send to shrink instead.
return ShrinkAction.NAME;
}
}
}
Loading