Search in sources :

Example 1 with TCloseOperationResp

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

the class HiveQueryResultSet method closeOperationHandle.

private void closeOperationHandle(TOperationHandle stmtHandle) throws SQLException {
    try {
        if (stmtHandle != null) {
            TCloseOperationReq closeReq = new TCloseOperationReq(stmtHandle);
            TCloseOperationResp closeResp = client.CloseOperation(closeReq);
            Utils.verifySuccessWithInfo(closeResp.getStatus());
        }
    } catch (SQLException e) {
        throw e;
    } catch (Exception e) {
        throw new SQLException(e.toString(), "08S01", e);
    }
}
Also used : SQLException(java.sql.SQLException) TCloseOperationResp(org.apache.hive.service.rpc.thrift.TCloseOperationResp) TCloseOperationReq(org.apache.hive.service.rpc.thrift.TCloseOperationReq) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException)

Example 2 with TCloseOperationResp

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

the class HiveStatement method closeStatementIfNeeded.

/**
 * Closes the statement if there is one running. Do not change the the flags.
 * @throws SQLException If there is an error closing the statement
 */
private void closeStatementIfNeeded() throws SQLException {
    try {
        if (stmtHandle.isPresent()) {
            TCloseOperationReq closeReq = new TCloseOperationReq(stmtHandle.get());
            TCloseOperationResp closeResp = client.CloseOperation(closeReq);
            if (!checkInvalidOperationHandle(closeResp)) {
                Utils.verifySuccessWithInfo(closeResp.getStatus());
            }
        }
    } catch (SQLException e) {
        throw e;
    } catch (TApplicationException tae) {
        String errorMsg = "Failed to close statement";
        if (tae.getType() == TApplicationException.BAD_SEQUENCE_ID) {
            errorMsg = "Failed to close statement. Mismatch thrift sequence id. A previous call to the Thrift library" + " failed and now position within the input stream is lost. Please enable verbose error logging and" + " check the status of previous calls.";
        }
        throw new SQLException(errorMsg, "08S01", tae);
    } catch (Exception e) {
        throw new SQLException("Failed to close statement", "08S01", e);
    } finally {
        stmtHandle = Optional.empty();
    }
}
Also used : SQLException(java.sql.SQLException) TCloseOperationResp(org.apache.hive.service.rpc.thrift.TCloseOperationResp) TCloseOperationReq(org.apache.hive.service.rpc.thrift.TCloseOperationReq) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLTimeoutException(java.sql.SQLTimeoutException) SQLException(java.sql.SQLException) TApplicationException(org.apache.thrift.TApplicationException) TException(org.apache.thrift.TException) TApplicationException(org.apache.thrift.TApplicationException)

Example 3 with TCloseOperationResp

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

the class HiveStatement method closeClientOperation.

void closeClientOperation() throws SQLException {
    try {
        if (stmtHandle != null) {
            TCloseOperationReq closeReq = new TCloseOperationReq(stmtHandle);
            TCloseOperationResp closeResp = client.CloseOperation(closeReq);
            Utils.verifySuccessWithInfo(closeResp.getStatus());
        }
    } catch (SQLException e) {
        throw e;
    } catch (Exception e) {
        throw new SQLException(e.toString(), "08S01", e);
    }
    isQueryClosed = true;
    isExecuteStatementFailed = false;
    stmtHandle = null;
}
Also used : SQLException(java.sql.SQLException) TCloseOperationResp(org.apache.hive.service.rpc.thrift.TCloseOperationResp) TCloseOperationReq(org.apache.hive.service.rpc.thrift.TCloseOperationReq) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLTimeoutException(java.sql.SQLTimeoutException) SQLException(java.sql.SQLException) TException(org.apache.thrift.TException)

Example 4 with TCloseOperationResp

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

the class ThriftCLIService method CloseOperation.

@Override
public TCloseOperationResp CloseOperation(TCloseOperationReq req) throws TException {
    TCloseOperationResp resp = new TCloseOperationResp();
    try {
        cliService.closeOperation(new OperationHandle(req.getOperationHandle()));
        resp.setStatus(OK_STATUS);
    } catch (Exception e) {
        LOG.error("Failed to close operation [request: {}]", req, e);
        resp.setStatus(HiveSQLException.toTStatus(e));
    }
    return resp;
}
Also used : TCloseOperationResp(org.apache.hive.service.rpc.thrift.TCloseOperationResp) OperationHandle(org.apache.hive.service.cli.OperationHandle) ServiceException(org.apache.hive.service.ServiceException) TException(org.apache.thrift.TException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) LoginException(javax.security.auth.login.LoginException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException)

Example 5 with TCloseOperationResp

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

the class ThriftCLIServiceClient method closeOperation.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#closeOperation(org.apache.hive.service.cli.OperationHandle)
   */
@Override
public void closeOperation(OperationHandle opHandle) throws HiveSQLException {
    try {
        TCloseOperationReq req = new TCloseOperationReq(opHandle.toTOperationHandle());
        TCloseOperationResp resp = cliService.CloseOperation(req);
        checkStatus(resp.getStatus());
    } catch (HiveSQLException e) {
        throw e;
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
}
Also used : HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TCloseOperationResp(org.apache.hive.service.rpc.thrift.TCloseOperationResp) TCloseOperationReq(org.apache.hive.service.rpc.thrift.TCloseOperationReq) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Aggregations

TCloseOperationResp (org.apache.hive.service.rpc.thrift.TCloseOperationResp)5 TCloseOperationReq (org.apache.hive.service.rpc.thrift.TCloseOperationReq)4 TException (org.apache.thrift.TException)4 SQLException (java.sql.SQLException)3 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)3 SQLTimeoutException (java.sql.SQLTimeoutException)2 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)2 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 LoginException (javax.security.auth.login.LoginException)1 ServiceException (org.apache.hive.service.ServiceException)1 OperationHandle (org.apache.hive.service.cli.OperationHandle)1 TApplicationException (org.apache.thrift.TApplicationException)1