Search in sources :

Example 1 with IntegerSerde

use of org.apache.samza.serializers.IntegerSerde 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 2 with IntegerSerde

use of org.apache.samza.serializers.IntegerSerde in project samza by apache.

the class TestExpandingInputDescriptor method testISDObjectsWithOverrides.

@Test
public void testISDObjectsWithOverrides() {
    ExampleExpandingSystemDescriptor expandingSystem = new ExampleExpandingSystemDescriptor("expandingSystem");
    IntegerSerde streamSerde = new IntegerSerde();
    ExampleExpandingInputDescriptor<Long> expandingISD = expandingSystem.getInputDescriptor("input-stream", streamSerde);
    assertEquals(streamSerde, expandingISD.getSerde());
    assertEquals(expandingSystem.getTransformer().get(), expandingISD.getTransformer().get());
}
Also used : ExampleExpandingSystemDescriptor(org.apache.samza.system.descriptors.examples.expanding.ExampleExpandingSystemDescriptor) IntegerSerde(org.apache.samza.serializers.IntegerSerde) Test(org.junit.Test)

Example 3 with IntegerSerde

use of org.apache.samza.serializers.IntegerSerde in project samza by apache.

the class TestTransformingInputDescriptor method testISDObjectsWithOverrides.

@Test
public void testISDObjectsWithOverrides() {
    ExampleTransformingSystemDescriptor imeTransformingSystem = new ExampleTransformingSystemDescriptor("imeTransformingSystem");
    IntegerSerde streamSerde = new IntegerSerde();
    ExampleTransformingInputDescriptor<Long> overridingISD = imeTransformingSystem.getInputDescriptor("input-stream", streamSerde);
    assertEquals(streamSerde, overridingISD.getSerde());
    assertEquals(imeTransformingSystem.getTransformer().get(), overridingISD.getTransformer().get());
}
Also used : ExampleTransformingSystemDescriptor(org.apache.samza.system.descriptors.examples.transforming.ExampleTransformingSystemDescriptor) IntegerSerde(org.apache.samza.serializers.IntegerSerde) Test(org.junit.Test)

Example 4 with IntegerSerde

use of org.apache.samza.serializers.IntegerSerde in project samza by apache.

the class TestTransformingInputDescriptor method testAPIUsage.

@Test
public void testAPIUsage() {
    // does not assert anything, but acts as a compile-time check on expected descriptor type parameters
    // and validates that the method calls can be chained.
    ExampleTransformingSystemDescriptor imeTransformingSystem = new ExampleTransformingSystemDescriptor("imeTransformingSystem").withSystemConfigs(Collections.emptyMap());
    ExampleTransformingInputDescriptor<Long> input1 = imeTransformingSystem.getInputDescriptor("input1", new IntegerSerde());
    ExampleTransformingOutputDescriptor<Integer> output1 = imeTransformingSystem.getOutputDescriptor("output1", new IntegerSerde());
    input1.shouldBootstrap().withOffsetDefault(SystemStreamMetadata.OffsetType.NEWEST).withPriority(1).shouldResetOffset().withStreamConfigs(Collections.emptyMap());
    output1.withStreamConfigs(Collections.emptyMap());
}
Also used : ExampleTransformingSystemDescriptor(org.apache.samza.system.descriptors.examples.transforming.ExampleTransformingSystemDescriptor) IntegerSerde(org.apache.samza.serializers.IntegerSerde) Test(org.junit.Test)

Example 5 with IntegerSerde

use of org.apache.samza.serializers.IntegerSerde in project samza by apache.

the class TestGenericInputDescriptor method testAPIUsage.

@Test
public void testAPIUsage() {
    // does not assert anything, but acts as a compile-time check on expected descriptor type parameters
    // and validates that the method calls can be chained.
    GenericSystemDescriptor mySystem = new GenericSystemDescriptor("input-system", "factory.class.name").withSystemConfigs(Collections.emptyMap()).withDefaultStreamConfigs(Collections.emptyMap());
    GenericInputDescriptor<Integer> input1 = mySystem.getInputDescriptor("input1", new IntegerSerde());
    GenericOutputDescriptor<Integer> output1 = mySystem.getOutputDescriptor("output1", new IntegerSerde());
    input1.withPhysicalName("input-1").shouldBootstrap().withOffsetDefault(SystemStreamMetadata.OffsetType.NEWEST).withPriority(1).shouldResetOffset().isBounded().shouldDeleteCommittedMessages().withStreamConfigs(Collections.emptyMap());
    output1.withPhysicalName("output-1").withStreamConfigs(Collections.emptyMap());
}
Also used : IntegerSerde(org.apache.samza.serializers.IntegerSerde) Test(org.junit.Test)

Aggregations

IntegerSerde (org.apache.samza.serializers.IntegerSerde)24 Test (org.junit.Test)17 StreamApplication (org.apache.samza.application.StreamApplication)9 KVSerde (org.apache.samza.serializers.KVSerde)9 Config (org.apache.samza.config.Config)8 Duration (java.time.Duration)7 HashMap (java.util.HashMap)7 StreamApplicationDescriptor (org.apache.samza.application.descriptors.StreamApplicationDescriptor)7 MapConfig (org.apache.samza.config.MapConfig)7 KV (org.apache.samza.operators.KV)6 List (java.util.List)5 MessageStream (org.apache.samza.operators.MessageStream)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 Context (org.apache.samza.context.Context)4 StringSerde (org.apache.samza.serializers.StringSerde)4 GenericInputDescriptor (org.apache.samza.system.descriptors.GenericInputDescriptor)4 InMemorySystemDescriptor (org.apache.samza.test.framework.system.descriptors.InMemorySystemDescriptor)4 ImmutableList (com.google.common.collect.ImmutableList)3 OutputStream (org.apache.samza.operators.OutputStream)3