use of org.apache.samza.application.TaskApplication in project samza by apache.
the class TestTaskApplicationDescriptorImpl method testWithTaskFactory.
@Test
public void testWithTaskFactory() {
TaskFactory mockTf = mock(TaskFactory.class);
TaskApplication testApp = appDesc -> appDesc.withTaskFactory(mockTf);
TaskApplicationDescriptorImpl appDesc = new TaskApplicationDescriptorImpl(testApp, config);
assertEquals(appDesc.getTaskFactory(), mockTf);
}
use of org.apache.samza.application.TaskApplication in project samza by apache.
the class TestTaskApplicationDescriptorImpl method testNoApplicationTaskContextFactory.
@Test
public void testNoApplicationTaskContextFactory() {
TaskApplication testApp = appDesc -> {
};
TaskApplicationDescriptorImpl appSpec = new TaskApplicationDescriptorImpl(testApp, mock(Config.class));
assertEquals(appSpec.getApplicationTaskContextFactory(), Optional.empty());
}
use of org.apache.samza.application.TaskApplication in project samza by apache.
the class TestZkLocalApplicationRunner method testApplicationShutdownShouldBeIndependentOfPerMessageProcessingTime.
@Test
public void testApplicationShutdownShouldBeIndependentOfPerMessageProcessingTime() throws Exception {
publishKafkaEvents(inputKafkaTopic, 0, NUM_KAFKA_EVENTS, PROCESSOR_IDS[0]);
// Create a TaskApplication with only one task per container.
// The task does not invokes taskCallback.complete for any of the dispatched message.
CountDownLatch shutdownLatch = new CountDownLatch(1);
CountDownLatch processedMessagesLatch1 = new CountDownLatch(1);
TaskApplication taskApplication = new TestTaskApplication(TEST_SYSTEM, inputKafkaTopic, outputKafkaTopic, processedMessagesLatch1, shutdownLatch);
MapConfig taskApplicationConfig = new MapConfig(ImmutableList.of(applicationConfig1, ImmutableMap.of(TaskConfig.MAX_CONCURRENCY, "1", JobConfig.SSP_GROUPER_FACTORY, "org.apache.samza.container.grouper.stream.AllSspToSingleTaskGrouperFactory")));
ApplicationRunner appRunner = ApplicationRunners.getApplicationRunner(taskApplication, taskApplicationConfig);
// Run the application.
executeRun(appRunner, applicationConfig1);
// Wait for the task to receive at least one dispatched message.
processedMessagesLatch1.await();
// Kill the application when none of the dispatched messages is acknowledged as completed by the task.
appRunner.kill();
appRunner.waitForFinish();
// Expect the shutdown latch to be triggered.
shutdownLatch.await();
// Assert that the shutdown was successful.
Assert.assertEquals(ApplicationStatus.SuccessfulFinish, appRunner.status());
}
use of org.apache.samza.application.TaskApplication in project samza by apache.
the class TestTaskApplicationDescriptorImpl method testAddOutputStreams.
@Test
public void testAddOutputStreams() {
TaskApplication testApp = appDesc -> {
mockOutputs.forEach(appDesc::withOutputStream);
};
TaskApplicationDescriptorImpl appDesc = new TaskApplicationDescriptorImpl(testApp, config);
assertEquals(mockOutputs.toArray(), appDesc.getOutputDescriptors().values().toArray());
}
use of org.apache.samza.application.TaskApplication in project samza by apache.
the class TestTaskApplicationDescriptorImpl method testNoApplicationContainerContextFactory.
@Test
public void testNoApplicationContainerContextFactory() {
TaskApplication testApp = appDesc -> {
};
TaskApplicationDescriptorImpl appSpec = new TaskApplicationDescriptorImpl(testApp, mock(Config.class));
assertEquals(appSpec.getApplicationContainerContextFactory(), Optional.empty());
}
Aggregations