You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by sp...@apache.org on 2016/09/28 21:18:08 UTC

[2/4] hive git commit: HIVE-14296: Session count is not decremented when HS2 clients do not shutdown cleanly. (Naveen Gangam, reviewed by Szehon Ho and Mohit Sabharwal)

HIVE-14296: Session count is not decremented when HS2 clients do not shutdown cleanly. (Naveen Gangam, reviewed by Szehon Ho and Mohit Sabharwal)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/fc902ffe
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/fc902ffe
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/fc902ffe

Branch: refs/heads/branch-2.1
Commit: fc902ffe6c57ea1126bf34400de3a38e1e60b9df
Parents: 2c95d36
Author: Sergio Pena <se...@cloudera.com>
Authored: Wed Sep 28 16:06:59 2016 -0500
Committer: Sergio Pena <se...@cloudera.com>
Committed: Wed Sep 28 16:06:59 2016 -0500

----------------------------------------------------------------------
 .../java/org/apache/hive/service/cli/session/SessionManager.java | 4 +++-
 .../org/apache/hive/service/cli/thrift/ThriftCLIService.java     | 3 ---
 2 files changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/fc902ffe/service/src/java/org/apache/hive/service/cli/session/SessionManager.java
----------------------------------------------------------------------
diff --git a/service/src/java/org/apache/hive/service/cli/session/SessionManager.java b/service/src/java/org/apache/hive/service/cli/session/SessionManager.java
index c2313c0..7bcf3a3 100644
--- a/service/src/java/org/apache/hive/service/cli/session/SessionManager.java
+++ b/service/src/java/org/apache/hive/service/cli/session/SessionManager.java
@@ -351,14 +351,16 @@ public class SessionManager extends CompositeService {
       throw new HiveSQLException("Failed to execute session hooks: " + e.getMessage(), e);
     }
     handleToSession.put(session.getSessionHandle(), session);
+    LOG.info("Session opened, " + session.getSessionHandle() + ", current sessions:" + getOpenSessionCount());
     return session;
   }
 
-  public void closeSession(SessionHandle sessionHandle) throws HiveSQLException {
+  public synchronized void closeSession(SessionHandle sessionHandle) throws HiveSQLException {
     HiveSession session = handleToSession.remove(sessionHandle);
     if (session == null) {
       throw new HiveSQLException("Session does not exist!");
     }
+    LOG.info("Session closed, " + sessionHandle + ", current sessions:" + getOpenSessionCount());
     try {
       session.close();
     } finally {

http://git-wip-us.apache.org/repos/asf/hive/blob/fc902ffe/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java
----------------------------------------------------------------------
diff --git a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java
index 24f1a61..e097b79 100644
--- a/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java
+++ b/service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java
@@ -117,7 +117,6 @@ public abstract class ThriftCLIService extends AbstractService implements TCLISe
   protected CLIService cliService;
   private static final TStatus OK_STATUS = new TStatus(TStatusCode.SUCCESS_STATUS);
   protected static HiveAuthFactory hiveAuthFactory;
-  private static final AtomicInteger sessionCount = new AtomicInteger();
 
   protected int portNum;
   protected InetAddress serverIPAddress;
@@ -320,7 +319,6 @@ public abstract class ThriftCLIService extends AbstractService implements TCLISe
       if (context != null) {
         context.setSessionHandle(sessionHandle);
       }
-      LOG.info("Opened a session, current sessions: " + sessionCount.incrementAndGet());
     } catch (Exception e) {
       LOG.warn("Error opening session: ", e);
       resp.setStatus(HiveSQLException.toTStatus(e));
@@ -466,7 +464,6 @@ public abstract class ThriftCLIService extends AbstractService implements TCLISe
     try {
       SessionHandle sessionHandle = new SessionHandle(req.getSessionHandle());
       cliService.closeSession(sessionHandle);
-      LOG.info("Closed a session, current sessions: " + sessionCount.decrementAndGet());
       resp.setStatus(OK_STATUS);
       ThriftCLIServerContext context =
         (ThriftCLIServerContext)currentServerContext.get();