You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ad...@apache.org on 2023/01/12 11:00:16 UTC
[jackrabbit-oak] 01/01: OAK-10050 - Enable access to the secondary Azure blobstore service endpoint in Oak segment node store
This is an automated email from the ASF dual-hosted git repository.
adulceanu pushed a commit to branch issues/OAK-10050
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit d0b03c1789f32c7118727c038e267598b509da6d
Author: dulceanu <an...@gmail.com>
AuthorDate: Thu Jan 12 11:51:22 2023 +0100
OAK-10050 - Enable access to the secondary Azure blobstore service endpoint in Oak segment node store
---
.../oak/segment/azure/AzureSegmentStoreService.java | 17 +++++++++++++++--
.../jackrabbit/oak/segment/azure/Configuration.java | 6 ++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentStoreService.java b/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentStoreService.java
index 529ae2b74e..9f515bda21 100644
--- a/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentStoreService.java
+++ b/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureSegmentStoreService.java
@@ -19,7 +19,10 @@
package org.apache.jackrabbit.oak.segment.azure;
import com.microsoft.azure.storage.CloudStorageAccount;
+import com.microsoft.azure.storage.LocationMode;
import com.microsoft.azure.storage.StorageException;
+import com.microsoft.azure.storage.blob.BlobRequestOptions;
+import com.microsoft.azure.storage.blob.CloudBlobClient;
import com.microsoft.azure.storage.blob.CloudBlobContainer;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.oak.segment.spi.persistence.SegmentNodeStorePersistence;
@@ -52,6 +55,8 @@ public class AzureSegmentStoreService {
public static final String DEFAULT_ROOT_PATH = "/oak";
+ public static final boolean DEFAULT_ENABLE_SECONDARY_LOCATION = false;
+
private ServiceRegistration registration;
@Activate
@@ -103,7 +108,7 @@ public class AzureSegmentStoreService {
if (!StringUtils.isBlank(configuration.blobEndpoint())) {
connectionString.append("BlobEndpoint=").append(configuration.blobEndpoint()).append(';');
}
- return createAzurePersistence(connectionString.toString(), configuration, false);
+ return createAzurePersistence(connectionString.toString(), configuration, false);
}
@NotNull
@@ -120,7 +125,15 @@ public class AzureSegmentStoreService {
try {
CloudStorageAccount cloud = CloudStorageAccount.parse(connectionString);
log.info("Connection string: '{}'", cloud);
- CloudBlobContainer container = cloud.createCloudBlobClient().getContainerReference(configuration.containerName());
+ CloudBlobClient cloudBlobClient = cloud.createCloudBlobClient();
+ BlobRequestOptions blobRequestOptions = new BlobRequestOptions();
+
+ if (configuration.enableSecondaryLocation()) {
+ blobRequestOptions.setLocationMode(LocationMode.PRIMARY_THEN_SECONDARY);
+ }
+ cloudBlobClient.setDefaultRequestOptions(blobRequestOptions);
+
+ CloudBlobContainer container = cloudBlobClient.getContainerReference(configuration.containerName());
if (createContainer) {
container.createIfNotExists();
}
diff --git a/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/Configuration.java b/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/Configuration.java
index 5923f7881e..2eaf628bc1 100644
--- a/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/Configuration.java
+++ b/oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/Configuration.java
@@ -74,4 +74,10 @@ import static org.apache.jackrabbit.oak.segment.azure.Configuration.PID;
"services in order to create services composed of multiple persistence instances. " +
"E.g. a SplitPersistence composed of a TAR persistence and an Azure persistence.")
String role() default "";
+
+ @AttributeDefinition(
+ name = "Azure segment store property to enable fallback to the secondary location",
+ description = "When set to true specifies that requests will be attempted in primary, then in secondary region." +
+ "Default value is '" + AzureSegmentStoreService.DEFAULT_ENABLE_SECONDARY_LOCATION + "'.")
+ boolean enableSecondaryLocation() default AzureSegmentStoreService.DEFAULT_ENABLE_SECONDARY_LOCATION;
}
\ No newline at end of file