Skip to content

Commit

Permalink
removing verifiableWriteable interface
Browse files Browse the repository at this point in the history
Signed-off-by: Himshikha Gupta <himshikh@amazon.com>
  • Loading branch information
Himshikha Gupta committed Sep 3, 2024
1 parent f30fd4d commit 0978f7b
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 51 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.index.translog.BufferedChecksumStreamOutput;

import java.io.IOException;
import java.util.Collections;
Expand Down Expand Up @@ -303,7 +304,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeMap(indicesBlocks, StreamOutput::writeString, (o, s) -> writeBlockSet(s, o));
}

public void writeVerifiableTo(StreamOutput out) throws IOException {
public void writeVerifiableTo(BufferedChecksumStreamOutput out) throws IOException {
writeTo(out);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
import org.opensearch.core.ParseField;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.VerifiableWriteable;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.xcontent.ConstructingObjectParser;
import org.opensearch.core.xcontent.ToXContentFragment;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.index.translog.BufferedChecksumStreamOutput;

import java.io.IOException;
import java.util.Arrays;
Expand All @@ -60,7 +60,7 @@
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class CoordinationMetadata implements VerifiableWriteable, ToXContentFragment {
public class CoordinationMetadata implements Writeable, ToXContentFragment {

public static final CoordinationMetadata EMPTY_METADATA = builder().build();

Expand Down Expand Up @@ -150,8 +150,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeCollection(votingConfigExclusions);
}

@Override
public void writeVerifiableTo(StreamOutput out) throws IOException {
public void writeVerifiableTo(BufferedChecksumStreamOutput out) throws IOException {
writeTo(out);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.opensearch.core.common.Strings;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.VerifiableWriteable;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.index.Index;
import org.opensearch.core.index.shard.ShardId;
Expand Down Expand Up @@ -106,7 +105,7 @@
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class IndexMetadata implements Diffable<IndexMetadata>, ToXContentFragment, VerifiableWriteable {
public class IndexMetadata implements Diffable<IndexMetadata>, ToXContentFragment {

public static final ClusterBlock INDEX_READ_ONLY_BLOCK = new ClusterBlock(
5,
Expand Down Expand Up @@ -1290,8 +1289,7 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

@Override
public void writeVerifiableTo(StreamOutput out) throws IOException {
public void writeVerifiableTo(BufferedChecksumStreamOutput out) throws IOException {
out.writeString(index.getName()); // uuid will come as part of settings
out.writeLong(version);
out.writeVLong(mappingVersion);
Expand All @@ -1301,15 +1299,15 @@ public void writeVerifiableTo(StreamOutput out) throws IOException {
out.writeByte(state.id());
writeSettingsToStream(settings, out);
out.writeVLongArray(primaryTerms);
((BufferedChecksumStreamOutput) out).writeMapValues(mappings, (stream, val) -> val.writeTo(stream));
((BufferedChecksumStreamOutput) out).writeMapValues(aliases, (stream, val) -> val.writeTo(stream));
out.writeMapValues(mappings, (stream, val) -> val.writeTo(stream));
out.writeMapValues(aliases, (stream, val) -> val.writeTo(stream));
out.writeMap(customData, StreamOutput::writeString, (stream, val) -> val.writeTo(stream));
out.writeMap(
inSyncAllocationIds,
StreamOutput::writeVInt,
(stream, val) -> DiffableUtils.StringSetValueSerializer.getInstance().write(new TreeSet<>(val), stream)
);
((BufferedChecksumStreamOutput) out).writeMapValues(rolloverInfos, (stream, val) -> val.writeTo(stream));
out.writeMapValues(rolloverInfos, (stream, val) -> val.writeTo(stream));
out.writeBoolean(isSystem);
if (out.getVersion().onOrAfter(Version.V_2_17_0)) {
out.writeOptionalWriteable(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalVInt(version);
}

public void writeVerifiableTo(StreamOutput out) throws IOException {
public void writeVerifiableTo(BufferedChecksumStreamOutput out) throws IOException {
out.writeString(name);
out.writeInt(order);
out.writeStringCollection(patterns);
Settings.writeSettingsToStream(settings, out);
out.writeMap(mappings, StreamOutput::writeString, (stream, val) -> val.writeTo(stream));
((BufferedChecksumStreamOutput) out).writeMapValues(aliases, (stream, val) -> val.writeTo(stream));
out.writeMapValues(aliases, (stream, val) -> val.writeTo(stream));
out.writeOptionalVInt(version);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.opensearch.cluster.AbstractDiffable;
import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.VerifiableWriteable;
import org.opensearch.core.xcontent.ToXContentFragment;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
Expand All @@ -29,7 +28,7 @@
* @opensearch.api
*/
@PublicApi(since = "2.15.0")
public class TemplatesMetadata extends AbstractDiffable<TemplatesMetadata> implements ToXContentFragment, VerifiableWriteable {
public class TemplatesMetadata extends AbstractDiffable<TemplatesMetadata> implements ToXContentFragment {
public static TemplatesMetadata EMPTY_METADATA = builder().build();
private final Map<String, IndexTemplateMetadata> templates;

Expand Down Expand Up @@ -67,9 +66,8 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

@Override
public void writeVerifiableTo(StreamOutput out) throws IOException {
((BufferedChecksumStreamOutput) out).writeMapValues(templates, (stream, value) -> value.writeVerifiableTo(stream));
public void writeVerifiableTo(BufferedChecksumStreamOutput out) throws IOException {
out.writeMapValues(templates, (stream, value) -> value.writeVerifiableTo((BufferedChecksumStreamOutput) stream));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.VerifiableWriteable;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.common.transport.TransportAddress;
import org.opensearch.core.xcontent.ToXContentFragment;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.index.translog.BufferedChecksumStreamOutput;
import org.opensearch.node.Node;

import java.io.IOException;
Expand Down Expand Up @@ -73,7 +74,7 @@
* @opensearch.api
*/
@PublicApi(since = "1.0.0")
public class DiscoveryNode implements VerifiableWriteable, ToXContentFragment {
public class DiscoveryNode implements Writeable, ToXContentFragment {

static final String COORDINATING_ONLY = "coordinating_only";

Expand Down Expand Up @@ -395,8 +396,7 @@ public void writeTo(StreamOutput out) throws IOException {
writeRolesAndVersion(out);
}

@Override
public void writeVerifiableTo(StreamOutput out) throws IOException {
public void writeVerifiableTo(BufferedChecksumStreamOutput out) throws IOException {
writeNodeDetails(out);
out.writeMap(attributes, StreamOutput::writeString, StreamOutput::writeString);
writeRolesAndVersion(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,9 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

public void writeVerifiableTo(StreamOutput out) throws IOException {
public void writeVerifiableTo(BufferedChecksumStreamOutput out) throws IOException {
writeClusterManager(out);
((BufferedChecksumStreamOutput) out).writeMapValues(nodes, (stream, val) -> val.writeVerifiableTo(stream));
out.writeMapValues(nodes, (stream, val) -> val.writeVerifiableTo((BufferedChecksumStreamOutput) stream));
}

private void writeClusterManager(StreamOutput out) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

public void writeVerifiableTo(StreamOutput out) throws IOException {
public void writeVerifiableTo(BufferedChecksumStreamOutput out) throws IOException {
index.writeTo(out);
((BufferedChecksumStreamOutput) out).writeMapValues(
out.writeMapValues(
shards,
(stream, value) -> IndexShardRoutingTable.Builder.writeVerifiableTo(value, stream)
(stream, value) -> IndexShardRoutingTable.Builder.writeVerifiableTo(value, (BufferedChecksumStreamOutput) stream)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.index.Index;
import org.opensearch.core.index.shard.ShardId;
import org.opensearch.index.translog.BufferedChecksumStreamOutput;
import org.opensearch.node.ResponseCollectorService;

import java.io.IOException;
Expand Down Expand Up @@ -1171,7 +1172,7 @@ public static void writeToThin(IndexShardRoutingTable indexShard, StreamOutput o
}
}

public static void writeVerifiableTo(IndexShardRoutingTable indexShard, StreamOutput out) throws IOException {
public static void writeVerifiableTo(IndexShardRoutingTable indexShard, BufferedChecksumStreamOutput out) throws IOException {
out.writeVInt(indexShard.shardId.id());
out.writeVInt(indexShard.shards.size());
// Order allocated shards by allocationId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

public void writeVerifiableTo(StreamOutput out) throws IOException {
public void writeVerifiableTo(BufferedChecksumStreamOutput out) throws IOException {
out.writeLong(version);
((BufferedChecksumStreamOutput) out).writeMapValues(indicesRouting, (stream, value) -> value.writeVerifiableTo(stream));
out.writeMapValues(indicesRouting, (stream, value) -> value.writeVerifiableTo((BufferedChecksumStreamOutput) stream));
}

private static class RoutingTableDiff implements Diff<RoutingTable>, StringKeyDiffProvider<IndexRoutingTable> {
Expand Down

0 comments on commit 0978f7b

Please sign in to comment.