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());
}
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());
}
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());
}
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);
}
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());
}
Aggregations