org.apache.spark.scheduler.SparkListenerTaskEnd Java Examples

The following examples show how to use org.apache.spark.scheduler.SparkListenerTaskEnd. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KylinSparkJobListener.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onTaskEnd(SparkListenerTaskEnd taskEnd) {
    if (taskEnd != null && taskEnd.taskMetrics() != null && taskEnd.taskMetrics().outputMetrics() != null) {
        metrics.bytesWritten += taskEnd.taskMetrics().outputMetrics().bytesWritten();
        metrics.recordsWritten += taskEnd.taskMetrics().outputMetrics().recordsWritten();
    }
}
 
Example #2
Source File: KylinSparkJobListener.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public void onTaskEnd(SparkListenerTaskEnd taskEnd) {
    if (taskEnd != null && taskEnd.taskMetrics() != null && taskEnd.taskMetrics().outputMetrics() != null) {
        metrics.bytesWritten += taskEnd.taskMetrics().outputMetrics().bytesWritten();
        metrics.recordsWritten += taskEnd.taskMetrics().outputMetrics().recordsWritten();
    }
}
 
Example #3
Source File: SparkListenerServiceImpl.java    From beakerx with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(SparkSessionBuilder sparkSessionBuilder, SparkUIApi sparkUI) {
  SparkContext sc = sparkSessionBuilder.getOrCreate().sparkContext();
  sc.addSparkListener(new SparkListener() {

    @Override
    public void onJobStart(SparkListenerJobStart jobStart) {
      super.onJobStart(jobStart);
    }

    @Override
    public void onJobEnd(SparkListenerJobEnd jobEnd) {
      super.onJobEnd(jobEnd);
    }

    @Override
    public void onStageSubmitted(SparkListenerStageSubmitted stageSubmitted) {
      super.onStageSubmitted(stageSubmitted);
      sparkUI.startStage(stageSubmitted.stageInfo().stageId(), stageSubmitted.stageInfo().numTasks());
    }

    @Override
    public void onStageCompleted(SparkListenerStageCompleted stageCompleted) {
      super.onStageCompleted(stageCompleted);
      sparkUI.endStage(stageCompleted.stageInfo().stageId());
    }

    @Override
    public void onTaskStart(SparkListenerTaskStart taskStart) {
      super.onTaskStart(taskStart);
      sparkUI.taskStart(taskStart.stageId(), taskStart.taskInfo().taskId());
    }

    @Override
    public void onTaskEnd(SparkListenerTaskEnd taskEnd) {
      super.onTaskEnd(taskEnd);
      String reason = taskEnd.reason().toString();
      if (reason.equals("Success")) {
        sparkUI.taskEnd(taskEnd.stageId(), taskEnd.taskInfo().taskId());
      } else if (reason.contains("stage cancelled")) {
        sparkUI.taskCancelled(taskEnd.stageId(), taskEnd.taskInfo().taskId());
      }
    }
  });
}