List of usage examples for org.apache.hadoop.mapreduce TaskReport getTaskCounters
public Counters getTaskCounters()
From source file:cascading.stats.hadoop.HadoopNodeCounterCache.java
License:Open Source License
protected Map<String, Map<String, Long>> getCounters(FlowNodeStats flowNodeStats) throws IOException { // will use final or cached remote stats flowNodeStats.captureDetail(CascadingStats.Type.SLICE); Map<String, Map<String, Long>> allCounters = new HashMap<>(); Collection<FlowSliceStats> children = flowNodeStats.getChildren(); for (FlowSliceStats sliceStats : children) { TaskReport taskReport = ((HadoopSliceStats) sliceStats).getTaskReport(); Counters counters = taskReport.getTaskCounters(); for (CounterGroup group : counters) { Map<String, Long> values = allCounters.get(group.getName()); if (values == null) { values = new HashMap<>(); allCounters.put(group.getName(), values); }/*from w ww .j av a 2s . c o m*/ for (Counter counter : group) { Long value = values.get(counter.getName()); if (value == null) value = 0L; value += counter.getValue(); values.put(counter.getName(), value); } } } return allCounters; }
From source file:cascading.stats.hadoop.HadoopSliceStats.java
License:Open Source License
private void setCounters(TaskReport taskReport) { this.counters = new HashMap<>(); Counters hadoopCounters = taskReport.getTaskCounters(); for (CounterGroup group : hadoopCounters) { Map<String, Long> values = new HashMap<String, Long>(); this.counters.put(group.getName(), values); for (Counter counter : group) values.put(counter.getName(), counter.getValue()); }/* w ww . ja va2s. c o m*/ }
From source file:co.cask.cdap.internal.app.runtime.batch.MapReduceMetricsWriter.java
License:Apache License
private void reportMapTaskMetrics(TaskReport taskReport) { Counters counters = taskReport.getTaskCounters(); MetricsContext metricsContext = mapTaskMetricsCollectors.getUnchecked(taskReport.getTaskId()); metricsContext.gauge(MapReduceMetrics.METRIC_TASK_INPUT_RECORDS, getTaskCounter(counters, TaskCounter.MAP_INPUT_RECORDS)); metricsContext.gauge(MapReduceMetrics.METRIC_TASK_OUTPUT_RECORDS, getTaskCounter(counters, TaskCounter.MAP_OUTPUT_RECORDS)); metricsContext.gauge(MapReduceMetrics.METRIC_TASK_BYTES, getTaskCounter(counters, TaskCounter.MAP_OUTPUT_BYTES)); metricsContext.gauge(MapReduceMetrics.METRIC_TASK_COMPLETION, (long) (taskReport.getProgress() * 100)); }
From source file:co.cask.cdap.internal.app.runtime.batch.MapReduceMetricsWriter.java
License:Apache License
private void reportReduceTaskMetrics(TaskReport taskReport) { Counters counters = taskReport.getTaskCounters(); MetricsContext metricsContext = reduceTaskMetricsCollectors.getUnchecked(taskReport.getTaskId()); metricsContext.gauge(MapReduceMetrics.METRIC_TASK_INPUT_RECORDS, getTaskCounter(counters, TaskCounter.REDUCE_INPUT_RECORDS)); metricsContext.gauge(MapReduceMetrics.METRIC_TASK_OUTPUT_RECORDS, getTaskCounter(counters, TaskCounter.REDUCE_OUTPUT_RECORDS)); metricsContext.gauge(MapReduceMetrics.METRIC_TASK_COMPLETION, (long) (taskReport.getProgress() * 100)); }