Skip to content

Commit

Permalink
Remove get/set method from interface
Browse files Browse the repository at this point in the history
Signed-off-by: Sooraj Sinha <soosinha@amazon.com>
  • Loading branch information
soosinha committed Jun 5, 2024
1 parent caf61a6 commit e1eddbe
Show file tree
Hide file tree
Showing 18 changed files with 12 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface RemoteWritableEntityStore<T, U extends RemoteWriteableEntity<T>

public void writeAsync(U entity, ActionListener<Void> listener);

public U read(U entity) throws IOException;
public T read(U entity) throws IOException;

public void readAsync(U entity, ActionListener<T> listener);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@
* @param <T> The object type which can be uploaded to or downloaded from remote storage.
*/
public interface RemoteWriteableEntity<T> {

/**
* @param object The object T which is to be set in this writable entity
*/
public void set(T object);

/**
* @return The entity T contained within this class
*/
public T get();

/**
* @return An InputStream created by serializing the entity T
* @throws IOException Exception encountered while serialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Metadata getGlobalMetadata(String clusterUUID, ClusterMetadataManifest clusterMe
if (globalMetadataFileName != null) {
RemoteGlobalMetadata remoteGlobalMetadata = new RemoteGlobalMetadata(globalMetadataFileName, clusterUUID,
compressor, namedXContentRegistry);
return globalMetadataBlobStore.read(remoteGlobalMetadata).get();
return globalMetadataBlobStore.read(remoteGlobalMetadata);
} else if (clusterMetadataManifest.hasMetadataAttributesFiles()) {
CoordinationMetadata coordinationMetadata = getCoordinationMetadata(
clusterUUID,
Expand Down Expand Up @@ -239,7 +239,7 @@ public CoordinationMetadata getCoordinationMetadata(String clusterUUID, String c
if (coordinationMetadataFileName != null) {
RemoteCoordinationMetadata remoteCoordinationMetadata = new RemoteCoordinationMetadata(coordinationMetadataFileName, clusterUUID,
compressor, namedXContentRegistry);
return coordinationMetadataBlobStore.read(remoteCoordinationMetadata).get();
return coordinationMetadataBlobStore.read(remoteCoordinationMetadata);
} else {
return CoordinationMetadata.EMPTY_METADATA;
}
Expand All @@ -257,7 +257,7 @@ public Settings getSettingsMetadata(String clusterUUID, String settingsMetadataF
if (settingsMetadataFileName != null) {
RemotePersistentSettingsMetadata remotePersistentSettingsMetadata = new RemotePersistentSettingsMetadata(settingsMetadataFileName, clusterUUID,
compressor, namedXContentRegistry);
return persistentSettingsBlobStore.read(remotePersistentSettingsMetadata).get();
return persistentSettingsBlobStore.read(remotePersistentSettingsMetadata);
} else {
return Settings.EMPTY;
}
Expand All @@ -275,7 +275,7 @@ public TemplatesMetadata getTemplatesMetadata(String clusterUUID, String templat
if (templatesMetadataFileName != null) {
RemoteTemplatesMetadata remoteTemplatesMetadata = new RemoteTemplatesMetadata(templatesMetadataFileName, clusterUUID,
compressor, namedXContentRegistry);
return templatesMetadataBlobStore.read(remoteTemplatesMetadata).get();
return templatesMetadataBlobStore.read(remoteTemplatesMetadata);
} else {
return TemplatesMetadata.EMPTY_METADATA;
}
Expand All @@ -292,7 +292,7 @@ public Metadata.Custom getCustomsMetadata(String clusterUUID, String customMetad
try {
// Fetch Custom metadata
RemoteCustomMetadata remoteCustomMetadata = new RemoteCustomMetadata(customMetadataFileName, custom, clusterUUID, compressor, namedXContentRegistry);
return customMetadataBlobStore.read(remoteCustomMetadata).get();
return customMetadataBlobStore.read(remoteCustomMetadata);
} catch (IOException e) {
throw new IllegalStateException(
String.format(Locale.ROOT, "Error while downloading Custom Metadata - %s", customMetadataFileName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ IndexMetadata getIndexMetadata(
RemoteIndexMetadata remoteIndexMetadata = new RemoteIndexMetadata(RemoteClusterStateUtils.getFormattedFileName(
uploadedIndexMetadata.getUploadedFilename(), manifestCodecVersion), clusterUUID, compressor, namedXContentRegistry);
try {
return indexMetadataBlobStore.read(remoteIndexMetadata).get();
return indexMetadataBlobStore.read(remoteIndexMetadata);
} catch (IOException e) {
throw new IllegalStateException(
String.format(Locale.ROOT, "Error while downloading IndexMetadata - %s", uploadedIndexMetadata.getUploadedFilename()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ ClusterMetadataManifest fetchRemoteClusterMetadataManifest(String clusterName, S
try {
String fullBlobName = getManifestFolderPath(clusterName, clusterUUID).buildAsString() + filename;
RemoteClusterMetadataManifest remoteClusterMetadataManifest = new RemoteClusterMetadataManifest(fullBlobName, clusterUUID, compressor, namedXContentRegistry);
return manifestBlobStore.read(remoteClusterMetadataManifest).get();
return manifestBlobStore.read(remoteClusterMetadataManifest);
} catch (IOException e) {
throw new IllegalStateException(String.format(Locale.ROOT, "Error while downloading cluster metadata - %s", filename), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,6 @@ public UploadedMetadata getUploadedMetadata() {
return new UploadedMetadataAttribute(CLUSTER_BLOCKS, blobName);
}

@Override
public void set(final ClusterBlocks clusterBlocks) {
this.clusterBlocks = clusterBlocks;
}

@Override
public ClusterBlocks get() {
return clusterBlocks;
}


@Override
public InputStream serialize() throws IOException {
return CLUSTER_BLOCKS_FORMAT.serialize(clusterBlocks, generateBlobFileName(), getCompressor(), RemoteClusterStateUtils.FORMAT_PARAMS).streamInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ public UploadedMetadata getUploadedMetadata() {
return new UploadedMetadataAttribute(MANIFEST_PATH_TOKEN, blobName);
}

@Override
public void set(final ClusterMetadataManifest manifest) {
this.clusterMetadataManifest = manifest;
}

@Override
public ClusterMetadataManifest get() {
return clusterMetadataManifest;
}

@Override
public InputStream serialize() throws IOException {
return CLUSTER_METADATA_MANIFEST_FORMAT.serialize(clusterMetadataManifest, generateBlobFileName(), getCompressor(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public RemoteClusterStateBlobStore(

@Override
public void writeAsync(final U entity, final ActionListener<Void> listener) {
assert entity.get() != null;
try {
try (InputStream inputStream = entity.serialize()) {
BlobPath blobPath = getBlobPathForUpload(entity);
Expand All @@ -64,19 +63,17 @@ public void writeAsync(final U entity, final ActionListener<Void> listener) {
}

@Override
public U read(final U entity) throws IOException {
public T read(final U entity) throws IOException {
// TODO Add timing logs and tracing
assert entity.get() == null && entity.getFullBlobName() != null;
T object = entity.deserialize(transferService.downloadBlob(getBlobPathForDownload(entity), entity.getBlobFileName()));
entity.set(object);
return entity;
assert entity.getFullBlobName() != null;
return entity.deserialize(transferService.downloadBlob(getBlobPathForDownload(entity), entity.getBlobFileName()));
}

@Override
public void readAsync(final U entity, final ActionListener<T> listener) {
executorService.execute(() -> {
try {
listener.onResponse(read(entity).get());
listener.onResponse(read(entity));
} catch (Exception e) {
listener.onFailure(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,6 @@ public ClusterMetadataManifest.UploadedMetadata getUploadedMetadata() {
return new ClusterMetadataManifest.UploadedMetadataAttribute(String.join(CUSTOM_DELIMITER, CLUSTER_STATE_CUSTOM, customType), blobName);
}

@Override
public void set(Custom custom) {
this.custom = custom;
}

@Override
public ClusterState.Custom get() {
return custom;
}

@Override
public InputStream serialize() throws IOException {
return clusterStateCustomBlobStoreFormat.serialize(custom, generateBlobFileName(), getCompressor(), RemoteClusterStateUtils.FORMAT_PARAMS).streamInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ public String generateBlobFileName() {
return blobFileName;
}

@Override
public void set(final CoordinationMetadata coordinationMetadata) {
this.coordinationMetadata = coordinationMetadata;
}

@Override
public CoordinationMetadata get() {
return coordinationMetadata;
}

@Override
public InputStream serialize() throws IOException {
return COORDINATION_METADATA_FORMAT.serialize(coordinationMetadata, generateBlobFileName(), getCompressor(), RemoteClusterStateUtils.FORMAT_PARAMS).streamInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,6 @@ public String generateBlobFileName() {
return blobFileName;
}

@Override
public void set(final Custom custom) {
this.custom = custom;
}

@Override
public Custom get() {
return custom;
}

@Override
public InputStream serialize() throws IOException {
return customBlobStoreFormat.serialize(custom, generateBlobFileName(), getCompressor(), RemoteClusterStateUtils.FORMAT_PARAMS).streamInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ public UploadedMetadata getUploadedMetadata() {
return new UploadedMetadataAttribute(DISCOVERY_NODES, blobName);
}

@Override
public void set(final DiscoveryNodes discoveryNodes) {
this.discoveryNodes = discoveryNodes;
}

@Override
public DiscoveryNodes get() {
return discoveryNodes;
}

@Override
public InputStream serialize() throws IOException {
return DISCOVERY_NODES_FORMAT.serialize(discoveryNodes, generateBlobFileName(), getCompressor(), RemoteClusterStateUtils.FORMAT_PARAMS).streamInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ public UploadedMetadata getUploadedMetadata() {
throw new UnsupportedOperationException();
}

@Override
public void set(final Metadata metadata) {
this.metadata = metadata;
}

@Override
public Metadata get() {
return metadata;
}

@Override
public InputStream serialize() throws IOException {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ public ClusterMetadataManifest.UploadedMetadata getUploadedMetadata() {
return new ClusterMetadataManifest.UploadedMetadataAttribute(HASHES_OF_CONSISTENT_SETTINGS, blobName);
}

@Override
public void set(final DiffableStringMap hashesOfConsistentSettings) {
this.hashesOfConsistentSettings = hashesOfConsistentSettings;
}

@Override
public DiffableStringMap get() {
return hashesOfConsistentSettings;
}

@Override
public InputStream serialize() throws IOException {
return HASHES_OF_CONSISTENT_SETTINGS_FORMAT.serialize(hashesOfConsistentSettings, generateBlobFileName(), getCompressor(), RemoteClusterStateUtils.FORMAT_PARAMS).streamInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ public RemoteIndexMetadata(final String blobName, final String clusterUUID, fina
this.blobName = blobName;
}

@Override
public void set(final IndexMetadata indexMetadata) {
this.indexMetadata = indexMetadata;
}

@Override
public IndexMetadata get() {
return indexMetadata;
}



@Override
public BlobPathParameters getBlobPathParameters() {
return new BlobPathParameters(List.of(INDEX_PATH_TOKEN, indexMetadata.getIndexUUID()), "metadata");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ public String generateBlobFileName() {
return blobFileName;
}

@Override
public void set(final Settings settings) {
this.persistentSettings = settings;
}

@Override
public Settings get() {
return persistentSettings;
}

@Override
public InputStream serialize() throws IOException {
return SETTINGS_METADATA_FORMAT.serialize(persistentSettings, generateBlobFileName(), getCompressor(), RemoteClusterStateUtils.FORMAT_PARAMS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,6 @@ public String generateBlobFileName() {
return blobFileName;
}

@Override
public void set(final TemplatesMetadata templatesMetadata) {
this.templatesMetadata = templatesMetadata;
}

@Override
public TemplatesMetadata get() {
return templatesMetadata;
}

@Override
public InputStream serialize() throws IOException {
return TEMPLATES_METADATA_FORMAT.serialize(templatesMetadata, generateBlobFileName(), getCompressor(), RemoteClusterStateUtils.FORMAT_PARAMS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ public String generateBlobFileName() {
return blobFileName;
}

@Override
public void set(final Settings settings) {
this.transientSettings = settings;
}

@Override
public Settings get() {
return transientSettings;
}

@Override
public InputStream serialize() throws IOException {
return SETTINGS_METADATA_FORMAT.serialize(transientSettings, generateBlobFileName(), getCompressor(), RemoteClusterStateUtils.FORMAT_PARAMS)
Expand Down

0 comments on commit e1eddbe

Please sign in to comment.