Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <[email protected]>
  • Loading branch information
Sachin Kale committed Aug 14, 2024
1 parent eeeae20 commit 296c86d
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -153,7 +155,7 @@ public void unpinTimestamp(long timestamp, String pinningEntity, ActionListener<
updatePinning(pinnedTimestamps -> pinnedTimestamps.unpin(timestamp, pinningEntity), listener);
}

private void updatePinning(Consumer<RemotePinnedTimestamps.PinnedTimestamps> updateConsumer, ActionListener<Void> listener) {
private void updatePinning(Consumer<PinnedTimestamps> updateConsumer, ActionListener<Void> listener) {
RemotePinnedTimestamps remotePinnedTimestamps = new RemotePinnedTimestamps(
clusterService.state().metadata().clusterUUID(),
blobStoreRepository.getCompressor()
Expand All @@ -162,7 +164,7 @@ private void updatePinning(Consumer<RemotePinnedTimestamps.PinnedTimestamps> upd
blobStoreTransferService.listAllInSortedOrder(path, remotePinnedTimestamps.getType(), Integer.MAX_VALUE, new ActionListener<>() {
@Override
public void onResponse(List<BlobMetadata> blobMetadata) {
RemotePinnedTimestamps.PinnedTimestamps pinnedTimestamps = remotePinnedTimestamps.getPinnedTimestamps();
PinnedTimestamps pinnedTimestamps = new PinnedTimestamps(new HashMap<>());
if (blobMetadata.isEmpty() == false) {
pinnedTimestamps = readExistingPinnedTimestamps(blobMetadata.get(0).name(), remotePinnedTimestamps);
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -258,10 +257,7 @@ public void onResponse(List<BlobMetadata> 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,
Expand Down

0 comments on commit 296c86d

Please sign in to comment.