Search in sources :

Example 1 with TaskEventMetadataGenerator

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");
}
Also used : TaskEventMetadataGenerator(org.apache.gobblin.runtime.api.TaskEventMetadataGenerator) State(org.apache.gobblin.configuration.State)

Example 2 with TaskEventMetadataGenerator

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);
}
Also used : TaskEventMetadataGenerator(org.apache.gobblin.runtime.api.TaskEventMetadataGenerator) EventSubmitter(org.apache.gobblin.metrics.event.EventSubmitter) State(org.apache.gobblin.configuration.State) GobblinEventBuilder(org.apache.gobblin.metrics.event.GobblinEventBuilder)

Aggregations

State (org.apache.gobblin.configuration.State)2 TaskEventMetadataGenerator (org.apache.gobblin.runtime.api.TaskEventMetadataGenerator)2 EventSubmitter (org.apache.gobblin.metrics.event.EventSubmitter)1 GobblinEventBuilder (org.apache.gobblin.metrics.event.GobblinEventBuilder)1