From 296c86d8215566caebe5ab91dd0d0bfe174fc484 Mon Sep 17 00:00:00 2001 From: Sachin Kale Date: Wed, 14 Aug 2024 14:51:04 +0530 Subject: [PATCH] Address PR comments Signed-off-by: Sachin Kale --- .../RemoteStorePinnedTimestampService.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/server/src/main/java/org/opensearch/node/remotestore/RemoteStorePinnedTimestampService.java b/server/src/main/java/org/opensearch/node/remotestore/RemoteStorePinnedTimestampService.java index 582a0bf928718..57cf8e5495529 100644 --- a/server/src/main/java/org/opensearch/node/remotestore/RemoteStorePinnedTimestampService.java +++ b/server/src/main/java/org/opensearch/node/remotestore/RemoteStorePinnedTimestampService.java @@ -21,6 +21,7 @@ import org.opensearch.common.util.concurrent.AbstractAsyncTask; import org.opensearch.core.action.ActionListener; import org.opensearch.gateway.remote.model.RemotePinnedTimestamps; +import org.opensearch.gateway.remote.model.RemotePinnedTimestamps.PinnedTimestamps; import org.opensearch.gateway.remote.model.RemoteStorePinnedTimestampsBlobStore; import org.opensearch.index.translog.transfer.BlobStoreTransferService; import org.opensearch.node.Node; @@ -31,6 +32,7 @@ import java.io.Closeable; import java.io.IOException; +import java.util.HashMap; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -153,7 +155,7 @@ public void unpinTimestamp(long timestamp, String pinningEntity, ActionListener< updatePinning(pinnedTimestamps -> pinnedTimestamps.unpin(timestamp, pinningEntity), listener); } - private void updatePinning(Consumer updateConsumer, ActionListener listener) { + private void updatePinning(Consumer updateConsumer, ActionListener listener) { RemotePinnedTimestamps remotePinnedTimestamps = new RemotePinnedTimestamps( clusterService.state().metadata().clusterUUID(), blobStoreRepository.getCompressor() @@ -162,7 +164,7 @@ private void updatePinning(Consumer upd blobStoreTransferService.listAllInSortedOrder(path, remotePinnedTimestamps.getType(), Integer.MAX_VALUE, new ActionListener<>() { @Override public void onResponse(List blobMetadata) { - RemotePinnedTimestamps.PinnedTimestamps pinnedTimestamps = remotePinnedTimestamps.getPinnedTimestamps(); + PinnedTimestamps pinnedTimestamps = new PinnedTimestamps(new HashMap<>()); if (blobMetadata.isEmpty() == false) { pinnedTimestamps = readExistingPinnedTimestamps(blobMetadata.get(0).name(), remotePinnedTimestamps); } @@ -194,10 +196,7 @@ public void onFailure(Exception e) { }); } - private RemotePinnedTimestamps.PinnedTimestamps readExistingPinnedTimestamps( - String blobFilename, - RemotePinnedTimestamps remotePinnedTimestamps - ) { + private PinnedTimestamps readExistingPinnedTimestamps(String blobFilename, RemotePinnedTimestamps remotePinnedTimestamps) { remotePinnedTimestamps.setBlobFileName(blobFilename); remotePinnedTimestamps.setFullBlobName(pinnedTimestampsBlobStore.getBlobPathForUpload(remotePinnedTimestamps)); try { @@ -258,10 +257,7 @@ public void onResponse(List blobMetadata) { if (blobMetadata.isEmpty()) { return; } - RemotePinnedTimestamps.PinnedTimestamps pinnedTimestamps = readExistingPinnedTimestamps( - blobMetadata.get(0).name(), - remotePinnedTimestamps - ); + PinnedTimestamps pinnedTimestamps = readExistingPinnedTimestamps(blobMetadata.get(0).name(), remotePinnedTimestamps); logger.debug( "Fetched pinned timestamps from remote store: {} - {}", triggerTimestamp,