Search in sources :

Example 1 with StringSerde

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

the class TestEventHubsOutputDescriptor method testEntityConnectionConfigs.

@Test
public void testEntityConnectionConfigs() {
    String systemName = "eventHub";
    String streamId = "output-stream";
    EventHubsSystemDescriptor systemDescriptor = new EventHubsSystemDescriptor(systemName);
    EventHubsOutputDescriptor<KV<String, String>> outputDescriptor = systemDescriptor.getOutputDescriptor(streamId, "entity-namespace", "entity3", new StringSerde()).withSasKeyName("secretkey").withSasKey("sasToken-123");
    Map<String, String> generatedConfigs = outputDescriptor.toConfig();
    assertEquals("eventHub", generatedConfigs.get("streams.output-stream.samza.system"));
    assertEquals("entity-namespace", generatedConfigs.get(String.format(EventHubConfig.CONFIG_STREAM_NAMESPACE, streamId)));
    assertEquals("entity3", generatedConfigs.get(String.format(EventHubConfig.CONFIG_STREAM_ENTITYPATH, streamId)));
    assertEquals("secretkey", generatedConfigs.get(String.format(EventHubConfig.CONFIG_STREAM_SAS_KEY_NAME, streamId)));
    assertEquals("sasToken-123", generatedConfigs.get(String.format(EventHubConfig.CONFIG_STREAM_SAS_TOKEN, streamId)));
}
Also used : StringSerde(org.apache.samza.serializers.StringSerde) KV(org.apache.samza.operators.KV) Test(org.junit.Test)

Example 2 with StringSerde

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

the class TestEventHubsOutputDescriptor method testMissingOutputDescriptorFields.

@Test
public void testMissingOutputDescriptorFields() {
    String systemName = "eventHub";
    String streamId = "input-stream";
    EventHubsSystemDescriptor systemDescriptor = new EventHubsSystemDescriptor(systemName);
    try {
        systemDescriptor.getOutputDescriptor(streamId, null, null, new StringSerde());
        fail("Should have thrown Config Exception");
    } catch (ConfigException exception) {
        assertEquals(String.format(// 
        "Missing namespace and entity path Event Hubs output descriptor in " + "system: {%s}, stream: {%s}", systemName, streamId), exception.getMessage());
    }
}
Also used : StringSerde(org.apache.samza.serializers.StringSerde) ConfigException(org.apache.samza.config.ConfigException) Test(org.junit.Test)

Example 3 with StringSerde

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

the class TestEventHubsInputDescriptor method testWithoutEntityConnectionConfigs.

@Test
public void testWithoutEntityConnectionConfigs() {
    String systemName = "eventHub";
    String streamId = "input-stream";
    EventHubsSystemDescriptor systemDescriptor = new EventHubsSystemDescriptor(systemName);
    EventHubsInputDescriptor<KV<String, String>> inputDescriptor = systemDescriptor.getInputDescriptor(streamId, "entity-namespace", "entity3", new StringSerde());
    Map<String, String> generatedConfigs = inputDescriptor.toConfig();
    assertEquals("eventHub", generatedConfigs.get("streams.input-stream.samza.system"));
    assertEquals("entity-namespace", generatedConfigs.get(String.format(EventHubConfig.CONFIG_STREAM_NAMESPACE, streamId)));
    assertEquals("entity3", generatedConfigs.get(String.format(EventHubConfig.CONFIG_STREAM_ENTITYPATH, streamId)));
    assertNull(generatedConfigs.get(String.format(EventHubConfig.CONFIG_STREAM_SAS_KEY_NAME, streamId)));
    assertNull(generatedConfigs.get(String.format(EventHubConfig.CONFIG_STREAM_SAS_TOKEN, streamId)));
    assertNull(generatedConfigs.get(String.format(EventHubConfig.CONFIG_STREAM_CONSUMER_GROUP, streamId)));
    // verify that there are no other configs
    assertEquals(3, generatedConfigs.size());
}
Also used : StringSerde(org.apache.samza.serializers.StringSerde) KV(org.apache.samza.operators.KV) Test(org.junit.Test)

Example 4 with StringSerde

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

the class TestEventHubsInputDescriptor method testMissingInputDescriptorFields.

@Test
public void testMissingInputDescriptorFields() {
    String systemName = "eventHub";
    String streamId = "input-stream";
    EventHubsSystemDescriptor systemDescriptor = new EventHubsSystemDescriptor(systemName);
    try {
        systemDescriptor.getInputDescriptor(streamId, null, null, new StringSerde());
        fail("Should have thrown Config Exception");
    } catch (ConfigException exception) {
        assertEquals(String.format(// 
        "Missing namespace and entity path Event Hubs input descriptor in " + "system: {%s}, stream: {%s}", systemName, streamId), exception.getMessage());
    }
}
Also used : StringSerde(org.apache.samza.serializers.StringSerde) ConfigException(org.apache.samza.config.ConfigException) Test(org.junit.Test)

Example 5 with StringSerde

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

the class TestEventHubsSystemDescriptor method testWithDescriptorOverrides.

@Test
public void testWithDescriptorOverrides() {
    String systemName = "system-name";
    String streamId1 = "input-stream1";
    String streamId2 = "input-stream2";
    String streamId3 = "output-stream1";
    String streamId4 = "output-stream2";
    EventHubsSystemDescriptor systemDescriptor = new EventHubsSystemDescriptor(systemName).withMaxEventCountPerPoll(1000).withNumClientThreads(5).withPartitioningMethod(PartitioningMethod.PARTITION_KEY_AS_PARTITION).withPrefetchCount(100).withReceiveQueueSize(500).withRuntimeInfoTimeout(60000).withSendKeys(false);
    systemDescriptor.getInputDescriptor(streamId1, "entity-namespace1", "entity1", new StringSerde());
    systemDescriptor.getInputDescriptor(streamId2, "entity-namespace2", "entity2", new StringSerde());
    systemDescriptor.getOutputDescriptor(streamId3, "entity-namespace3", "entity3", new StringSerde());
    systemDescriptor.getOutputDescriptor(streamId4, "entity-namespace4", "entity4", new StringSerde());
    Map<String, String> generatedConfigs = systemDescriptor.toConfig();
    assertEquals("org.apache.samza.system.eventhub.EventHubSystemFactory", generatedConfigs.get(String.format("systems.%s.samza.factory", systemName)));
    assertEquals("1000", generatedConfigs.get(String.format(EventHubConfig.CONFIG_MAX_EVENT_COUNT_PER_POLL, systemName)));
    assertEquals("5", generatedConfigs.get(String.format(EventHubConfig.CONFIG_SYSTEM_NUM_CLIENT_THREADS, systemName)));
    assertEquals("PARTITION_KEY_AS_PARTITION", generatedConfigs.get(String.format(EventHubConfig.CONFIG_PRODUCER_PARTITION_METHOD, systemName)));
    assertEquals("100", generatedConfigs.get(String.format(EventHubConfig.CONFIG_PREFETCH_COUNT, systemName)));
    assertEquals("500", generatedConfigs.get(String.format(EventHubConfig.CONFIG_CONSUMER_BUFFER_CAPACITY, systemName)));
    assertEquals("60000", generatedConfigs.get(String.format(EventHubConfig.CONFIG_FETCH_RUNTIME_INFO_TIMEOUT_MILLIS, systemName)));
    assertEquals("false", generatedConfigs.get(String.format(EventHubConfig.CONFIG_SEND_KEY_IN_EVENT_PROPERTIES, systemName)));
    assertEquals(streamId1 + "," + streamId2 + "," + streamId3 + "," + streamId4, generatedConfigs.get(String.format(EventHubConfig.CONFIG_STREAM_LIST, systemName)));
}
Also used : StringSerde(org.apache.samza.serializers.StringSerde) Test(org.junit.Test)

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