use of io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage in project pravega by pravega.
the class StorageFactoryTests method testS3StorageFactoryCreator.
private void testS3StorageFactoryCreator(S3StorageConfig config) {
StorageFactoryCreator factoryCreator = new S3StorageFactoryCreator();
val expected = new StorageFactoryInfo[] { StorageFactoryInfo.builder().name("S3").storageLayoutType(StorageLayoutType.CHUNKED_STORAGE).build() };
val factoryInfoList = factoryCreator.getStorageFactories();
Assert.assertEquals(1, factoryInfoList.length);
Assert.assertArrayEquals(expected, factoryInfoList);
// Simple Storage
ConfigSetup configSetup1 = mock(ConfigSetup.class);
when(configSetup1.getConfig(any())).thenReturn(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, config);
val factory1 = factoryCreator.createFactory(expected[0], configSetup1, executorService());
Assert.assertTrue(factory1 instanceof S3SimpleStorageFactory);
@Cleanup Storage storage1 = ((S3SimpleStorageFactory) factory1).createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService()));
Assert.assertTrue(storage1 instanceof ChunkedSegmentStorage);
Assert.assertTrue(((ChunkedSegmentStorage) storage1).getChunkStorage() instanceof S3ChunkStorage);
AssertExtensions.assertThrows("createStorageAdapter should throw UnsupportedOperationException.", () -> factory1.createStorageAdapter(), ex -> ex instanceof UnsupportedOperationException);
}
use of io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage in project pravega by pravega.
the class StorageFactoryTests method testHDFSStorageFactoryCreator.
@Test
public void testHDFSStorageFactoryCreator() {
StorageFactoryCreator factoryCreator = new HDFSStorageFactoryCreator();
val expected = new StorageFactoryInfo[] { StorageFactoryInfo.builder().name("HDFS").storageLayoutType(StorageLayoutType.CHUNKED_STORAGE).build(), StorageFactoryInfo.builder().name("HDFS").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, HDFSStorageConfig.builder().build());
val factory1 = factoryCreator.createFactory(expected[0], configSetup1, executorService());
Assert.assertTrue(factory1 instanceof HDFSSimpleStorageFactory);
@Cleanup Storage storage1 = ((HDFSSimpleStorageFactory) factory1).createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService()));
Assert.assertTrue(storage1 instanceof ChunkedSegmentStorage);
Assert.assertTrue(((ChunkedSegmentStorage) storage1).getChunkStorage() instanceof HDFSChunkStorage);
// Legacy Storage
ConfigSetup configSetup2 = mock(ConfigSetup.class);
when(configSetup2.getConfig(any())).thenReturn(HDFSStorageConfig.builder().build());
val factory2 = factoryCreator.createFactory(expected[1], configSetup2, executorService());
Assert.assertTrue(factory2 instanceof HDFSStorageFactory);
@Cleanup Storage storage2 = factory2.createStorageAdapter();
Assert.assertTrue(storage2 instanceof AsyncStorageWrapper);
SyncStorage syncStorage = factory2.createSyncStorage();
Assert.assertNotNull(syncStorage);
AssertExtensions.assertThrows("createStorageAdapter should throw UnsupportedOperationException.", () -> factory1.createStorageAdapter(), ex -> ex instanceof UnsupportedOperationException);
}
use of io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage in project pravega by pravega.
the class S3SimpleStorageFactory method createStorageAdapter.
@Override
public Storage createStorageAdapter(int containerId, ChunkMetadataStore metadataStore) {
S3Client s3Client = createS3Client(this.config);
ChunkedSegmentStorage chunkedSegmentStorage = new ChunkedSegmentStorage(containerId, new S3ChunkStorage(s3Client, this.config, this.executor, true), metadataStore, this.executor, this.chunkedSegmentStorageConfig);
return chunkedSegmentStorage;
}
use of io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage in project pravega by pravega.
the class InMemorySimpleStorageFactoryTests method testReuse.
@Test
public void testReuse() {
@Cleanup("shutdownNow") val executor = ExecutorServiceHelpers.newScheduledThreadPool(1, "test");
val factory = new InMemorySimpleStorageFactory(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executor, true);
@Cleanup val s1 = (ChunkedSegmentStorage) factory.createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executor));
@Cleanup val s2 = (ChunkedSegmentStorage) factory.createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executor));
Assert.assertEquals(s1.getChunkStorage(), s2.getChunkStorage());
}
use of io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage in project pravega by pravega.
the class InMemorySimpleStorageFactoryTests method testNoReuse.
@Test
public void testNoReuse() {
@Cleanup("shutdownNow") val executor = ExecutorServiceHelpers.newScheduledThreadPool(1, "test");
val factory = new InMemorySimpleStorageFactory(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executor, false);
@Cleanup val s1 = (ChunkedSegmentStorage) factory.createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executor));
@Cleanup val s2 = (ChunkedSegmentStorage) factory.createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executor));
Assert.assertNotEquals(s1.getChunkStorage(), s2.getChunkStorage());
}
Aggregations