Search in sources :

Example 1 with TCloseOperationReq

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

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

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

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

TCloseOperationReq (org.apache.hive.service.rpc.thrift.TCloseOperationReq)4 TCloseOperationResp (org.apache.hive.service.rpc.thrift.TCloseOperationResp)4 SQLException (java.sql.SQLException)3 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)3 TException (org.apache.thrift.TException)3 SQLTimeoutException (java.sql.SQLTimeoutException)2 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)1 TApplicationException (org.apache.thrift.TApplicationException)1