Updated Branches: refs/heads/trunk 5616152ac -> 465c2751f
SQOOP-616 HBase import/export is not working on non secure cluster where security is available (Jarek Jarcec Cecho via Cheolsoo Park) Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/465c2751 Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/465c2751 Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/465c2751 Branch: refs/heads/trunk Commit: 465c2751f7cc69b9808b55f8d1fbf93b666e25a5 Parents: 5616152 Author: Cheolsoo Park <[email protected]> Authored: Wed Sep 26 14:17:37 2012 -0700 Committer: Cheolsoo Park <[email protected]> Committed: Wed Sep 26 14:17:37 2012 -0700 ---------------------------------------------------------------------- .../org/apache/sqoop/mapreduce/HBaseImportJob.java | 25 +++++++++----- 1 files changed, 16 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sqoop/blob/465c2751/src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java b/src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java index 467c5fd..a6e5546 100644 --- a/src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java +++ b/src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java @@ -145,32 +145,39 @@ public class HBaseImportJob extends DataDrivenImportJob { // 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.");
