flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpe...@apache.org
Subject git commit: FLUME-2023. Login to secure HBase before creating HTable object
Date Thu, 25 Apr 2013 09:32:40 GMT
Updated Branches:
  refs/heads/trunk 0a855488a -> 496b7c2da


FLUME-2023. Login to secure HBase before creating HTable object

(Hari Shreedharan via Mike Percy)


Project: http://git-wip-us.apache.org/repos/asf/flume/repo
Commit: http://git-wip-us.apache.org/repos/asf/flume/commit/496b7c2d
Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/496b7c2d
Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/496b7c2d

Branch: refs/heads/trunk
Commit: 496b7c2da4e3bcde836968f823c67c57b85f1ede
Parents: 0a85548
Author: Mike Percy <mpercy@apache.org>
Authored: Thu Apr 25 02:31:29 2013 -0700
Committer: Mike Percy <mpercy@apache.org>
Committed: Thu Apr 25 02:31:29 2013 -0700

----------------------------------------------------------------------
 .../org/apache/flume/sink/hbase/HBaseSink.java     |   32 +++++++++------
 1 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flume/blob/496b7c2d/flume-ng-sinks/flume-ng-hbase-sink/src/main/java/org/apache/flume/sink/hbase/HBaseSink.java
----------------------------------------------------------------------
diff --git a/flume-ng-sinks/flume-ng-hbase-sink/src/main/java/org/apache/flume/sink/hbase/HBaseSink.java
b/flume-ng-sinks/flume-ng-hbase-sink/src/main/java/org/apache/flume/sink/hbase/HBaseSink.java
index 31fb7ff..8f0e3e9 100644
--- a/flume-ng-sinks/flume-ng-hbase-sink/src/main/java/org/apache/flume/sink/hbase/HBaseSink.java
+++ b/flume-ng-sinks/flume-ng-hbase-sink/src/main/java/org/apache/flume/sink/hbase/HBaseSink.java
@@ -111,24 +111,30 @@ public class HBaseSink extends AbstractSink implements Configurable
{
     Preconditions.checkArgument(table == null, "Please call stop " +
         "before calling start on an old instance.");
     try {
-      table = new HTable(config, tableName);
-      //flush is controlled by us. This ensures that HBase changing
-      //their criteria for flushing does not change how we flush.
-      table.setAutoFlush(false);
-    } catch (IOException e) {
-      logger.error("Could not load table, " + tableName +
-          " from HBase", e);
-      throw new FlumeException("Could not load table, " + tableName +
-          " from HBase", e);
-    }
-    try {
       if (HBaseSinkSecurityManager.isSecurityEnabled(config)) {
         hbaseUser = HBaseSinkSecurityManager.login(config, null,
-                kerberosPrincipal, kerberosKeytab);
+          kerberosPrincipal, kerberosKeytab);
       }
     } catch (Exception ex) {
       throw new FlumeException("Failed to login to HBase using "
-              + "provided credentials.", ex);
+        + "provided credentials.", ex);
+    }
+    try {
+      table = runPrivileged(new PrivilegedExceptionAction<HTable>() {
+        @Override
+        public HTable run() throws Exception {
+          HTable table = new HTable(config, tableName);
+          table.setAutoFlush(false);
+          // Flush is controlled by us. This ensures that HBase changing
+          // their criteria for flushing does not change how we flush.
+          return table;
+        }
+      });
+    } catch (Exception e) {
+      logger.error("Could not load table, " + tableName +
+          " from HBase", e);
+      throw new FlumeException("Could not load table, " + tableName +
+          " from HBase", e);
     }
     try {
       if (!runPrivileged(new PrivilegedExceptionAction<Boolean>() {


Mime
View raw message