Search in sources :

Example 6 with LegacyTaskApplication

use of org.apache.samza.application.LegacyTaskApplication in project samza by apache.

the class TestLocalApplicationRunner method testRunIdForBatch.

/**
 * For app.mode=BATCH ensure that the run.id generation utils --
 * DistributedLock, ClusterMembership and MetadataStore are created.
 * Also ensure that metadataStore.put is invoked (to write the run.id)
 */
@Test
public void testRunIdForBatch() throws Exception {
    final Map<String, String> cfgs = new HashMap<>();
    cfgs.put(ApplicationConfig.APP_MODE, "BATCH");
    cfgs.put(ApplicationConfig.APP_PROCESSOR_ID_GENERATOR_CLASS, UUIDGenerator.class.getName());
    cfgs.put(JobConfig.JOB_NAME, "test-task-job");
    cfgs.put(JobConfig.JOB_ID, "jobId");
    config = new MapConfig(cfgs);
    mockApp = new LegacyTaskApplication(IdentityStreamTask.class.getName());
    prepareTestForRunId();
    runner.run();
    verify(coordinationUtils, Mockito.times(1)).getLock(CoordinationConstants.RUNID_LOCK_ID);
    verify(clusterMembership, Mockito.times(1)).getNumberOfProcessors();
    verify(metadataStore, Mockito.times(1)).put(eq(CoordinationConstants.RUNID_STORE_KEY), any(byte[].class));
    verify(metadataStore, Mockito.times(1)).flush();
}
Also used : HashMap(java.util.HashMap) LegacyTaskApplication(org.apache.samza.application.LegacyTaskApplication) Matchers.anyString(org.mockito.Matchers.anyString) MapConfig(org.apache.samza.config.MapConfig) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

LegacyTaskApplication (org.apache.samza.application.LegacyTaskApplication)6 MapConfig (org.apache.samza.config.MapConfig)6 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 Matchers.anyString (org.mockito.Matchers.anyString)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 ApplicationConfig (org.apache.samza.config.ApplicationConfig)3 Config (org.apache.samza.config.Config)3 JobConfig (org.apache.samza.config.JobConfig)3 JobCoordinatorConfig (org.apache.samza.config.JobCoordinatorConfig)3 CoordinatorStreamStore (org.apache.samza.coordinator.metadatastore.CoordinatorStreamStore)2 StreamProcessor (org.apache.samza.processor.StreamProcessor)2 StreamSpec (org.apache.samza.system.StreamSpec)2 ClusterManagerConfig (org.apache.samza.config.ClusterManagerConfig)1 InMemorySystemConfig (org.apache.samza.config.InMemorySystemConfig)1 StreamConfig (org.apache.samza.config.StreamConfig)1 TaskConfig (org.apache.samza.config.TaskConfig)1 ExternalContext (org.apache.samza.context.ExternalContext)1 KV (org.apache.samza.operators.KV)1 EndOfStreamMessage (org.apache.samza.system.EndOfStreamMessage)1