use of org.apache.hive.service.cli.CLIServiceClient in project hive by apache.
the class TestMiniHS2StateWithNoZookeeper method openSessionAndClose.
@Test
public void openSessionAndClose() throws Exception {
CLIServiceClient client = miniHS2.getServiceClient();
SessionHandle sessionHandle = client.openSession(null, null, null);
client.closeSession(sessionHandle);
Thread.sleep(100);
Assert.assertEquals(Service.STATE.STARTED, miniHS2.getState());
}
use of org.apache.hive.service.cli.CLIServiceClient in project hive by apache.
the class TestHs2Metrics method testClosedScopes.
@Test
public void testClosedScopes() throws Exception {
CLIServiceClient serviceClient = miniHS2.getServiceClient();
SessionHandle sessHandle = serviceClient.openSession("foo", "bar");
// this should error at analyze scope
Exception expectedException = null;
try {
serviceClient.executeStatement(sessHandle, "select aaa", confOverlay);
} catch (Exception e) {
expectedException = e;
}
Assert.assertNotNull("Expected semantic exception", expectedException);
// verify all scopes were recorded
CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance();
String json = metrics.dumpJson();
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.TIMER, "api_parse", 1);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.TIMER, "api_semanticAnalyze", 1);
// verify all scopes are closed.
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, "active_calls_api_parse", 0);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, "active_calls_api_semanticAnalyze", 0);
serviceClient.closeSession(sessHandle);
}
use of org.apache.hive.service.cli.CLIServiceClient in project hive by apache.
the class TestHs2Metrics method testMetrics.
@Test
public void testMetrics() throws Exception {
String tableName = "testMetrics";
CLIServiceClient serviceClient = miniHS2.getServiceClient();
SessionHandle sessHandle = serviceClient.openSession("foo", "bar");
// Block on semantic analysis to check 'active_calls'
serviceClient.executeStatement(sessHandle, "CREATE TABLE " + tableName + " (id INT)", confOverlay);
// check that all calls were recorded.
CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance();
String json = metrics.dumpJson();
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.TIMER, "api_hs2_operation_INITIALIZED", 1);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.TIMER, "api_hs2_operation_PENDING", 1);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.TIMER, "api_hs2_operation_RUNNING", 1);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, "hs2_completed_operation_FINISHED", 1);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.TIMER, "api_hs2_sql_operation_PENDING", 1);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.TIMER, "api_hs2_sql_operation_RUNNING", 1);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, "hs2_completed_sql_operation_FINISHED", 1);
// but there should be no more active calls.
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, "active_calls_api_semanticAnalyze", 0);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, "active_calls_api_compile", 0);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, "active_calls_api_hs2_operation_RUNNING", 0);
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, "active_calls_api_hs2_sql_operation_RUNNING", 0);
serviceClient.closeSession(sessHandle);
}
use of org.apache.hive.service.cli.CLIServiceClient in project hive by apache.
the class TestHiveServer2 method testConnection.
/**
* Open a new session and run a test query
* @throws Exception
*/
@Test
public void testConnection() throws Exception {
String tableName = "TestHiveServer2TestConnection";
CLIServiceClient serviceClient = miniHS2.getServiceClient();
SessionHandle sessHandle = serviceClient.openSession("foo", "bar");
serviceClient.executeStatement(sessHandle, "DROP TABLE IF EXISTS " + tableName, confOverlay);
serviceClient.executeStatement(sessHandle, "CREATE TABLE " + tableName + " (id INT)", confOverlay);
OperationHandle opHandle = serviceClient.executeStatement(sessHandle, "SHOW TABLES", confOverlay);
RowSet rowSet = serviceClient.fetchResults(opHandle);
assertFalse(rowSet.numRows() == 0);
serviceClient.executeStatement(sessHandle, "DROP TABLE IF EXISTS " + tableName, confOverlay);
serviceClient.closeSession(sessHandle);
}
use of org.apache.hive.service.cli.CLIServiceClient in project hive by apache.
the class TestHiveServer2SessionTimeout method testConnection.
@Test
public void testConnection() throws Exception {
CLIServiceClient serviceClient = miniHS2.getServiceClient();
SessionHandle sessHandle = serviceClient.openSession("foo", "bar");
OperationHandle handle = serviceClient.executeStatement(sessHandle, "SELECT 1", confOverlay);
Thread.sleep(7000);
try {
serviceClient.closeOperation(handle);
fail("Operation should have been closed by timeout!");
} catch (HiveSQLException e) {
assertTrue(StringUtils.stringifyException(e), e.getMessage().contains("Invalid OperationHandle"));
}
}
Aggregations