Search in sources :

Example 1 with AsyncStorageWrapper

use of io.pravega.segmentstore.storage.AsyncStorageWrapper in project pravega by pravega.

the class ExtendedS3StorageFactory method createStorageAdapter.

@Override
public Storage createStorageAdapter() {
    S3Config s3Config = new S3Config(config.getUrl()).withIdentity(config.getAccessKey()).withSecretKey(config.getSecretKey()).withNamespace(config.getNamespace());
    S3JerseyClient client = new S3JerseyClient(s3Config);
    ExtendedS3Storage s = new ExtendedS3Storage(client, this.config);
    return new AsyncStorageWrapper(new RollingStorage(s), this.executor);
}
Also used : S3Config(com.emc.object.s3.S3Config) S3JerseyClient(com.emc.object.s3.jersey.S3JerseyClient) AsyncStorageWrapper(io.pravega.segmentstore.storage.AsyncStorageWrapper) RollingStorage(io.pravega.segmentstore.storage.rolling.RollingStorage)

Example 2 with AsyncStorageWrapper

use of io.pravega.segmentstore.storage.AsyncStorageWrapper in project pravega by pravega.

the class InMemoryStorageTests method testFencing.

@Test
@Override
public void testFencing() throws Exception {
    final String segment1 = "segment1";
    final String segment2 = "segment2";
    @Cleanup val baseStorage = new InMemoryStorage();
    @Cleanup val storage = new AsyncStorageWrapper(baseStorage, executorService());
    storage.initialize(DEFAULT_EPOCH);
    // Part 1: Create a segment and verify all operations are allowed.
    storage.create(segment1, TIMEOUT).get(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
    SegmentHandle handle1 = storage.openWrite(segment1).join();
    verifyAllOperationsSucceed(handle1, storage);
    // Part 2: Change owner, verify segment operations are not allowed until a call to open() is made.
    baseStorage.changeOwner();
    verifyWriteOperationsFail(handle1, storage);
    handle1 = storage.openWrite(segment1).join();
    verifyAllOperationsSucceed(handle1, storage);
    // Part 3: Create new segment and verify all operations are allowed.
    storage.create(segment2, TIMEOUT).get(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
    SegmentHandle handle2 = storage.openWrite(segment2).join();
    verifyAllOperationsSucceed(handle2, storage);
    // Cleanup.
    storage.delete(handle1, TIMEOUT).get(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
    storage.delete(handle2, TIMEOUT).get(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
}
Also used : lombok.val(lombok.val) AsyncStorageWrapper(io.pravega.segmentstore.storage.AsyncStorageWrapper) Cleanup(lombok.Cleanup) SegmentHandle(io.pravega.segmentstore.storage.SegmentHandle) Test(org.junit.Test)

Aggregations

AsyncStorageWrapper (io.pravega.segmentstore.storage.AsyncStorageWrapper)2 S3Config (com.emc.object.s3.S3Config)1 S3JerseyClient (com.emc.object.s3.jersey.S3JerseyClient)1 SegmentHandle (io.pravega.segmentstore.storage.SegmentHandle)1 RollingStorage (io.pravega.segmentstore.storage.rolling.RollingStorage)1 Cleanup (lombok.Cleanup)1 lombok.val (lombok.val)1 Test (org.junit.Test)1