Search in sources :

Example 1 with FileDataStore

use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.

the class LengthCachingDataStoreTest method referenceHandling.

@Test
public void referenceHandling() throws Exception {
    int minSize = new FileDataStore().getMinRecordLength();
    LengthCachingDataStore fds = new LengthCachingDataStore();
    fds.setDelegateClass(FileDataStore.class.getName());
    fds.init(tempFolder.newFolder().getAbsolutePath());
    fds.setReadOnly(false);
    DataRecord dr1 = fds.addRecord(byteStream(minSize + 10));
    assertNotNull(fds.getRecordFromReference(dr1.getReference()));
    assertEquals(dr1.getIdentifier(), fds.getRecordFromReference(dr1.getReference()).getIdentifier());
}
Also used : DataRecord(org.apache.jackrabbit.core.data.DataRecord) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) Test(org.junit.Test)

Example 2 with FileDataStore

use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.

the class LengthCachingDataStoreTest method delegateRecordTest.

@Test
public void delegateRecordTest() throws Exception {
    FileDataStore ds = new FileDataStore();
    byte[] data = bytes(ds.getMinRecordLength() + 10);
    ds.init(tempFolder.getRoot().getAbsolutePath());
    DataRecord dr = ds.addRecord(new ByteArrayInputStream(data));
    File mappingFile = new File(tempFolder.getRoot(), "mapping.txt");
    String text = String.format("%s|%s", data.length, dr.getIdentifier().toString());
    Files.write(text, mappingFile, Charset.defaultCharset());
    LengthCachingDataStore fds = new LengthCachingDataStore();
    fds.setDelegateClass(FileDataStore.class.getName());
    fds.setMappingFilePath(mappingFile.getAbsolutePath());
    fds.init(tempFolder.getRoot().getAbsolutePath());
    DataRecord dr2 = fds.getRecordIfStored(dr.getIdentifier());
    assertEquals(dr, dr2);
    assertEquals(dr.getLength(), dr2.getLength());
    assertTrue(supplier(dr).contentEquals(supplier(dr2)));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DataRecord(org.apache.jackrabbit.core.data.DataRecord) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) File(java.io.File) Test(org.junit.Test)

Example 3 with FileDataStore

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;
}
Also used : FileDataStore(org.apache.jackrabbit.core.data.FileDataStore)

Example 4 with FileDataStore

use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.

the class OakFileDataStoreTest method testGetAllIdentifiers.

private void testGetAllIdentifiers(String path, String unnormalizedPath) throws Exception {
    File testDir = new File(path);
    FileUtils.touch(new File(testDir, "ab/cd/ef/abcdef"));
    FileUtils.touch(new File(testDir, "bc/de/fg/bcdefg"));
    FileUtils.touch(new File(testDir, "cd/ef/gh/cdefgh"));
    FileUtils.touch(new File(testDir, "c"));
    FileDataStore fds = new OakFileDataStore();
    fds.setPath(unnormalizedPath);
    fds.init(null);
    Iterator<DataIdentifier> dis = fds.getAllIdentifiers();
    Set<String> fileNames = Sets.newHashSet(Iterators.transform(dis, new Function<DataIdentifier, String>() {

        @Override
        public String apply(@Nullable DataIdentifier input) {
            return input.toString();
        }
    }));
    Set<String> expectedNames = Sets.newHashSet("abcdef", "bcdefg", "cdefgh");
    assertEquals(expectedNames, fileNames);
    FileUtils.cleanDirectory(testDir);
}
Also used : Function(com.google.common.base.Function) DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) File(java.io.File) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) Nullable(javax.annotation.Nullable)

Example 5 with FileDataStore

use of org.apache.jackrabbit.core.data.FileDataStore in project jackrabbit-oak by apache.

the class LuceneWritesOnSegmentStatsTest method createBlobStore.

private BlobStore createBlobStore() {
    FileDataStore fds = new OakFileDataStore();
    fdsDir = "target/fds-" + codec + copyOnRW + minRecordLength + mergePolicy;
    fds.setPath(fdsDir);
    if (minRecordLength > 0) {
        fds.setMinRecordLength(minRecordLength);
    }
    fds.init(null);
    dataStoreBlobStore = new DataStoreBlobStore(fds);
    StatisticsProvider sp = new DefaultStatisticsProvider(scheduledExecutorService);
    BlobStatsCollector collector = new BlobStoreStats(sp);
    dataStoreBlobStore.setBlobStatsCollector(collector);
    return dataStoreBlobStore;
}
Also used : OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) BlobStatsCollector(org.apache.jackrabbit.oak.spi.blob.stats.BlobStatsCollector) BlobStoreStats(org.apache.jackrabbit.oak.plugins.blob.BlobStoreStats) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) OakFileDataStore(org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore) DefaultStatisticsProvider(org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider) StatisticsProvider(org.apache.jackrabbit.oak.stats.StatisticsProvider) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Aggregations

FileDataStore (org.apache.jackrabbit.core.data.FileDataStore)22 DataStoreBlobStore (org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)14 Test (org.junit.Test)13 File (java.io.File)10 ByteArrayInputStream (java.io.ByteArrayInputStream)8 DataRecord (org.apache.jackrabbit.core.data.DataRecord)5 Random (java.util.Random)4 Blob (org.apache.jackrabbit.oak.api.Blob)4 InputStream (java.io.InputStream)3 OakFileDataStore (org.apache.jackrabbit.oak.plugins.blob.datastore.OakFileDataStore)3 AbstractBlob (org.apache.jackrabbit.oak.plugins.memory.AbstractBlob)3 FileBlob (org.apache.jackrabbit.oak.segment.file.FileBlob)3 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)3 DataIdentifier (org.apache.jackrabbit.core.data.DataIdentifier)2 DataStore (org.apache.jackrabbit.core.data.DataStore)2 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)2 BlobStoreBlob (org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob)2 BlobStoreStats (org.apache.jackrabbit.oak.plugins.blob.BlobStoreStats)2 BlobStore (org.apache.jackrabbit.oak.spi.blob.BlobStore)2 Function (com.google.common.base.Function)1