Skip to content

Commit

Permalink
Remove first ephemeral upload check from incremental update
Browse files Browse the repository at this point in the history
Signed-off-by: Sooraj Sinha <[email protected]>
  • Loading branch information
soosinha committed Jun 16, 2024
1 parent d61fe23 commit e7bc511
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,11 @@ public RemoteClusterStateManifestInfo writeIncrementalMetadata(
assert previousClusterState.metadata().coordinationMetadata().term() == clusterState.metadata().coordinationMetadata().term();

boolean firstUploadForSplitGlobalMetadata = !previousManifest.hasMetadataAttributesFiles();
boolean firstUploadForEphemeralMetadata = previousManifest.getDiscoveryNodesMetadata() == null;

final DiffableUtils.MapDiff<String, Metadata.Custom, Map<String, Metadata.Custom>> customsDiff = remoteGlobalMetadataManager
.getCustomsDiff(clusterState, previousClusterState, firstUploadForSplitGlobalMetadata, isPublicationEnabled);
final DiffableUtils.MapDiff<String, ClusterState.Custom, Map<String, ClusterState.Custom>> clusterStateCustomsDiff =
remoteClusterStateAttributesManager.getUpdatedCustoms(
clusterState,
previousClusterState,
isPublicationEnabled,
firstUploadForEphemeralMetadata
);
remoteClusterStateAttributesManager.getUpdatedCustoms(clusterState, previousClusterState, isPublicationEnabled, false);
final Map<String, UploadedMetadataAttribute> allUploadedCustomMap = new HashMap<>(previousManifest.getCustomMetadataMap());
final Map<String, UploadedMetadataAttribute> allUploadedClusterStateCustomsMap = new HashMap<>(
previousManifest.getClusterStateCustomMap()
Expand Down Expand Up @@ -351,15 +345,17 @@ public RemoteClusterStateManifestInfo writeIncrementalMetadata(
;
boolean updateSettingsMetadata = firstUploadForSplitGlobalMetadata
|| Metadata.isSettingsMetadataEqual(previousClusterState.metadata(), clusterState.metadata()) == false;
boolean updateTransientSettingsMetadata = firstUploadForEphemeralMetadata
|| Metadata.isTransientSettingsMetadataEqual(previousClusterState.metadata(), clusterState.metadata()) == false;
boolean updateTransientSettingsMetadata = Metadata.isTransientSettingsMetadataEqual(
previousClusterState.metadata(),
clusterState.metadata()
) == false;
boolean updateTemplatesMetadata = firstUploadForSplitGlobalMetadata
|| Metadata.isTemplatesMetadataEqual(previousClusterState.metadata(), clusterState.metadata()) == false;

final boolean updateDiscoveryNodes = isPublicationEnabled
&& clusterState.getNodes().delta(previousClusterState.getNodes()).hasChanges();
final boolean updateClusterBlocks = isPublicationEnabled && !clusterState.blocks().equals(previousClusterState.blocks());
final boolean updateHashesOfConsistentSettings = isPublicationEnabled && firstUploadForEphemeralMetadata
final boolean updateHashesOfConsistentSettings = isPublicationEnabled
|| Metadata.isHashesOfConsistentSettingsEqual(previousClusterState.metadata(), clusterState.metadata()) == false;

uploadedMetadataResults = writeMetadataInParallel(
Expand Down Expand Up @@ -401,13 +397,13 @@ public RemoteClusterStateManifestInfo writeIncrementalMetadata(
if (!updateTemplatesMetadata) {
uploadedMetadataResults.uploadedTemplatesMetadata = previousManifest.getTemplatesMetadata();
}
if (!updateDiscoveryNodes && !firstUploadForEphemeralMetadata) {
if (!updateDiscoveryNodes) {
uploadedMetadataResults.uploadedDiscoveryNodes = previousManifest.getDiscoveryNodesMetadata();
}
if (!updateClusterBlocks && !firstUploadForEphemeralMetadata) {
if (!updateClusterBlocks) {
uploadedMetadataResults.uploadedClusterBlocks = previousManifest.getClusterBlocksMetadata();
}
if (!updateHashesOfConsistentSettings && !firstUploadForEphemeralMetadata) {
if (!updateHashesOfConsistentSettings) {
uploadedMetadataResults.uploadedHashesOfConsistentSettings = previousManifest.getHashesOfConsistentSettings();
}
uploadedMetadataResults.uploadedCustomMetadataMap = allUploadedCustomMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,27 +284,27 @@ DiffableUtils.MapDiff<String, Metadata.Custom, Map<String, Metadata.Custom>> get
ClusterState currentState,
ClusterState previousState,
boolean firstUploadForSplitGlobalMetadata,
boolean includeEphemeral
boolean isRemotePublicationEnabled
) {
if (firstUploadForSplitGlobalMetadata) {
// For first split global metadata upload, we want to upload all customs
return DiffableUtils.diff(
Collections.emptyMap(),
filterCustoms(currentState.metadata().customs(), includeEphemeral),
filterCustoms(currentState.metadata().customs(), isRemotePublicationEnabled),
DiffableUtils.getStringKeySerializer(),
NonDiffableValueSerializer.getAbstractInstance()
);
}
return DiffableUtils.diff(
filterCustoms(previousState.metadata().customs(), includeEphemeral),
filterCustoms(currentState.metadata().customs(), includeEphemeral),
filterCustoms(previousState.metadata().customs(), isRemotePublicationEnabled),
filterCustoms(currentState.metadata().customs(), isRemotePublicationEnabled),
DiffableUtils.getStringKeySerializer(),
NonDiffableValueSerializer.getAbstractInstance()
);
}

public static Map<String, Metadata.Custom> filterCustoms(Map<String, Metadata.Custom> customs, boolean includeEphemeral) {
if (includeEphemeral) {
public static Map<String, Metadata.Custom> filterCustoms(Map<String, Metadata.Custom> customs, boolean isRemotePublicationEnabled) {
if (isRemotePublicationEnabled) {
return customs;
}
return customs.entrySet()
Expand Down

0 comments on commit e7bc511

Please sign in to comment.