use of org.apache.hive.service.cli.SessionHandle in project hive by apache.
the class ThriftCLIService method CancelDelegationToken.
@Override
public TCancelDelegationTokenResp CancelDelegationToken(TCancelDelegationTokenReq req) throws TException {
TCancelDelegationTokenResp resp = new TCancelDelegationTokenResp();
if (hiveAuthFactory == null || !hiveAuthFactory.isSASLKerberosUser()) {
resp.setStatus(unsecureTokenErrorStatus());
} else {
try {
cliService.cancelDelegationToken(new SessionHandle(req.getSessionHandle()), hiveAuthFactory, req.getDelegationToken());
resp.setStatus(OK_STATUS);
} catch (HiveSQLException e) {
LOG.error("Error canceling delegation token", e);
resp.setStatus(HiveSQLException.toTStatus(e));
}
}
return resp;
}
use of org.apache.hive.service.cli.SessionHandle in project hive by apache.
the class MiniHS2 method waitForStartup.
private void waitForStartup() throws Exception {
int waitTime = 0;
long startupTimeout = 1000L * 1000L;
CLIServiceClient hs2Client = getServiceClientInternal();
SessionHandle sessionHandle = null;
do {
Thread.sleep(500L);
waitTime += 500L;
if (waitTime > startupTimeout) {
throw new TimeoutException("Couldn't access new HiveServer2: " + getJdbcURL());
}
try {
Map<String, String> sessionConf = new HashMap<String, String>();
/**
if (isUseMiniKdc()) {
getMiniKdc().loginUser(getMiniKdc().getDefaultUserPrincipal());
sessionConf.put("principal", serverPrincipal);
}
*/
sessionHandle = hs2Client.openSession("foo", "bar", sessionConf);
} catch (Exception e) {
// service not started yet
continue;
}
hs2Client.closeSession(sessionHandle);
break;
} while (true);
}
use of org.apache.hive.service.cli.SessionHandle in project hive by apache.
the class TestOperationLoggingLayout method setupSession.
private SessionHandle setupSession() throws Exception {
// Open a session
SessionHandle sessionHandle = client.openSession(null, null, null);
// Change lock manager to embedded mode
String queryString = "SET hive.lock.manager=" + "org.apache.hadoop.hive.ql.lockmgr.EmbeddedLockManager";
client.executeStatement(sessionHandle, queryString, null);
// Drop the table if it exists
queryString = "DROP TABLE IF EXISTS " + tableName;
client.executeStatement(sessionHandle, queryString, null);
// Create a test table
queryString = "create table " + tableName + " (key int, value string)";
client.executeStatement(sessionHandle, queryString, null);
// Load data
queryString = "load data local inpath '" + dataFile + "' into table " + tableName;
client.executeStatement(sessionHandle, queryString, null);
// Precondition check: verify whether the table is created and data is fetched correctly.
OperationHandle operationHandle = client.executeStatement(sessionHandle, sql, null);
RowSet rowSetResult = client.fetchResults(operationHandle);
Assert.assertEquals(500, rowSetResult.numRows());
Assert.assertEquals(238, rowSetResult.iterator().next()[0]);
Assert.assertEquals("val_238", rowSetResult.iterator().next()[1]);
return sessionHandle;
}
use of org.apache.hive.service.cli.SessionHandle in project hive by apache.
the class TestQueryDisplay method testQueryDisplay.
/**
* Test if query display captures information on current/historic SQL operations.
*/
@Test
public void testQueryDisplay() throws Exception {
HiveSession session = sessionManager.createSession(new SessionHandle(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8), TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8, "testuser", "", "", new HashMap<String, String>(), false, "");
SessionState.start(conf);
OperationHandle opHandle1 = session.executeStatement("show databases", null);
SessionState.start(conf);
OperationHandle opHandle2 = session.executeStatement("show tables", null);
List<SQLOperationDisplay> liveSqlOperations, historicSqlOperations;
liveSqlOperations = sessionManager.getOperationManager().getLiveSqlOperations();
historicSqlOperations = sessionManager.getOperationManager().getHistoricalSQLOperations();
Assert.assertEquals(liveSqlOperations.size(), 2);
Assert.assertEquals(historicSqlOperations.size(), 0);
verifyDDL(liveSqlOperations.get(0), "show databases", opHandle1.getHandleIdentifier().toString(), false);
verifyDDL(liveSqlOperations.get(1), "show tables", opHandle2.getHandleIdentifier().toString(), false);
session.closeOperation(opHandle1);
liveSqlOperations = sessionManager.getOperationManager().getLiveSqlOperations();
historicSqlOperations = sessionManager.getOperationManager().getHistoricalSQLOperations();
Assert.assertEquals(liveSqlOperations.size(), 1);
Assert.assertEquals(historicSqlOperations.size(), 1);
verifyDDL(historicSqlOperations.get(0), "show databases", opHandle1.getHandleIdentifier().toString(), true);
verifyDDL(liveSqlOperations.get(0), "show tables", opHandle2.getHandleIdentifier().toString(), false);
session.closeOperation(opHandle2);
liveSqlOperations = sessionManager.getOperationManager().getLiveSqlOperations();
historicSqlOperations = sessionManager.getOperationManager().getHistoricalSQLOperations();
Assert.assertEquals(liveSqlOperations.size(), 0);
Assert.assertEquals(historicSqlOperations.size(), 2);
verifyDDL(historicSqlOperations.get(1), "show databases", opHandle1.getHandleIdentifier().toString(), true);
verifyDDL(historicSqlOperations.get(0), "show tables", opHandle2.getHandleIdentifier().toString(), true);
session.close();
}
use of org.apache.hive.service.cli.SessionHandle in project hive by apache.
the class TestQueryDisplay method testWebUI.
/**
* Test if webui captures information on current/historic SQL operations.
*/
@Test
public void testWebUI() throws Exception {
HiveSession session = sessionManager.createSession(new SessionHandle(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8), TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8, "testuser", "", "", new HashMap<String, String>(), false, "");
SessionState.start(conf);
OperationHandle opHandle1 = session.executeStatement("show databases", null);
SessionState.start(conf);
OperationHandle opHandle2 = session.executeStatement("show tables", null);
verifyDDLHtml("show databases", opHandle1.getHandleIdentifier().toString());
verifyDDLHtml("show tables", opHandle2.getHandleIdentifier().toString());
session.closeOperation(opHandle1);
session.closeOperation(opHandle2);
verifyDDLHtml("show databases", opHandle1.getHandleIdentifier().toString());
verifyDDLHtml("show tables", opHandle2.getHandleIdentifier().toString());
session.close();
}
Aggregations