|
18 | 18 | package org.apache.hadoop.hbase.mapreduce; |
19 | 19 |
|
20 | 20 | import java.io.IOException; |
| 21 | +import java.lang.reflect.Method; |
21 | 22 | import java.util.Map; |
22 | 23 | import org.apache.hadoop.conf.Configuration; |
23 | 24 | import org.apache.hadoop.hbase.DoNotRetryIOException; |
@@ -95,6 +96,27 @@ public void restart(byte[] firstRow) throws IOException { |
95 | 96 | } |
96 | 97 | } |
97 | 98 |
|
| 99 | + /** |
| 100 | + * In new mapreduce APIs, TaskAttemptContext has two getCounter methods |
| 101 | + * Check if getCounter(String, String) method is available. |
| 102 | + * @return The getCounter method or null if not available. |
| 103 | + * @deprecated since 2.4.0 and 2.3.2, will be removed in 4.0.0 |
| 104 | + */ |
| 105 | + @Deprecated |
| 106 | + protected static Method retrieveGetCounterWithStringsParams(TaskAttemptContext context) |
| 107 | + throws IOException { |
| 108 | + Method m = null; |
| 109 | + try { |
| 110 | + m = context.getClass().getMethod("getCounter", |
| 111 | + new Class [] {String.class, String.class}); |
| 112 | + } catch (SecurityException e) { |
| 113 | + throw new IOException("Failed test for getCounter", e); |
| 114 | + } catch (NoSuchMethodException e) { |
| 115 | + // Ignore |
| 116 | + } |
| 117 | + return m; |
| 118 | + } |
| 119 | + |
98 | 120 | /** |
99 | 121 | * Sets the HBase table. |
100 | 122 | * @param htable The table to scan. |
@@ -267,6 +289,16 @@ private void updateCounters() { |
267 | 289 | updateCounters(scanMetrics, numRestarts, context, numStale); |
268 | 290 | } |
269 | 291 |
|
| 292 | + /** |
| 293 | + * @deprecated since 2.4.0 and 2.3.2, will be removed in 4.0.0 |
| 294 | + * Use {@link #updateCounters(ScanMetrics, long, TaskAttemptContext, long)} instead. |
| 295 | + */ |
| 296 | + @Deprecated |
| 297 | + protected static void updateCounters(ScanMetrics scanMetrics, long numScannerRestarts, |
| 298 | + Method getCounter, TaskAttemptContext context, long numStale) { |
| 299 | + updateCounters(scanMetrics, numScannerRestarts, context, numStale); |
| 300 | + } |
| 301 | + |
270 | 302 | protected static void updateCounters(ScanMetrics scanMetrics, long numScannerRestarts, |
271 | 303 | TaskAttemptContext context, long numStale) { |
272 | 304 | // we can get access to counters only if hbase uses new mapreduce APIs |
|
0 commit comments