public static CLIServiceClientWrapper newRetryingCLIServiceClient(HiveConf conf) throws HiveSQLException { RetryingThriftCLIServiceClient retryClient = new RetryingThriftCLIServiceClient(conf); TTransport tTransport = retryClient .connectWithRetry(conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT)); ICLIService cliService = (ICLIService) Proxy.newProxyInstance(RetryingThriftCLIServiceClient.class.getClassLoader(), CLIServiceClient.class.getInterfaces(), retryClient); return new CLIServiceClientWrapper(cliService, tTransport, conf); }
@Override public void close() { connected = false; if (hs2Client != null) { hs2Client.closeTransport(); } } }
public static RetryingThriftCLIServiceClient.CLIServiceClientWrapper newRetryingCLIServiceClient(HiveConf conf) throws Exception { RetryingThriftCLIServiceClientSasl retryClient = new RetryingThriftCLIServiceClientSasl(conf); TTransport tTransport = retryClient .connectWithRetry(conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT)); ICLIService cliService = (ICLIService) Proxy.newProxyInstance(RetryingThriftCLIServiceClientSasl.class.getClassLoader(), CLIServiceClient.class.getInterfaces(), retryClient); return new RetryingThriftCLIServiceClient.CLIServiceClientWrapper(cliService, tTransport); }
@Override public void close() { connected = false; if (hs2Client != null) { hs2Client.closeTransport(); } } }
public static CLIServiceClientWrapper newRetryingCLIServiceClient(HiveConf conf) throws HiveSQLException { RetryingThriftCLIServiceClient retryClient = new RetryingThriftCLIServiceClient(conf); TTransport tTransport = retryClient .connectWithRetry(conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT)); ICLIService cliService = (ICLIService) Proxy.newProxyInstance(RetryingThriftCLIServiceClient.class.getClassLoader(), CLIServiceClient.class.getInterfaces(), retryClient); return new CLIServiceClientWrapper(cliService, tTransport, conf); }
Map<String, String> conf = new HashMap<>(); conf.put(HiveConf.ConfVars.HIVE_SERVER2_CLOSE_SESSION_ON_DISCONNECT.varname, "false"); SessionHandle sessionHandle = client.openSession("anonymous", "anonymous", conf); assertNotNull(sessionHandle); HiveSession session = service.getSessionManager().getSession(sessionHandle); OperationHandle op1 = session.executeStatementAsync("show databases", null); assertNotNull(op1); client.closeTransport(); client.closeSession(sessionHandle); client.getOperationStatus(op, false); fail("Should have failed."); } catch (HiveSQLException ignored) {
RetryingThriftCLIServiceClientTest.handlerInst.callCount = 0; RetryingThriftCLIServiceClientTest.handlerInst.connectCount = 0; cliServiceClient.openSession("anonymous", "anonymous"); } catch (HiveSQLException exc) { exc.printStackTrace(); assertEquals(3, RetryingThriftCLIServiceClientTest.handlerInst.connectCount); } finally { cliServiceClient.closeTransport();
@Test public void testTransportClose() throws InterruptedException, HiveSQLException { hiveConf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT, 0); try { startHiveServer(); RetryingThriftCLIServiceClient.CLIServiceClientWrapper client = RetryingThriftCLIServiceClientTest.newRetryingCLIServiceClient(hiveConf); client.closeTransport(); try { client.openSession("anonymous", "anonymous"); fail("Shouldn't be able to open session when transport is closed."); } catch(HiveSQLException ignored) { } } finally { hiveConf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_CONNECTION_RETRY_LIMIT, 3); stopHiveServer(); } }
public static CLIServiceClientWrapper newRetryingCLIServiceClient(HiveConf conf) throws HiveSQLException { handlerInst = new RetryingThriftCLIServiceClientTest(conf); TTransport tTransport = handlerInst.connectWithRetry(conf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_CLIENT_RETRY_LIMIT)); ICLIService cliService = (ICLIService) Proxy.newProxyInstance(RetryingThriftCLIServiceClientTest.class.getClassLoader(), CLIServiceClient.class.getInterfaces(), handlerInst); return new CLIServiceClientWrapper(cliService, tTransport, conf); }