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());
}
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);
}
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());
}
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());
}
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);
}
Aggregations