Search in sources :

Example 1 with FailureEventBuilder

use of org.apache.gobblin.metrics.event.FailureEventBuilder in project incubator-gobblin by apache.

the class R2RestResponseHandler method handleResponse.

@Override
public R2ResponseStatus handleResponse(Request<RestRequest> request, RestResponse response) {
    R2ResponseStatus status = new R2ResponseStatus(StatusType.OK);
    int statusCode = response.getStatus();
    status.setStatusCode(statusCode);
    HttpUtils.updateStatusType(status, statusCode, errorCodeWhitelist);
    if (status.getType() == StatusType.OK) {
        status.setContent(response.getEntity());
        status.setContentType(response.getHeader(CONTENT_TYPE_HEADER));
    } else {
        log.info("Receive an unsuccessful response with status code: " + statusCode);
        Map<String, String> metadata = Maps.newHashMap();
        metadata.put(HttpConstants.STATUS_CODE, String.valueOf(statusCode));
        metadata.put(HttpConstants.REQUEST, request.toString());
        if (status.getType() != StatusType.CONTINUE) {
            FailureEventBuilder failureEvent = new FailureEventBuilder(R2_FAILED_REQUEST_EVENT);
            failureEvent.addAdditionalMetadata(metadata);
            failureEvent.submit(metricsContext);
        } else {
            GobblinTrackingEvent event = new GobblinTrackingEvent(0L, R2_RESPONSE_EVENT_NAMESPACE, R2_FAILED_REQUEST_EVENT, metadata);
            metricsContext.submitEvent(event);
        }
    }
    return status;
}
Also used : GobblinTrackingEvent(org.apache.gobblin.metrics.GobblinTrackingEvent) FailureEventBuilder(org.apache.gobblin.metrics.event.FailureEventBuilder)

Example 2 with FailureEventBuilder

use of org.apache.gobblin.metrics.event.FailureEventBuilder in project incubator-gobblin by apache.

the class SafeDatasetCommit method maySubmitFailureEvent.

private void maySubmitFailureEvent(JobState.DatasetState datasetState) {
    if (datasetState.getState() == JobState.RunningState.FAILED) {
        FailureEventBuilder failureEvent = new FailureEventBuilder(FAILED_DATASET_EVENT);
        failureEvent.addMetadata(DATASET_STATE, datasetState.toString());
        failureEvent.submit(metricContext);
    }
}
Also used : FailureEventBuilder(org.apache.gobblin.metrics.event.FailureEventBuilder)

Example 3 with FailureEventBuilder

use of org.apache.gobblin.metrics.event.FailureEventBuilder in project incubator-gobblin by apache.

the class AsyncHttpWriter method onFailure.

protected void onFailure(AsyncRequest<D, RQ> asyncRequest, DispatchException exception) {
    if (exception.isFatal()) {
        // Report failure event
        FailureEventBuilder failureEvent = new FailureEventBuilder(FATAL_ASYNC_HTTP_WRITE_EVENT);
        failureEvent.setRootCause(exception);
        failureEvent.addMetadata(ASYNC_REQUEST, asyncRequest.toString());
        failureEvent.submit(context);
    }
    for (AsyncRequest.Thunk thunk : asyncRequest.getThunks()) {
        thunk.callback.onFailure(exception);
    }
}
Also used : AsyncRequest(org.apache.gobblin.async.AsyncRequest) FailureEventBuilder(org.apache.gobblin.metrics.event.FailureEventBuilder)

Example 4 with FailureEventBuilder

use of org.apache.gobblin.metrics.event.FailureEventBuilder in project incubator-gobblin by apache.

the class FileFailureEventReporterTest method testReport.

@Test
public void testReport() throws IOException {
    MetricContext testContext = MetricContext.builder(getClass().getCanonicalName()).build();
    FileSystem fs = mock(FileSystem.class);
    Path failureLogPath = mock(Path.class);
    FSDataOutputStream outputStream = mock(FSDataOutputStream.class);
    FileFailureEventReporter reporter = new FileFailureEventReporter(testContext, fs, failureLogPath);
    when(fs.exists(any())).thenReturn(true);
    when(fs.append(any())).thenReturn(outputStream);
    final String eventName = "testEvent";
    final String eventNamespace = "testNamespace";
    GobblinTrackingEvent event = new GobblinTrackingEvent(0L, eventNamespace, eventName, Maps.newHashMap());
    // Noop on normal event
    testContext.submitEvent(event);
    verify(fs, never()).append(failureLogPath);
    verify(outputStream, never()).write(anyByte());
    // Process failure event
    FailureEventBuilder failureEvent = new FailureEventBuilder(eventName, eventNamespace);
    failureEvent.submit(testContext);
    reporter.report();
    // Failure log output is setup
    verify(fs, times(1)).append(failureLogPath);
    // Report successfully
    doAnswer(invocation -> null).when(outputStream).write(any(byte[].class), anyInt(), anyInt());
    verify(outputStream, times(1)).write(any(byte[].class), anyInt(), anyInt());
}
Also used : Path(org.apache.hadoop.fs.Path) GobblinTrackingEvent(org.apache.gobblin.metrics.GobblinTrackingEvent) MetricContext(org.apache.gobblin.metrics.MetricContext) FileSystem(org.apache.hadoop.fs.FileSystem) FailureEventBuilder(org.apache.gobblin.metrics.event.FailureEventBuilder) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) Test(org.testng.annotations.Test)

Example 5 with FailureEventBuilder

use of org.apache.gobblin.metrics.event.FailureEventBuilder in project incubator-gobblin by apache.

the class Task method failTask.

private void failTask(Throwable t) {
    LOG.error(String.format("Task %s failed", this.taskId), t);
    this.taskState.setWorkingState(WorkUnitState.WorkingState.FAILED);
    this.taskState.setProp(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY, Throwables.getStackTraceAsString(t));
    // Send task failure event
    FailureEventBuilder failureEvent = new FailureEventBuilder(FAILED_TASK_EVENT);
    failureEvent.setRootCause(t);
    failureEvent.addMetadata(TASK_STATE, this.taskState.toString());
    failureEvent.submit(taskContext.getTaskMetrics().getMetricContext());
}
Also used : FailureEventBuilder(org.apache.gobblin.metrics.event.FailureEventBuilder)

Aggregations

FailureEventBuilder (org.apache.gobblin.metrics.event.FailureEventBuilder)5 GobblinTrackingEvent (org.apache.gobblin.metrics.GobblinTrackingEvent)2 AsyncRequest (org.apache.gobblin.async.AsyncRequest)1 MetricContext (org.apache.gobblin.metrics.MetricContext)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 Test (org.testng.annotations.Test)1