Search in sources :

Example 1 with FileSystemSimpleStorageFactory

use of io.pravega.storage.filesystem.FileSystemSimpleStorageFactory in project pravega by pravega.

the class StorageFactoryTests method testNull.

@Test
public void testNull() {
    AssertExtensions.assertThrows(" should throw exception.", () -> new FileSystemSimpleStorageFactory(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, null, executorService()), ex -> ex instanceof NullPointerException);
    AssertExtensions.assertThrows(" should throw exception.", () -> new ExtendedS3SimpleStorageFactory(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, null, executorService()), ex -> ex instanceof NullPointerException);
    AssertExtensions.assertThrows(" should throw exception.", () -> new HDFSSimpleStorageFactory(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, null, executorService()), ex -> ex instanceof NullPointerException);
    AssertExtensions.assertThrows(" should throw exception.", () -> new FileSystemSimpleStorageFactory(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, FileSystemStorageConfig.builder().build(), null), ex -> ex instanceof NullPointerException);
    AssertExtensions.assertThrows(" should throw exception.", () -> new ExtendedS3SimpleStorageFactory(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, ExtendedS3StorageConfig.builder().build(), null), ex -> ex instanceof NullPointerException);
    AssertExtensions.assertThrows(" should throw exception.", () -> new HDFSSimpleStorageFactory(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, HDFSStorageConfig.builder().build(), null), ex -> ex instanceof NullPointerException);
    AssertExtensions.assertThrows(" should throw exception.", () -> new FileSystemSimpleStorageFactory(null, FileSystemStorageConfig.builder().build(), executorService()), ex -> ex instanceof NullPointerException);
    AssertExtensions.assertThrows(" should throw exception.", () -> new ExtendedS3SimpleStorageFactory(null, ExtendedS3StorageConfig.builder().build(), executorService()), ex -> ex instanceof NullPointerException);
    AssertExtensions.assertThrows(" should throw exception.", () -> new HDFSSimpleStorageFactory(null, HDFSStorageConfig.builder().build(), executorService()), ex -> ex instanceof NullPointerException);
}
Also used : ExtendedS3SimpleStorageFactory(io.pravega.storage.extendeds3.ExtendedS3SimpleStorageFactory) FileSystemSimpleStorageFactory(io.pravega.storage.filesystem.FileSystemSimpleStorageFactory) HDFSSimpleStorageFactory(io.pravega.storage.hdfs.HDFSSimpleStorageFactory) Test(org.junit.Test)

Example 2 with FileSystemSimpleStorageFactory

use of io.pravega.storage.filesystem.FileSystemSimpleStorageFactory in project pravega by pravega.

the class StorageLoaderTest method testSimpleFileSystemStorage.

@Test
public void testSimpleFileSystemStorage() 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, ChunkedSegmentStorageConfig.DEFAULT_CONFIG, FileSystemStorageConfig.builder().build());
    val factory = getStorageFactory(configSetup, storageType, "FILESYSTEM", StorageLayoutType.CHUNKED_STORAGE);
    assertTrue(factory instanceof FileSystemSimpleStorageFactory);
}
Also used : lombok.val(lombok.val) FileSystemSimpleStorageFactory(io.pravega.storage.filesystem.FileSystemSimpleStorageFactory) ConfigSetup(io.pravega.segmentstore.storage.ConfigSetup) Test(org.junit.Test)

Example 3 with FileSystemSimpleStorageFactory

use of io.pravega.storage.filesystem.FileSystemSimpleStorageFactory 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);
}
Also used : lombok.val(lombok.val) SyncStorage(io.pravega.segmentstore.storage.SyncStorage) FileSystemStorageFactoryCreator(io.pravega.storage.filesystem.FileSystemStorageFactoryCreator) FileSystemStorageFactory(io.pravega.storage.filesystem.FileSystemStorageFactory) StorageFactoryInfo(io.pravega.segmentstore.storage.StorageFactoryInfo) ChunkedSegmentStorage(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage) FileSystemSimpleStorageFactory(io.pravega.storage.filesystem.FileSystemSimpleStorageFactory) Cleanup(lombok.Cleanup) Storage(io.pravega.segmentstore.storage.Storage) ChunkedSegmentStorage(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage) ExtendedS3ChunkStorage(io.pravega.storage.extendeds3.ExtendedS3ChunkStorage) HDFSChunkStorage(io.pravega.storage.hdfs.HDFSChunkStorage) S3ChunkStorage(io.pravega.storage.s3.S3ChunkStorage) SyncStorage(io.pravega.segmentstore.storage.SyncStorage) FileSystemChunkStorage(io.pravega.storage.filesystem.FileSystemChunkStorage) AsyncStorageWrapper(io.pravega.segmentstore.storage.AsyncStorageWrapper) InMemoryMetadataStore(io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore) S3StorageFactoryCreator(io.pravega.storage.s3.S3StorageFactoryCreator) HDFSStorageFactoryCreator(io.pravega.storage.hdfs.HDFSStorageFactoryCreator) StorageFactoryCreator(io.pravega.segmentstore.storage.StorageFactoryCreator) ExtendedS3StorageFactoryCreator(io.pravega.storage.extendeds3.ExtendedS3StorageFactoryCreator) FileSystemStorageFactoryCreator(io.pravega.storage.filesystem.FileSystemStorageFactoryCreator) ConfigSetup(io.pravega.segmentstore.storage.ConfigSetup) FileSystemChunkStorage(io.pravega.storage.filesystem.FileSystemChunkStorage) Test(org.junit.Test)

Example 4 with FileSystemSimpleStorageFactory

use of io.pravega.storage.filesystem.FileSystemSimpleStorageFactory in project pravega by pravega.

the class StorageCommandsTest method setUp.

@Before
public void setUp() throws Exception {
    this.baseDir = Files.createTempDirectory("TestStorage").toFile().getAbsoluteFile();
    this.logsDir = Files.createTempDirectory("Storage").toFile().getAbsoluteFile();
    FileSystemStorageConfig adapterConfig = FileSystemStorageConfig.builder().with(FileSystemStorageConfig.ROOT, this.baseDir.getAbsolutePath()).with(FileSystemStorageConfig.REPLACE_ENABLED, true).build();
    ChunkedSegmentStorageConfig config = ChunkedSegmentStorageConfig.DEFAULT_CONFIG;
    this.storageFactory = new FileSystemSimpleStorageFactory(config, adapterConfig, executorService());
}
Also used : ChunkedSegmentStorageConfig(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorageConfig) FileSystemSimpleStorageFactory(io.pravega.storage.filesystem.FileSystemSimpleStorageFactory) FileSystemStorageConfig(io.pravega.storage.filesystem.FileSystemStorageConfig) Before(org.junit.Before)

Aggregations

FileSystemSimpleStorageFactory (io.pravega.storage.filesystem.FileSystemSimpleStorageFactory)4 Test (org.junit.Test)3 ConfigSetup (io.pravega.segmentstore.storage.ConfigSetup)2 lombok.val (lombok.val)2 AsyncStorageWrapper (io.pravega.segmentstore.storage.AsyncStorageWrapper)1 Storage (io.pravega.segmentstore.storage.Storage)1 StorageFactoryCreator (io.pravega.segmentstore.storage.StorageFactoryCreator)1 StorageFactoryInfo (io.pravega.segmentstore.storage.StorageFactoryInfo)1 SyncStorage (io.pravega.segmentstore.storage.SyncStorage)1 ChunkedSegmentStorage (io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage)1 ChunkedSegmentStorageConfig (io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorageConfig)1 InMemoryMetadataStore (io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore)1 ExtendedS3ChunkStorage (io.pravega.storage.extendeds3.ExtendedS3ChunkStorage)1 ExtendedS3SimpleStorageFactory (io.pravega.storage.extendeds3.ExtendedS3SimpleStorageFactory)1 ExtendedS3StorageFactoryCreator (io.pravega.storage.extendeds3.ExtendedS3StorageFactoryCreator)1 FileSystemChunkStorage (io.pravega.storage.filesystem.FileSystemChunkStorage)1 FileSystemStorageConfig (io.pravega.storage.filesystem.FileSystemStorageConfig)1 FileSystemStorageFactory (io.pravega.storage.filesystem.FileSystemStorageFactory)1 FileSystemStorageFactoryCreator (io.pravega.storage.filesystem.FileSystemStorageFactoryCreator)1 HDFSChunkStorage (io.pravega.storage.hdfs.HDFSChunkStorage)1