t-rana commented on code in PR #1329:
URL: https://github.com/apache/jackrabbit-oak/pull/1329#discussion_r1508497917


##########
oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/cli/container/SegmentAzureServicePrincipalNodeStoreContainer.java:
##########
@@ -0,0 +1,100 @@
+package org.apache.jackrabbit.oak.upgrade.cli.container;
+
+import com.microsoft.azure.storage.blob.CloudBlobDirectory;
+import org.apache.jackrabbit.guava.common.io.Files;
+import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
+import org.apache.jackrabbit.oak.segment.azure.AzurePersistence;
+import org.apache.jackrabbit.oak.segment.azure.AzureUtilities;
+import org.apache.jackrabbit.oak.segment.azure.tool.ToolUtils;
+import org.apache.jackrabbit.oak.segment.azure.util.Environment;
+import org.apache.jackrabbit.oak.segment.file.FileStore;
+import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder;
+import org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException;
+import org.apache.jackrabbit.oak.spi.blob.BlobStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.upgrade.cli.node.FileStoreUtils;
+
+import java.io.File;
+import java.io.IOException;
+
+public class SegmentAzureServicePrincipalNodeStoreContainer implements 
NodeStoreContainer {
+    private static final Environment ENVIRONMENT = new Environment();
+    private static final String CONTAINER_NAME = "oak-migration-test";
+    private static final String DIR = "repository";
+    private static final String AZURE_SEGMENT_STORE_PATH = 
"https://%s.blob.core.windows.net/%s/%s";;
+
+    private final BlobStore blobStore;
+    private FileStore fs;
+    private File tmpDir;
+    private AzurePersistence azurePersistence;
+
+    public SegmentAzureServicePrincipalNodeStoreContainer() {
+        this(null);
+    }
+
+    public SegmentAzureServicePrincipalNodeStoreContainer(BlobStore blobStore) 
{
+        this.blobStore = blobStore;
+    }
+
+
+    @Override
+    public NodeStore open() throws IOException {
+        try {
+            azurePersistence = createAzurePersistence();
+        } catch (Exception e) {
+            throw new IllegalStateException(e);
+        }
+
+        tmpDir = Files.createTempDir();
+        FileStoreBuilder builder = FileStoreBuilder.fileStoreBuilder(tmpDir)
+                
.withCustomPersistence(azurePersistence).withMemoryMapping(false);
+        if (blobStore != null) {
+            builder.withBlobStore(blobStore);
+        }
+
+        try {
+            fs = builder.build();
+        } catch (InvalidFileStoreVersionException e) {
+            throw new IllegalStateException(e);
+        }
+
+        return new 
FileStoreUtils.NodeStoreWithFileStore(SegmentNodeStoreBuilders.builder(fs).build(),
 fs);
+    }
+
+    private AzurePersistence createAzurePersistence() {
+        if (azurePersistence != null) {
+            return azurePersistence;
+        }
+        String path = String.format(AZURE_SEGMENT_STORE_PATH, 
ENVIRONMENT.getVariable(AzureUtilities.AZURE_ACCOUNT_NAME),
+                CONTAINER_NAME, DIR);
+        CloudBlobDirectory cloudBlobDirectory = 
ToolUtils.createCloudBlobDirectory(path, ENVIRONMENT);
+        return new AzurePersistence(cloudBlobDirectory);
+    }
+
+    @Override
+    public void close() {
+        if (tmpDir != null) {

Review Comment:
   this is done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to