コード例 #1
0
ファイル: TaskContext.java プロジェクト: Ravion/Presto-1
  public TaskStats getTaskStats() {
    // check for end state to avoid callback ordering problems
    if (taskStateMachine.getState().isDone()) {
      DateTime now = DateTime.now();
      if (executionEndTime.compareAndSet(null, now)) {
        lastExecutionStartTime.set(now);
        endNanos.set(System.nanoTime());
      }
    }

    List<PipelineStats> pipelineStats =
        ImmutableList.copyOf(transform(pipelineContexts, pipelineStatsGetter()));

    int totalDrivers = 0;
    int queuedDrivers = 0;
    int runningDrivers = 0;
    int completedDrivers = 0;

    long totalScheduledTime = 0;
    long totalCpuTime = 0;
    long totalUserTime = 0;
    long totalBlockedTime = 0;

    long rawInputDataSize = 0;
    long rawInputPositions = 0;

    long processedInputDataSize = 0;
    long processedInputPositions = 0;

    long outputDataSize = 0;
    long outputPositions = 0;

    for (PipelineStats pipeline : pipelineStats) {
      totalDrivers += pipeline.getTotalDrivers();
      queuedDrivers += pipeline.getQueuedDrivers();
      runningDrivers += pipeline.getRunningDrivers();
      completedDrivers += pipeline.getCompletedDrivers();

      totalScheduledTime += pipeline.getTotalScheduledTime().roundTo(NANOSECONDS);
      totalCpuTime += pipeline.getTotalCpuTime().roundTo(NANOSECONDS);
      totalUserTime += pipeline.getTotalUserTime().roundTo(NANOSECONDS);
      totalBlockedTime += pipeline.getTotalBlockedTime().roundTo(NANOSECONDS);

      if (pipeline.isInputPipeline()) {
        rawInputDataSize += pipeline.getRawInputDataSize().toBytes();
        rawInputPositions += pipeline.getRawInputPositions();

        processedInputDataSize += pipeline.getProcessedInputDataSize().toBytes();
        processedInputPositions += pipeline.getProcessedInputPositions();
      }

      if (pipeline.isOutputPipeline()) {
        outputDataSize += pipeline.getOutputDataSize().toBytes();
        outputPositions += pipeline.getOutputPositions();
      }
    }

    long startNanos = this.startNanos.get();
    if (startNanos < createNanos) {
      startNanos = System.nanoTime();
    }
    Duration queuedTime = new Duration(startNanos - createNanos, NANOSECONDS);

    long endNanos = this.endNanos.get();
    Duration elapsedTime;
    if (endNanos >= startNanos) {
      elapsedTime = new Duration(endNanos - createNanos, NANOSECONDS);
    } else {
      elapsedTime = new Duration(0, NANOSECONDS);
    }

    return new TaskStats(
        createdTime,
        executionStartTime.get(),
        lastExecutionStartTime.get(),
        executionEndTime.get(),
        elapsedTime.convertToMostSuccinctTimeUnit(),
        queuedTime.convertToMostSuccinctTimeUnit(),
        totalDrivers,
        queuedDrivers,
        runningDrivers,
        completedDrivers,
        new DataSize(memoryReservation.get(), BYTE).convertToMostSuccinctDataSize(),
        new Duration(totalScheduledTime, NANOSECONDS).convertToMostSuccinctTimeUnit(),
        new Duration(totalCpuTime, NANOSECONDS).convertToMostSuccinctTimeUnit(),
        new Duration(totalUserTime, NANOSECONDS).convertToMostSuccinctTimeUnit(),
        new Duration(totalBlockedTime, NANOSECONDS).convertToMostSuccinctTimeUnit(),
        new DataSize(rawInputDataSize, BYTE).convertToMostSuccinctDataSize(),
        rawInputPositions,
        new DataSize(processedInputDataSize, BYTE).convertToMostSuccinctDataSize(),
        processedInputPositions,
        new DataSize(outputDataSize, BYTE).convertToMostSuccinctDataSize(),
        outputPositions,
        pipelineStats);
  }
コード例 #2
0
ファイル: TaskContext.java プロジェクト: Ravion/Presto-1
 public boolean isDone() {
   return taskStateMachine.getState().isDone();
 }