Search in sources :

Example 1 with LlapTokenClient

use of org.apache.hadoop.hive.llap.security.LlapTokenClient in project hive by apache.

the class TezSessionState method getLlapToken.

private static Token<LlapTokenIdentifier> getLlapToken(String user, final Configuration conf) throws IOException {
    // TODO: parts of this should be moved out of TezSession to reuse the clients, but there's
    // no good place for that right now (HIVE-13698).
    // TODO: De-link from SessionState. A TezSession can be linked to different Hive Sessions via the pool.
    SessionState session = SessionState.get();
    boolean isInHs2 = session != null && session.isHiveServerQuery();
    Token<LlapTokenIdentifier> token = null;
    // For Tez, we don't use appId to distinguish the tokens.
    LlapCoordinator coordinator = null;
    if (isInHs2) {
        // We are in HS2, get the token locally.
        // TODO: coordinator should be passed in; HIVE-13698. Must be initialized for now.
        coordinator = LlapCoordinator.getInstance();
        if (coordinator == null) {
            throw new IOException("LLAP coordinator not initialized; cannot get LLAP tokens");
        }
        // Signing is not required for Tez.
        token = coordinator.getLocalTokenClient(conf, user).createToken(null, null, false);
    } else {
        // We are not in HS2; always create a new client for now.
        token = new LlapTokenClient(conf).getDelegationToken(null);
    }
    if (LOG.isInfoEnabled()) {
        LOG.info("Obtained a LLAP token: " + token);
    }
    return token;
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState) LlapTokenIdentifier(org.apache.hadoop.hive.llap.security.LlapTokenIdentifier) IOException(java.io.IOException) LlapCoordinator(org.apache.hadoop.hive.llap.coordinator.LlapCoordinator) LlapTokenClient(org.apache.hadoop.hive.llap.security.LlapTokenClient)

Aggregations

IOException (java.io.IOException)1 LlapCoordinator (org.apache.hadoop.hive.llap.coordinator.LlapCoordinator)1 LlapTokenClient (org.apache.hadoop.hive.llap.security.LlapTokenClient)1 LlapTokenIdentifier (org.apache.hadoop.hive.llap.security.LlapTokenIdentifier)1 SessionState (org.apache.hadoop.hive.ql.session.SessionState)1