Skip to content

Commit

Permalink
Remove custom serialiser elsewhere
Browse files Browse the repository at this point in the history
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
  • Loading branch information
Bukhtawar committed Aug 4, 2024
1 parent b1781a0 commit 607317a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,7 @@ public DiffableUtils.MapDiff<String, IndexRoutingTable, Map<String, IndexRouting
RoutingTable before,
RoutingTable after
) {
return DiffableUtils.diff(
before.getIndicesRouting(),
after.getIndicesRouting(),
DiffableUtils.getStringKeySerializer(),
CUSTOM_ROUTING_TABLE_DIFFABLE_VALUE_SERIALIZER
);
return new RoutingTableIncrementalDiff(before, after).getIndicesRouting();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ public DiffableUtils.MapDiff<String, IndexRoutingTable, Map<String, IndexRouting
RoutingTable before,
RoutingTable after
) {
return DiffableUtils.diff(
Map.of(),
Map.of(),
DiffableUtils.getStringKeySerializer(),
CUSTOM_ROUTING_TABLE_DIFFABLE_VALUE_SERIALIZER
);
return new RoutingTableIncrementalDiff(before, after).getIndicesRouting();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,6 @@
*/
public interface RemoteRoutingTableService extends LifecycleComponent {

DiffableUtils.DiffableValueSerializer<String, IndexRoutingTable> CUSTOM_ROUTING_TABLE_DIFFABLE_VALUE_SERIALIZER =
new DiffableUtils.DiffableValueSerializer<>() {
@Override
public IndexRoutingTable read(StreamInput in, String key) throws IOException {
return IndexRoutingTable.readFrom(in);
}

@Override
public void write(IndexRoutingTable value, StreamOutput out) throws IOException {
value.writeTo(out);
}

@Override
public Diff<IndexRoutingTable> readDiff(StreamInput in, String key) throws IOException {
return IndexRoutingTable.readDiffFrom(in);
}

@Override
public Diff<IndexRoutingTable> diff(IndexRoutingTable currentState, IndexRoutingTable previousState) {
return new RoutingTableIncrementalDiff.IndexRoutingTableIncrementalDiff(currentState.getIndex(), currentState, previousState);
}
};

List<IndexRoutingTable> getIndicesRouting(RoutingTable routingTable);

void getAsyncIndexRoutingReadAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.cluster.node.DiscoveryNodes;
import org.opensearch.cluster.routing.IndexRoutingTable;
import org.opensearch.cluster.routing.RoutingTableIncrementalDiff;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.core.common.bytes.BytesReference;
Expand All @@ -42,7 +43,6 @@
import static java.util.stream.Collectors.toList;
import static org.opensearch.Version.CURRENT;
import static org.opensearch.cluster.ClusterState.EMPTY_STATE;
import static org.opensearch.cluster.routing.remote.RemoteRoutingTableService.CUSTOM_ROUTING_TABLE_DIFFABLE_VALUE_SERIALIZER;
import static org.opensearch.core.common.transport.TransportAddress.META_ADDRESS;
import static org.opensearch.gateway.remote.ClusterMetadataManifest.CODEC_V3;
import static org.opensearch.gateway.remote.RemoteClusterStateServiceTests.generateClusterStateWithOneIndex;
Expand Down Expand Up @@ -163,15 +163,9 @@ public void testClusterStateWithRoutingTableDiffInDiffManifestXContent1() throws

private ClusterStateDiffManifest verifyRoutingTableDiffManifest(ClusterState previousState, ClusterState currentState) {
// Create initial and updated IndexRoutingTable maps
Map<String, IndexRoutingTable> initialRoutingTableMap = previousState.getRoutingTable().indicesRouting();
Map<String, IndexRoutingTable> updatedRoutingTableMap = currentState.getRoutingTable().indicesRouting();

DiffableUtils.MapDiff<String, IndexRoutingTable, Map<String, IndexRoutingTable>> routingTableIncrementalDiff = DiffableUtils.diff(
initialRoutingTableMap,
updatedRoutingTableMap,
DiffableUtils.getStringKeySerializer(),
CUSTOM_ROUTING_TABLE_DIFFABLE_VALUE_SERIALIZER
);
DiffableUtils.MapDiff<String, IndexRoutingTable, Map<String, IndexRoutingTable>> routingTableIncrementalDiff = new RoutingTableIncrementalDiff(
previousState.getRoutingTable(),
currentState.getRoutingTable()).getIndicesRouting();
ClusterStateDiffManifest manifest = new ClusterStateDiffManifest(
currentState,
previousState,
Expand Down

0 comments on commit 607317a

Please sign in to comment.