This is an automated email from the ASF dual-hosted git repository.

adulceanu pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 1446e1b098 OAK-10050 - Enable access to the secondary Azure blobstore 
service endpoint in Oak segment node store (#820)
1446e1b098 is described below

commit 1446e1b09839c2378132fdab971e86105d30fab8
Author: Andrei Dulceanu <dulce...@users.noreply.github.com>
AuthorDate: Mon Mar 27 17:57:28 2023 +0300

    OAK-10050 - Enable access to the secondary Azure blobstore service endpoint 
in Oak segment node store (#820)
---
 .../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

Reply via email to