use of org.apache.hive.service.cli.session.HiveSession in project hive by apache.
the class CLIService method executeStatementAsync.
/**
* Execute statement asynchronously on the server with a timeout. This is a non-blocking call
*/
@Override
public OperationHandle executeStatementAsync(SessionHandle sessionHandle, String statement, Map<String, String> confOverlay, long queryTimeout) throws HiveSQLException {
HiveSession session = sessionManager.getSession(sessionHandle);
// need to reset the monitor, as operation handle is not available down stream, Ideally the
// monitor should be associated with the operation handle.
session.getSessionState().updateProgressMonitor(null);
OperationHandle opHandle = session.executeStatementAsync(statement, confOverlay, queryTimeout);
LOG.debug(sessionHandle + ": executeStatementAsync()");
return opHandle;
}
use of org.apache.hive.service.cli.session.HiveSession in project hive by apache.
the class CLIService method executeStatement.
/**
* Execute statement on the server. This is a blocking call.
*/
@Override
public OperationHandle executeStatement(SessionHandle sessionHandle, String statement, Map<String, String> confOverlay) throws HiveSQLException {
HiveSession session = sessionManager.getSession(sessionHandle);
// need to reset the monitor, as operation handle is not available down stream, Ideally the
// monitor should be associated with the operation handle.
session.getSessionState().updateProgressMonitor(null);
OperationHandle opHandle = session.executeStatement(statement, confOverlay);
LOG.debug(sessionHandle + ": executeStatement()");
return opHandle;
}
use of org.apache.hive.service.cli.session.HiveSession in project hive by apache.
the class CLIService method executeStatement.
/**
* Execute statement on the server with a timeout. This is a blocking call.
*/
@Override
public OperationHandle executeStatement(SessionHandle sessionHandle, String statement, Map<String, String> confOverlay, long queryTimeout) throws HiveSQLException {
HiveSession session = sessionManager.getSession(sessionHandle);
// need to reset the monitor, as operation handle is not available down stream, Ideally the
// monitor should be associated with the operation handle.
session.getSessionState().updateProgressMonitor(null);
OperationHandle opHandle = session.executeStatement(statement, confOverlay, queryTimeout);
LOG.debug(sessionHandle + ": executeStatement()");
return opHandle;
}
use of org.apache.hive.service.cli.session.HiveSession in project hive by apache.
the class TestRetryingThriftCLIServiceClient method testSessionLifeAfterTransportClose.
@Test
public void testSessionLifeAfterTransportClose() throws InterruptedException, HiveSQLException {
try {
startHiveServer();
CLIService service = null;
for (Service s : server.getServices()) {
if (s instanceof CLIService) {
service = (CLIService) s;
}
}
if (service == null) {
service = new CLIService(server);
}
RetryingThriftCLIServiceClient.CLIServiceClientWrapper client = RetryingThriftCLIServiceClientTest.newRetryingCLIServiceClient(hiveConf);
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();
// Verify that session wasn't closed on transport close.
assertEquals(session, service.getSessionManager().getSession(sessionHandle));
// Should be able to execute without failure in the session whose transport has been closed.
OperationHandle op2 = session.executeStatementAsync("show databases", null);
assertNotNull(op2);
// Make new client, since transport was closed for the last one.
client = RetryingThriftCLIServiceClientTest.newRetryingCLIServiceClient(hiveConf);
client.closeSession(sessionHandle);
// operations will be lost once owning session is closed.
for (OperationHandle op : new OperationHandle[] { op1, op2 }) {
try {
client.getOperationStatus(op, false);
fail("Should have failed.");
} catch (HiveSQLException ignored) {
}
}
} finally {
stopHiveServer();
}
}
use of org.apache.hive.service.cli.session.HiveSession in project hive by apache.
the class TestSQLOperationMetrics method setup.
@Before
public void setup() throws Exception {
HiveConf conf = new HiveConf();
conf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_METRICS_ENABLED, true);
MetricsFactory.init(conf);
HiveSession session = mock(HiveSession.class);
when(session.getHiveConf()).thenReturn(conf);
when(session.getSessionState()).thenReturn(mock(SessionState.class));
when(session.getUserName()).thenReturn("userName");
operation = new SQLOperation(session, "select * from dummy", Maps.<String, String>newHashMap(), false, 0L);
metrics = (CodahaleMetrics) MetricsFactory.getInstance();
}
Aggregations