Search in sources :

Example 1 with SplitStatistics

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

the class EventUtility method visit.

private static void visit(SplitCompletedEvent event, BiConsumer<String, Object> consumer) {
    consumer.accept(QUERY_ID, event.getQueryId());
    consumer.accept("Stage ID", event.getStageId());
    consumer.accept("Task ID", event.getTaskId());
    consumer.accept(CREATE_TIME, event.getCreateTime());
    event.getStartTime().ifPresent(startTime -> consumer.accept("Start Time", startTime));
    event.getEndTime().ifPresent(endTime -> consumer.accept("End Time", endTime));
    event.getFailureInfo().ifPresent(failureInfo -> {
        consumer.accept("Split Failure Type", failureInfo.getFailureType());
        consumer.accept("Split Failure Message", failureInfo.getFailureMessage());
    });
    SplitStatistics statistics = event.getStatistics();
    consumer.accept("CPU Time", statistics.getCpuTime());
    consumer.accept("Wall Time", statistics.getWallTime());
    consumer.accept("Queued Time", statistics.getQueuedTime());
    consumer.accept("Completed Positions", statistics.getCompletedPositions());
    consumer.accept("Completed Data Size", statistics.getCompletedDataSizeBytes());
}
Also used : SplitStatistics(io.prestosql.spi.eventlistener.SplitStatistics)

Example 2 with SplitStatistics

use of io.prestosql.spi.eventlistener.SplitStatistics 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

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