use of io.pravega.storage.filesystem.FileSystemStorageFactory in project pravega by pravega.
the class DataRecoveryTest method setUp.
@Before
public void setUp() throws Exception {
this.baseDir = Files.createTempDirectory("TestDataRecovery").toFile().getAbsoluteFile();
this.logsDir = Files.createTempDirectory("DataRecovery").toFile().getAbsoluteFile();
FileSystemStorageConfig adapterConfig = FileSystemStorageConfig.builder().with(FileSystemStorageConfig.ROOT, this.baseDir.getAbsolutePath()).with(FileSystemStorageConfig.REPLACE_ENABLED, true).build();
this.storageFactory = new FileSystemStorageFactory(adapterConfig, executorService());
}
use of io.pravega.storage.filesystem.FileSystemStorageFactory in project pravega by pravega.
the class StorageLoaderTest method testFileSystemStorage.
@Test
public void testFileSystemStorage() throws Exception {
val storageType = ServiceConfig.StorageType.FILESYSTEM;
ConfigSetup configSetup = mock(ConfigSetup.class);
val extraConfig = StorageExtraConfig.builder().with(StorageExtraConfig.STORAGE_NO_OP_MODE, false).build();
when(configSetup.getConfig(any())).thenReturn(extraConfig, FileSystemStorageConfig.builder().build());
val factory = getStorageFactory(configSetup, storageType, "FILESYSTEM", StorageLayoutType.ROLLING_STORAGE);
assertTrue(factory instanceof FileSystemStorageFactory);
}
use of io.pravega.storage.filesystem.FileSystemStorageFactory in project pravega by pravega.
the class StorageFactoryTests method testFileSystemStorageFactoryCreator.
@Test
public void testFileSystemStorageFactoryCreator() {
StorageFactoryCreator factoryCreator = new FileSystemStorageFactoryCreator();
val expected = new StorageFactoryInfo[] { StorageFactoryInfo.builder().name("FILESYSTEM").storageLayoutType(StorageLayoutType.CHUNKED_STORAGE).build(), StorageFactoryInfo.builder().name("FILESYSTEM").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, FileSystemStorageConfig.builder().build());
val factory1 = factoryCreator.createFactory(expected[0], configSetup1, executorService());
Assert.assertTrue(factory1 instanceof FileSystemSimpleStorageFactory);
@Cleanup Storage storage1 = ((FileSystemSimpleStorageFactory) factory1).createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService()));
Assert.assertTrue(storage1 instanceof ChunkedSegmentStorage);
Assert.assertTrue(((ChunkedSegmentStorage) storage1).getChunkStorage() instanceof FileSystemChunkStorage);
// Legacy Storage
ConfigSetup configSetup2 = mock(ConfigSetup.class);
when(configSetup2.getConfig(any())).thenReturn(FileSystemStorageConfig.builder().build());
val factory2 = factoryCreator.createFactory(expected[1], configSetup2, executorService());
Assert.assertTrue(factory2 instanceof FileSystemStorageFactory);
Storage storage2 = factory2.createStorageAdapter();
Assert.assertTrue(storage2 instanceof AsyncStorageWrapper);
@Cleanup SyncStorage syncStorage = factory2.createSyncStorage();
Assert.assertNotNull(syncStorage);
AssertExtensions.assertThrows("createStorageAdapter should throw UnsupportedOperationException.", () -> factory1.createStorageAdapter(), ex -> ex instanceof UnsupportedOperationException);
}
Aggregations