You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2017/03/13 19:42:29 UTC
[28/46] hive git commit: HIVE-16172: Switch to a fairness lock to
synchronize HS2 thrift client (Tao Li reviewed by Vaibhav Gumashta)
HIVE-16172: Switch to a fairness lock to synchronize HS2 thrift client (Tao Li reviewed by Vaibhav Gumashta)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/7071db4b
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/7071db4b
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/7071db4b
Branch: refs/heads/hive-14535
Commit: 7071db4b466e76dc3d19d5db763ec4116d2638d3
Parents: 9cccb95
Author: Vaibhav Gumashta <vg...@hortonworks.com>
Authored: Fri Mar 10 09:13:27 2017 -0800
Committer: Vaibhav Gumashta <vg...@hortonworks.com>
Committed: Fri Mar 10 09:13:27 2017 -0800
----------------------------------------------------------------------
jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/7071db4b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
----------------------------------------------------------------------
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
index ed899c6..1695c5d 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
@@ -106,6 +106,7 @@ import java.util.Map.Entry;
import java.util.Properties;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReentrantLock;
/**
* HiveConnection.
@@ -1491,6 +1492,7 @@ public class HiveConnection implements java.sql.Connection {
private static class SynchronizedHandler implements InvocationHandler {
private final TCLIService.Iface client;
+ private final ReentrantLock lock = new ReentrantLock(true);
SynchronizedHandler(TCLIService.Iface client) {
this.client = client;
@@ -1500,9 +1502,8 @@ public class HiveConnection implements java.sql.Connection {
public Object invoke(Object proxy, Method method, Object [] args)
throws Throwable {
try {
- synchronized (client) {
- return method.invoke(client, args);
- }
+ lock.lock();
+ return method.invoke(client, args);
} catch (InvocationTargetException e) {
// all IFace APIs throw TException
if (e.getTargetException() instanceof TException) {
@@ -1514,6 +1515,8 @@ public class HiveConnection implements java.sql.Connection {
}
} catch (Exception e) {
throw new TException("Error in calling method " + method.getName(), e);
+ } finally {
+ lock.unlock();
}
}
}