Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

java api access security hbase ticket expires

Solved Go to solution
Highlighted

java api access security hbase ticket expires

Contributor

My keytab ticket maxlife time is 7days. with the api code

UserGroupInformation.loginUserFromKeytab(conf.get("hbase.master.kerberos.principal"), conf.get("hbase.keytab.path"));

The ticket will expire 7days later,how to fix it? (How to access hbase all the time?)

 

rube

1 ACCEPTED SOLUTION

Accepted Solutions

Re: java api access security hbase ticket expires

Master Guru
If you cannot get the admins to provide your app with a near-infinite
ticket lifetime, you need to instead loop the login process via a
daemon thread, such as via this thread snippet as an example:

private void runLoginAndRenewalThread(final Configuration conf) throws
IOException {
// Do a blocking login first
SecurityUtil.login(conf, KEYTAB_CONF, KEYTAB_USER);
// Spawn the relogin thread next
Thread reloginThread = new Thread() {
@Override
public void run() {
while (true) {
try {
SecurityUtil.login(conf, KEYTAB_CONF, KEYTAB_USER);
Thread.sleep(ELEVEN_MINUTES);
} catch (IOException e) {
e.printStackTrace();
interrupt();
} catch (InterruptedException e) {
e.printStackTrace();
interrupt();
}
}
}
};
reloginThread.setDaemon(true);
reloginThread.start();
}

1 REPLY 1

Re: java api access security hbase ticket expires

Master Guru
If you cannot get the admins to provide your app with a near-infinite
ticket lifetime, you need to instead loop the login process via a
daemon thread, such as via this thread snippet as an example:

private void runLoginAndRenewalThread(final Configuration conf) throws
IOException {
// Do a blocking login first
SecurityUtil.login(conf, KEYTAB_CONF, KEYTAB_USER);
// Spawn the relogin thread next
Thread reloginThread = new Thread() {
@Override
public void run() {
while (true) {
try {
SecurityUtil.login(conf, KEYTAB_CONF, KEYTAB_USER);
Thread.sleep(ELEVEN_MINUTES);
} catch (IOException e) {
e.printStackTrace();
interrupt();
} catch (InterruptedException e) {
e.printStackTrace();
interrupt();
}
}
}
};
reloginThread.setDaemon(true);
reloginThread.start();
}

Don't have an account?
Coming from Hortonworks? Activate your account here