@Override public OperationHandle executeStatementAsync(SessionHandle sessionHandle, String statement, Map<String, String> confOverlay) throws HiveSQLException { return executeStatementInternal(sessionHandle, statement, confOverlay, true, 0); }
@Override public RowSet fetchResults(OperationHandle opHandle) throws HiveSQLException { return fetchResults( opHandle, FetchOrientation.FETCH_NEXT, defaultFetchRows, FetchType.QUERY_OUTPUT); }
@Override public synchronized void init(HiveConf hiveConf) { init(hiveConf, null); }
private void verifyInitProperty(String key, String value, SessionHandle sessionHandle) throws Exception { OperationHandle operationHandle = client.executeStatement(sessionHandle, "set " + key, null); RowSet rowSet = client.fetchResults(operationHandle); Assert.assertEquals(1, rowSet.numRows()); // we know rowSet has only one element Assert.assertEquals(key + "=" + value, rowSet.iterator().next()[0]); client.closeOperation(operationHandle); } }
private String getServerInstanceURI() throws Exception { if ((thriftCLIService == null) || (thriftCLIService.getServerIPAddress() == null)) { throw new Exception("Unable to get the server address; it hasn't been initialized yet."); } return thriftCLIService.getServerIPAddress().getHostName() + ":" + thriftCLIService.getPortNumber(); }
private String getUsername(HttpServletRequest request, String authType) throws HttpAuthenticationException { String creds[] = getAuthHeaderTokens(request, authType); // Username must be present if (creds[0] == null || creds[0].isEmpty()) { throw new HttpAuthenticationException("Authorization header received " + "from the client does not contain username."); } return creds[0]; }
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); }
static ThriftCLIServiceClient getServiceClientInternal() { for (Service service : hiveServer2.getServices()) { if (service instanceof ThriftBinaryCLIService) { return new ThriftCLIServiceClient((ThriftBinaryCLIService) service); } if (service instanceof ThriftHttpCLIService) { return new ThriftCLIServiceClient((ThriftHttpCLIService) service); } } throw new IllegalStateException("HiveServer2 not running Thrift service"); }
@Test public void testSessionGlobalInitFileWithUser() throws Exception { //Test when the session is opened by a user. (HiveSessionImplwithUGI) SessionHandle sessionHandle = client.openSession("hive", "password", null); verifyInitProperty("a", "1", sessionHandle); client.closeSession(sessionHandle); }
public String getServerHost() throws Exception { if ((thriftCLIService == null) || (thriftCLIService.getServerIPAddress() == null)) { throw new Exception("Unable to get the server address; it hasn't been initialized yet."); } return thriftCLIService.getServerIPAddress().getHostName(); }
@Override protected synchronized TTransport connect(HiveConf conf) throws HiveSQLException, TTransportException { connectCount++; return super.connect(conf); } }
@Override public synchronized void start() { super.start(); if (!isStarted && !isEmbedded) { initServer(); serverThread = new Thread(this); serverThread.setName("Thrift Server"); serverThread.start(); isStarted = true; } }
@Override public synchronized void stop() { if (isStarted && !isEmbedded) { if (serverThread != null) { serverThread.interrupt(); serverThread = null; } stopServer(); isStarted = false; } super.stop(); }
/** * @throws java.lang.Exception */ @AfterClass public static void tearDownAfterClass() throws Exception { stopHiveServer2(); }
/** * @throws java.lang.Exception */ @AfterClass public static void tearDownAfterClass() throws Exception { stopHiveServer2(); }
@Override public OperationHandle executeStatement(SessionHandle sessionHandle, String statement, Map<String, String> confOverlay, long queryTimeout) throws HiveSQLException { return executeStatementInternal(sessionHandle, statement, confOverlay, false, queryTimeout); }
private String getPassword(HttpServletRequest request, String authType) throws HttpAuthenticationException { String creds[] = getAuthHeaderTokens(request, authType); // Password must be present if (creds[1] == null || creds[1].isEmpty()) { throw new HttpAuthenticationException("Authorization header received " + "from the client does not contain username."); } return creds[1]; }
protected static ThriftCLIServiceClient getServiceClientInternal() { for (Service service : hiveServer2.getServices()) { if (service instanceof ThriftBinaryCLIService) { return new ThriftCLIServiceClient((ThriftBinaryCLIService) service); } if (service instanceof ThriftHttpCLIService) { return new ThriftCLIServiceClient((ThriftHttpCLIService) service); } } throw new IllegalStateException("HiveServer2 not running Thrift service"); }
@Override public OperationHandle executeStatementAsync(SessionHandle sessionHandle, String statement, Map<String, String> confOverlay, long queryTimeout) throws HiveSQLException { return executeStatementInternal(sessionHandle, statement, confOverlay, true, queryTimeout); }
@Override public OperationHandle executeStatement(SessionHandle sessionHandle, String statement, Map<String, String> confOverlay) throws HiveSQLException { return executeStatementInternal(sessionHandle, statement, confOverlay, false, 0); }