use of org.apache.samza.serializers.StringSerde in project samza by apache.
the class TestRocksDbTableDescriptor method testRocksDbConfig.
@Test
public void testRocksDbConfig() {
Map tableConfig = new RocksDbTableDescriptor<Integer, String>(TABLE_ID, KVSerde.of(new IntegerSerde(), new StringSerde())).withBlockSize(1).withCacheSize(2).withCompactionStyle("fifo").withCompressionType("snappy").withMaxLogFileSize(3).withNumLogFilesToKeep(4).withNumWriteBuffers(5).withObjectCacheSize(6).withTtl(7).withWriteBatchSize(8).withWriteBufferSize(9).withMaxOpenFiles(10).withMaxFileOpeningThreads(11).withConfig("abc", "xyz").toConfig(createJobConfig());
Assert.assertEquals(16, tableConfig.size());
assertEquals("1", RocksDbTableDescriptor.ROCKSDB_BLOCK_SIZE_BYTES, tableConfig);
assertEquals("2", RocksDbTableDescriptor.CONTAINER_CACHE_SIZE_BYTES, tableConfig);
assertEquals("3", RocksDbTableDescriptor.ROCKSDB_MAX_LOG_FILE_SIZE_BYTES, tableConfig);
assertEquals("4", RocksDbTableDescriptor.ROCKSDB_KEEP_LOG_FILE_NUM, tableConfig);
assertEquals("5", RocksDbTableDescriptor.ROCKSDB_NUM_WRITE_BUFFERS, tableConfig);
assertEquals("6", RocksDbTableDescriptor.OBJECT_CACHE_SIZE, tableConfig);
assertEquals("7", RocksDbTableDescriptor.ROCKSDB_TTL_MS, tableConfig);
assertEquals("8", RocksDbTableDescriptor.WRITE_BATCH_SIZE, tableConfig);
assertEquals("9", RocksDbTableDescriptor.CONTAINER_WRITE_BUFFER_SIZE_BYTES, tableConfig);
assertEquals("10", RocksDbTableDescriptor.ROCKSDB_MAX_OPEN_FILES, tableConfig);
assertEquals("11", RocksDbTableDescriptor.ROCKSDB_MAX_FILE_OPENING_THREADS, tableConfig);
assertEquals("snappy", RocksDbTableDescriptor.ROCKSDB_COMPRESSION, tableConfig);
assertEquals("fifo", RocksDbTableDescriptor.ROCKSDB_COMPACTION_STYLE, tableConfig);
Assert.assertFalse(tableConfig.containsKey(String.format(StorageConfig.CHANGELOG_STREAM, TABLE_ID)));
Assert.assertFalse(tableConfig.containsKey(String.format(StorageConfig.CHANGELOG_REPLICATION_FACTOR, TABLE_ID)));
Assert.assertEquals("xyz", tableConfig.get("abc"));
}
use of org.apache.samza.serializers.StringSerde in project samza by apache.
the class TestCouchbaseTableWriteFunction method testPutAsyncStringValue.
@Test
public void testPutAsyncStringValue() throws Exception {
String key = "key";
String value = "value";
Bucket bucket = mock(Bucket.class);
AsyncBucket asyncBucket = mock(AsyncBucket.class);
CouchbaseTableWriteFunction<String> writeFunction = createAndInit(String.class, new StringSerde(), bucket, asyncBucket);
when(asyncBucket.upsert(any(Document.class), anyLong(), any(TimeUnit.class))).thenReturn(Observable.just(null));
assertNull(writeFunction.putAsync(key, value).get());
}
use of org.apache.samza.serializers.StringSerde in project samza by apache.
the class TestCouchbaseTableWriteFunction method testDeleteAsyncStringValue.
@Test
public void testDeleteAsyncStringValue() throws Exception {
String key = "key";
Bucket bucket = mock(Bucket.class);
AsyncBucket asyncBucket = mock(AsyncBucket.class);
CouchbaseTableWriteFunction<String> writeFunction = createAndInit(String.class, new StringSerde(), bucket, asyncBucket);
when(asyncBucket.remove(eq(key), anyLong(), any(TimeUnit.class))).thenReturn(Observable.just(null));
assertNull(writeFunction.deleteAsync(key).get());
}
use of org.apache.samza.serializers.StringSerde in project samza by apache.
the class TestCouchbaseTableReadFunction method testGetAsyncStringValue.
@Test
public void testGetAsyncStringValue() throws Exception {
String key = "key";
String value = "value";
StringSerde stringSerde = new StringSerde();
Bucket bucket = mock(Bucket.class);
AsyncBucket asyncBucket = mock(AsyncBucket.class);
CouchbaseTableReadFunction readFunction = createAndInit(String.class, stringSerde, bucket, asyncBucket);
when(asyncBucket.get(eq(key), anyObject(), anyLong(), any(TimeUnit.class))).thenReturn(Observable.just(BinaryDocument.create(key, Unpooled.wrappedBuffer(stringSerde.toBytes(value)))));
assertEquals(value, readFunction.getAsync(key).get());
}
use of org.apache.samza.serializers.StringSerde in project samza by apache.
the class TestCouchbaseTableReadFunction method testGetAsyncNullValue.
@Test
public void testGetAsyncNullValue() throws Exception {
String key = "NonExistingKey";
Bucket bucket = mock(Bucket.class);
AsyncBucket asyncBucket = mock(AsyncBucket.class);
CouchbaseTableReadFunction readFunction = createAndInit(String.class, new StringSerde(), bucket, asyncBucket);
when(asyncBucket.get(eq(key), anyObject(), anyLong(), any(TimeUnit.class))).thenReturn(Observable.empty());
assertNull(readFunction.getAsync(key).get());
}
Aggregations