From 6cd94e88203932b5db23ab863fdb64029b7fb8e8 Mon Sep 17 00:00:00 2001 From: Biju Nair <gs.biju@gmail.com> Date: Fri, 22 Jan 2016 18:14:39 -0500 Subject: [PATCH] [hbase10] changes to be able to work with secured hbase cluster --- .../java/com/yahoo/ycsb/db/HBaseClient10.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hbase10/src/main/java/com/yahoo/ycsb/db/HBaseClient10.java b/hbase10/src/main/java/com/yahoo/ycsb/db/HBaseClient10.java index 49b699a3..70843256 100644 --- a/hbase10/src/main/java/com/yahoo/ycsb/db/HBaseClient10.java +++ b/hbase10/src/main/java/com/yahoo/ycsb/db/HBaseClient10.java @@ -24,6 +24,7 @@ import com.yahoo.ycsb.DBException; import com.yahoo.ycsb.Status; import com.yahoo.ycsb.measurements.Measurements; +import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; @@ -112,6 +113,22 @@ public class HBaseClient10 extends com.yahoo.ycsb.DB { Durability.valueOf(getProperties().getProperty("durability")); } + if ("kerberos".equalsIgnoreCase(config.get("hbase.security.authentication"))) { + config.set("hadoop.security.authentication", "Kerberos"); + UserGroupInformation.setConfiguration(config); + } + + if ((getProperties().getProperty("principal")!=null) + && (getProperties().getProperty("keytab")!=null)) { + try { + UserGroupInformation.loginUserFromKeytab(getProperties().getProperty("principal"), + getProperties().getProperty("keytab")); + } catch (IOException e) { + System.err.println("Keytab file is not readable or not found"); + throw new DBException(e); + } + } + try { connection = ConnectionFactory.createConnection(config); } catch (java.io.IOException e) { -- GitLab