Search in sources :

Example 6 with StorageEngine

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

the class TestBaseKeyValueStorageEngineFactory method testWithLoggedStoreAndCachedStore.

@Test
public void testWithLoggedStoreAndCachedStore() {
    Config config = new MapConfig(BASE_CONFIG);
    StorageEngine storageEngine = callGetStorageEngine(config, CHANGELOG_SSP);
    KeyValueStorageEngine<?, ?> keyValueStorageEngine = baseStorageEngineValidation(storageEngine);
    assertStoreProperties(keyValueStorageEngine.getStoreProperties(), true, true, false);
    NullSafeKeyValueStore<?, ?> nullSafeKeyValueStore = assertAndCast(keyValueStorageEngine.getWrapperStore(), NullSafeKeyValueStore.class);
    CachedStore<?, ?> cachedStore = assertAndCast(nullSafeKeyValueStore.getStore(), CachedStore.class);
    SerializedKeyValueStore<?, ?> serializedKeyValueStore = assertAndCast(cachedStore.getStore(), SerializedKeyValueStore.class);
    LoggedStore<?, ?> loggedStore = assertAndCast(serializedKeyValueStore.getStore(), LoggedStore.class);
    // type generics don't match due to wildcard type, but checking reference equality, so type generics don't matter
    // noinspection AssertEqualsBetweenInconvertibleTypes
    assertEquals(this.rawKeyValueStore, loggedStore.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 7 with StorageEngine

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

the class TestBaseKeyValueStorageEngineFactory method testInMemoryKeyValueStore.

@Test
public void testInMemoryKeyValueStore() {
    Config config = new MapConfig(DISABLE_CACHE, ImmutableMap.of(String.format(StorageConfig.FACTORY, STORE_NAME), "org.apache.samza.storage.kv.inmemory.InMemoryKeyValueStorageEngineFactory"));
    StorageEngine storageEngine = callGetStorageEngine(config, null);
    KeyValueStorageEngine<?, ?> keyValueStorageEngine = baseStorageEngineValidation(storageEngine);
    assertStoreProperties(keyValueStorageEngine.getStoreProperties(), false, false, false);
    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)

Example 8 with StorageEngine

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

the class TestBaseKeyValueStorageEngineFactory method testWithLoggedStore.

@Test
public void testWithLoggedStore() {
    Config config = new MapConfig(BASE_CONFIG, DISABLE_CACHE);
    StorageEngine storageEngine = callGetStorageEngine(config, CHANGELOG_SSP);
    KeyValueStorageEngine<?, ?> keyValueStorageEngine = baseStorageEngineValidation(storageEngine);
    assertStoreProperties(keyValueStorageEngine.getStoreProperties(), true, true, false);
    NullSafeKeyValueStore<?, ?> nullSafeKeyValueStore = assertAndCast(keyValueStorageEngine.getWrapperStore(), NullSafeKeyValueStore.class);
    SerializedKeyValueStore<?, ?> serializedKeyValueStore = assertAndCast(nullSafeKeyValueStore.getStore(), SerializedKeyValueStore.class);
    LoggedStore<?, ?> loggedStore = assertAndCast(serializedKeyValueStore.getStore(), LoggedStore.class);
    // type generics don't match due to wildcard type, but checking reference equality, so type generics don't matter
    // noinspection AssertEqualsBetweenInconvertibleTypes
    assertEquals(this.rawKeyValueStore, loggedStore.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 9 with StorageEngine

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

the class TestTableManager method doTestInit.

private void doTestInit(Map<String, String> map) {
    Map<String, StorageEngine> storageEngines = new HashMap<>();
    storageEngines.put(TABLE_ID, mock(StorageEngine.class));
    TableManager tableManager = new TableManager(new MapConfig(map));
    tableManager.init(new MockContext());
    for (int i = 0; i < 2; i++) {
        Table table = tableManager.getTable(TABLE_ID);
        verify(DummyTableProviderFactory.tableProvider, times(1)).init(anyObject());
        verify(DummyTableProviderFactory.tableProvider, times(1)).getTable();
        Assert.assertEquals(DummyTableProviderFactory.table, table);
    }
    Map<String, TableManager.TableCtx> ctxMap = getFieldValue(tableManager, "tableContexts");
    TableManager.TableCtx ctx = ctxMap.get(TABLE_ID);
    Assert.assertEquals(TABLE_ID, ctxMap.keySet().iterator().next());
    TableProvider tableProvider = getFieldValue(ctx, "tableProvider");
    Assert.assertNotNull(tableProvider);
}
Also used : MockContext(org.apache.samza.context.MockContext) HashMap(java.util.HashMap) StorageEngine(org.apache.samza.storage.StorageEngine) MapConfig(org.apache.samza.config.MapConfig)

Example 10 with StorageEngine

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

the class TestBaseKeyValueStorageEngineFactory method testDisallowLargeMessages.

@Test
public void testDisallowLargeMessages() {
    Config config = new MapConfig(BASE_CONFIG, DISABLE_CACHE, DISALLOW_LARGE_MESSAGES);
    StorageEngine storageEngine = callGetStorageEngine(config, null);
    KeyValueStorageEngine<?, ?> keyValueStorageEngine = baseStorageEngineValidation(storageEngine);
    assertStoreProperties(keyValueStorageEngine.getStoreProperties(), true, false, false);
    NullSafeKeyValueStore<?, ?> nullSafeKeyValueStore = assertAndCast(keyValueStorageEngine.getWrapperStore(), NullSafeKeyValueStore.class);
    SerializedKeyValueStore<?, ?> serializedKeyValueStore = assertAndCast(nullSafeKeyValueStore.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)

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