incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tof...@apache.org
Subject svn commit: r1299065 - in /incubator/hcatalog/trunk: ./ storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/
Date Fri, 09 Mar 2012 21:41:15 GMT
Author: toffer
Date: Fri Mar  9 21:41:14 2012
New Revision: 1299065

URL: http://svn.apache.org/viewvc?rev=1299065&view=rev
Log:
HCAT-296 Hcatalog should be able talk to secure hbase server using hbase delegation token
(rohini via toffer)

Added:
    incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseMapredUtil.java
Modified:
    incubator/hcatalog/trunk/CHANGES.txt
    incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseBulkOutputFormat.java
    incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseDirectOutputFormat.java
    incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseInputFormat.java
    incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/ImportSequenceFile.java

Modified: incubator/hcatalog/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1299065&r1=1299064&r2=1299065&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Fri Mar  9 21:41:14 2012
@@ -53,6 +53,8 @@ Release 0.4.0 - Unreleased
   HCAT-240. Changes to HCatOutputFormat to make it use SerDes instead of StorageDriver (toffer)
 
   NEW FEATURES
+  HCAT-296 Hcatalog should be able talk to secure hbase server using hbase delegation token
(rohini via toffer)
+
   HCAT-249 Rework JSON StorageDriver into a JSON SerDe (khorgath via gates)
 
   HCAT-255 Define hadoop properties on the hcat command line (ctdean via gates)

Modified: incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseBulkOutputFormat.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseBulkOutputFormat.java?rev=1299065&r1=1299064&r2=1299065&view=diff
==============================================================================
--- incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseBulkOutputFormat.java
(original)
+++ incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseBulkOutputFormat.java
Fri Mar  9 21:41:14 2012
@@ -27,6 +27,7 @@ import org.apache.hadoop.fs.Path;
 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 @@ class HBaseBulkOutputFormat extends HBas
         job.setOutputValueClass(Put.class);
         job.setOutputCommitter(HBaseBulkOutputCommitter.class);
         baseOutputFormat.checkOutputSpecs(ignored, job);
-        getJTDelegationToken(job);
+        HBaseMapredUtil.addHBaseDelegationToken(job);
+        addJTDelegationToken(job);
     }
 
     @Override
@@ -76,10 +78,10 @@ class HBaseBulkOutputFormat extends HBas
                 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"),

Modified: incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseDirectOutputFormat.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseDirectOutputFormat.java?rev=1299065&r1=1299064&r2=1299065&view=diff
==============================================================================
--- incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseDirectOutputFormat.java
(original)
+++ incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseDirectOutputFormat.java
Fri Mar  9 21:41:14 2012
@@ -67,6 +67,7 @@ class HBaseDirectOutputFormat extends HB
         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

Modified: incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseInputFormat.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseInputFormat.java?rev=1299065&r1=1299064&r2=1299065&view=diff
==============================================================================
--- incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseInputFormat.java
(original)
+++ incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseInputFormat.java
Fri Mar  9 21:41:14 2012
@@ -105,6 +105,7 @@ class HBaseInputFormat implements InputF
     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)));
     }

Added: incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseMapredUtil.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseMapredUtil.java?rev=1299065&view=auto
==============================================================================
--- incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseMapredUtil.java
(added)
+++ incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/HBaseMapredUtil.java
Fri Mar  9 21:41:14 2012
@@ -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);
+            }
+        }
+    }
+
+}

Modified: incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/ImportSequenceFile.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/ImportSequenceFile.java?rev=1299065&r1=1299064&r2=1299065&view=diff
==============================================================================
--- incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/ImportSequenceFile.java
(original)
+++ incubator/hcatalog/trunk/storage-drivers/hbase/src/java/org/apache/hcatalog/hbase/ImportSequenceFile.java
Fri Mar  9 21:41:14 2012
@@ -220,6 +220,7 @@ class ImportSequenceFile {
         }
 
         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"));
 



Mime
View raw message