use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.
the class ExternalBlobIT method testOfflineCompaction.
@Test
public void testOfflineCompaction() throws Exception {
FileDataStore fds = createFileDataStore();
DataStoreBlobStore dbs = new DataStoreBlobStore(fds);
nodeStore = getNodeStore(dbs);
int size = 2 * 1024 * 1024;
byte[] data2 = new byte[size];
new Random().nextBytes(data2);
Blob b = nodeStore.createBlob(new ByteArrayInputStream(data2));
NodeBuilder builder = nodeStore.getRoot().builder();
builder.child("hello").setProperty("world", b);
nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
store.flush();
// blob went to the external store
assertTrue(store.getStats().getApproximateSize() < 10 * 1024);
close();
SegmentGCOptions gcOptions = defaultGCOptions().setOffline();
store = fileStoreBuilder(getWorkDir()).withMaxFileSize(1).withGCOptions(gcOptions).build();
assertTrue(store.getStats().getApproximateSize() < 10 * 1024);
store.compact();
store.cleanup();
}
use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.
the class ExternalBlobIT method createFileDataStore.
private FileDataStore createFileDataStore() {
FileDataStore fds = new FileDataStore();
fds.setMinRecordLength(4092);
fds.init(getWorkDir().getAbsolutePath());
return fds;
}
use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.
the class ActiveDeletedBlobCollectionIT method createRepository.
@Override
protected ContentRepository createRepository() {
adbc = new ActiveDeletedBlobCollectorImpl(clock, new File(blobCollectionRoot.getRoot(), "deleted-blobs"), executorService);
IndexCopier copier = createIndexCopier();
editorProvider = new LuceneIndexEditorProvider(copier, null, new ExtractedTextCache(10 * FileUtils.ONE_MB, 100), null, Mounts.defaultMountInfoProvider(), adbc);
provider = new LuceneIndexProvider(copier);
mongoConnection = connectionFactory.getConnection();
MongoUtils.dropCollections(mongoConnection.getDB());
if (dataStoreType == DataStoreType.WITHOUT_FDS) {
MongoBlobStore blobStore = new MongoBlobStore(mongoConnection.getDB());
blobStore.setBlockSize(128);
blobStore.setBlockSizeMin(48);
this.blobStore = new CountingBlobStore(blobStore);
} else {
FileDataStore fds = new FileDataStore();
fds.init(fileDataStoreRoot.getRoot().getAbsolutePath());
DataStoreBlobStore dsbs = new DataStoreBlobStore(fds);
dsbs.setBlockSize(128);
this.blobStore = new CountingBlobStore(dsbs);
}
nodeStore = new DocumentMK.Builder().setMongoDB(mongoConnection.getDB()).setBlobStore(this.blobStore).getNodeStore();
asyncIndexUpdate = new AsyncIndexUpdate("async", nodeStore, editorProvider);
return new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) provider).with((Observer) provider).with(editorProvider).createContentRepository();
}
use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.
the class BlobStoreFixtureProvider method create.
@CheckForNull
public static BlobStoreFixture create(Options options) throws Exception {
BlobStoreOptions bsopts = options.getOptionBean(BlobStoreOptions.class);
if (bsopts == null) {
return null;
}
Type bsType = bsopts.getBlobStoreType();
if (bsType == Type.NONE) {
return null;
}
Closer closer = Closer.create();
DataStore delegate;
if (bsType == Type.S3) {
SharedS3DataStore s3ds = new SharedS3DataStore();
Properties props = loadAndTransformProps(bsopts.getS3ConfigPath());
s3ds.setProperties(props);
File homeDir = Files.createTempDir();
closer.register(asCloseable(homeDir));
s3ds.init(homeDir.getAbsolutePath());
delegate = s3ds;
} else if (bsType == Type.AZURE) {
AzureDataStore azureds = new AzureDataStore();
String cfgPath = bsopts.getAzureConfigPath();
Properties props = loadAndTransformProps(cfgPath);
azureds.setProperties(props);
File homeDir = Files.createTempDir();
azureds.init(homeDir.getAbsolutePath());
closer.register(asCloseable(homeDir));
delegate = azureds;
} else if (bsType == Type.FAKE) {
FileDataStore fakeDs = new DummyDataStore();
fakeDs.setPath(bsopts.getFakeDataStorePath());
fakeDs.init(null);
delegate = fakeDs;
} else {
FileDataStore fds = new OakFileDataStore();
delegate = fds;
if (bsopts.getFDSPath() != null) {
fds.setPath(bsopts.getFDSPath());
} else {
String cfgPath = bsopts.getFDSConfigPath();
Properties props = loadAndTransformProps(cfgPath);
populate(delegate, asMap(props), true);
}
delegate.init(null);
}
DataStoreBlobStore blobStore = new DataStoreBlobStore(delegate);
return new DataStoreFixture(blobStore, closer, !options.getCommonOpts().isReadWrite());
}
use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.
the class ReadOnlyBlobStoreWrapperTest method readOnly.
@Test
public void readOnly() throws Exception {
FileDataStore fds = new FileDataStore();
fds.setPath(temporaryFolder.getRoot().getAbsolutePath());
fds.init(null);
DataStoreBlobStore writableBS = new DataStoreBlobStore(fds);
BlobStore readOnly = ReadOnlyBlobStoreWrapper.wrap(writableBS);
try {
readOnly.writeBlob(new ByteArrayInputStream("foo".getBytes()));
fail();
} catch (Exception ignore) {
}
String blobId = writableBS.writeBlob(new ByteArrayInputStream("foo".getBytes()));
try (InputStream is = readOnly.getInputStream(blobId)) {
assertNotNull(is);
}
}
Aggregations