Search in sources :

Example 16 with SessionHandle

use of org.apache.hive.service.cli.SessionHandle in project hive by apache.

the class ThriftCLIService method GetCatalogs.

@Override
public TGetCatalogsResp GetCatalogs(TGetCatalogsReq req) throws TException {
    TGetCatalogsResp resp = new TGetCatalogsResp();
    try {
        OperationHandle opHandle = cliService.getCatalogs(new SessionHandle(req.getSessionHandle()));
        resp.setOperationHandle(opHandle.toTOperationHandle());
        resp.setStatus(OK_STATUS);
    } catch (Exception e) {
        LOG.warn("Error getting catalogs: ", e);
        resp.setStatus(HiveSQLException.toTStatus(e));
    }
    return resp;
}
Also used : SessionHandle(org.apache.hive.service.cli.SessionHandle) OperationHandle(org.apache.hive.service.cli.OperationHandle) LoginException(javax.security.auth.login.LoginException) ServiceException(org.apache.hive.service.ServiceException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) TGetCatalogsResp(org.apache.hive.service.rpc.thrift.TGetCatalogsResp)

Example 17 with SessionHandle

use of org.apache.hive.service.cli.SessionHandle in project hive by apache.

the class ThriftCLIService method GetDelegationToken.

@Override
public TGetDelegationTokenResp GetDelegationToken(TGetDelegationTokenReq req) throws TException {
    TGetDelegationTokenResp resp = new TGetDelegationTokenResp();
    if (hiveAuthFactory == null || !hiveAuthFactory.isSASLKerberosUser()) {
        resp.setStatus(unsecureTokenErrorStatus());
    } else {
        try {
            String token = cliService.getDelegationToken(new SessionHandle(req.getSessionHandle()), hiveAuthFactory, req.getOwner(), req.getRenewer());
            resp.setDelegationToken(token);
            resp.setStatus(OK_STATUS);
        } catch (HiveSQLException e) {
            LOG.error("Error obtaining delegation token", e);
            TStatus tokenErrorStatus = HiveSQLException.toTStatus(e);
            tokenErrorStatus.setSqlState("42000");
            resp.setStatus(tokenErrorStatus);
        }
    }
    return resp;
}
Also used : HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TStatus(org.apache.hive.service.rpc.thrift.TStatus) TGetDelegationTokenResp(org.apache.hive.service.rpc.thrift.TGetDelegationTokenResp) SessionHandle(org.apache.hive.service.cli.SessionHandle)

Example 18 with SessionHandle

use of org.apache.hive.service.cli.SessionHandle in project hive by apache.

the class ThriftCLIService method getSessionHandle.

/**
   * Create a session handle
   * @param req
   * @param res
   * @return
   * @throws HiveSQLException
   * @throws LoginException
   * @throws IOException
   */
SessionHandle getSessionHandle(TOpenSessionReq req, TOpenSessionResp res) throws HiveSQLException, LoginException, IOException {
    String userName = getUserName(req);
    String ipAddress = getIpAddress();
    TProtocolVersion protocol = getMinVersion(CLIService.SERVER_VERSION, req.getClient_protocol());
    SessionHandle sessionHandle;
    if (cliService.getHiveConf().getBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS) && (userName != null)) {
        String delegationTokenStr = getDelegationToken(userName);
        sessionHandle = cliService.openSessionWithImpersonation(protocol, userName, req.getPassword(), ipAddress, req.getConfiguration(), delegationTokenStr);
    } else {
        sessionHandle = cliService.openSession(protocol, userName, req.getPassword(), ipAddress, req.getConfiguration());
    }
    res.setServerProtocolVersion(protocol);
    return sessionHandle;
}
Also used : TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) SessionHandle(org.apache.hive.service.cli.SessionHandle)

Example 19 with SessionHandle

use of org.apache.hive.service.cli.SessionHandle in project hive by apache.

the class ThriftCLIService method GetSchemas.

@Override
public TGetSchemasResp GetSchemas(TGetSchemasReq req) throws TException {
    TGetSchemasResp resp = new TGetSchemasResp();
    try {
        OperationHandle opHandle = cliService.getSchemas(new SessionHandle(req.getSessionHandle()), req.getCatalogName(), req.getSchemaName());
        resp.setOperationHandle(opHandle.toTOperationHandle());
        resp.setStatus(OK_STATUS);
    } catch (Exception e) {
        LOG.warn("Error getting schemas: ", e);
        resp.setStatus(HiveSQLException.toTStatus(e));
    }
    return resp;
}
Also used : SessionHandle(org.apache.hive.service.cli.SessionHandle) TGetSchemasResp(org.apache.hive.service.rpc.thrift.TGetSchemasResp) OperationHandle(org.apache.hive.service.cli.OperationHandle) LoginException(javax.security.auth.login.LoginException) ServiceException(org.apache.hive.service.ServiceException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 20 with SessionHandle

use of org.apache.hive.service.cli.SessionHandle in project hive by apache.

the class ThriftCLIService method GetColumns.

@Override
public TGetColumnsResp GetColumns(TGetColumnsReq req) throws TException {
    TGetColumnsResp resp = new TGetColumnsResp();
    try {
        OperationHandle opHandle = cliService.getColumns(new SessionHandle(req.getSessionHandle()), req.getCatalogName(), req.getSchemaName(), req.getTableName(), req.getColumnName());
        resp.setOperationHandle(opHandle.toTOperationHandle());
        resp.setStatus(OK_STATUS);
    } catch (Exception e) {
        LOG.warn("Error getting columns: ", e);
        resp.setStatus(HiveSQLException.toTStatus(e));
    }
    return resp;
}
Also used : SessionHandle(org.apache.hive.service.cli.SessionHandle) OperationHandle(org.apache.hive.service.cli.OperationHandle) TGetColumnsResp(org.apache.hive.service.rpc.thrift.TGetColumnsResp) LoginException(javax.security.auth.login.LoginException) ServiceException(org.apache.hive.service.ServiceException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

SessionHandle (org.apache.hive.service.cli.SessionHandle)66 OperationHandle (org.apache.hive.service.cli.OperationHandle)38 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)35 Test (org.junit.Test)27 IOException (java.io.IOException)15 TException (org.apache.thrift.TException)15 UnknownHostException (java.net.UnknownHostException)13 LoginException (javax.security.auth.login.LoginException)13 ServiceException (org.apache.hive.service.ServiceException)13 ExploreException (co.cask.cdap.explore.service.ExploreException)12 QueryHandle (co.cask.cdap.proto.QueryHandle)11 HashMap (java.util.HashMap)8 CLIServiceClient (org.apache.hive.service.cli.CLIServiceClient)8 RowSet (org.apache.hive.service.cli.RowSet)6 TimeoutException (java.util.concurrent.TimeoutException)4 HiveConf (org.apache.hadoop.hive.conf.HiveConf)4 ThriftCLIServiceClient (org.apache.hive.service.cli.thrift.ThriftCLIServiceClient)4 CLIService (org.apache.hive.service.cli.CLIService)3 OperationState (org.apache.hive.service.cli.OperationState)3 OperationStatus (org.apache.hive.service.cli.OperationStatus)3