/** * Constructs counter groups from job runtime statistics. Hive mangles Hadoop Counter data, * forming counter names with format "$groupName::$counterName". * * @param counterNameToValue mangled hadoop counters from hive. * @return counter groups by name. */ public static Map<String, CounterGroup> counterGroupInfoMap(Map<String, Double> counterNameToValue) { Counters counters = new Counters(); for (Map.Entry<String, ? extends Number> entry : counterNameToValue.entrySet()) { String key = entry.getKey(); Number value = entry.getValue(); String[] cNames = key.split("::"); String groupName = cNames[0]; String counterName = cNames[1]; Counter counter = counters.findCounter(groupName, counterName); counter.setValue(value.longValue()); } return CounterGroup.counterGroupsByName(counters); }
@JsonIgnore public void setJobStats(HadoopStepStats stats) { Counters counters = new Counters(); for (String groupName : stats.getCounterGroups()) { for (String counterName : stats.getCountersFor(groupName)) { Long counterValue = stats.getCounterValue(groupName, counterName); counters.findCounter(groupName, counterName).setValue(counterValue); } } setCounterGroupMap(CounterGroup.counterGroupsByName(counters)); } }
@JsonIgnore public void setJobStats(HadoopStepStats stats) { Counters counters = new Counters(); for (String groupName : stats.getCounterGroups()) { for (String counterName : stats.getCountersFor(groupName)) { Long counterValue = stats.getCounterValue(groupName, counterName); counters.findCounter(groupName, counterName).setValue(counterValue); } } setCounterGroupMap(CounterGroup.counterGroupsByName(counters)); } }
protected static void setCounterValue(@Nullable Counter counter, long value) { if (counter != null) { synchronized (counter) { counter.setValue(value); } } }
/** * Updates the {@link TaskCounter#COMMITTED_HEAP_BYTES} counter to reflect the * current total committed heap space usage of this JVM. */ @SuppressWarnings("deprecation") private void updateHeapUsageCounter() { long currentHeapUsage = Runtime.getRuntime().totalMemory(); counters.findCounter(TaskCounter.COMMITTED_HEAP_BYTES) .setValue(currentHeapUsage); }
protected static void setCounterValue(@Nullable Counter counter, long value) { if (counter != null) { synchronized (counter) { counter.setValue(value); } } }
protected static void setCounterValue(@Nullable Counter counter, long value) { if (counter != null) { synchronized (counter) { counter.setValue(value); } } }
@JsonIgnore public void setJobStats(HadoopStepStats stats) { Counters counters = new Counters(); for (String groupName : stats.getCounterGroups()) { for (String counterName : stats.getCountersFor(groupName)) { Long counterValue = stats.getCounterValue(groupName, counterName); counters.findCounter(groupName, counterName).setValue(counterValue); } } setCounterGroupMap(CounterGroup.counterGroupsByName(counters)); } }
/** * Updates the {@link TaskCounter#COMMITTED_HEAP_BYTES} counter to reflect the * current total committed heap space usage of this JVM. */ @SuppressWarnings("deprecation") private void updateHeapUsageCounter() { long currentHeapUsage = Runtime.getRuntime().totalMemory(); counters.findCounter(TaskCounter.COMMITTED_HEAP_BYTES) .setValue(currentHeapUsage); }
/** * Updates the {@link TaskCounter#COMMITTED_HEAP_BYTES} counter to reflect the * current total committed heap space usage of this JVM. */ @SuppressWarnings("deprecation") private void updateHeapUsageCounter() { long currentHeapUsage = Runtime.getRuntime().totalMemory(); counters.findCounter(TaskCounter.COMMITTED_HEAP_BYTES) .setValue(currentHeapUsage); }
/** * Updates the {@link TaskCounter#COMMITTED_HEAP_BYTES} counter to reflect the * current total committed heap space usage of this JVM. */ @SuppressWarnings("deprecation") private void updateHeapUsageCounter() { long currentHeapUsage = Runtime.getRuntime().totalMemory(); counters.findCounter(TaskCounter.COMMITTED_HEAP_BYTES) .setValue(currentHeapUsage); }
@JsonIgnore public void setJobStats(HadoopStepStats stats) { Counters counters = new Counters(); for (String groupName : stats.getCounterGroups()) { for (String counterName : stats.getCountersFor(groupName)) { Long counterValue = stats.getCounterValue(groupName, counterName); counters.findCounter(groupName, counterName).setValue(counterValue); } } setCounterGroupMap(CounterGroup.counterGroupsByName(counters)); } }
private void setCounterValue(Counter counter, long value) { Counters.Counter counterObj = reporter.getCounter(counter); if (counterObj != null) { counterObj.setValue(value); } }
protected static void setCounterValue(@Nullable Counter counter, long value) { if (counter != null) { synchronized (counter) { counter.setValue(value); } } }
protected static void setCounterValue(@Nullable Counter counter, long value) { if (counter != null) { synchronized (counter) { counter.setValue(value); } } }
private void setCounterValue(Counter counter, long value) { Counters.Counter counterObj = reporter.getCounter(counter); if (counterObj != null) { counterObj.setValue(value); } }
long expectedValue = initValue; Counter counter = counters.findCounter("foo", "bar"); counter.setValue(initValue); assertEquals("Counter value is not initialized correctly", expectedValue, counter.getValue()); counter.setValue(expectedValue); assertEquals("Counter value is not set correctly", expectedValue, counter.getValue());
Mockito.verify(this.recordSizeDistributionCount).increment(3l); Mockito.verify(this.totalDurationCount).increment(3l); Mockito.verify(this.queueSize).setValue(1000);
@Override protected void reportValue(MetricContext context, String name, long value) { this.reporter.getCounter(context.getName(), name).setValue(value); }