use of org.apache.gobblin.runtime.api.TaskEventMetadataGenerator in project incubator-gobblin by apache.
the class HelixTaskEventMetadataGeneratorTest method testGetMetadata.
public void testGetMetadata() {
State state = new State();
state.setProp(ConfigurationKeys.TASK_EVENT_METADATA_GENERATOR_CLASS_KEY, "helixtask");
state.setProp(GobblinClusterConfigurationKeys.CONTAINER_ID_KEY, "container-1");
state.setProp(GobblinClusterConfigurationKeys.HELIX_TASK_ID_KEY, "task-1");
state.setProp(GobblinClusterConfigurationKeys.HELIX_JOB_ID_KEY, "job-1");
TaskEventMetadataGenerator metadataGenerator = TaskEventMetadataUtils.getTaskEventMetadataGenerator(state);
// Ensure instantiation is done correctly
Assert.assertTrue(metadataGenerator != null);
// Ensure metadata map is correctly populated
Map<String, String> metadataMap = metadataGenerator.getMetadata(state, "testEventName");
Assert.assertEquals(metadataMap.size(), 5);
Assert.assertEquals(metadataMap.get(HelixTaskEventMetadataGenerator.HELIX_INSTANCE_KEY), "");
Assert.assertEquals(metadataMap.get(HelixTaskEventMetadataGenerator.CONTAINER_ID_KEY), "container-1");
Assert.assertEquals(metadataMap.get(HelixTaskEventMetadataGenerator.HOST_NAME_KEY), "");
Assert.assertEquals(metadataMap.get(HelixTaskEventMetadataGenerator.HELIX_TASK_ID_KEY), "task-1");
Assert.assertEquals(metadataMap.get(HelixTaskEventMetadataGenerator.HELIX_JOB_ID_KEY), "job-1");
}
use of org.apache.gobblin.runtime.api.TaskEventMetadataGenerator in project incubator-gobblin by apache.
the class GobblinTaskRunner method submitEvent.
private void submitEvent(ContainerHealthCheckFailureEvent event) {
EventSubmitter eventSubmitter = new EventSubmitter.Builder(RootMetricContext.get(), getClass().getPackage().getName()).build();
GobblinEventBuilder eventBuilder = new GobblinEventBuilder(event.getClass().getSimpleName());
State taskState = ConfigUtils.configToState(event.getConfig());
// Add task metadata such as Helix taskId, containerId, and workflowId if configured
TaskEventMetadataGenerator taskEventMetadataGenerator = TaskEventMetadataUtils.getTaskEventMetadataGenerator(taskState);
eventBuilder.addAdditionalMetadata(taskEventMetadataGenerator.getMetadata(taskState, event.getClass().getSimpleName()));
eventBuilder.addAdditionalMetadata(event.getMetadata());
eventSubmitter.submit(eventBuilder);
}
Aggregations