mirror of
https://github.com/apache/sqoop.git
synced 2025-05-04 20:30:06 +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.
|
// 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
|
// We're currently supporting HBase version 0.90 that do not have security
|
||||||
// patches which means that it do not have required method
|
// patches which means that it do not have required methods
|
||||||
// "obtainAuthTokenForJob".
|
// "isSecurityEnabled" and "obtainAuthTokenForJob".
|
||||||
//
|
//
|
||||||
// We're using reflection API to see if this method is available and call
|
// We're using reflection API to see if those methods are available and call
|
||||||
// it only if it's present.
|
// them only if they are present.
|
||||||
//
|
//
|
||||||
// After we will remove support for HBase 0.90 we can simplify the code to
|
// After we will remove support for HBase 0.90 we can simplify the code to
|
||||||
// following code fragment:
|
// following code fragment:
|
||||||
/*
|
/*
|
||||||
try {
|
try {
|
||||||
User user = User.getCurrent();
|
if (User.isSecurityEnabled()) {
|
||||||
user.obtainAuthTokenForJob(conf, job);
|
User user = User.getCurrent();
|
||||||
|
user.obtainAuthTokenForJob(conf, job);
|
||||||
|
}
|
||||||
} catch(InterruptedException ex) {
|
} catch(InterruptedException ex) {
|
||||||
throw new ImportException("Can't get authentication token", ex);
|
throw new ImportException("Can't get authentication token", ex);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
// Get the method
|
// Get method isSecurityEnabled
|
||||||
|
Method isSecurityEnabled = User.class.getMethod("isSecurityEnabled");
|
||||||
|
|
||||||
|
// Get method obtainAuthTokenForJob
|
||||||
Method obtainAuthTokenForJob = User.class.getMethod(
|
Method obtainAuthTokenForJob = User.class.getMethod(
|
||||||
"obtainAuthTokenForJob", Configuration.class, Job.class);
|
"obtainAuthTokenForJob", Configuration.class, Job.class);
|
||||||
|
|
||||||
// Get current user
|
// Get current user
|
||||||
User user = User.getCurrent();
|
User user = User.getCurrent();
|
||||||
|
|
||||||
// Obtain security token if needed (it's no-op on non secure cluster)
|
// Obtain security token if needed
|
||||||
obtainAuthTokenForJob.invoke(user, conf, job);
|
if((Boolean)isSecurityEnabled.invoke(null)) {
|
||||||
|
obtainAuthTokenForJob.invoke(user, conf, job);
|
||||||
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
LOG.info("It seems that we're running on HBase without security"
|
LOG.info("It seems that we're running on HBase without security"
|
||||||
+ " additions. Security additions will not be used during this job.");
|
+ " additions. Security additions will not be used during this job.");
|
||||||
|
Loading…
Reference in New Issue
Block a user