Search in sources :

Example 11 with JobCoordinatorMetadata

use of org.apache.samza.job.JobCoordinatorMetadata in project samza by apache.

the class TestJobCoordinatorMetadataManager method testCheckForMetadataChangesNoPreviousMetadata.

@Test
public void testCheckForMetadataChangesNoPreviousMetadata() {
    JobCoordinatorMetadata newMetadata = new JobCoordinatorMetadata(NEW_EPOCH_ID, NEW_CONFIG_ID, NEW_JOB_MODEL_ID);
    Set<JobMetadataChange> metadataChanges = this.jobCoordinatorMetadataManager.checkForMetadataChanges(newMetadata, null);
    assertEquals("Metadata check should indicate all changes", ImmutableSet.of(JobMetadataChange.NEW_DEPLOYMENT, JobMetadataChange.JOB_MODEL, JobMetadataChange.CONFIG), metadataChanges);
    assertEquals("New deployment should be 1 since Epoch ID changed", 1, this.jobCoordinatorMetadataManager.getMetrics().getNewDeployment().getValue().intValue());
    assertEquals("Job model changed across application attempts should be 0", 0, this.jobCoordinatorMetadataManager.getMetrics().getJobModelChangedAcrossApplicationAttempt().getValue().intValue());
    assertEquals("Config changed across application attempts should be 0", 0, this.jobCoordinatorMetadataManager.getMetrics().getConfigChangedAcrossApplicationAttempt().getValue().intValue());
}
Also used : JobCoordinatorMetadata(org.apache.samza.job.JobCoordinatorMetadata) JobMetadataChange(org.apache.samza.job.JobMetadataChange) Test(org.junit.Test)

Example 12 with JobCoordinatorMetadata

use of org.apache.samza.job.JobCoordinatorMetadata in project samza by apache.

the class TestJobCoordinatorMetadataManager method testGenerateJobCoordinatorMetadataForRepeatability.

@Test
public void testGenerateJobCoordinatorMetadataForRepeatability() {
    when(jobCoordinatorMetadataManager.getEnvProperty(CONTAINER_ID_PROPERTY)).thenReturn(OLD_CONTAINER_ID);
    JobCoordinatorMetadata expectedMetadata = jobCoordinatorMetadataManager.generateJobCoordinatorMetadata(new JobModel(OLD_CONFIG, containerModelMap), OLD_CONFIG);
    assertEquals("Mismatch in epoch identifier.", OLD_EPOCH_ID, expectedMetadata.getEpochId());
    JobCoordinatorMetadata actualMetadata = jobCoordinatorMetadataManager.generateJobCoordinatorMetadata(new JobModel(OLD_CONFIG, containerModelMap), OLD_CONFIG);
    assertEquals("Expected repeatable job coordinator metadata", expectedMetadata, actualMetadata);
}
Also used : JobCoordinatorMetadata(org.apache.samza.job.JobCoordinatorMetadata) JobModel(org.apache.samza.job.model.JobModel) Test(org.junit.Test)

Example 13 with JobCoordinatorMetadata

use of org.apache.samza.job.JobCoordinatorMetadata in project samza by apache.

the class TestJobCoordinatorMetadataManager method testCheckForMetadataChangesConfigChange.

@Test
public void testCheckForMetadataChangesConfigChange() {
    JobCoordinatorMetadata previousMetadata = new JobCoordinatorMetadata(OLD_EPOCH_ID, OLD_CONFIG_ID, OLD_JOB_MODEL_ID);
    JobCoordinatorMetadata newMetadata = new JobCoordinatorMetadata(OLD_EPOCH_ID, NEW_CONFIG_ID, OLD_JOB_MODEL_ID);
    Set<JobMetadataChange> metadataChanges = this.jobCoordinatorMetadataManager.checkForMetadataChanges(newMetadata, previousMetadata);
    assertEquals("Metadata check should indicate new config", ImmutableSet.of(JobMetadataChange.CONFIG), metadataChanges);
    assertEquals("Config changed across application attempts should be 1", 1, this.jobCoordinatorMetadataManager.getMetrics().getConfigChangedAcrossApplicationAttempt().getValue().intValue());
    assertEquals("Application attempt count should be 0", 0, this.jobCoordinatorMetadataManager.getMetrics().getApplicationAttemptCount().getValue().intValue());
}
Also used : JobCoordinatorMetadata(org.apache.samza.job.JobCoordinatorMetadata) JobMetadataChange(org.apache.samza.job.JobMetadataChange) Test(org.junit.Test)

Example 14 with JobCoordinatorMetadata

use of org.apache.samza.job.JobCoordinatorMetadata in project samza by apache.

the class TestJobCoordinatorMetadataManager method testCheckForMetadataChangesNoChanges.

@Test
public void testCheckForMetadataChangesNoChanges() {
    JobCoordinatorMetadata previousMetadata = new JobCoordinatorMetadata(OLD_EPOCH_ID, OLD_CONFIG_ID, OLD_JOB_MODEL_ID);
    JobCoordinatorMetadata newMetadata = new JobCoordinatorMetadata(OLD_EPOCH_ID, OLD_CONFIG_ID, OLD_JOB_MODEL_ID);
    Set<JobMetadataChange> metadataChanges = this.jobCoordinatorMetadataManager.checkForMetadataChanges(newMetadata, previousMetadata);
    assertEquals("Metadata check should indicate no changes", ImmutableSet.of(), metadataChanges);
    assertEquals("New deployment should be 0 since Epoch ID did not change", 0, this.jobCoordinatorMetadataManager.getMetrics().getNewDeployment().getValue().intValue());
    assertEquals("Job model changed across application attempts should be 0", 0, this.jobCoordinatorMetadataManager.getMetrics().getJobModelChangedAcrossApplicationAttempt().getValue().intValue());
    assertEquals("Config changed across application attempts should be 0", 0, this.jobCoordinatorMetadataManager.getMetrics().getConfigChangedAcrossApplicationAttempt().getValue().intValue());
    assertEquals("Application attempt count should be 1", 1, this.jobCoordinatorMetadataManager.getMetrics().getApplicationAttemptCount().getValue().intValue());
}
Also used : JobCoordinatorMetadata(org.apache.samza.job.JobCoordinatorMetadata) JobMetadataChange(org.apache.samza.job.JobMetadataChange) Test(org.junit.Test)

Example 15 with JobCoordinatorMetadata

use of org.apache.samza.job.JobCoordinatorMetadata in project samza by apache.

the class TestJobCoordinatorMetadataManager method testGenerateJobCoordinatorMetadataWithConfigChanges.

@Test
public void testGenerateJobCoordinatorMetadataWithConfigChanges() {
    when(jobCoordinatorMetadataManager.getEnvProperty(CONTAINER_ID_PROPERTY)).thenReturn(OLD_CONTAINER_ID);
    JobCoordinatorMetadata expectedMetadata = jobCoordinatorMetadataManager.generateJobCoordinatorMetadata(new JobModel(OLD_CONFIG, containerModelMap), OLD_CONFIG);
    Map<String, String> additionalConfig = new HashMap<>();
    additionalConfig.put("yarn.am.high-availability.enabled", "true");
    additionalConfig.putAll(OLD_CONFIG);
    Config modifiedConfig = new MapConfig(additionalConfig);
    JobCoordinatorMetadata actualMetadata = jobCoordinatorMetadataManager.generateJobCoordinatorMetadata(new JobModel(modifiedConfig, containerModelMap), modifiedConfig);
    assertEquals("Job coordinator metadata should remain the same", expectedMetadata, actualMetadata);
}
Also used : JobCoordinatorMetadata(org.apache.samza.job.JobCoordinatorMetadata) HashMap(java.util.HashMap) MapConfig(org.apache.samza.config.MapConfig) Config(org.apache.samza.config.Config) JobModel(org.apache.samza.job.model.JobModel) Matchers.anyString(org.mockito.Matchers.anyString) MapConfig(org.apache.samza.config.MapConfig) Test(org.junit.Test)

Aggregations

JobCoordinatorMetadata (org.apache.samza.job.JobCoordinatorMetadata)21 Test (org.junit.Test)16 JobModel (org.apache.samza.job.model.JobModel)9 Config (org.apache.samza.config.Config)7 MapConfig (org.apache.samza.config.MapConfig)7 JobMetadataChange (org.apache.samza.job.JobMetadataChange)7 JobConfig (org.apache.samza.config.JobConfig)6 MetadataResourceUtil (org.apache.samza.coordinator.MetadataResourceUtil)5 StreamPartitionCountMonitor (org.apache.samza.coordinator.StreamPartitionCountMonitor)5 StreamRegexMonitor (org.apache.samza.coordinator.StreamRegexMonitor)4 SamzaException (org.apache.samza.SamzaException)3 JobCoordinatorMetadataManager (org.apache.samza.job.metadata.JobCoordinatorMetadataManager)2 Matchers.anyString (org.mockito.Matchers.anyString)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 ApplicationConfig (org.apache.samza.config.ApplicationConfig)1