Skip to content

Commit

Permalink
Simplify apply diff
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 5, 2024
1 parent c31e278 commit 987cb02
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ public RemoteClusterStateManifestInfo writeIncrementalMetadata(
final DiffableUtils.MapDiff<String, IndexRoutingTable, Map<String, IndexRoutingTable>> routingTableIncrementalDiff =
remoteRoutingTableService.getIndicesRoutingMapDiff(previousClusterState.getRoutingTable(), clusterState.getRoutingTable());

Map<String, Diff<IndexRoutingTable>> indexRoutingTableDiffs = routingTableIncrementalDiff.getDiffs();
routingTableIncrementalDiff.getDiffs().forEach((k, v) -> indicesRoutingToUpload.add(clusterState.getRoutingTable().index(k)));
routingTableIncrementalDiff.getUpserts().forEach((k, v) -> indicesRoutingToUpload.add(v));

Expand Down Expand Up @@ -1020,7 +1019,7 @@ ClusterState readClusterStateInParallel(
Map<String, UploadedMetadataAttribute> clusterStateCustomToRead,
boolean readIndexRoutingTableDiff,
boolean includeEphemeral
) throws IOException {
) {
int totalReadTasks = indicesToRead.size() + customToRead.size() + (readCoordinationMetadata ? 1 : 0) + (readSettingsMetadata
? 1
: 0) + (readTemplatesMetadata ? 1 : 0) + (readDiscoveryNodes ? 1 : 0) + (readClusterBlocks ? 1 : 0)
Expand Down Expand Up @@ -1295,11 +1294,7 @@ ClusterState readClusterStateInParallel(
);
RoutingTableIncrementalDiff routingTableDiff = readIndexRoutingTableDiffResults.get();
if (routingTableDiff != null) {
routingTableDiff.getIndicesRouting().getDiffs().forEach((key, diff) -> {
IndexRoutingTable previousIndexRoutingTable = indicesRouting.get(key);
IndexRoutingTable updatedTable = diff.apply(previousIndexRoutingTable);
indicesRouting.put(key, updatedTable);
});
routingTableDiff.apply(previousState.getRoutingTable());
}
clusterStateBuilder.routingTable(new RoutingTable(manifest.getRoutingTableVersion(), indicesRouting));

Expand Down Expand Up @@ -1360,8 +1355,7 @@ public ClusterState getClusterStateForManifest(

}

public ClusterState getClusterStateUsingDiff(ClusterMetadataManifest manifest, ClusterState previousState, String localNodeId)
throws IOException {
public ClusterState getClusterStateUsingDiff(ClusterMetadataManifest manifest, ClusterState previousState, String localNodeId) {
assert manifest.getDiffManifest() != null : "Diff manifest null which is required for downloading cluster state";
ClusterStateDiffManifest diff = manifest.getDiffManifest();
List<UploadedIndexMetadata> updatedIndices = diff.getIndicesUpdated().stream().map(idx -> {
Expand Down

0 comments on commit 987cb02

Please sign in to comment.