boolean harRequested)
throws IOException, MetaException, TException, Exception {
if (UserGroupInformation.isSecurityEnabled()) {
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
// check if oozie has set up a hcat deleg. token - if so use it
TokenSelector<? extends TokenIdentifier> hiveTokenSelector = new DelegationTokenSelector();
//Oozie does not change the service field of the token
//hence by default token generation will have a value of "new Text("")"
//HiveClient will look for a use TokenSelector.selectToken() with service
//set to empty "Text" if hive.metastore.token.signature property is set to null
Token<? extends TokenIdentifier> hiveToken = hiveTokenSelector.selectToken(
new Text(), ugi.getTokens());
if (hiveToken == null) {
// we did not get token set up by oozie, let's get them ourselves here.
// we essentially get a token per unique Output HCatTableInfo - this is
// done because through Pig, setOutput() method is called multiple times