hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1666478 - in /hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore: Deadline.java RawStoreProxy.java
Date Fri, 13 Mar 2015 15:20:07 GMT
Author: brock
Date: Fri Mar 13 15:20:06 2015
New Revision: 1666478

URL: http://svn.apache.org/r1666478
Log:
HIVE-9906 - Add timeout mechanism in RawStoreProxy (Dong Chen via Brock)

Modified:
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Deadline.java
    hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/RawStoreProxy.java

Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Deadline.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Deadline.java?rev=1666478&r1=1666477&r2=1666478&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Deadline.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Deadline.java Fri Mar 13
15:20:06 2015
@@ -100,6 +100,21 @@ public class Deadline {
   }
 
   /**
+   * Check whether the timer is started.
+   * @return
+   * @throws MetaException
+   */
+  public static boolean isStarted() throws MetaException {
+    Deadline deadline = getCurrentDeadline();
+    if (deadline != null) {
+      return deadline.startTime >= 0;
+    } else {
+      throw newMetaException(new DeadlineException("The threadlocal Deadline is null," +
+          " please register it firstly."));
+    }
+  }
+
+  /**
    * start the timer before a method is invoked.
    * @param method
    */

Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/RawStoreProxy.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/RawStoreProxy.java?rev=1666478&r1=1666477&r2=1666478&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/RawStoreProxy.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/RawStoreProxy.java Fri
Mar 13 15:20:06 2015
@@ -24,6 +24,7 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.lang.ClassUtils;
 import org.apache.hadoop.conf.Configuration;
@@ -93,9 +94,28 @@ public class RawStoreProxy implements In
   @Override
   public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
     Object ret = null;
+    boolean isTimerStarted = false;
 
     try {
+      try {
+        if (!Deadline.isStarted()) {
+          Deadline.startTimer(method.getName());
+          isTimerStarted = true;
+        }
+      } catch (MetaException e) {
+        // Deadline was not registered yet.
+        long timeout = HiveConf.getTimeVar(hiveConf,
+            HiveConf.ConfVars.METASTORE_CLIENT_SOCKET_TIMEOUT, TimeUnit.MILLISECONDS);
+        Deadline.registerIfNot(timeout);
+        Deadline.startTimer(method.getName());
+        isTimerStarted = true;
+      }
+
       ret = method.invoke(base, args);
+
+      if (isTimerStarted) {
+        Deadline.stopTimer();
+      }
     } catch (UndeclaredThrowableException e) {
       throw e.getCause();
     } catch (InvocationTargetException e) {



Mime
View raw message