Search in sources :

Example 16 with StreamPartitionCountMonitor

use of org.apache.samza.coordinator.StreamPartitionCountMonitor in project samza by apache.

the class TestStaticResourceJobCoordinator method testPartitionCountChange.

@Test
public void testPartitionCountChange() throws IOException {
    Config jobModelConfig = mock(Config.class);
    JobModel jobModel = setupJobModel(jobModelConfig);
    StreamPartitionCountMonitor streamPartitionCountMonitor = mock(StreamPartitionCountMonitor.class);
    ArgumentCaptor<StreamPartitionCountMonitor.Callback> callbackArgumentCaptor = ArgumentCaptor.forClass(StreamPartitionCountMonitor.Callback.class);
    when(this.streamPartitionCountMonitorFactory.build(eq(jobModelConfig), callbackArgumentCaptor.capture())).thenReturn(streamPartitionCountMonitor);
    StreamRegexMonitor streamRegexMonitor = setupStreamRegexMonitor(jobModel, jobModelConfig);
    JobCoordinatorMetadata newMetadata = setupJobCoordinatorMetadata(jobModel, jobModelConfig, ImmutableSet.of(JobMetadataChange.NEW_DEPLOYMENT, JobMetadataChange.JOB_MODEL), true);
    setUpDiagnosticsManager(jobModel);
    MetadataResourceUtil metadataResourceUtil = metadataResourceUtil(jobModel);
    this.staticResourceJobCoordinator.start();
    verifyStartLifecycle();
    verify(this.staticResourceJobCoordinator).doSetLoggingContextConfig(jobModelConfig);
    verify(this.diagnosticsManager).start();
    verifyPrepareWorkerExecutionAndMonitor(jobModel, metadataResourceUtil, streamPartitionCountMonitor, streamRegexMonitor, newMetadata, SINGLE_SSP_FANOUT);
    // call the callback from the monitor
    callbackArgumentCaptor.getValue().onSystemStreamPartitionChange(ImmutableSet.of(SYSTEM_STREAM));
    verify(this.jobRestartSignal).restartJob();
}
Also used : StreamRegexMonitor(org.apache.samza.coordinator.StreamRegexMonitor) JobCoordinatorMetadata(org.apache.samza.job.JobCoordinatorMetadata) MapConfig(org.apache.samza.config.MapConfig) Config(org.apache.samza.config.Config) JobConfig(org.apache.samza.config.JobConfig) StreamPartitionCountMonitor(org.apache.samza.coordinator.StreamPartitionCountMonitor) JobModel(org.apache.samza.job.model.JobModel) MetadataResourceUtil(org.apache.samza.coordinator.MetadataResourceUtil) Test(org.junit.Test)

Aggregations

StreamPartitionCountMonitor (org.apache.samza.coordinator.StreamPartitionCountMonitor)16 MapConfig (org.apache.samza.config.MapConfig)14 Test (org.junit.Test)14 JobModel (org.apache.samza.job.model.JobModel)12 Config (org.apache.samza.config.Config)11 JobConfig (org.apache.samza.config.JobConfig)11 StreamRegexMonitor (org.apache.samza.coordinator.StreamRegexMonitor)8 MetadataResourceUtil (org.apache.samza.coordinator.MetadataResourceUtil)6 JobCoordinatorMetadata (org.apache.samza.job.JobCoordinatorMetadata)5 HashMap (java.util.HashMap)3 NoOpMetricsRegistry (org.apache.samza.util.NoOpMetricsRegistry)3 Partition (org.apache.samza.Partition)2 ApplicationConfig (org.apache.samza.config.ApplicationConfig)2 CoordinatorStreamSystemProducer (org.apache.samza.coordinator.stream.CoordinatorStreamSystemProducer)2 MetricsRegistry (org.apache.samza.metrics.MetricsRegistry)2 SystemStreamPartition (org.apache.samza.system.SystemStreamPartition)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 JobModelMonitors (org.apache.samza.coordinator.JobModelMonitors)1 SystemStream (org.apache.samza.system.SystemStream)1 ZkSessionStateChangedListener (org.apache.samza.zk.ZkJobCoordinator.ZkSessionStateChangedListener)1