hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1476647 - /hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
Date Sat, 27 Apr 2013 17:56:00 GMT
Author: hashutosh
Date: Sat Apr 27 17:56:00 2013
New Revision: 1476647

URL: http://svn.apache.org/r1476647
Log:
HIVE-4398 : HS2 Resource leak: operation handles not cleaned when originating session is closed
(Ashish Vaidya via Ashutosh Chauhan)

Modified:
    hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java

Modified: hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java?rev=1476647&r1=1476646&r2=1476647&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java Sat
Apr 27 17:56:00 2013
@@ -19,8 +19,10 @@
 package org.apache.hive.service.cli.session;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
@@ -64,6 +66,7 @@ public class HiveSessionImpl implements 
   private SessionManager sessionManager;
   private OperationManager operationManager;
   private IMetaStoreClient metastoreClient = null;
+  private final Set<OperationHandle> opHandleSet = new HashSet<OperationHandle>();
 
   public HiveSessionImpl(String username, String password, Map<String, String> sessionConf)
{
     this.username = username;
@@ -164,7 +167,9 @@ public class HiveSessionImpl implements 
       ExecuteStatementOperation operation = getOperationManager()
           .newExecuteStatementOperation(getSession(), statement, confOverlay);
       operation.run();
-      return operation.getHandle();
+      OperationHandle opHandle = operation.getHandle();
+      opHandleSet.add(opHandle);
+      return opHandle;
     } finally {
       release();
     }
@@ -176,7 +181,9 @@ public class HiveSessionImpl implements 
     try {
       GetTypeInfoOperation operation = getOperationManager().newGetTypeInfoOperation(getSession());
       operation.run();
-      return operation.getHandle();
+      OperationHandle opHandle = operation.getHandle();
+      opHandleSet.add(opHandle);
+      return opHandle;
     } finally {
       release();
     }
@@ -188,7 +195,9 @@ public class HiveSessionImpl implements 
     try {
       GetCatalogsOperation operation = getOperationManager().newGetCatalogsOperation(getSession());
       operation.run();
-      return operation.getHandle();
+      OperationHandle opHandle = operation.getHandle();
+      opHandleSet.add(opHandle);
+      return opHandle;
     } finally {
       release();
     }
@@ -201,7 +210,9 @@ public class HiveSessionImpl implements 
       GetSchemasOperation operation =
           getOperationManager().newGetSchemasOperation(getSession(), catalogName, schemaName);
       operation.run();
-      return operation.getHandle();
+      OperationHandle opHandle = operation.getHandle();
+      opHandleSet.add(opHandle);
+      return opHandle;
     } finally {
       release();
     }
@@ -215,7 +226,9 @@ public class HiveSessionImpl implements 
       MetadataOperation operation =
           getOperationManager().newGetTablesOperation(getSession(), catalogName, schemaName,
tableName, tableTypes);
       operation.run();
-      return operation.getHandle();
+      OperationHandle opHandle = operation.getHandle();
+      opHandleSet.add(opHandle);
+      return opHandle;
     } finally {
       release();
     }
@@ -227,7 +240,9 @@ public class HiveSessionImpl implements 
     try {
       GetTableTypesOperation operation = getOperationManager().newGetTableTypesOperation(getSession());
       operation.run();
-      return operation.getHandle();
+      OperationHandle opHandle = operation.getHandle();
+      opHandleSet.add(opHandle);
+      return opHandle;
     } finally {
       release();
     }
@@ -240,7 +255,9 @@ public class HiveSessionImpl implements 
     GetColumnsOperation operation = getOperationManager().newGetColumnsOperation(getSession(),
         catalogName, schemaName, tableName, columnName);
     operation.run();
-    return operation.getHandle();
+    OperationHandle opHandle = operation.getHandle();
+    opHandleSet.add(opHandle);
+    return opHandle;
     } finally {
       release();
     }
@@ -253,7 +270,9 @@ public class HiveSessionImpl implements 
       GetFunctionsOperation operation = getOperationManager()
           .newGetFunctionsOperation(getSession(), catalogName, schemaName, functionName);
       operation.run();
-      return operation.getHandle();
+      OperationHandle opHandle = operation.getHandle();
+      opHandleSet.add(opHandle);
+      return opHandle;
     } finally {
       release();
     }
@@ -270,6 +289,11 @@ public class HiveSessionImpl implements 
       if (metastoreClient != null) {
         metastoreClient.close();
       }
+      // Iterate through the opHandles and close their operations
+      for (OperationHandle opHandle : opHandleSet) {
+        operationManager.closeOperation(opHandle);
+      }
+      opHandleSet.clear();
     } finally {
       release();
     }
@@ -300,7 +324,8 @@ public class HiveSessionImpl implements 
   public void closeOperation(OperationHandle opHandle) throws HiveSQLException {
     acquire();
     try {
-      sessionManager.getOperationManager().closeOperation(opHandle);
+      operationManager.closeOperation(opHandle);
+      opHandleSet.remove(opHandle);
     } finally {
       release();
     }
@@ -341,4 +366,4 @@ public class HiveSessionImpl implements 
   protected HiveSession getSession() {
     return this;
   }
-}
+}
\ No newline at end of file



Mime
View raw message