@Override public Counters.Counter getCounter(Enum<?> name) { return (context != null) ? (Counters.Counter) context.getCounter(name) : null; }
@Override public Counters.Counter getCounter(String group, String name) { return (context != null) ? (Counters.Counter) context.getCounter(group, name) : null; }
@Override public void incrementContextCounter(TaskInputOutputContext context, String group, String name, long incr) { context.getCounter(group, name).increment(incr); }
@Override public void incrementContextCounter(TaskInputOutputContext context, String group, String name, long incr) { context.getCounter(group, name).increment(incr); }
@Override public long getContextCounter(TaskInputOutputContext context, String group, String name) { return context.getCounter(group, name).getValue(); }
@Override public long getContextCounter(TaskInputOutputContext context, String group, String name) { return context.getCounter(group, name).getValue(); }
@Override public void incrCounter(Enum<?> key, long amount) { if (context != null) { context.getCounter(key).increment(amount); } }
@Override public void incrCounter(String group, String counter, long amount) { if (context != null) { context.getCounter(group, counter).increment(amount); } }
@Override protected void reportIncremental(MetricContext context, String name, long incremental) { this.hadoopContext.getCounter(context.getName(), name).increment(incremental); }
@Override protected void reportValue(MetricContext context, String name, long value) { this.hadoopContext.getCounter(context.getName(), name).setValue(value); }
@SuppressWarnings({"unchecked"}) public void write(Object key, Object value) throws IOException, InterruptedException { context.getCounter(COUNTERS_GROUP, counterName).increment(1); writer.write(key, value); }
@BeforeClass @SuppressWarnings("unchecked") public void setUp() { TaskInputOutputContext<Object, Object, Object, Object> mockContext = Mockito.mock(TaskInputOutputContext.class); this.recordsProcessedCount = Mockito.mock(Counter.class); Mockito.when(mockContext.getCounter( this.name, MetricRegistry.name(RECORDS_PROCESSED, Measurements.COUNT.getName()))) .thenReturn(this.recordsProcessedCount); this.recordProcessRateCount = Mockito.mock(Counter.class); Mockito.when(mockContext.getCounter( this.name, MetricRegistry.name(RECORD_PROCESS_RATE, Measurements.COUNT.getName()))) .thenReturn(this.recordProcessRateCount); this.recordSizeDistributionCount = Mockito.mock(Counter.class); Mockito.when(mockContext.getCounter( this.name, MetricRegistry.name(RECORD_SIZE_DISTRIBUTION, Measurements.COUNT.getName()))) .thenReturn(this.recordSizeDistributionCount); this.totalDurationCount = Mockito.mock(Counter.class); Mockito.when(mockContext.getCounter( this.name, MetricRegistry.name(TOTAL_DURATION, Measurements.COUNT.getName()))) .thenReturn(this.totalDurationCount); this.queueSize = Mockito.mock(Counter.class); Mockito.when(mockContext.getCounter(this.name, QUEUE_SIZE)).thenReturn(this.queueSize); this.hadoopCounterReporter = NewAPIHadoopCounterReporter.builder(mockContext) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.SECONDS) .filter(MetricFilter.ALL) .build(MetricContext.builder(this.name).build()); }
/** * @deprecated The {@link Counter} class changed incompatibly between Hadoop 1 and 2 * (from a class to an interface) so user programs should avoid this method and use * one of the <code>increment</code> methods instead, such as {@link #increment(Enum)}. */ @Deprecated protected Counter getCounter(Enum<?> counterName) { if (context == null) { return null; } return context.getCounter(counterName); }
protected Counter getCounter(String groupName, String counterName) { if (context == null) { return TestCounters.getCounter(groupName, counterName); } return context.getCounter(groupName, counterName); }
@Override public void incrCounter(String group, String counter, long amount) { if (context != null) { context.getCounter(group, counter).increment(amount); } }
@SuppressWarnings({"unchecked"}) public void write(Object key, Object value) throws IOException, InterruptedException { context.getCounter(COUNTERS_GROUP, counterName).increment(1); writer.write(key, value); }
@SuppressWarnings({"unchecked"}) public void write(Object key, Object value) throws IOException, InterruptedException { context.getCounter(COUNTERS_GROUP, counterName).increment(1); writer.write(key, value); }
@SuppressWarnings({"unchecked"}) public void write(Object key, Object value) throws IOException, InterruptedException { context.getCounter(COUNTERS_GROUP, counterName).increment(1); writer.write(key, value); }
@Override public void write(K key, V value) throws IOException, InterruptedException { context.getCounter(groupName, counterName).increment(1); writer.write(key, value); }
@SuppressWarnings({"unchecked"}) public void write(Object key, Object value) throws IOException, InterruptedException { context.getCounter(COUNTERS_GROUP, counterName).increment(1); writer.write(key, value); }