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)));
}
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());
}
}
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());
}
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());
}
}
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)));
}
Aggregations