use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.
the class BinaryAccessUnsupportedIT method createRepository.
@Override
protected Repository createRepository(NodeStore nodeStore) {
Whiteboard wb = new DefaultWhiteboard();
BlobStore blobStore = getNodeStoreComponent(BlobStore.class);
if (blobStore != null && blobStore instanceof BlobAccessProvider) {
wb.register(BlobAccessProvider.class, (BlobAccessProvider) blobStore, Collections.emptyMap());
}
return initJcr(new Jcr(nodeStore).with(wb)).createRepository();
}
use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.
the class SegmentMemoryNodeStoreFixture method createNodeStore.
@Override
public NodeStore createNodeStore() {
try {
log.info("Creating NodeStore using " + toString());
File fileStoreRoot = FixtureUtils.createTempFolder();
FileStoreBuilder fileStoreBuilder = FileStoreBuilder.fileStoreBuilder(fileStoreRoot).withNodeDeduplicationCacheSize(16384).withMaxFileSize(256).withMemoryMapping(false);
File dataStoreFolder = null;
BlobStore blobStore = null;
DataStore dataStore = null;
if (dataStoreFixture != null) {
dataStore = dataStoreFixture.createDataStore();
// init with a new folder inside a temporary one
dataStoreFolder = FixtureUtils.createTempFolder();
dataStore.init(dataStoreFolder.getAbsolutePath());
blobStore = new DataStoreBlobStore(dataStore);
fileStoreBuilder.withBlobStore(blobStore);
}
FileStore fileStore = fileStoreBuilder.build();
NodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
// track all main components
if (dataStore != null) {
components.put(nodeStore, DataStore.class.getName(), dataStore);
components.put(nodeStore, DataStore.class.getName() + ":folder", dataStoreFolder);
}
if (blobStore != null) {
components.put(nodeStore, BlobStore.class.getName(), blobStore);
}
components.put(nodeStore, FileStore.class.getName(), fileStore);
components.put(nodeStore, FileStore.class.getName() + ":root", fileStoreRoot);
return nodeStore;
} catch (IOException | InvalidFileStoreVersionException | RepositoryException e) {
throw new AssertionError("Cannot create test repo fixture " + toString(), e);
}
}
use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.
the class BlobStoreFixture method getDataStore.
public static BlobStoreFixture getDataStore(final File basedir, final int fdsCacheInMB, final StatisticsProvider statisticsProvider) {
return new BlobStoreFixture("DS") {
private DataStore dataStore;
private BlobStore blobStore;
private File storeDir;
private Map<String, ?> config;
@Override
public BlobStore setUp() {
String className = System.getProperty("dataStore");
checkNotNull(className, "No system property named 'dataStore' defined");
try {
dataStore = Class.forName(className).asSubclass(DataStore.class).newInstance();
config = getConfig();
configure(dataStore, config);
dataStore = configureIfCloudDataStore(className, dataStore, config, unique.toLowerCase(), statisticsProvider);
storeDir = new File(basedir, unique);
dataStore.init(storeDir.getAbsolutePath());
blobStore = new DataStoreBlobStore(dataStore, true, fdsCacheInMB);
configure(blobStore);
return blobStore;
} catch (Exception e) {
throw new IllegalStateException("Cannot instantiate DataStore " + className, e);
}
}
@Override
public void tearDown() {
if (blobStore instanceof DataStoreBlobStore) {
try {
((DataStoreBlobStore) blobStore).close();
cleanup(storeDir, config, unique.toLowerCase());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
@Override
public long size() {
throw new UnsupportedOperationException("Implementation pending");
}
};
}
use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.
the class SegmentTarFixture method setUpCluster.
@Override
public Oak[] setUpCluster(int n, StatisticsProvider statsProvider) throws Exception {
init(n);
Oak[] cluster = new Oak[n];
for (int i = 0; i < cluster.length; i++) {
BlobStore blobStore = null;
if (useBlobStore) {
blobStoreFixtures[i] = BlobStoreFixture.create(parentPath, true, dsCacheSize, statsProvider);
blobStore = blobStoreFixtures[i].setUp();
}
FileStoreBuilder builder = fileStoreBuilder(new File(parentPath, "primary-" + i));
if (awsBucketName != null) {
Configuration config = getAwsConfig(awsBucketName + "-" + i, awsRootPath, awsJournalTableName + "-" + i, awsLockTableName + "-" + i);
AwsContext awsContext = AwsContext.create(config);
builder.withCustomPersistence(new AwsPersistence(awsContext));
}
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 AzurePersistence(directory));
}
if (blobStore != null) {
builder.withBlobStore(blobStore);
}
stores[i] = builder.withMaxFileSize(maxFileSize).withStatisticsProvider(statsProvider).withSegmentCacheSize(segmentCacheSize).withMemoryMapping(memoryMapping).withStrictVersionCheck(true).build();
if (withColdStandby) {
attachStandby(i, n, statsProvider, blobStore);
}
cluster[i] = newOak(SegmentNodeStoreBuilders.builder(stores[i]).build());
if (blobStore != null) {
cluster[i].getWhiteboard().register(BlobAccessProvider.class, (BlobAccessProvider) blobStore, Collections.EMPTY_MAP);
}
}
return cluster;
}
use of org.apache.jackrabbit.oak.spi.blob.BlobStore in project jackrabbit-oak by apache.
the class NodeStoreFixtureProvider method create.
public static NodeStoreFixture create(Options options, boolean readOnly) throws Exception {
CommonOptions commonOpts = options.getOptionBean(CommonOptions.class);
Closer closer = Closer.create();
Whiteboard wb = new ClosingWhiteboard(options.getWhiteboard(), closer);
BlobStoreFixture blobFixture = BlobStoreFixtureProvider.create(options);
BlobStore blobStore = null;
if (blobFixture != null) {
blobStore = blobFixture.getBlobStore();
closer.register(blobFixture);
}
StatisticsProvider statisticsProvider = createStatsProvider(options, wb, closer);
wb.register(StatisticsProvider.class, statisticsProvider, emptyMap());
NodeStore store;
if (commonOpts.isMemory()) {
store = new MemoryNodeStore();
} else if (commonOpts.isMongo() || commonOpts.isRDB()) {
DocumentNodeStore dns = DocumentFixtureProvider.configureDocumentMk(options, blobStore, wb, closer, readOnly);
store = dns;
if (blobStore == null) {
blobStore = dns.getBlobStore();
}
} else if (commonOpts.isOldSegment()) {
store = SegmentFixtureProvider.create(options, blobStore, wb, closer, readOnly);
} else {
try {
store = SegmentTarFixtureProvider.configureSegment(options, blobStore, wb, closer, readOnly);
} catch (InvalidFileStoreVersionException e) {
if (oldSegmentStore(options)) {
store = SegmentFixtureProvider.create(options, blobStore, wb, closer, readOnly);
} else {
throw e;
}
}
}
return new SimpleNodeStoreFixture(store, blobStore, wb, closer);
}
Aggregations