Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.jackrabbit.oak.composite.CompositeSegmentStoreFixture;
import org.apache.jackrabbit.oak.segment.aws.fixture.SegmentAwsFixture;
import org.apache.jackrabbit.oak.segment.azure.fixture.SegmentAzureFixture;
import org.apache.jackrabbit.oak.segment.azure.fixture.SegmentAzureFixtureV8;
import org.apache.jackrabbit.oak.segment.fixture.SegmentTarFixture;

public class NodeStoreFixtures {
Expand All @@ -44,8 +43,6 @@ public class NodeStoreFixtures {

public static final NodeStoreFixture SEGMENT_AWS = new SegmentAwsFixture();

public static final NodeStoreFixture SEGMENT_AZURE_V8 = new SegmentAzureFixtureV8();

public static final NodeStoreFixture SEGMENT_AZURE = new SegmentAzureFixture();

public static final NodeStoreFixture DOCUMENT_NS = new DocumentMongoFixture();
Expand Down Expand Up @@ -83,9 +80,6 @@ public static Collection<Object[]> asJunitParameters(Set<FixturesHelper.Fixture>
if (fixtures.contains(FixturesHelper.Fixture.SEGMENT_AZURE)) {
configuredFixtures.add(SEGMENT_AZURE);
}
if (fixtures.contains(FixturesHelper.Fixture.SEGMENT_AZURE_V8)) {
configuredFixtures.add(SEGMENT_AZURE_V8);
}
if (fixtures.contains(FixturesHelper.Fixture.COMPOSITE_SEGMENT)) {
configuredFixtures.add(COMPOSITE_SEGMENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public void moveToDescendant() {
if (fixture == NodeStoreFixtures.SEGMENT_TAR || fixture == NodeStoreFixtures.MEMORY_NS
|| fixture == NodeStoreFixtures.COMPOSITE_MEM || fixture == NodeStoreFixtures.COMPOSITE_SEGMENT
|| fixture == NodeStoreFixtures.COW_DOCUMENT || fixture == NodeStoreFixtures.SEGMENT_AWS
|| fixture == NodeStoreFixtures.SEGMENT_AZURE_V8 || fixture == NodeStoreFixtures.SEGMENT_AZURE) {
|| fixture == NodeStoreFixtures.SEGMENT_AZURE) {
assertTrue(x.moveTo(x, "xx"));
assertFalse(x.exists());
assertFalse(test.hasChildNode("x"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.blob.CloudBlobContainer;
import com.microsoft.azure.storage.blob.CloudBlobDirectory;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.models.BlobStorageException;
import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.core.data.FileDataStore;
import org.apache.jackrabbit.oak.Oak;
Expand All @@ -44,7 +42,8 @@
import org.apache.jackrabbit.oak.segment.aws.AwsContext;
import org.apache.jackrabbit.oak.segment.aws.AwsPersistence;
import org.apache.jackrabbit.oak.segment.aws.Configuration;
import org.apache.jackrabbit.oak.segment.azure.v8.AzurePersistenceV8;
import org.apache.jackrabbit.oak.segment.azure.AzurePersistence;
import org.apache.jackrabbit.oak.segment.azure.AzurePersistenceManager;
import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions;
import org.apache.jackrabbit.oak.segment.file.FileStore;
import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder;
Expand Down Expand Up @@ -183,7 +182,7 @@ public SegmentTarFixture build() {
private StandbyClientSync[] clientSyncs;
private ScheduledExecutorService[] executors;

private CloudBlobContainer[] containers;
private BlobContainerClient[] containers;

public SegmentTarFixture(SegmentTarFixtureBuilder builder) {
this(builder, false, -1);
Expand Down Expand Up @@ -285,11 +284,9 @@ public Oak getOak(int clusterId) throws Exception {
}

if (azureConnectionString != null) {
CloudStorageAccount cloud = CloudStorageAccount.parse(azureConnectionString);
CloudBlobContainer container = cloud.createCloudBlobClient().getContainerReference(azureContainerName);
container.createIfNotExists();
CloudBlobDirectory directory = container.getDirectoryReference(azureRootPath);
fileStoreBuilder.withCustomPersistence(new AzurePersistenceV8(directory));
String azureAccountName = getAzureAccountName(azureConnectionString);
AzurePersistence azurePersistence = AzurePersistenceManager.createAzurePersistence(azureConnectionString, null, azureAccountName, azureContainerName, azureRootPath, false, true);
fileStoreBuilder.withCustomPersistence(azurePersistence);
}

BlobStore blobStore = null;
Expand Down Expand Up @@ -336,12 +333,10 @@ public Oak[] setUpCluster(int n, StatisticsProvider statsProvider) throws Except
}

if (azureConnectionString != null) {
CloudStorageAccount cloud = CloudStorageAccount.parse(azureConnectionString);
CloudBlobContainer container = cloud.createCloudBlobClient().getContainerReference(azureContainerName);
container.createIfNotExists();
containers[i] = container;
CloudBlobDirectory directory = container.getDirectoryReference(azureRootPath + "/primary-" + i);
builder.withCustomPersistence(new AzurePersistenceV8(directory));
String azureAccountName = getAzureAccountName(azureConnectionString);
AzurePersistence azurePersistence = AzurePersistenceManager.createAzurePersistence(azureConnectionString, null, azureAccountName, azureContainerName, azureRootPath + "/primary-" + i, false, true);
containers[i] = azurePersistence.getReadBlobContainerClient();
builder.withCustomPersistence(azurePersistence);
}

if (blobStore != null) {
Expand Down Expand Up @@ -481,7 +476,7 @@ private void init(int n) {
blobStoreFixtures = new BlobStoreFixture[blobStoresLength];

if (azureConnectionString != null) {
containers = new CloudBlobContainer[n];
containers = new BlobContainerClient[n];
}
}

Expand Down Expand Up @@ -514,11 +509,11 @@ public void tearDownCluster() {
}

if (containers != null) {
for (CloudBlobContainer container : containers) {
for (BlobContainerClient container : containers) {
if (container != null) {
try {
container.deleteIfExists();
} catch (StorageException e) {
} catch (BlobStorageException e) {
log.error("Can't remove container", e);
}
}
Expand All @@ -528,6 +523,27 @@ public void tearDownCluster() {
FileUtils.deleteQuietly(parentPath);
}

/**
* Extracts the Azure Storage Account Name from a connection string.
* @param azureConnectionString The full Azure Storage connection string.
* @return The account name, or null if not found.
*/
private String getAzureAccountName(String azureConnectionString) {
if (azureConnectionString == null || azureConnectionString.isEmpty()) {
return null;
}

String[] parts = azureConnectionString.split(";");
for (String part : parts) {
String[] keyValue = part.split("=", 2);
if (keyValue.length == 2 && keyValue[0].trim().equalsIgnoreCase("AccountName")) {
return keyValue[1].trim();
}
}

return null;
}

public BlobStoreFixture[] getBlobStoreFixtures() {
return blobStoreFixtures;
}
Expand Down
4 changes: 0 additions & 4 deletions oak-segment-azure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@
</dependency>

<!-- Azure Blob Storage dependency -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.jackrabbit.oak.segment.azure;

import org.apache.jackrabbit.oak.segment.azure.v8.AzurePersistenceV8;
import org.apache.jackrabbit.oak.segment.azure.v8.AzureSegmentStoreV8;
import org.apache.jackrabbit.oak.segment.spi.persistence.SegmentNodeStorePersistence;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
Expand Down Expand Up @@ -51,34 +49,18 @@ public class AzureSegmentStoreService {

private ServiceRegistration registration;

public static final String SEGMENT_AZURE_V_12_ENABLED = "segment.azure.v12.enabled";

private final boolean useAzureSdkV12 = Boolean.getBoolean(SEGMENT_AZURE_V_12_ENABLED);


@Activate
public void activate(ComponentContext context, Configuration config) throws IOException {
if (useAzureSdkV12) {
log.info("Starting node store using Azure SDK 12");
AzurePersistence persistence = AzurePersistenceManager.createAzurePersistenceFrom(config);
registration = context.getBundleContext()
.registerService(SegmentNodeStorePersistence.class, persistence, new Hashtable<String, Object>() {{
put(SERVICE_PID, String.format("%s(%s, %s)", AzurePersistence.class.getName(), config.accountName(), config.rootPath()));
if (!Objects.equals(config.role(), "")) {
put("role", config.role());
}
}});
} else {
log.info("Starting node store using Azure SDK 8");
AzurePersistenceV8 persistence = AzureSegmentStoreV8.createAzurePersistenceFrom(config);
registration = context.getBundleContext()
.registerService(SegmentNodeStorePersistence.class, persistence, new Hashtable<String, Object>() {{
put(SERVICE_PID, String.format("%s(%s, %s)", AzurePersistenceV8.class.getName(), config.accountName(), config.rootPath()));
if (!Objects.equals(config.role(), "")) {
put("role", config.role());
}
}});
}
log.info("Starting node store using Azure SDK 12");
AzurePersistence persistence = AzurePersistenceManager.createAzurePersistenceFrom(config);
registration = context.getBundleContext()
.registerService(SegmentNodeStorePersistence.class, persistence, new Hashtable<String, Object>() {{
put(SERVICE_PID, String.format("%s(%s, %s)", AzurePersistence.class.getName(), config.accountName(), config.rootPath()));
if (!Objects.equals(config.role(), "")) {
put("role", config.role());
}
}});

}

@Deactivate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public static Map<String, String> parseAzureConfigurationFromCustomConnection(St
config.put(KEY_CONTAINER_NAME, tempConfig.get(CONTAINER_NAME));
config.put(KEY_DIR, tempConfig.get(DIRECTORY));
config.put(KEY_SHARED_ACCESS_SIGNATURE, tempConfig.get(SHARED_ACCESS_SIGNATURE));
config.put(KEY_ACCOUNT_NAME, tempConfig.get(ACCOUNT_NAME));
return config;
}

Expand Down

This file was deleted.

Loading
Loading