Search in sources :

Example 6 with TOpenSessionResp

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

the class HiveConnection method openSession.

private void openSession(TOpenSessionReq openReq) throws TException, SQLException {
    TOpenSessionResp openResp = client.OpenSession(openReq);
    // Populate a given configuration from HS2 server HiveConf, only if that configuration
    // is not already present in Connection parameter HiveConf i.e., client side configuration
    // takes precedence over the server side configuration.
    Map<String, String> serverHiveConf = openResp.getConfiguration();
    updateServerHiveConf(serverHiveConf, connParams);
    // validate connection
    Utils.verifySuccess(openResp.getStatus());
    if (!supportedProtocols.contains(openResp.getServerProtocolVersion())) {
        throw new TException("Unsupported Hive2 protocol");
    }
    protocol = openResp.getServerProtocolVersion();
    sessHandle = openResp.getSessionHandle();
    final String serverFetchSizeString = openResp.getConfiguration().get(ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE.varname);
    if (serverFetchSizeString == null) {
        throw new IllegalStateException("Server returned a null default fetch size. Check that " + ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE.varname + " is configured correctly.");
    }
    this.defaultFetchSize = Integer.parseInt(serverFetchSizeString);
    if (this.defaultFetchSize <= 0) {
        throw new IllegalStateException("Default fetch size must be greater than 0");
    }
}
Also used : TException(org.apache.thrift.TException) TOpenSessionResp(org.apache.hive.service.rpc.thrift.TOpenSessionResp)

Aggregations

TOpenSessionResp (org.apache.hive.service.rpc.thrift.TOpenSessionResp)6 TOpenSessionReq (org.apache.hive.service.rpc.thrift.TOpenSessionReq)4 TCLIService (org.apache.hive.service.rpc.thrift.TCLIService)3 TException (org.apache.thrift.TException)3 HashMap (java.util.HashMap)2 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)2 SessionHandle (org.apache.hive.service.cli.SessionHandle)2 TExecuteStatementReq (org.apache.hive.service.rpc.thrift.TExecuteStatementReq)2 TSessionHandle (org.apache.hive.service.rpc.thrift.TSessionHandle)2 TTransport (org.apache.thrift.transport.TTransport)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 LoginException (javax.security.auth.login.LoginException)1 CodahaleMetrics (org.apache.hadoop.hive.common.metrics.metrics2.CodahaleMetrics)1 HiveAuthzContext (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveAuthzContext)1 HiveOperationType (org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType)1