Skip to content
Merged
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 @@ -30,7 +30,6 @@
import org.apache.commons.io.FileUtils;
import org.apache.jackrabbit.oak.commons.pio.Closer;
import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
import org.apache.jackrabbit.oak.segment.azure.v8.AzureStorageCredentialManagerV8;
import org.apache.jackrabbit.oak.segment.azure.tool.ToolUtils;
import org.apache.jackrabbit.oak.segment.file.FileStore;
import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder;
Expand All @@ -53,12 +52,10 @@ static NodeStore configureSegment(Options options, BlobStore blobStore, Whiteboa

FileStoreBuilder builder;
if (segmentStoreType == ToolUtils.SegmentStoreType.AZURE) {
final AzureStorageCredentialManagerV8 azureStorageCredentialManagerV8 = new AzureStorageCredentialManagerV8();
SegmentNodeStorePersistence segmentNodeStorePersistence =
ToolUtils.newSegmentNodeStorePersistence(segmentStoreType, pathOrUri, azureStorageCredentialManagerV8);
ToolUtils.newSegmentNodeStorePersistence(segmentStoreType, pathOrUri);
File tempDir = Files.createTempDirectory("azure-segment-store").toFile();
closer.register(() -> FileUtils.deleteQuietly(tempDir));
closer.register(azureStorageCredentialManagerV8);
builder = fileStoreBuilder(tempDir).withCustomPersistence(segmentNodeStorePersistence);
} else {
builder = fileStoreBuilder(new File(pathOrUri)).withMaxFileSize(256);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.jackrabbit.oak.explorer;

import org.apache.jackrabbit.oak.segment.azure.v8.AzureStorageCredentialManagerV8;
import org.apache.jackrabbit.oak.segment.azure.tool.ToolUtils;
import org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException;
import org.apache.jackrabbit.oak.segment.spi.persistence.JournalFile;
Expand All @@ -39,16 +38,14 @@
public class AzureSegmentStoreExplorerBackend extends AbstractSegmentTarExplorerBackend {
private final String path;
private SegmentNodeStorePersistence persistence;
private final AzureStorageCredentialManagerV8 azureStorageCredentialManagerV8;

public AzureSegmentStoreExplorerBackend(String path) {
this.path = path;
this.azureStorageCredentialManagerV8 = new AzureStorageCredentialManagerV8();
}

@Override
public void open() throws IOException {
this.persistence = newSegmentNodeStorePersistence(ToolUtils.SegmentStoreType.AZURE, path, azureStorageCredentialManagerV8);
this.persistence = newSegmentNodeStorePersistence(ToolUtils.SegmentStoreType.AZURE, path);

try {
this.store = fileStoreBuilder(Files.createTempDirectory(getClass().getSimpleName() + "-").toFile())
Expand All @@ -63,7 +60,6 @@ public void open() throws IOException {
@Override
public void close() {
super.close();
azureStorageCredentialManagerV8.close();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import org.apache.jackrabbit.oak.run.commons.Command;
import org.apache.jackrabbit.oak.segment.azure.v8.AzureStorageCredentialManagerV8;
import org.apache.jackrabbit.oak.segment.azure.tool.ToolUtils;
import org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore;
import org.apache.jackrabbit.oak.segment.spi.persistence.SegmentNodeStorePersistence;
Expand Down Expand Up @@ -86,22 +85,20 @@ public void execute(String... args) throws Exception {
}
} else {
if (pathOrURI.startsWith("az:")) {
try (AzureStorageCredentialManagerV8 azureStorageCredentialManagerV8 = new AzureStorageCredentialManagerV8()) {
SegmentNodeStorePersistence azurePersistence = ToolUtils.newSegmentNodeStorePersistence(ToolUtils.SegmentStoreType.AZURE, pathOrURI, azureStorageCredentialManagerV8);
ReadOnlyFileStore store = fileStoreBuilder(Files.createTempDirectory(getClass().getSimpleName() + "-").toFile())
.withCustomPersistence(azurePersistence).withBlobStore(newBasicReadOnlyBlobStore()).buildReadOnly();
statusCode = Diff.builder()
.withPath(pathOrURI)
.withReadOnlyFileStore(store)
.withOutput(out)
.withInterval(interval)
.withIncremental(incremental)
.withFilter(path)
.withIgnoreMissingSegments(ignoreSNFEs)
.withRevisionsProcessor(ToolUtils::readRevisions)
.build()
.run();
}
SegmentNodeStorePersistence azurePersistence = ToolUtils.newSegmentNodeStorePersistence(ToolUtils.SegmentStoreType.AZURE, pathOrURI);
ReadOnlyFileStore store = fileStoreBuilder(Files.createTempDirectory(getClass().getSimpleName() + "-").toFile())
.withCustomPersistence(azurePersistence).withBlobStore(newBasicReadOnlyBlobStore()).buildReadOnly();
statusCode = Diff.builder()
.withPath(pathOrURI)
.withReadOnlyFileStore(store)
.withOutput(out)
.withInterval(interval)
.withIncremental(incremental)
.withFilter(path)
.withIgnoreMissingSegments(ignoreSNFEs)
.withRevisionsProcessor(ToolUtils::readRevisions)
.build()
.run();
} else {
ReadOnlyFileStore store = fileStoreBuilder(new File(pathOrURI)).withBlobStore(newBasicReadOnlyBlobStore()).buildReadOnly();
statusCode = Diff.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
import org.apache.jackrabbit.oak.run.cli.BlobStoreOptions.Type;
import org.apache.jackrabbit.oak.segment.SegmentNodeStore;
import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
import org.apache.jackrabbit.oak.segment.azure.v8.AzureStorageCredentialManagerV8;
import org.apache.jackrabbit.oak.segment.azure.v8.AzureUtilitiesV8;
import org.apache.jackrabbit.oak.segment.azure.AzurePersistenceManager;
import org.apache.jackrabbit.oak.segment.azure.tool.ToolUtils;
import org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions;
import org.apache.jackrabbit.oak.segment.file.FileStore;
Expand Down Expand Up @@ -1128,7 +1127,6 @@ class SegmentStoreFixture implements StoreFixture {
class AzureSegmentStoreFixture extends SegmentStoreFixture {
private static final String AZURE_DIR = "repository";
private String container;
private final AzureStorageCredentialManagerV8 azureStorageCredentialManagerV8 = new AzureStorageCredentialManagerV8();

@Override public NodeStore init(DataStoreBlobStore blobStore, File storeFile) throws Exception {
Properties props = AzureDataStoreUtils.getAzureConfig();
Expand All @@ -1138,14 +1136,14 @@ class AzureSegmentStoreFixture extends SegmentStoreFixture {
container = container + System.currentTimeMillis();
// Create the azure segment container
String connectionString = getAzureConnectionString(accessKey, secretKey, container, AZURE_DIR);
AzureUtilitiesV8.cloudBlobDirectoryFrom(connectionString, container, AZURE_DIR);
AzurePersistenceManager.createAzurePersistence(connectionString, null, accessKey, container, AZURE_DIR, false, true);

// get the azure uri expected by the command
storePath = getAzureUri(accessKey, container, AZURE_DIR);

// initialize azure segment for test setup
SegmentNodeStorePersistence segmentNodeStorePersistence =
ToolUtils.newSegmentNodeStorePersistence(ToolUtils.SegmentStoreType.AZURE, storePath, azureStorageCredentialManagerV8);
ToolUtils.newSegmentNodeStorePersistence(ToolUtils.SegmentStoreType.AZURE, storePath);
fileStore = fileStoreBuilder(storeFile).withBlobStore(blobStore)
.withCustomPersistence(segmentNodeStorePersistence).build();

Expand Down Expand Up @@ -1177,7 +1175,6 @@ protected String getAzureConnectionString(String accountName, String secret, Str
public void after() {
try {
AzureDataStoreUtils.deleteContainer(container);
azureStorageCredentialManagerV8.close();
} catch(Exception e) {
log.error("Error in cleaning the container {}", container, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public class AzurePersistence implements SegmentNodeStorePersistence {

protected WriteAccessController writeAccessController = new WriteAccessController();

public AzurePersistence(BlobContainerClient blobContainerClient, String rootPrefix) {
this(blobContainerClient, blobContainerClient, blobContainerClient, rootPrefix);
}

public AzurePersistence(BlobContainerClient readBlobContainerClient, BlobContainerClient writeBlobContainerClient, BlobContainerClient noRetryBlobContainerClient, String rootPrefix) {
this(readBlobContainerClient, writeBlobContainerClient, noRetryBlobContainerClient, rootPrefix, null);
}
Expand Down
Loading
Loading