use of org.apache.hive.jdbc.HiveConnection in project incubator-gobblin by apache.
the class HiveProxyQueryExecutor method setProxiedConnection.
private synchronized void setProxiedConnection(final List<String> proxies) throws IOException, InterruptedException, TException {
Preconditions.checkArgument(this.state.contains(ConfigurationKeys.SUPER_USER_KEY_TAB_LOCATION), "Missing required property " + ConfigurationKeys.SUPER_USER_KEY_TAB_LOCATION);
String superUser = this.state.getProp(ComplianceConfigurationKeys.GOBBLIN_COMPLIANCE_SUPER_USER);
String keytabLocation = this.state.getProp(ConfigurationKeys.SUPER_USER_KEY_TAB_LOCATION);
String realm = this.state.getProp(ConfigurationKeys.KERBEROS_REALM);
UserGroupInformation loginUser = UserGroupInformation.loginUserFromKeytabAndReturnUGI(HostUtils.getPrincipalUsingHostname(superUser, realm), keytabLocation);
loginUser.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws MetaException, SQLException, ClassNotFoundException {
for (String proxy : proxies) {
HiveConnection hiveConnection = getHiveConnection(Optional.fromNullable(proxy));
Statement statement = hiveConnection.createStatement();
statementMap.put(proxy, statement);
connectionMap.put(proxy, hiveConnection);
for (String setting : settings) {
statement.execute(setting);
}
}
return null;
}
});
}
use of org.apache.hive.jdbc.HiveConnection in project incubator-gobblin by apache.
the class HiveProxyQueryExecutor method setConnection.
private synchronized void setConnection() throws ClassNotFoundException, SQLException {
HiveConnection hiveConnection = getHiveConnection(Optional.<String>absent());
Statement statement = hiveConnection.createStatement();
this.statementMap.put(DEFAULT, statement);
this.connectionMap.put(DEFAULT, hiveConnection);
for (String setting : settings) {
statement.execute(setting);
}
}
Aggregations