Search in sources :

Example 11 with StorageEngine

use of org.apache.samza.storage.StorageEngine in project samza by apache.

the class TestBaseKeyValueStorageEngineFactory method testDropLargeMessagesWithCache.

@Test
public void testDropLargeMessagesWithCache() {
    Config config = new MapConfig(BASE_CONFIG, DROP_LARGE_MESSAGES);
    StorageEngine storageEngine = callGetStorageEngine(config, null);
    KeyValueStorageEngine<?, ?> keyValueStorageEngine = baseStorageEngineValidation(storageEngine);
    assertStoreProperties(keyValueStorageEngine.getStoreProperties(), true, false, false);
    NullSafeKeyValueStore<?, ?> nullSafeKeyValueStore = assertAndCast(keyValueStorageEngine.getWrapperStore(), NullSafeKeyValueStore.class);
    CachedStore<?, ?> cachedStore = assertAndCast(nullSafeKeyValueStore.getStore(), CachedStore.class);
    SerializedKeyValueStore<?, ?> serializedKeyValueStore = assertAndCast(cachedStore.getStore(), SerializedKeyValueStore.class);
    LargeMessageSafeStore largeMessageSafeStore = assertAndCast(serializedKeyValueStore.getStore(), LargeMessageSafeStore.class);
    assertEquals(this.rawKeyValueStore, largeMessageSafeStore.getStore());
}
Also used : MapConfig(org.apache.samza.config.MapConfig) StorageConfig(org.apache.samza.config.StorageConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) StorageEngine(org.apache.samza.storage.StorageEngine) Test(org.junit.Test)

Example 12 with StorageEngine

use of org.apache.samza.storage.StorageEngine in project samza by apache.

the class TestBaseKeyValueStorageEngineFactory method testDurableKeyValueStore.

@Test
public void testDurableKeyValueStore() {
    Config config = new MapConfig(BASE_CONFIG, DISABLE_CACHE, ImmutableMap.of(String.format(StorageConfig.STORE_BACKUP_FACTORIES, STORE_NAME), "backendFactory,backendFactory2"));
    StorageEngine storageEngine = callGetStorageEngine(config, null);
    KeyValueStorageEngine<?, ?> keyValueStorageEngine = baseStorageEngineValidation(storageEngine);
    assertStoreProperties(keyValueStorageEngine.getStoreProperties(), true, false, true);
    NullSafeKeyValueStore<?, ?> nullSafeKeyValueStore = assertAndCast(keyValueStorageEngine.getWrapperStore(), NullSafeKeyValueStore.class);
    SerializedKeyValueStore<?, ?> serializedKeyValueStore = assertAndCast(nullSafeKeyValueStore.getStore(), SerializedKeyValueStore.class);
    // config has the in-memory key-value factory, but still calling the test factory, so store will be the test store
    assertEquals(this.rawKeyValueStore, serializedKeyValueStore.getStore());
}
Also used : MapConfig(org.apache.samza.config.MapConfig) StorageConfig(org.apache.samza.config.StorageConfig) Config(org.apache.samza.config.Config) MapConfig(org.apache.samza.config.MapConfig) StorageEngine(org.apache.samza.storage.StorageEngine) Test(org.junit.Test)

Aggregations

MapConfig (org.apache.samza.config.MapConfig)12 StorageEngine (org.apache.samza.storage.StorageEngine)12 Config (org.apache.samza.config.Config)11 Test (org.junit.Test)11 StorageConfig (org.apache.samza.config.StorageConfig)10 HashMap (java.util.HashMap)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 File (java.io.File)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1