Search in sources :

Example 1 with GuavaCacheTableDescriptor

use of org.apache.samza.table.descriptors.GuavaCacheTableDescriptor in project samza by apache.

the class TestCachingTable method testSerializeWithCacheInstance.

@Test
public void testSerializeWithCacheInstance() {
    String tableId = "guavaCacheId";
    GuavaCacheTableDescriptor guavaTableDesc = new GuavaCacheTableDescriptor(tableId).withCache(CacheBuilder.newBuilder().build());
    Map<String, String> tableConfig = guavaTableDesc.toConfig(new MapConfig());
    assertExists(GuavaCacheTableDescriptor.GUAVA_CACHE, tableId, tableConfig);
    doTestSerialize(guavaTableDesc);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) MapConfig(org.apache.samza.config.MapConfig) GuavaCacheTableDescriptor(org.apache.samza.table.descriptors.GuavaCacheTableDescriptor) Test(org.junit.Test)

Example 2 with GuavaCacheTableDescriptor

use of org.apache.samza.table.descriptors.GuavaCacheTableDescriptor in project samza by apache.

the class TestRemoteTableEndToEnd method getCachingTable.

private <K, V> Table<KV<K, V>> getCachingTable(TableDescriptor<K, V, ?> actualTableDesc, boolean defaultCache, StreamApplicationDescriptor appDesc) {
    String id = actualTableDesc.getTableId();
    CachingTableDescriptor<K, V> cachingDesc;
    if (defaultCache) {
        cachingDesc = new CachingTableDescriptor<>("caching-table-" + id, actualTableDesc);
        cachingDesc.withReadTtl(Duration.ofMinutes(5));
        cachingDesc.withWriteTtl(Duration.ofMinutes(5));
    } else {
        GuavaCacheTableDescriptor<K, V> guavaTableDesc = new GuavaCacheTableDescriptor<>("guava-table-" + id);
        guavaTableDesc.withCache(CacheBuilder.newBuilder().expireAfterAccess(5, TimeUnit.MINUTES).build());
        cachingDesc = new CachingTableDescriptor<>("caching-table-" + id, actualTableDesc, guavaTableDesc);
    }
    return appDesc.getTable(cachingDesc);
}
Also used : KV(org.apache.samza.operators.KV) Matchers.anyString(org.mockito.Matchers.anyString) GuavaCacheTableDescriptor(org.apache.samza.table.descriptors.GuavaCacheTableDescriptor)

Aggregations

GuavaCacheTableDescriptor (org.apache.samza.table.descriptors.GuavaCacheTableDescriptor)2 Matchers.anyString (org.mockito.Matchers.anyString)2 MapConfig (org.apache.samza.config.MapConfig)1 KV (org.apache.samza.operators.KV)1 Test (org.junit.Test)1