Search in sources :

Example 1 with SplitFailureInfo

use of io.prestosql.spi.eventlistener.SplitFailureInfo in project hetu-core by openlookeng.

the class SplitMonitor method splitCompletedEvent.

private void splitCompletedEvent(TaskId taskId, DriverStats driverStats, @Nullable String failureType, @Nullable String failureMessage) {
    Optional<Duration> timeToStart = Optional.empty();
    if (driverStats.getStartTime() != null) {
        timeToStart = Optional.of(ofMillis(driverStats.getStartTime().getMillis() - driverStats.getCreateTime().getMillis()));
    }
    Optional<Duration> timeToEnd = Optional.empty();
    if (driverStats.getEndTime() != null) {
        timeToEnd = Optional.of(ofMillis(driverStats.getEndTime().getMillis() - driverStats.getCreateTime().getMillis()));
    }
    Optional<SplitFailureInfo> splitFailureMetadata = Optional.empty();
    if (failureType != null) {
        splitFailureMetadata = Optional.of(new SplitFailureInfo(failureType, failureMessage != null ? failureMessage : ""));
    }
    try {
        eventListenerManager.splitCompleted(new SplitCompletedEvent(taskId.getQueryId().toString(), taskId.getStageId().toString(), Integer.toString(taskId.getId()), driverStats.getCreateTime().toDate().toInstant(), Optional.ofNullable(driverStats.getStartTime()).map(startTime -> startTime.toDate().toInstant()), Optional.ofNullable(driverStats.getEndTime()).map(endTime -> endTime.toDate().toInstant()), new SplitStatistics(ofMillis(driverStats.getTotalCpuTime().toMillis()), ofMillis(driverStats.getElapsedTime().toMillis()), ofMillis(driverStats.getQueuedTime().toMillis()), ofMillis(driverStats.getRawInputReadTime().toMillis()), driverStats.getRawInputPositions(), driverStats.getRawInputDataSize().toBytes(), timeToStart, timeToEnd), splitFailureMetadata, objectMapper.writeValueAsString(driverStats)));
    } catch (JsonProcessingException e) {
        log.error(e, "Error processing split completion event for task %s", taskId);
    }
}
Also used : SplitCompletedEvent(io.prestosql.spi.eventlistener.SplitCompletedEvent) SplitStatistics(io.prestosql.spi.eventlistener.SplitStatistics) SplitFailureInfo(io.prestosql.spi.eventlistener.SplitFailureInfo) Duration(java.time.Duration) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 SplitCompletedEvent (io.prestosql.spi.eventlistener.SplitCompletedEvent)1 SplitFailureInfo (io.prestosql.spi.eventlistener.SplitFailureInfo)1 SplitStatistics (io.prestosql.spi.eventlistener.SplitStatistics)1 Duration (java.time.Duration)1