Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Shivansh Arora <[email protected]>
  • Loading branch information
shiv0408 committed Jun 10, 2024
1 parent 3868cb9 commit f39d686
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 277 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,6 @@ public ClusterStateDiffManifest getDiffManifest() {
return diffManifest;
}

public UploadedMetadataAttribute getDiscoverNodeMetadata() {
return uploadedDiscoveryNodesMetadata;
}

public Map<String, UploadedMetadataAttribute> getClusterStateCustomMap() {
return uploadedClusterStateCustomMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.xcontent.MediaTypeRegistry;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.ToXContentFragment;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParseException;
import org.opensearch.core.xcontent.XContentParser;
Expand All @@ -39,7 +39,7 @@
*
* @opensearch.internal
*/
public class ClusterStateDiffManifest implements ToXContentObject, Writeable {
public class ClusterStateDiffManifest implements ToXContentFragment, Writeable {
private static final String FROM_STATE_UUID_FIELD = "from_state_uuid";
private static final String TO_STATE_UUID_FIELD = "to_state_uuid";
private static final String METADATA_DIFF_FIELD = "metadata_diff";
Expand Down Expand Up @@ -183,71 +183,68 @@ public ClusterStateDiffManifest(StreamInput in) throws IOException {

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(FROM_STATE_UUID_FIELD, fromStateUUID);
builder.field(TO_STATE_UUID_FIELD, toStateUUID);
builder.startObject(METADATA_DIFF_FIELD);
{
builder.field(FROM_STATE_UUID_FIELD, fromStateUUID);
builder.field(TO_STATE_UUID_FIELD, toStateUUID);
builder.startObject(METADATA_DIFF_FIELD);
{
builder.field(COORDINATION_METADATA_UPDATED_FIELD, coordinationMetadataUpdated);
builder.field(SETTINGS_METADATA_UPDATED_FIELD, settingsMetadataUpdated);
builder.field(TRANSIENT_SETTINGS_METADATA_UPDATED_FIELD, transientSettingsMetadataUpdated);
builder.field(TEMPLATES_METADATA_UPDATED_FIELD, templatesMetadataUpdated);
builder.startObject(INDICES_DIFF_FIELD);
builder.startArray(UPSERTS_FIELD);
for (String index : indicesUpdated) {
builder.value(index);
}
builder.endArray();
builder.startArray(DELETES_FIELD);
for (String index : indicesDeleted) {
builder.value(index);
}
builder.endArray();
builder.endObject();
builder.startObject(METADATA_CUSTOM_DIFF_FIELD);
builder.startArray(UPSERTS_FIELD);
for (String custom : customMetadataUpdated) {
builder.value(custom);
}
builder.endArray();
builder.startArray(DELETES_FIELD);
for (String custom : customMetadataDeleted) {
builder.value(custom);
}
builder.endArray();
builder.endObject();
builder.field(HASHES_OF_CONSISTENT_SETTINGS_UPDATED_FIELD, hashesOfConsistentSettingsUpdated);
}
builder.endObject();
builder.field(CLUSTER_BLOCKS_UPDATED_FIELD, clusterBlocksUpdated);
builder.field(DISCOVERY_NODES_UPDATED_FIELD, discoveryNodesUpdated);

builder.startObject(ROUTING_TABLE_DIFF);
builder.field(COORDINATION_METADATA_UPDATED_FIELD, coordinationMetadataUpdated);
builder.field(SETTINGS_METADATA_UPDATED_FIELD, settingsMetadataUpdated);
builder.field(TRANSIENT_SETTINGS_METADATA_UPDATED_FIELD, transientSettingsMetadataUpdated);
builder.field(TEMPLATES_METADATA_UPDATED_FIELD, templatesMetadataUpdated);
builder.startObject(INDICES_DIFF_FIELD);
builder.startArray(UPSERTS_FIELD);
for (String index : indicesRoutingUpdated) {
for (String index : indicesUpdated) {
builder.value(index);
}
builder.endArray();
builder.startArray(DELETES_FIELD);
for (String index : indicesRoutingDeleted) {
for (String index : indicesDeleted) {
builder.value(index);
}
builder.endArray();
builder.endObject();
builder.startObject(CLUSTER_STATE_CUSTOM_DIFF_FIELD);
builder.startObject(METADATA_CUSTOM_DIFF_FIELD);
builder.startArray(UPSERTS_FIELD);
for (String custom : clusterStateCustomUpdated) {
for (String custom : customMetadataUpdated) {
builder.value(custom);
}
builder.endArray();
builder.startArray(DELETES_FIELD);
for (String custom : clusterStateCustomDeleted) {
for (String custom : customMetadataDeleted) {
builder.value(custom);
}
builder.endArray();
builder.endObject();

builder.field(HASHES_OF_CONSISTENT_SETTINGS_UPDATED_FIELD, hashesOfConsistentSettingsUpdated);
}
builder.endObject();
builder.field(CLUSTER_BLOCKS_UPDATED_FIELD, clusterBlocksUpdated);
builder.field(DISCOVERY_NODES_UPDATED_FIELD, discoveryNodesUpdated);

builder.startObject(ROUTING_TABLE_DIFF);
builder.startArray(UPSERTS_FIELD);
for (String index : indicesRoutingUpdated) {
builder.value(index);
}
builder.endArray();
builder.startArray(DELETES_FIELD);
for (String index : indicesRoutingDeleted) {
builder.value(index);
}
builder.endArray();
builder.endObject();
builder.startObject(CLUSTER_STATE_CUSTOM_DIFF_FIELD);
builder.startArray(UPSERTS_FIELD);
for (String custom : clusterStateCustomUpdated) {
builder.value(custom);
}
builder.endArray();
builder.startArray(DELETES_FIELD);
for (String custom : clusterStateCustomDeleted) {
builder.value(custom);
}
builder.endArray();
builder.endObject();
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ public RemoteStateTransferException(String errorDesc, RemoteWriteableEntity<?> e
super(errorDesc, cause);
this.entity = entity;
}

@Override
public String toString() {
String message = super.toString();
if (entity != null) {
message += ", failed entity:" + entity;
}
return message;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.opensearch.core.common.io.stream.BytesStreamInput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.compress.Compressor;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.gateway.remote.ClusterMetadataManifest.UploadedMetadata;
import org.opensearch.gateway.remote.ClusterMetadataManifest.UploadedMetadataAttribute;
import org.opensearch.index.remote.RemoteStoreUtils;
Expand All @@ -40,25 +39,14 @@ public class RemoteClusterBlocks extends AbstractRemoteWritableBlobEntity<Cluste
private ClusterBlocks clusterBlocks;
private long stateVersion;

public RemoteClusterBlocks(
final ClusterBlocks clusterBlocks,
long stateVersion,
String clusterUUID,
final Compressor compressor,
final NamedXContentRegistry namedXContentRegistry
) {
super(clusterUUID, compressor, namedXContentRegistry);
public RemoteClusterBlocks(final ClusterBlocks clusterBlocks, long stateVersion, String clusterUUID, final Compressor compressor) {
super(clusterUUID, compressor, null);
this.clusterBlocks = clusterBlocks;
this.stateVersion = stateVersion;
}

public RemoteClusterBlocks(
final String blobName,
final String clusterUUID,
final Compressor compressor,
final NamedXContentRegistry namedXContentRegistry
) {
super(clusterUUID, compressor, namedXContentRegistry);
public RemoteClusterBlocks(final String blobName, final String clusterUUID, final Compressor compressor) {
super(clusterUUID, compressor, null);
this.blobName = blobName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.opensearch.core.common.io.stream.NamedWriteableAwareStreamInput;
import org.opensearch.core.common.io.stream.NamedWriteableRegistry;
import org.opensearch.core.compress.Compressor;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.gateway.remote.ClusterMetadataManifest;
import org.opensearch.index.remote.RemoteStoreUtils;

Expand Down Expand Up @@ -50,10 +49,9 @@ public RemoteClusterStateCustoms(
final long stateVersion,
final String clusterUUID,
final Compressor compressor,
final NamedXContentRegistry namedXContentRegistry,
final NamedWriteableRegistry namedWriteableRegistry
) {
super(clusterUUID, compressor, namedXContentRegistry);
super(clusterUUID, compressor, null);
this.stateVersion = stateVersion;
this.customType = customType;
this.custom = custom;
Expand All @@ -65,18 +63,18 @@ public RemoteClusterStateCustoms(
final String customType,
final String clusterUUID,
final Compressor compressor,
final NamedXContentRegistry namedXContentRegistry,
final NamedWriteableRegistry namedWriteableRegistry
) {
super(clusterUUID, compressor, namedXContentRegistry);
super(clusterUUID, compressor, null);
this.blobName = blobName;
this.customType = customType;
this.namedWriteableRegistry = namedWriteableRegistry;
}

@Override
public BlobPathParameters getBlobPathParameters() {
return new BlobPathParameters(List.of(CLUSTER_STATE_EPHEMERAL_PATH_TOKEN), CLUSTER_STATE_CUSTOM);
String prefix = String.join(CUSTOM_DELIMITER, CLUSTER_STATE_CUSTOM, customType);
return new BlobPathParameters(List.of(CLUSTER_STATE_EPHEMERAL_PATH_TOKEN), prefix);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.opensearch.core.common.io.stream.BytesStreamInput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.compress.Compressor;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.gateway.remote.ClusterMetadataManifest.UploadedMetadata;
import org.opensearch.gateway.remote.ClusterMetadataManifest.UploadedMetadataAttribute;
import org.opensearch.index.remote.RemoteStoreUtils;
Expand Down Expand Up @@ -44,21 +43,15 @@ public RemoteDiscoveryNodes(
final DiscoveryNodes discoveryNodes,
final long stateVersion,
final String clusterUUID,
final Compressor compressor,
final NamedXContentRegistry namedXContentRegistry
final Compressor compressor
) {
super(clusterUUID, compressor, namedXContentRegistry);
super(clusterUUID, compressor, null);
this.discoveryNodes = discoveryNodes;
this.stateVersion = stateVersion;
}

public RemoteDiscoveryNodes(
final String blobName,
final String clusterUUID,
final Compressor compressor,
final NamedXContentRegistry namedXContentRegistry
) {
super(clusterUUID, compressor, namedXContentRegistry);
public RemoteDiscoveryNodes(final String blobName, final String clusterUUID, final Compressor compressor) {
super(clusterUUID, compressor, null);
this.blobName = blobName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.opensearch.core.common.io.stream.BytesStreamInput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.compress.Compressor;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.gateway.remote.ClusterMetadataManifest;
import org.opensearch.index.remote.RemoteStoreUtils;

Expand All @@ -42,21 +41,15 @@ public RemoteHashesOfConsistentSettings(
final DiffableStringMap hashesOfConsistentSettings,
final long metadataVersion,
final String clusterUUID,
final Compressor compressor,
final NamedXContentRegistry namedXContentRegistry
final Compressor compressor
) {
super(clusterUUID, compressor, namedXContentRegistry);
super(clusterUUID, compressor, null);
this.metadataVersion = metadataVersion;
this.hashesOfConsistentSettings = hashesOfConsistentSettings;
}

public RemoteHashesOfConsistentSettings(
final String blobName,
final String clusterUUID,
final Compressor compressor,
final NamedXContentRegistry namedXContentRegistry
) {
super(clusterUUID, compressor, namedXContentRegistry);
public RemoteHashesOfConsistentSettings(final String blobName, final String clusterUUID, final Compressor compressor) {
super(clusterUUID, compressor, null);
this.blobName = blobName;
}

Expand Down
Loading

0 comments on commit f39d686

Please sign in to comment.