Search in sources :

Example 6 with StringSerde

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"));
}
Also used : StringSerde(org.apache.samza.serializers.StringSerde) Map(java.util.Map) IntegerSerde(org.apache.samza.serializers.IntegerSerde) Test(org.junit.Test)

Example 7 with StringSerde

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());
}
Also used : StringSerde(org.apache.samza.serializers.StringSerde) AsyncBucket(com.couchbase.client.java.AsyncBucket) Bucket(com.couchbase.client.java.Bucket) AsyncBucket(com.couchbase.client.java.AsyncBucket) TimeUnit(java.util.concurrent.TimeUnit) Document(com.couchbase.client.java.document.Document) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 8 with StringSerde

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());
}
Also used : StringSerde(org.apache.samza.serializers.StringSerde) AsyncBucket(com.couchbase.client.java.AsyncBucket) Bucket(com.couchbase.client.java.Bucket) AsyncBucket(com.couchbase.client.java.AsyncBucket) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 9 with StringSerde

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());
}
Also used : StringSerde(org.apache.samza.serializers.StringSerde) AsyncBucket(com.couchbase.client.java.AsyncBucket) Bucket(com.couchbase.client.java.Bucket) AsyncBucket(com.couchbase.client.java.AsyncBucket) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 10 with StringSerde

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());
}
Also used : StringSerde(org.apache.samza.serializers.StringSerde) AsyncBucket(com.couchbase.client.java.AsyncBucket) Bucket(com.couchbase.client.java.Bucket) AsyncBucket(com.couchbase.client.java.AsyncBucket) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

StringSerde (org.apache.samza.serializers.StringSerde)52 Test (org.junit.Test)32 KV (org.apache.samza.operators.KV)25 KVSerde (org.apache.samza.serializers.KVSerde)19 KafkaSystemDescriptor (org.apache.samza.system.kafka.descriptors.KafkaSystemDescriptor)14 Config (org.apache.samza.config.Config)13 JsonSerdeV2 (org.apache.samza.serializers.JsonSerdeV2)13 StreamApplication (org.apache.samza.application.StreamApplication)11 Duration (java.time.Duration)10 StreamApplicationDescriptor (org.apache.samza.application.descriptors.StreamApplicationDescriptor)10 MessageStream (org.apache.samza.operators.MessageStream)10 KafkaInputDescriptor (org.apache.samza.system.kafka.descriptors.KafkaInputDescriptor)10 ApplicationRunner (org.apache.samza.runtime.ApplicationRunner)9 ApplicationRunners (org.apache.samza.runtime.ApplicationRunners)9 NoOpSerde (org.apache.samza.serializers.NoOpSerde)9 KafkaOutputDescriptor (org.apache.samza.system.kafka.descriptors.KafkaOutputDescriptor)9 TableDescriptor (org.apache.samza.table.descriptors.TableDescriptor)9 CommandLine (org.apache.samza.util.CommandLine)9 OutputStream (org.apache.samza.operators.OutputStream)8 Windows (org.apache.samza.operators.windows.Windows)8