Search in sources :

Example 1 with SessionManager

use of org.apache.hive.service.cli.session.SessionManager in project hive by apache.

the class CLIService method init.

@Override
public synchronized void init(HiveConf hiveConf) {
    this.hiveConf = hiveConf;
    sessionManager = new SessionManager(hiveServer2);
    defaultFetchRows = hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE);
    addService(sessionManager);
    //  If the hadoop cluster is secure, do a kerberos login for the service from the keytab
    if (UserGroupInformation.isSecurityEnabled()) {
        try {
            HiveAuthFactory.loginFromKeytab(hiveConf);
            this.serviceUGI = Utils.getUGI();
        } catch (IOException e) {
            throw new ServiceException("Unable to login to kerberos with given principal/keytab", e);
        } catch (LoginException e) {
            throw new ServiceException("Unable to login to kerberos with given principal/keytab", e);
        }
        // Also try creating a UGI object for the SPNego principal
        String principal = hiveConf.getVar(ConfVars.HIVE_SERVER2_SPNEGO_PRINCIPAL);
        String keyTabFile = hiveConf.getVar(ConfVars.HIVE_SERVER2_SPNEGO_KEYTAB);
        if (principal.isEmpty() || keyTabFile.isEmpty()) {
            LOG.info("SPNego httpUGI not created, spNegoPrincipal: " + principal + ", ketabFile: " + keyTabFile);
        } else {
            try {
                this.httpUGI = HiveAuthFactory.loginFromSpnegoKeytabAndReturnUGI(hiveConf);
                LOG.info("SPNego httpUGI successfully created.");
            } catch (IOException e) {
                LOG.warn("SPNego httpUGI creation failed: ", e);
            }
        }
    }
    // creates connection to HMS and thus *must* occur after kerberos login above
    try {
        applyAuthorizationConfigPolicy(hiveConf);
    } catch (Exception e) {
        throw new RuntimeException("Error applying authorization policy on hive configuration: " + e.getMessage(), e);
    }
    setupBlockedUdfs();
    super.init(hiveConf);
}
Also used : ServiceException(org.apache.hive.service.ServiceException) SessionManager(org.apache.hive.service.cli.session.SessionManager) LoginException(javax.security.auth.login.LoginException) IOException(java.io.IOException) LoginException(javax.security.auth.login.LoginException) ServiceException(org.apache.hive.service.ServiceException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) TimeoutException(java.util.concurrent.TimeoutException) CancellationException(java.util.concurrent.CancellationException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException)

Example 2 with SessionManager

use of org.apache.hive.service.cli.session.SessionManager in project hive by apache.

the class QueryProfileServlet method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String opId = (String) request.getParameter("operationId");
    ServletContext ctx = getServletContext();
    SessionManager sessionManager = (SessionManager) ctx.getAttribute("hive.sm");
    OperationManager opManager = sessionManager.getOperationManager();
    SQLOperationDisplay sod = opManager.getSQLOperationDisplay(opId);
    if (sod == null) {
        LOG.debug("No display object found for operation {} ", opId);
        return;
    }
    new QueryProfileTmpl().render(response.getWriter(), sod);
}
Also used : SQLOperationDisplay(org.apache.hive.service.cli.operation.SQLOperationDisplay) SessionManager(org.apache.hive.service.cli.session.SessionManager) QueryProfileTmpl(org.apache.hive.tmpl.QueryProfileTmpl) ServletContext(javax.servlet.ServletContext) OperationManager(org.apache.hive.service.cli.operation.OperationManager)

Aggregations

SessionManager (org.apache.hive.service.cli.session.SessionManager)2 IOException (java.io.IOException)1 CancellationException (java.util.concurrent.CancellationException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 LoginException (javax.security.auth.login.LoginException)1 ServletContext (javax.servlet.ServletContext)1 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1 ServiceException (org.apache.hive.service.ServiceException)1 OperationManager (org.apache.hive.service.cli.operation.OperationManager)1 SQLOperationDisplay (org.apache.hive.service.cli.operation.SQLOperationDisplay)1 QueryProfileTmpl (org.apache.hive.tmpl.QueryProfileTmpl)1