Search in sources :

Example 1 with TaskMetrics

use of org.apache.spark.executor.TaskMetrics in project hive by apache.

the class LocalSparkJobStatus method getSparkStatistics.

@Override
public SparkStatistics getSparkStatistics() {
    SparkStatisticsBuilder sparkStatisticsBuilder = new SparkStatisticsBuilder();
    // add Hive operator level statistics.
    sparkStatisticsBuilder.add(sparkCounters);
    // add spark job metrics.
    Map<Integer, List<Map.Entry<TaskMetrics, TaskInfo>>> jobMetric = jobMetricsListener.getJobMetric(jobId);
    if (jobMetric == null) {
        return null;
    }
    MetricsCollection metricsCollection = new MetricsCollection();
    Set<Integer> stageIds = jobMetric.keySet();
    for (int stageId : stageIds) {
        List<Map.Entry<TaskMetrics, TaskInfo>> taskMetrics = jobMetric.get(stageId);
        for (Map.Entry<TaskMetrics, TaskInfo> taskMetric : taskMetrics) {
            Metrics metrics = new Metrics(taskMetric.getKey(), taskMetric.getValue());
            metricsCollection.addMetrics(jobId, stageId, 0, metrics);
        }
    }
    Map<String, Long> flatJobMetric = SparkMetricsUtils.collectMetrics(metricsCollection.getAllMetrics());
    for (Map.Entry<String, Long> entry : flatJobMetric.entrySet()) {
        sparkStatisticsBuilder.add(SparkStatisticsNames.SPARK_GROUP_NAME, entry.getKey(), Long.toString(entry.getValue()));
    }
    return sparkStatisticsBuilder.build();
}
Also used : MetricsCollection(org.apache.hive.spark.client.MetricsCollection) TaskInfo(org.apache.spark.scheduler.TaskInfo) TaskMetrics(org.apache.spark.executor.TaskMetrics) Metrics(org.apache.hive.spark.client.metrics.Metrics) TaskMetrics(org.apache.spark.executor.TaskMetrics) List(java.util.List) SparkStatisticsBuilder(org.apache.hadoop.hive.ql.exec.spark.Statistic.SparkStatisticsBuilder) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 SparkStatisticsBuilder (org.apache.hadoop.hive.ql.exec.spark.Statistic.SparkStatisticsBuilder)1 MetricsCollection (org.apache.hive.spark.client.MetricsCollection)1 Metrics (org.apache.hive.spark.client.metrics.Metrics)1 TaskMetrics (org.apache.spark.executor.TaskMetrics)1 TaskInfo (org.apache.spark.scheduler.TaskInfo)1