Index: storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/ImportSequenceFile.java =================================================================== --- storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/ImportSequenceFile.java (revision 1298653) +++ storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/ImportSequenceFile.java (working copy) @@ -220,6 +220,7 @@ } conf.set(HBaseConstants.PROPERTY_OUTPUT_TABLE_NAME_KEY, tableName); + conf.setBoolean(JobContext.JOB_CANCEL_DELEGATION_TOKEN, false); boolean localMode = "local".equals(conf.get("mapred.job.tracker")); Index: storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseDirectOutputFormat.java =================================================================== --- storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseDirectOutputFormat.java (revision 1298653) +++ storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseDirectOutputFormat.java (working copy) @@ -67,6 +67,7 @@ job.setIfUnset(TableOutputFormat.OUTPUT_TABLE, job.get(HBaseConstants.PROPERTY_OUTPUT_TABLE_NAME_KEY)); outputFormat.checkOutputSpecs(ignored, job); + HBaseMapredUtil.addHBaseDelegationToken(job); } private static class HBaseDirectRecordWriter implements Index: storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseMapredUtil.java =================================================================== --- storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseMapredUtil.java (revision 0) +++ storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseMapredUtil.java (revision 0) @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hcatalog.hbase; + +import java.io.IOException; + +import org.apache.hadoop.hbase.security.User; +import org.apache.hadoop.mapred.JobConf; + +public class HBaseMapredUtil { + + private HBaseMapredUtil() { + } + + /** + * Get delegation token from hbase and add it to JobConf + * @param job + * @throws IOException + */ + public static void addHBaseDelegationToken(JobConf job) throws IOException { + if (User.isHBaseSecurityEnabled(job)) { + try { + User.getCurrent().obtainAuthTokenForJob(job); + } catch (InterruptedException e) { + throw new IOException("Error while obtaining hbase delegation token", e); + } + } + } + +} Index: storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseBulkOutputFormat.java =================================================================== --- storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseBulkOutputFormat.java (revision 1298653) +++ storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseBulkOutputFormat.java (working copy) @@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; +import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.io.Text; import org.apache.hadoop.io.WritableComparable; import org.apache.hadoop.mapred.FileOutputCommitter; @@ -64,7 +65,8 @@ job.setOutputValueClass(Put.class); job.setOutputCommitter(HBaseBulkOutputCommitter.class); baseOutputFormat.checkOutputSpecs(ignored, job); - getJTDelegationToken(job); + HBaseMapredUtil.addHBaseDelegationToken(job); + addJTDelegationToken(job); } @Override @@ -76,10 +78,10 @@ ignored, job, name, progress), version); } - private void getJTDelegationToken(JobConf job) throws IOException { + private void addJTDelegationToken(JobConf job) throws IOException { // Get jobTracker delegation token if security is enabled // we need to launch the ImportSequenceFile job - if (job.getBoolean("hadoop.security.authorization", false)) { + if (User.isSecurityEnabled()) { JobClient jobClient = new JobClient(new JobConf(job)); try { job.getCredentials().addToken(new Text("my mr token"), Index: storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseInputFormat.java =================================================================== --- storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseInputFormat.java (revision 1298653) +++ storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseInputFormat.java (working copy) @@ -105,6 +105,7 @@ public org.apache.hadoop.mapred.InputSplit[] getSplits(JobConf job, int numSplits) throws IOException { inputFormat.setConf(job); + HBaseMapredUtil.addHBaseDelegationToken(job); return convertSplits(inputFormat.getSplits(HCatMapRedUtil.createJobContext(job, null, Reporter.NULL))); }