Skip to content

Commit

Permalink
Skip ephemeral objects
Browse files Browse the repository at this point in the history
Signed-off-by: Sooraj Sinha <[email protected]>
  • Loading branch information
soosinha committed Jun 11, 2024
1 parent 982a785 commit 9469b7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.opensearch.cluster.metadata.DiffableStringMap;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.cluster.metadata.Metadata;
import org.opensearch.cluster.metadata.Metadata.XContentContext;
import org.opensearch.cluster.metadata.TemplatesMetadata;
import org.opensearch.cluster.node.DiscoveryNodes;
import org.opensearch.cluster.node.DiscoveryNodes.Builder;
Expand Down Expand Up @@ -998,7 +999,8 @@ private ClusterState readClusterStateInParallel(
boolean readClusterBlocks,
List<UploadedIndexMetadata> indicesRoutingToRead,
boolean readHashesOfConsistentSettings,
Map<String, UploadedMetadataAttribute> clusterStateCustomToRead
Map<String, UploadedMetadataAttribute> clusterStateCustomToRead,
boolean includeEphemeral
) throws IOException {
int totalReadTasks = indicesToRead.size() + customToRead.size() + (readCoordinationMetadata ? 1 : 0) + (readSettingsMetadata
? 1
Expand Down Expand Up @@ -1223,7 +1225,10 @@ private ClusterState readClusterStateInParallel(
indexMetadataMap.put(indexMetadata.getIndex().getName(), indexMetadata);
break;
case CUSTOM_METADATA:
metadataBuilder.putCustom(remoteReadResult.getComponentName(), (Metadata.Custom) remoteReadResult.getObj());
Metadata.Custom metadataCustom = (Metadata.Custom) remoteReadResult.getObj();
if (includeEphemeral || (!includeEphemeral && metadataCustom.context().contains(XContentContext.GATEWAY))) {
metadataBuilder.putCustom(remoteReadResult.getComponentName(), (Metadata.Custom) remoteReadResult.getObj());
}
break;
case COORDINATION_METADATA:
metadataBuilder.coordinationMetadata((CoordinationMetadata) remoteReadResult.getObj());
Expand Down Expand Up @@ -1293,7 +1298,8 @@ public ClusterState getClusterStateForManifest(
includeEphemeral && manifest.getClusterBlocksMetadata() != null,
includeEphemeral ? manifest.getIndicesRouting() : emptyList(),
includeEphemeral && manifest.getHashesOfConsistentSettings() != null,
includeEphemeral ? manifest.getClusterStateCustomMap() : emptyMap()
includeEphemeral ? manifest.getClusterStateCustomMap() : emptyMap(),
includeEphemeral
);
} else {
ClusterState clusterState = readClusterStateInParallel(
Expand All @@ -1312,7 +1318,8 @@ public ClusterState getClusterStateForManifest(
false,
emptyList(),
false,
emptyMap()
emptyMap(),
false
);
Metadata.Builder mb = Metadata.builder(remoteGlobalMetadataManager.getGlobalMetadata(manifest.getClusterUUID(), manifest));
mb.indices(clusterState.metadata().indices());
Expand Down Expand Up @@ -1371,7 +1378,8 @@ public ClusterState getClusterStateUsingDiff(
diff.isClusterBlocksUpdated(),
updatedIndexRouting,
diff.isHashesOfConsistentSettingsUpdated(),
updatedClusterStateCustom
updatedClusterStateCustom,
true
);
ClusterState.Builder clusterStateBuilder = ClusterState.builder(updatedClusterState);
Metadata.Builder metadataBuilder = Metadata.builder(updatedClusterState.metadata());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ public void testCoordinationMetadataOnlyUpdated() throws IOException {
Function<ClusterState, ClusterState> updater = (initialClusterState) -> ClusterState.builder(initialClusterState)
.metadata(
Metadata.builder(initialClusterState.metadata())
.version(initialClusterState.metadata().version() + 1)
.coordinationMetadata(
CoordinationMetadata.builder(initialClusterState.coordinationMetadata())
.addVotingConfigExclusion(new CoordinationMetadata.VotingConfigExclusion("excludedNodeId", "excludedNodeName"))
Expand Down

0 comments on commit 9469b7c

Please sign in to comment.