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:
parent
5616152ac4
commit
465c2751f7
@ -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.");
|
||||
|
Loading…
Reference in New Issue
Block a user