This is an automated email from the ASF dual-hosted git repository.

prasanthj pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/branch-3 by this push:
     new 91c243c  HIVE-21925: HiveConnection retries should support backoff 
(Rajkumar Singh reviewed by Prasanth Jayachandran)
91c243c is described below

commit 91c243c11a14534aa3e96f7ed5ce42fdfc656f24
Author: Rajkumar Singh <rajkumar.si...@cloudera.com>
AuthorDate: Sat Jul 6 22:01:15 2019 -0700

    HIVE-21925: HiveConnection retries should support backoff (Rajkumar Singh 
reviewed by Prasanth Jayachandran)
---
 jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java | 12 +++++++++++-
 jdbc/src/java/org/apache/hive/jdbc/Utils.java          |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java 
b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
index a4920bf..e3dda87 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
@@ -218,11 +218,16 @@ public class HiveConnection implements 
java.sql.Connection {
       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
       }
 
@@ -263,7 +268,12 @@ public class HiveConnection implements java.sql.Connection 
{
           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 42b3975..881c1d9 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 @@ public class Utils {
 
     // 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.

Reply via email to