HBASE-24831 : Addendum for source compatibility

Closes #2403

Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
This commit is contained in:
Viraj Jasani 2020-09-15 20:10:50 +05:30
parent a3f40287ad
commit 325317ff9e
No known key found for this signature in database
GPG Key ID: B3D6C0B41C8ADFD5
1 changed files with 32 additions and 0 deletions

View File

@ -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