use of org.apache.hive.jdbc.Utils.JdbcConnectionParams in project hive by apache.
the class cbo_rp_TestJdbcDriver2 method testParseUrlHttpMode.
@Test
public void testParseUrlHttpMode() throws SQLException, JdbcUriParseException, ZooKeeperHiveClientException {
new HiveDriver();
for (String[] testValues : HTTP_URL_PROPERTIES) {
JdbcConnectionParams params = Utils.parseURL(testValues[0], new Properties());
assertEquals(params.getHost(), testValues[1]);
assertEquals(params.getPort(), Integer.parseInt(testValues[2]));
assertEquals(params.getDbName(), testValues[3]);
assertEquals(params.getSessionVars().get("transportMode"), testValues[4]);
assertEquals(params.getSessionVars().get("httpPath"), testValues[5]);
}
}
use of org.apache.hive.jdbc.Utils.JdbcConnectionParams in project hive by apache.
the class ZooKeeperHiveClientHelper method getDirectParamsList.
static List<JdbcConnectionParams> getDirectParamsList(JdbcConnectionParams connParams) throws ZooKeeperHiveClientException {
CuratorFramework zooKeeperClient = null;
try {
zooKeeperClient = getZkClient(connParams);
List<String> serverHosts = getServerHosts(connParams, zooKeeperClient);
final List<JdbcConnectionParams> directParamsList = new ArrayList<>();
// For each node
for (String serverNode : serverHosts) {
JdbcConnectionParams directConnParams = new JdbcConnectionParams(connParams);
directParamsList.add(directConnParams);
updateParamsWithZKServerNode(directConnParams, zooKeeperClient, serverNode);
}
return directParamsList;
} catch (Exception e) {
throw new ZooKeeperHiveClientException("Unable to read HiveServer2 configs from ZooKeeper", e);
} finally {
// Close the client connection with ZooKeeper
if (zooKeeperClient != null) {
zooKeeperClient.close();
}
}
}
use of org.apache.hive.jdbc.Utils.JdbcConnectionParams in project hive by apache.
the class TestJdbcDriver2 method testParseUrlHttpMode.
@Test
public void testParseUrlHttpMode() throws SQLException, JdbcUriParseException, ZooKeeperHiveClientException {
new HiveDriver();
for (String[] testValues : HTTP_URL_PROPERTIES) {
JdbcConnectionParams params = Utils.parseURL(testValues[0], new Properties());
assertEquals(params.getHost(), testValues[1]);
assertEquals(params.getPort(), Integer.parseInt(testValues[2]));
assertEquals(params.getDbName(), testValues[3]);
assertEquals(params.getSessionVars().get("transportMode"), testValues[4]);
assertEquals(params.getSessionVars().get("httpPath"), testValues[5]);
}
}
use of org.apache.hive.jdbc.Utils.JdbcConnectionParams in project hive by apache.
the class HiveDriver method parseURLforPropertyInfo.
/**
* Takes a url in the form of jdbc:hive://[hostname]:[port]/[db_name] and
* parses it. Everything after jdbc:hive// is optional.
*
* The output from Utils.parseUrl() is massaged for the needs of getPropertyInfo
* @param url
* @param defaults
* @return
* @throws java.sql.SQLException
*/
private Properties parseURLforPropertyInfo(String url, Properties defaults) throws SQLException {
Properties urlProps = (defaults != null) ? new Properties(defaults) : new Properties();
if (url == null || !url.startsWith(Utils.URL_PREFIX)) {
throw new SQLException("Invalid connection url: " + url);
}
JdbcConnectionParams params = null;
try {
params = Utils.parseURL(url, defaults);
} catch (ZooKeeperHiveClientException e) {
throw new SQLException(e);
}
String host = params.getHost();
if (host == null) {
host = "";
}
String port = Integer.toString(params.getPort());
if (host.equals("")) {
port = "";
} else if (port.equals("0") || port.equals("-1")) {
port = Utils.DEFAULT_PORT;
}
String db = params.getDbName();
urlProps.put(HOST_PROPERTY_KEY, host);
urlProps.put(PORT_PROPERTY_KEY, port);
urlProps.put(DBNAME_PROPERTY_KEY, db);
return urlProps;
}
Aggregations