From e8226d4c1470a48a548dcc8ad9349d2dc1713989 Mon Sep 17 00:00:00 2001 From: bansvaru Date: Thu, 10 Aug 2023 17:41:58 +0530 Subject: [PATCH] Add support to download IndexMetadata from Remote Cluster State Signed-off-by: bansvaru --- .../cluster/store/RemoteClusterStateService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/src/main/java/org/opensearch/cluster/store/RemoteClusterStateService.java b/server/src/main/java/org/opensearch/cluster/store/RemoteClusterStateService.java index 5127ff9637936..e733ff3530c68 100644 --- a/server/src/main/java/org/opensearch/cluster/store/RemoteClusterStateService.java +++ b/server/src/main/java/org/opensearch/cluster/store/RemoteClusterStateService.java @@ -15,6 +15,8 @@ import org.opensearch.common.blobstore.BlobMetadata; import org.opensearch.cluster.store.ClusterMetadataMarker.UploadedIndexMetadata; import org.opensearch.common.settings.Settings; +import org.opensearch.core.common.io.stream.InputStreamStreamInput; +import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.indices.IndicesService; import org.opensearch.repositories.RepositoriesService; import org.opensearch.repositories.Repository; @@ -194,4 +196,15 @@ public String getLatestMarkerFileName(String clusterUUID, String clusterState) { } return null; } + + public Map getLatestIndexMetadata(String clusterUUID, String clusterName) throws IOException { + Map remoteIndexMetadata = new HashMap<>(); + ClusterMetadataMarker clusterMetadataMarker = getLatestClusterMetadataMarker(clusterUUID, clusterName); + for (Map.Entry entry: clusterMetadataMarker.getIndices().entrySet()) { + IndexMetadata indexMetadata = IndexMetadata.readFrom(new InputStreamStreamInput( + getMarkerBlobContainer(clusterUUID, clusterName).readBlob(entry.getValue().getUploadedFilename()))); + remoteIndexMetadata.put(entry.getKey(), indexMetadata); + } + return remoteIndexMetadata; + } }