Search in sources :

Example 11 with MetadataResourceUtil

use of org.apache.samza.coordinator.MetadataResourceUtil 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

MetadataResourceUtil (org.apache.samza.coordinator.MetadataResourceUtil)11 JobConfig (org.apache.samza.config.JobConfig)8 JobModel (org.apache.samza.job.model.JobModel)8 Config (org.apache.samza.config.Config)7 MapConfig (org.apache.samza.config.MapConfig)7 Test (org.junit.Test)7 StreamPartitionCountMonitor (org.apache.samza.coordinator.StreamPartitionCountMonitor)6 StreamRegexMonitor (org.apache.samza.coordinator.StreamRegexMonitor)6 JobCoordinatorMetadata (org.apache.samza.job.JobCoordinatorMetadata)5 StartpointManager (org.apache.samza.startpoint.StartpointManager)3 HashMap (java.util.HashMap)2 SamzaException (org.apache.samza.SamzaException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 Map (java.util.Map)1 StorageConfig (org.apache.samza.config.StorageConfig)1 ZkConfig (org.apache.samza.config.ZkConfig)1 TaskName (org.apache.samza.container.TaskName)1 NamespaceAwareCoordinatorStreamStore (org.apache.samza.coordinator.metadatastore.NamespaceAwareCoordinatorStreamStore)1 CoordinatorStreamValueSerde (org.apache.samza.coordinator.stream.CoordinatorStreamValueSerde)1