Updated Branches: refs/heads/flume-1.4 fcf638fc3 -> f31b3947d
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/f31b3947 Tree: http://git-wip-us.apache.org/repos/asf/flume/tree/f31b3947 Diff: http://git-wip-us.apache.org/repos/asf/flume/diff/f31b3947 Branch: refs/heads/flume-1.4 Commit: f31b3947d3afec14ef1bee1dbdbd9a6d713b089b Parents: fcf638f Author: Mike Percy <[email protected]> Authored: Thu Apr 25 02:31:29 2013 -0700 Committer: Mike Percy <[email protected]> Committed: Thu Apr 25 02:32:33 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/f31b3947/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>() {
