Search in sources :

Example 1 with BlobRecord

use of com.enonic.xp.blob.BlobRecord in project xp by enonic.

the class FileBlobStoreTest method getRecord.

@Test
public void getRecord() {
    final BlobKey key = createRecord("hello").getKey();
    final BlobRecord record = this.blobStore.getRecord(this.segment, key);
    assertNotNull(record);
}
Also used : BlobRecord(com.enonic.xp.blob.BlobRecord) BlobKey(com.enonic.xp.blob.BlobKey) Test(org.junit.jupiter.api.Test)

Example 2 with BlobRecord

use of com.enonic.xp.blob.BlobRecord in project xp by enonic.

the class CachedBlobStore method addRecord.

@Override
public BlobRecord addRecord(final Segment segment, final ByteSource in) throws BlobStoreException {
    final BlobRecord record = this.store.addRecord(segment, in);
    addToCache(record);
    return record;
}
Also used : BlobRecord(com.enonic.xp.blob.BlobRecord)

Example 3 with BlobRecord

use of com.enonic.xp.blob.BlobRecord in project xp by enonic.

the class ReadThroughBlobStore method getRecord.

@Override
public BlobRecord getRecord(final Segment segment, final BlobKey key) throws BlobStoreException {
    BlobRecord record = this.readThroughStore.getRecord(segment, key);
    if (record != null) {
        return record;
    }
    record = store.getRecord(segment, key);
    if (record != null) {
        this.readThroughStore.addRecord(segment, record);
    }
    return record;
}
Also used : BlobRecord(com.enonic.xp.blob.BlobRecord)

Example 4 with BlobRecord

use of com.enonic.xp.blob.BlobRecord in project xp by enonic.

the class BlobStoreFactoryTest method doTestProviderStore.

private void doTestProviderStore(final boolean cache) {
    final MemoryBlobStore memory1 = new MemoryBlobStore();
    final MemoryBlobStoreProvider provider1 = new MemoryBlobStoreProvider("memory1", memory1, createProviderConfig("memory2", true));
    final MemoryBlobStore memory2 = new MemoryBlobStore();
    final MemoryBlobStoreProvider provider2 = new MemoryBlobStoreProvider("memory2", memory2, createProviderConfig(null, false));
    final BlobStoreProviders blobStoreProviders = new BlobStoreProviders();
    blobStoreProviders.add(provider2);
    final BlobStore finalBlobStore = BlobStoreFactory.create().provider(provider1).config(createBlobstoreConfig(cache)).providers(blobStoreProviders).build().execute();
    assertNotNull(finalBlobStore);
    final Segment segment = Segment.from("test", "blob");
    final BlobRecord record = finalBlobStore.addRecord(segment, ByteSource.wrap("hei".getBytes()));
    assertEquals(finalBlobStore.getRecord(segment, record.getKey()), memory1.getRecord(segment, record.getKey()));
    assertEquals(finalBlobStore.getRecord(segment, record.getKey()), memory2.getRecord(segment, record.getKey()));
}
Also used : BlobRecord(com.enonic.xp.blob.BlobRecord) BlobStore(com.enonic.xp.blob.BlobStore) Segment(com.enonic.xp.blob.Segment)

Example 5 with BlobRecord

use of com.enonic.xp.blob.BlobRecord in project xp by enonic.

the class CachedBlobStoreTest method lastModified.

@Test
public void lastModified() throws Exception {
    final BlobRecord record = newRecord("0123", 10L, Instant.now().toEpochMilli());
    Mockito.when(this.blobStore.getRecord(segment, record.getKey())).thenReturn(record);
    final BlobRecord firstRetrieval = this.cachedBlobStore.getRecord(this.segment, record.getKey());
    assertNotNull(firstRetrieval);
    assertEquals(firstRetrieval.lastModified(), record.lastModified());
    final BlobRecord secondRetrieval = this.cachedBlobStore.getRecord(this.segment, record.getKey());
    assertNotNull(secondRetrieval);
    assertEquals(secondRetrieval.lastModified(), record.lastModified());
}
Also used : BlobRecord(com.enonic.xp.blob.BlobRecord) Test(org.junit.jupiter.api.Test)

Aggregations

BlobRecord (com.enonic.xp.blob.BlobRecord)39 Test (org.junit.jupiter.api.Test)27 Segment (com.enonic.xp.blob.Segment)20 ByteSource (com.google.common.io.ByteSource)14 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)3 MemoryBlobRecord (com.enonic.xp.internal.blobstore.MemoryBlobRecord)3 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)3 BlobStore (com.enonic.xp.blob.BlobStore)2 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)2 Node (com.enonic.xp.node.Node)2 NodeVersion (com.enonic.xp.node.NodeVersion)2 RepoDumpException (com.enonic.xp.repo.impl.dump.RepoDumpException)2 BlobKey (com.enonic.xp.blob.BlobKey)1 CachingBlobStore (com.enonic.xp.blob.CachingBlobStore)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 MemoryBlobStore (com.enonic.xp.internal.blobstore.MemoryBlobStore)1 CachedBlobStore (com.enonic.xp.internal.blobstore.cache.CachedBlobStore)1 AttachedBinary (com.enonic.xp.node.AttachedBinary)1 NodeId (com.enonic.xp.node.NodeId)1 RepoLoadException (com.enonic.xp.repo.impl.dump.RepoLoadException)1