Skip to content

Commit

Permalink
[hbase10] changes to be able to work with secured hbase cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
bijugs committed Jan 22, 2016
1 parent 025f3b4 commit 6cd94e8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hbase10/src/main/java/com/yahoo/ycsb/db/HBaseClient10.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -112,6 +113,22 @@ public void init() throws DBException {
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) {
Expand Down

0 comments on commit 6cd94e8

Please sign in to comment.