Search in sources :

Example 6 with StorageFactoryCreator

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

the class InMemorySimpleStorageFactoryTests method testInMemorySimpleStorageFactoryCreator.

@Test
public void testInMemorySimpleStorageFactoryCreator() {
    StorageFactoryCreator factoryCreator = new InMemoryStorageFactoryCreator();
    @Cleanup("shutdownNow") val executor = ExecutorServiceHelpers.newScheduledThreadPool(1, "test");
    val expected = new StorageFactoryInfo[] { StorageFactoryInfo.builder().name("INMEMORY").storageLayoutType(StorageLayoutType.CHUNKED_STORAGE).build(), StorageFactoryInfo.builder().name("INMEMORY").storageLayoutType(StorageLayoutType.ROLLING_STORAGE).build() };
    val factoryInfoList = factoryCreator.getStorageFactories();
    Assert.assertEquals(2, factoryInfoList.length);
    Assert.assertArrayEquals(expected, factoryInfoList);
    // Simple Storage
    ConfigSetup configSetup1 = mock(ConfigSetup.class);
    when(configSetup1.getConfig(any())).thenReturn(ChunkedSegmentStorageConfig.DEFAULT_CONFIG);
    val factory1 = factoryCreator.createFactory(expected[0], configSetup1, executor);
    Assert.assertTrue(factory1 instanceof InMemorySimpleStorageFactory);
    @Cleanup Storage storage1 = ((InMemorySimpleStorageFactory) factory1).createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executor));
    Assert.assertTrue(storage1 instanceof ChunkedSegmentStorage);
    // Legacy Storage
    ConfigSetup configSetup2 = mock(ConfigSetup.class);
    when(configSetup2.getConfig(any())).thenReturn(ChunkedSegmentStorageConfig.DEFAULT_CONFIG);
    val factory2 = factoryCreator.createFactory(expected[1], configSetup2, executor);
    Assert.assertTrue(factory2 instanceof InMemoryStorageFactory);
    Storage storage2 = factory2.createStorageAdapter();
    Assert.assertTrue(storage2 instanceof AsyncStorageWrapper);
    SyncStorage syncStorage = factory2.createSyncStorage();
    Assert.assertNotNull(syncStorage);
}
Also used : lombok.val(lombok.val) SyncStorage(io.pravega.segmentstore.storage.SyncStorage) StorageFactoryInfo(io.pravega.segmentstore.storage.StorageFactoryInfo) ChunkedSegmentStorage(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage) Cleanup(lombok.Cleanup) Storage(io.pravega.segmentstore.storage.Storage) SyncStorage(io.pravega.segmentstore.storage.SyncStorage) ChunkedSegmentStorage(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage) AsyncStorageWrapper(io.pravega.segmentstore.storage.AsyncStorageWrapper) StorageFactoryCreator(io.pravega.segmentstore.storage.StorageFactoryCreator) ConfigSetup(io.pravega.segmentstore.storage.ConfigSetup) Test(org.junit.Test)

Aggregations

StorageFactoryCreator (io.pravega.segmentstore.storage.StorageFactoryCreator)6 lombok.val (lombok.val)6 ConfigSetup (io.pravega.segmentstore.storage.ConfigSetup)5 Storage (io.pravega.segmentstore.storage.Storage)5 StorageFactoryInfo (io.pravega.segmentstore.storage.StorageFactoryInfo)5 SyncStorage (io.pravega.segmentstore.storage.SyncStorage)5 ChunkedSegmentStorage (io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage)5 Cleanup (lombok.Cleanup)5 AsyncStorageWrapper (io.pravega.segmentstore.storage.AsyncStorageWrapper)4 InMemoryMetadataStore (io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore)4 ExtendedS3ChunkStorage (io.pravega.storage.extendeds3.ExtendedS3ChunkStorage)4 ExtendedS3StorageFactoryCreator (io.pravega.storage.extendeds3.ExtendedS3StorageFactoryCreator)4 FileSystemChunkStorage (io.pravega.storage.filesystem.FileSystemChunkStorage)4 FileSystemStorageFactoryCreator (io.pravega.storage.filesystem.FileSystemStorageFactoryCreator)4 HDFSChunkStorage (io.pravega.storage.hdfs.HDFSChunkStorage)4 HDFSStorageFactoryCreator (io.pravega.storage.hdfs.HDFSStorageFactoryCreator)4 S3ChunkStorage (io.pravega.storage.s3.S3ChunkStorage)4 S3StorageFactoryCreator (io.pravega.storage.s3.S3StorageFactoryCreator)4 Test (org.junit.Test)4 ExtendedS3SimpleStorageFactory (io.pravega.storage.extendeds3.ExtendedS3SimpleStorageFactory)2