Search in sources :

Example 6 with CLIService

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

the class TestPluggableHiveSessionImpl method testSessionImpl.

@Test
public void testSessionImpl() throws Exception {
    HiveConf hiveConf = new HiveConf();
    hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER.getDefaultValue());
    hiveConf.setVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_CLASSNAME, SampleHiveSessionImpl.class.getName());
    hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS, false);
    CLIService cliService = new CLIService(null);
    cliService.init(hiveConf);
    ThriftBinaryCLIService service = new ThriftBinaryCLIService(cliService, null);
    service.init(hiveConf);
    ThriftCLIServiceClient client = new ThriftCLIServiceClient(service);
    SessionHandle sessionHandle = null;
    sessionHandle = client.openSession("tom", "password");
    assertEquals(SampleHiveSessionImpl.class.getName(), service.getHiveConf().getVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_CLASSNAME));
    HiveSession session = cliService.getSessionManager().getSession(sessionHandle);
    assertEquals(SampleHiveSessionImpl.MAGIC_RETURN_VALUE, session.getNoOperationTime());
    client.closeSession(sessionHandle);
}
Also used : ThriftBinaryCLIService(org.apache.hive.service.cli.thrift.ThriftBinaryCLIService) HiveConf(org.apache.hadoop.hive.conf.HiveConf) SessionHandle(org.apache.hive.service.cli.SessionHandle) CLIService(org.apache.hive.service.cli.CLIService) ThriftBinaryCLIService(org.apache.hive.service.cli.thrift.ThriftBinaryCLIService) ThriftCLIServiceClient(org.apache.hive.service.cli.thrift.ThriftCLIServiceClient) Test(org.junit.Test)

Example 7 with CLIService

use of org.apache.hive.service.cli.CLIService in project cdap by caskdata.

the class Hive14ExploreService method initOperationStatus.

private Method initOperationStatus() {
    /*
    Hive 1.2.1000.2.6.0.0-598, that ships with HDP 2.6.0 introduced a change as part of
    https://issues.apache.org/jira/browse/HIVE-15473 in the getOperationStatus method and introduced a boolean argument
    to get the progress update for the operation. Previous versions of the method just took an {@link OperationHandle}
    as the single argument.
    To handle this we are using reflection to find out how many arguments the method takes and then call it accordingly.
     */
    CLIService cliService = getCliService();
    Method getOperationStatus = null;
    for (Method method : cliService.getClass().getMethods()) {
        if ("getOperationStatus".equals(method.getName())) {
            getOperationStatus = method;
            break;
        }
    }
    if (getOperationStatus == null) {
        throw new RuntimeException("Unable to find getOperationStatus method from the Hive CLIService.");
    }
    return getOperationStatus;
}
Also used : Method(java.lang.reflect.Method) CLIService(org.apache.hive.service.cli.CLIService)

Aggregations

CLIService (org.apache.hive.service.cli.CLIService)7 ThriftBinaryCLIService (org.apache.hive.service.cli.thrift.ThriftBinaryCLIService)4 HiveConf (org.apache.hadoop.hive.conf.HiveConf)3 SessionHandle (org.apache.hive.service.cli.SessionHandle)3 ThriftCLIService (org.apache.hive.service.cli.thrift.ThriftCLIService)2 ThriftCLIServiceClient (org.apache.hive.service.cli.thrift.ThriftCLIServiceClient)2 Test (org.junit.Test)2 QueryStatus (co.cask.cdap.proto.QueryStatus)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 TimeoutException (java.util.concurrent.TimeoutException)1 OptionBuilder (org.apache.commons.cli.OptionBuilder)1 Hive (org.apache.hadoop.hive.ql.metadata.Hive)1 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)1 HttpServer (org.apache.hive.http.HttpServer)1 ServiceException (org.apache.hive.service.ServiceException)1 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)1 OperationStatus (org.apache.hive.service.cli.OperationStatus)1