diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java index ec9c1932e5..cb0b0d1c92 100644 --- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java +++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java @@ -298,11 +298,16 @@ public HiveConnection(String uri, Properties info) throws SQLException { executeInitSql(); } else { int maxRetries = 1; + long retryInterval = 1000L; try { String strRetries = sessConfMap.get(JdbcConnectionParams.RETRIES); if (StringUtils.isNotBlank(strRetries)) { maxRetries = Integer.parseInt(strRetries); } + String strRetryInterval = sessConfMap.get(JdbcConnectionParams.RETRY_INTERVAL); + if(StringUtils.isNotBlank(strRetryInterval)){ + retryInterval = Long.parseLong(strRetryInterval); + } } catch(NumberFormatException e) { // Ignore the exception } @@ -343,7 +348,12 @@ public HiveConnection(String uri, Properties info) throws SQLException { if (numRetries >= maxRetries) { throw new SQLException(errMsg + e.getMessage(), " 08S01", e); } else { - LOG.warn(warnMsg + e.getMessage() + " Retrying " + numRetries + " of " + maxRetries); + LOG.warn(warnMsg + e.getMessage() + " Retrying " + numRetries + " of " + maxRetries+" with retry interval "+retryInterval+"ms"); + try { + Thread.sleep(retryInterval); + } catch (InterruptedException ex) { + //Ignore + } } } } diff --git a/jdbc/src/java/org/apache/hive/jdbc/Utils.java b/jdbc/src/java/org/apache/hive/jdbc/Utils.java index 3c18f09641..e23826eb56 100644 --- a/jdbc/src/java/org/apache/hive/jdbc/Utils.java +++ b/jdbc/src/java/org/apache/hive/jdbc/Utils.java @@ -81,6 +81,7 @@ // Retry setting static final String RETRIES = "retries"; + public static final String RETRY_INTERVAL = "retryInterval"; public static final String AUTH_TYPE = "auth"; // We're deprecating this variable's name.