5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-04 16:41:08 +08:00

SQOOP-616 HBase import/export is not working on non secure cluster where

security is available

(Jarek Jarcec Cecho via Cheolsoo Park)
This commit is contained in:
Cheolsoo Park 2012-09-26 14:17:37 -07:00
parent 5616152ac4
commit 465c2751f7

View File

@ -145,32 +145,39 @@ protected void jobSetup(Job job) throws IOException, ImportException {
// Add authentication token to the job if we're running on secure cluster.
//
// We're currently supporting HBase version 0.90 that do not have security
// patches which means that it do not have required method
// "obtainAuthTokenForJob".
// patches which means that it do not have required methods
// "isSecurityEnabled" and "obtainAuthTokenForJob".
//
// We're using reflection API to see if this method is available and call
// it only if it's present.
// We're using reflection API to see if those methods are available and call
// them only if they are present.
//
// After we will remove support for HBase 0.90 we can simplify the code to
// following code fragment:
/*
try {
User user = User.getCurrent();
user.obtainAuthTokenForJob(conf, job);
if (User.isSecurityEnabled()) {
User user = User.getCurrent();
user.obtainAuthTokenForJob(conf, job);
}
} catch(InterruptedException ex) {
throw new ImportException("Can't get authentication token", ex);
}
*/
try {
// Get the method
// Get method isSecurityEnabled
Method isSecurityEnabled = User.class.getMethod("isSecurityEnabled");
// Get method obtainAuthTokenForJob
Method obtainAuthTokenForJob = User.class.getMethod(
"obtainAuthTokenForJob", Configuration.class, Job.class);
// Get current user
User user = User.getCurrent();
// Obtain security token if needed (it's no-op on non secure cluster)
obtainAuthTokenForJob.invoke(user, conf, job);
// Obtain security token if needed
if((Boolean)isSecurityEnabled.invoke(null)) {
obtainAuthTokenForJob.invoke(user, conf, job);
}
} catch (NoSuchMethodException e) {
LOG.info("It seems that we're running on HBase without security"
+ " additions. Security additions will not be used during this job.");