Search in sources :

Example 1 with AsyncStreamTaskAdapter

use of org.apache.samza.task.AsyncStreamTaskAdapter in project samza by apache.

the class TestStreamProcessor method testStreamProcessorWithAsyncStreamTaskFactory.

/**
   * Should be able to create task instances from the provided task factory.
   */
@Test
public void testStreamProcessorWithAsyncStreamTaskFactory() {
    final String testSystem = "test-system";
    final String inputTopic = "numbers3";
    final String outputTopic = "output3";
    final int messageCount = 20;
    final Config configs = new MapConfig(createConfigs("1", testSystem, inputTopic, outputTopic, messageCount));
    final ExecutorService executorService = Executors.newSingleThreadExecutor();
    createTopics(inputTopic, outputTopic);
    final AsyncStreamTaskFactory stf = () -> new AsyncStreamTaskAdapter(new IdentityStreamTask(), executorService);
    final StreamProcessor processor = new StreamProcessor(configs, new HashMap<>(), stf, listener);
    produceMessages(inputTopic, messageCount);
    run(processor, endLatch);
    verifyNumMessages(outputTopic, messageCount);
    executorService.shutdownNow();
}
Also used : StreamProcessor(org.apache.samza.processor.StreamProcessor) MapConfig(org.apache.samza.config.MapConfig) ZkConfig(org.apache.samza.config.ZkConfig) Config(org.apache.samza.config.Config) ExecutorService(java.util.concurrent.ExecutorService) AsyncStreamTaskFactory(org.apache.samza.task.AsyncStreamTaskFactory) MapConfig(org.apache.samza.config.MapConfig) AsyncStreamTaskAdapter(org.apache.samza.task.AsyncStreamTaskAdapter) Test(org.junit.Test)

Aggregations

ExecutorService (java.util.concurrent.ExecutorService)1 Config (org.apache.samza.config.Config)1 MapConfig (org.apache.samza.config.MapConfig)1 ZkConfig (org.apache.samza.config.ZkConfig)1 StreamProcessor (org.apache.samza.processor.StreamProcessor)1 AsyncStreamTaskAdapter (org.apache.samza.task.AsyncStreamTaskAdapter)1 AsyncStreamTaskFactory (org.apache.samza.task.AsyncStreamTaskFactory)1 Test (org.junit.Test)1