diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java index 5242bd94c8c..c84b25b0004 100644 --- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java +++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase.mapreduce; import java.io.IOException; +import java.lang.reflect.Method; import java.util.Map; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.DoNotRetryIOException; @@ -95,6 +96,27 @@ public class TableRecordReaderImpl { } } + /** + * In new mapreduce APIs, TaskAttemptContext has two getCounter methods + * Check if getCounter(String, String) method is available. + * @return The getCounter method or null if not available. + * @deprecated since 2.4.0 and 2.3.2, will be removed in 4.0.0 + */ + @Deprecated + protected static Method retrieveGetCounterWithStringsParams(TaskAttemptContext context) + throws IOException { + Method m = null; + try { + m = context.getClass().getMethod("getCounter", + new Class [] {String.class, String.class}); + } catch (SecurityException e) { + throw new IOException("Failed test for getCounter", e); + } catch (NoSuchMethodException e) { + // Ignore + } + return m; + } + /** * Sets the HBase table. * @param htable The table to scan. @@ -267,6 +289,16 @@ public class TableRecordReaderImpl { updateCounters(scanMetrics, numRestarts, context, numStale); } + /** + * @deprecated since 2.4.0 and 2.3.2, will be removed in 4.0.0 + * Use {@link #updateCounters(ScanMetrics, long, TaskAttemptContext, long)} instead. + */ + @Deprecated + protected static void updateCounters(ScanMetrics scanMetrics, long numScannerRestarts, + Method getCounter, TaskAttemptContext context, long numStale) { + updateCounters(scanMetrics, numScannerRestarts, context, numStale); + } + protected static void updateCounters(ScanMetrics scanMetrics, long numScannerRestarts, TaskAttemptContext context, long numStale) { // we can get access to counters only if hbase uses new mapreduce APIs