Skip to content

Commit

Permalink
Implement missing methods for EncryptedBlobStore and EncryptedBlobCon…
Browse files Browse the repository at this point in the history
…tainer

Signed-off-by: Sandeep Kumawat <2025sandeepkumawat@gmail.com>
  • Loading branch information
skumawat2025 committed Jun 6, 2024
1 parent 0b2e012 commit 1be954e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.opensearch.common.blobstore;

import org.opensearch.common.CheckedBiConsumer;
import org.opensearch.common.annotation.ExperimentalApi;
import org.opensearch.common.crypto.CryptoHandler;
import org.opensearch.common.crypto.DecryptedRangedStreamProvider;
import org.opensearch.common.crypto.EncryptedHeaderContentSupplier;
Expand Down Expand Up @@ -50,6 +51,14 @@ public InputStream readBlob(String blobName) throws IOException {
return cryptoHandler.createDecryptingStream(inputStream);
}

@ExperimentalApi
@Override
public InputStreamWithMetadata readBlobWithMetadata(String blobName) throws IOException {
InputStreamWithMetadata inputStreamWithMetadata = blobContainer.readBlobWithMetadata(blobName);
InputStream decryptInputStream = cryptoHandler.createDecryptingStream(inputStreamWithMetadata.getInputStream());
return new InputStreamWithMetadata(decryptInputStream, inputStreamWithMetadata.getMetadata());
}

EncryptedHeaderContentSupplier getEncryptedHeaderContentSupplier(String blobName) {
return (start, end) -> {
byte[] buffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public Map<Metric, Map<String, Long>> extendedStats() {
return blobStore.extendedStats();
}

@Override
public boolean isBlobMetadataEnabled() {
return blobStore.isBlobMetadataEnabled();
}

/**
* Closes the EncryptedBlobStore by decrementing the reference count of the CryptoManager and closing the
* underlying BlobStore. This ensures proper cleanup of resources.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void testTranslogMetadataAllowedTrueWithMinVersionNewer() {
when(blobStoreMock.isBlobMetadataEnabled()).thenReturn(true);
RemoteStoreCustomMetadataResolver resolver = new RemoteStoreCustomMetadataResolver(
remoteStoreSettings,
() -> Version.CURRENT,
() -> Version.V_2_15_0,
() -> repositoriesService,
settings
);
Expand All @@ -200,7 +200,7 @@ public void testTranslogMetadataAllowedFalseWithMinVersionNewer() {
RemoteStoreSettings remoteStoreSettings = new RemoteStoreSettings(settings, clusterSettings);
RemoteStoreCustomMetadataResolver resolver = new RemoteStoreCustomMetadataResolver(
remoteStoreSettings,
() -> Version.CURRENT,
() -> Version.V_2_15_0,
() -> repositoriesService,
settings
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private static Metadata createIndexMetadataWithRemoteStoreSettings(String indexN
Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.V_2_15_0)
.put(IndexMetadata.INDEX_REMOTE_STORE_ENABLED_SETTING.getKey(), true)
.put(IndexMetadata.INDEX_REMOTE_TRANSLOG_REPOSITORY_SETTING.getKey(), "dummy-tlog-repo")
.put(IndexMetadata.INDEX_REMOTE_SEGMENT_STORE_REPOSITORY_SETTING.getKey(), "dummy-segment-repo")
Expand Down

0 comments on commit 1be954e

Please sign in to comment.