Search in sources :

Example 1 with TProtocolVersion

use of org.apache.hive.service.rpc.thrift.TProtocolVersion 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 2 with TProtocolVersion

use of org.apache.hive.service.rpc.thrift.TProtocolVersion in project hive by apache.

the class ThriftCLIService method getMinVersion.

private TProtocolVersion getMinVersion(TProtocolVersion... versions) {
    TProtocolVersion[] values = TProtocolVersion.values();
    int current = values[values.length - 1].getValue();
    for (TProtocolVersion version : versions) {
        if (current > version.getValue()) {
            current = version.getValue();
        }
    }
    for (TProtocolVersion version : values) {
        if (version.getValue() == current) {
            return version;
        }
    }
    throw new IllegalArgumentException("never");
}
Also used : TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion)

Example 3 with TProtocolVersion

use of org.apache.hive.service.rpc.thrift.TProtocolVersion in project hive by apache.

the class ThriftCLIServiceClient method executeStatementInternal.

private OperationHandle executeStatementInternal(SessionHandle sessionHandle, String statement, Map<String, String> confOverlay, boolean isAsync, long queryTimeout) throws HiveSQLException {
    try {
        TExecuteStatementReq req = new TExecuteStatementReq(sessionHandle.toTSessionHandle(), statement);
        req.setConfOverlay(confOverlay);
        req.setRunAsync(isAsync);
        req.setQueryTimeout(queryTimeout);
        TExecuteStatementResp resp = cliService.ExecuteStatement(req);
        checkStatus(resp.getStatus());
        TProtocolVersion protocol = sessionHandle.getProtocolVersion();
        return new OperationHandle(resp.getOperationHandle(), protocol);
    } catch (HiveSQLException e) {
        throw e;
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
}
Also used : TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TExecuteStatementReq(org.apache.hive.service.rpc.thrift.TExecuteStatementReq) OperationHandle(org.apache.hive.service.cli.OperationHandle) TExecuteStatementResp(org.apache.hive.service.rpc.thrift.TExecuteStatementResp) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 4 with TProtocolVersion

use of org.apache.hive.service.rpc.thrift.TProtocolVersion in project hive by apache.

the class ThriftCLIServiceClient method getFunctions.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getFunctions(org.apache.hive.service.cli.SessionHandle)
   */
@Override
public OperationHandle getFunctions(SessionHandle sessionHandle, String catalogName, String schemaName, String functionName) throws HiveSQLException {
    try {
        TGetFunctionsReq req = new TGetFunctionsReq(sessionHandle.toTSessionHandle(), functionName);
        req.setCatalogName(catalogName);
        req.setSchemaName(schemaName);
        TGetFunctionsResp resp = cliService.GetFunctions(req);
        checkStatus(resp.getStatus());
        TProtocolVersion protocol = sessionHandle.getProtocolVersion();
        return new OperationHandle(resp.getOperationHandle(), protocol);
    } catch (HiveSQLException e) {
        throw e;
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
}
Also used : TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TGetFunctionsResp(org.apache.hive.service.rpc.thrift.TGetFunctionsResp) TGetFunctionsReq(org.apache.hive.service.rpc.thrift.TGetFunctionsReq) OperationHandle(org.apache.hive.service.cli.OperationHandle) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 5 with TProtocolVersion

use of org.apache.hive.service.rpc.thrift.TProtocolVersion in project hive by apache.

the class ThriftCLIServiceClient method getCatalogs.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getCatalogs(org.apache.hive.service.cli.SessionHandle)
   */
@Override
public OperationHandle getCatalogs(SessionHandle sessionHandle) throws HiveSQLException {
    try {
        TGetCatalogsReq req = new TGetCatalogsReq(sessionHandle.toTSessionHandle());
        TGetCatalogsResp resp = cliService.GetCatalogs(req);
        checkStatus(resp.getStatus());
        TProtocolVersion protocol = sessionHandle.getProtocolVersion();
        return new OperationHandle(resp.getOperationHandle(), protocol);
    } catch (HiveSQLException e) {
        throw e;
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
}
Also used : TGetCatalogsReq(org.apache.hive.service.rpc.thrift.TGetCatalogsReq) TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) OperationHandle(org.apache.hive.service.cli.OperationHandle) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException) TGetCatalogsResp(org.apache.hive.service.rpc.thrift.TGetCatalogsResp)

Aggregations

TProtocolVersion (org.apache.hive.service.rpc.thrift.TProtocolVersion)13 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)11 OperationHandle (org.apache.hive.service.cli.OperationHandle)11 TException (org.apache.thrift.TException)10 HashMap (java.util.HashMap)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 SessionHandle (org.apache.hive.service.cli.SessionHandle)1 ExecuteStatementOperation (org.apache.hive.service.cli.operation.ExecuteStatementOperation)1 OperationManager (org.apache.hive.service.cli.operation.OperationManager)1 TExecuteStatementReq (org.apache.hive.service.rpc.thrift.TExecuteStatementReq)1 TExecuteStatementResp (org.apache.hive.service.rpc.thrift.TExecuteStatementResp)1 TGetCatalogsReq (org.apache.hive.service.rpc.thrift.TGetCatalogsReq)1 TGetCatalogsResp (org.apache.hive.service.rpc.thrift.TGetCatalogsResp)1 TGetColumnsReq (org.apache.hive.service.rpc.thrift.TGetColumnsReq)1 TGetColumnsResp (org.apache.hive.service.rpc.thrift.TGetColumnsResp)1 TGetCrossReferenceReq (org.apache.hive.service.rpc.thrift.TGetCrossReferenceReq)1 TGetCrossReferenceResp (org.apache.hive.service.rpc.thrift.TGetCrossReferenceResp)1 TGetFunctionsReq (org.apache.hive.service.rpc.thrift.TGetFunctionsReq)1 TGetFunctionsResp (org.apache.hive.service.rpc.thrift.TGetFunctionsResp)1 TGetPrimaryKeysReq (org.apache.hive.service.rpc.thrift.TGetPrimaryKeysReq)1