diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java index e0d2d6d..8dadda7 100644 --- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java +++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java @@ -218,7 +218,7 @@ private String getServerHttpUrl(boolean useSsl) { String schemeName = useSsl ? "https" : "http"; // http path should begin with "/" String httpPath; - httpPath = hiveConfMap.get(JdbcConnectionParams.HTTP_PATH); + httpPath = sessConfMap.get(JdbcConnectionParams.HTTP_PATH); if (httpPath == null) { httpPath = "/"; } else if (!httpPath.startsWith("/")) { @@ -485,7 +485,7 @@ private boolean isKerberosAuthMode() { } private boolean isHttpTransportMode() { - String transportMode = hiveConfMap.get(JdbcConnectionParams.TRANSPORT_MODE); + String transportMode = sessConfMap.get(JdbcConnectionParams.TRANSPORT_MODE); if(transportMode != null && (transportMode.equalsIgnoreCase("http"))) { return true; } diff --git a/jdbc/src/java/org/apache/hive/jdbc/Utils.java b/jdbc/src/java/org/apache/hive/jdbc/Utils.java index 8961e2b..24189ea 100644 --- a/jdbc/src/java/org/apache/hive/jdbc/Utils.java +++ b/jdbc/src/java/org/apache/hive/jdbc/Utils.java @@ -66,7 +66,9 @@ // Client param names: static final String AUTH_TYPE = "auth"; - static final String AUTH_QOP = "sasl.qop"; + // We're deprecating this variable's name. + static final String AUTH_QOP_DEPRECATED = "sasl.qop"; + static final String AUTH_QOP = "saslQop"; static final String AUTH_SIMPLE = "noSasl"; static final String AUTH_TOKEN = "delegationToken"; static final String AUTH_USER = "user"; @@ -79,8 +81,14 @@ static final String USE_SSL = "ssl"; static final String SSL_TRUST_STORE = "sslTrustStore"; static final String SSL_TRUST_STORE_PASSWORD = "trustStorePassword"; - static final String TRANSPORT_MODE = "hive.server2.transport.mode"; - static final String HTTP_PATH = "hive.server2.thrift.http.path"; + // We're deprecating the name and placement of this in the parsed map (from hive conf vars to + // hive session vars). + static final String TRANSPORT_MODE_DEPRECATED = "hive.server2.transport.mode"; + static final String TRANSPORT_MODE = "transportMode"; + // We're deprecating the name and placement of this in the parsed map (from hive conf vars to + // hive session vars). + static final String HTTP_PATH_DEPRECATED = "hive.server2.thrift.http.path"; + static final String HTTP_PATH = "httpPath"; static final String SERVICE_DISCOVERY_MODE = "serviceDiscoveryMode"; // Don't use dynamic serice discovery static final String SERVICE_DISCOVERY_MODE_NONE = "none"; @@ -287,6 +295,10 @@ public static JdbcConnectionParams parseURL(String uri) throws JdbcUriParseExcep // key=value pattern Pattern pattern = Pattern.compile("([^;]*)=([^;]*)[;]?"); + Map sessionVarMap = connParams.getSessionVars(); + Map hiveConfMap = connParams.getHiveConfs(); + Map hiveVarMap = connParams.getHiveVars(); + // dbname and session settings String sessVars = jdbcURI.getPath(); if ((sessVars != null) && !sessVars.isEmpty()) { @@ -303,7 +315,7 @@ public static JdbcConnectionParams parseURL(String uri) throws JdbcUriParseExcep if (sessVars != null) { Matcher sessMatcher = pattern.matcher(sessVars); while (sessMatcher.find()) { - if (connParams.getSessionVars().put(sessMatcher.group(1), sessMatcher.group(2)) != null) { + if (sessionVarMap.put(sessMatcher.group(1), sessMatcher.group(2)) != null) { throw new JdbcUriParseException("Bad URL format: Multiple values for property " + sessMatcher.group(1)); } @@ -320,7 +332,7 @@ public static JdbcConnectionParams parseURL(String uri) throws JdbcUriParseExcep if (confStr != null) { Matcher confMatcher = pattern.matcher(confStr); while (confMatcher.find()) { - connParams.getHiveConfs().put(confMatcher.group(1), confMatcher.group(2)); + hiveConfMap.put(confMatcher.group(1), confMatcher.group(2)); } } @@ -329,10 +341,33 @@ public static JdbcConnectionParams parseURL(String uri) throws JdbcUriParseExcep if (varStr != null) { Matcher varMatcher = pattern.matcher(varStr); while (varMatcher.find()) { - connParams.getHiveVars().put(varMatcher.group(1), varMatcher.group(2)); + hiveVarMap.put(varMatcher.group(1), varMatcher.group(2)); } } + // Handle all deprecations here: + String newUsage; + // Handle deprecation of AUTH_QOP_DEPRECATED + newUsage = + "jdbc:hive2://:/dbName;" + JdbcConnectionParams.AUTH_QOP + "="; + handleParamDeprecation(sessionVarMap, sessionVarMap, JdbcConnectionParams.AUTH_QOP_DEPRECATED, + JdbcConnectionParams.AUTH_QOP, newUsage); + + // Handle deprecation of TRANSPORT_MODE_DEPRECATED + newUsage = + "jdbc:hive2://:/dbName;" + JdbcConnectionParams.TRANSPORT_MODE + + "="; + handleParamDeprecation(hiveConfMap, sessionVarMap, + JdbcConnectionParams.TRANSPORT_MODE_DEPRECATED, JdbcConnectionParams.TRANSPORT_MODE, + newUsage); + + // Handle deprecation of TRANSPORT_MODE_DEPRECATED + newUsage = + "jdbc:hive2://:/dbName;" + JdbcConnectionParams.HTTP_PATH + + "="; + handleParamDeprecation(hiveConfMap, sessionVarMap, JdbcConnectionParams.HTTP_PATH_DEPRECATED, + JdbcConnectionParams.HTTP_PATH, newUsage); + // Extract host, port if (connParams.isEmbeddedMode()) { // In case of embedded mode we were supplied with an empty authority. @@ -360,6 +395,25 @@ public static JdbcConnectionParams parseURL(String uri) throws JdbcUriParseExcep } /** + * Remove the deprecatedName param from the fromMap and put the key value in the toMap. + * Also log a deprecation message for the client. + * @param fromMap + * @param toMap + * @param oldName + * @param newName + */ + private static void handleParamDeprecation(Map fromMap, Map toMap, + String deprecatedName, String newName, String newUsage) { + if (fromMap.containsKey(deprecatedName)) { + LOG.warn("***** JDBC param deprecation *****"); + LOG.warn("The use of " + deprecatedName + " is deprecated."); + LOG.warn("Please use " + newName +" like so: " + newUsage); + String paramValue = fromMap.remove(deprecatedName); + toMap.put(newName, paramValue); + } + } + + /** * Get the authority string from the supplied uri, which could potentially contain multiple * host:port pairs. *