use of org.apache.hive.service.cli.operation.OperationManager in project hive by apache.
the class TestSessionGlobalInitFile method doTestSessionGlobalInitFile.
/**
* create session, and fetch the property set in global init file. Test if
* the global init file .hiverc is loaded correctly by checking the expected
* setting property.
*/
private void doTestSessionGlobalInitFile() throws Exception {
OperationManager operationManager = service.getService().getSessionManager().getOperationManager();
SessionHandle sessionHandle = client.openSession(null, null, null);
// ensure there is no operation related object leak
Assert.assertEquals("Verifying all operations used for init file are closed", 0, operationManager.getOperations().size());
verifyInitProperty("a", "1", sessionHandle);
verifyInitProperty("b", "1", sessionHandle);
verifyInitProperty("c", "1", sessionHandle);
verifyInitProperty("hivevar:c", "1", sessionHandle);
verifyInitProperty("d", "1", sessionHandle);
/**
* TODO: client.executeStatement do not support listing resources command
* (beeline> list jar)
*/
// Assert.assertEquals("expected uri", api.getAddedResource("jar"));
Assert.assertEquals("Verifying all operations used for checks are closed", 0, operationManager.getOperations().size());
client.closeSession(sessionHandle);
}
use of org.apache.hive.service.cli.operation.OperationManager in project hive by apache.
the class TestSessionManagerMetrics method testActiveSessionMetrics.
@Test
public void testActiveSessionMetrics() throws Exception {
final CyclicBarrier ready = new CyclicBarrier(2);
CyclicBarrier completed = new CyclicBarrier(2);
String json = metrics.dumpJson();
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.GAUGE, MetricsConstant.HS2_ACTIVE_SESSIONS, 0);
SessionHandle handle = sm.openSession(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V9, "user", "passw", "127.0.0.1", new HashMap<String, String>());
final HiveSession session = sm.getSession(handle);
OperationManager operationManager = mock(OperationManager.class);
when(operationManager.newGetTablesOperation(session, "catalog", "schema", "table", null)).thenReturn(new BlockingOperation(session, OperationType.GET_TABLES, ready, completed));
session.setOperationManager(operationManager);
new Thread(new Runnable() {
@Override
public void run() {
try {
OperationHandle handle = session.getTables("catalog", "schema", "table", null);
session.closeOperation(handle);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
try {
ready.await();
} catch (InterruptedException | BrokenBarrierException e) {
// ignore
}
}
}
}).start();
ready.await(2, TimeUnit.SECONDS);
ready.reset();
json = metrics.dumpJson();
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.GAUGE, MetricsConstant.HS2_ACTIVE_SESSIONS, 1);
completed.await(2, TimeUnit.SECONDS);
ready.await(2, TimeUnit.SECONDS);
json = metrics.dumpJson();
MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.GAUGE, MetricsConstant.HS2_ACTIVE_SESSIONS, 0);
}
use of org.apache.hive.service.cli.operation.OperationManager in project hive by apache.
the class HiveSessionImpl method getTableTypes.
@Override
public OperationHandle getTableTypes() throws HiveSQLException {
acquire(true, true);
OperationManager operationManager = getOperationManager();
GetTableTypesOperation operation = operationManager.newGetTableTypesOperation(getSession());
OperationHandle opHandle = operation.getHandle();
try {
operation.run();
addOpHandle(opHandle);
return opHandle;
} catch (HiveSQLException e) {
operationManager.closeOperation(opHandle);
throw e;
} finally {
release(true, true);
}
}
use of org.apache.hive.service.cli.operation.OperationManager in project hive by apache.
the class HiveSessionImpl method getCatalogs.
@Override
public OperationHandle getCatalogs() throws HiveSQLException {
acquire(true, true);
OperationManager operationManager = getOperationManager();
GetCatalogsOperation operation = operationManager.newGetCatalogsOperation(getSession());
OperationHandle opHandle = operation.getHandle();
try {
operation.run();
addOpHandle(opHandle);
return opHandle;
} catch (HiveSQLException e) {
operationManager.closeOperation(opHandle);
throw e;
} finally {
release(true, true);
}
}
use of org.apache.hive.service.cli.operation.OperationManager in project hive by apache.
the class HiveSessionImpl method getCrossReference.
@Override
public OperationHandle getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws HiveSQLException {
acquire(true, true);
OperationManager operationManager = getOperationManager();
GetCrossReferenceOperation operation = operationManager.newGetCrossReferenceOperation(getSession(), primaryCatalog, primarySchema, primaryTable, foreignCatalog, foreignSchema, foreignTable);
OperationHandle opHandle = operation.getHandle();
try {
operation.run();
addOpHandle(opHandle);
return opHandle;
} catch (HiveSQLException e) {
operationManager.closeOperation(opHandle);
throw e;
} finally {
release(true, true);
}
}
Aggregations