hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jxi...@apache.org
Subject hive git commit: HIVE-15630: add operation handle before operation.run instead of after operation.run (Zhihai Xu via Jimmy Xiang)
Date Fri, 07 Apr 2017 17:57:13 GMT
Repository: hive
Updated Branches:
  refs/heads/master a5f94c071 -> 07224d22d


HIVE-15630: add operation handle before operation.run instead of after operation.run (Zhihai
Xu via Jimmy Xiang)


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

Branch: refs/heads/master
Commit: 07224d22d20b5640671d5ba1eceb5bd92537f2ef
Parents: a5f94c0
Author: Zhihai Xu <zhihaixu2012@gmail.com>
Authored: Fri Apr 7 10:48:40 2017 -0700
Committer: Jimmy Xiang <jxiang@apache.org>
Committed: Fri Apr 7 10:50:22 2017 -0700

----------------------------------------------------------------------
 .../service/cli/session/HiveSessionImpl.java    | 36 ++++++++++++++------
 1 file changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/07224d22/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
----------------------------------------------------------------------
diff --git a/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java b/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
index 418f453..7df4563 100644
--- a/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
+++ b/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
@@ -527,14 +527,15 @@ public class HiveSessionImpl implements HiveSession {
       operation = getOperationManager().newExecuteStatementOperation(getSession(), statement,
           confOverlay, runAsync, queryTimeout);
       opHandle = operation.getHandle();
-      operation.run();
       addOpHandle(opHandle);
+      operation.run();
       return opHandle;
     } catch (HiveSQLException e) {
       // Refering to SQLOperation.java, there is no chance that a HiveSQLException throws
and the
       // async background operation submits to thread pool successfully at the same time.
So, Cleanup
       // opHandle directly when got HiveSQLException
       if (opHandle != null) {
+        removeOpHandle(opHandle);
         getOperationManager().closeOperation(opHandle);
       }
       throw e;
@@ -567,10 +568,11 @@ public class HiveSessionImpl implements HiveSession {
     GetTypeInfoOperation operation = operationManager.newGetTypeInfoOperation(getSession());
     OperationHandle opHandle = operation.getHandle();
     try {
-      operation.run();
       addOpHandle(opHandle);
+      operation.run();
       return opHandle;
     } catch (HiveSQLException e) {
+      removeOpHandle(opHandle);
       operationManager.closeOperation(opHandle);
       throw e;
     } finally {
@@ -587,10 +589,11 @@ public class HiveSessionImpl implements HiveSession {
     GetCatalogsOperation operation = operationManager.newGetCatalogsOperation(getSession());
     OperationHandle opHandle = operation.getHandle();
     try {
-      operation.run();
       addOpHandle(opHandle);
+      operation.run();
       return opHandle;
     } catch (HiveSQLException e) {
+      removeOpHandle(opHandle);
       operationManager.closeOperation(opHandle);
       throw e;
     } finally {
@@ -608,10 +611,11 @@ public class HiveSessionImpl implements HiveSession {
         operationManager.newGetSchemasOperation(getSession(), catalogName, schemaName);
     OperationHandle opHandle = operation.getHandle();
     try {
-      operation.run();
       addOpHandle(opHandle);
+      operation.run();
       return opHandle;
     } catch (HiveSQLException e) {
+      removeOpHandle(opHandle);
       operationManager.closeOperation(opHandle);
       throw e;
     } finally {
@@ -630,10 +634,11 @@ public class HiveSessionImpl implements HiveSession {
         operationManager.newGetTablesOperation(getSession(), catalogName, schemaName, tableName,
tableTypes);
     OperationHandle opHandle = operation.getHandle();
     try {
-      operation.run();
       addOpHandle(opHandle);
+      operation.run();
       return opHandle;
     } catch (HiveSQLException e) {
+      removeOpHandle(opHandle);
       operationManager.closeOperation(opHandle);
       throw e;
     } finally {
@@ -650,10 +655,11 @@ public class HiveSessionImpl implements HiveSession {
     GetTableTypesOperation operation = operationManager.newGetTableTypesOperation(getSession());
     OperationHandle opHandle = operation.getHandle();
     try {
-      operation.run();
       addOpHandle(opHandle);
+      operation.run();
       return opHandle;
     } catch (HiveSQLException e) {
+      removeOpHandle(opHandle);
       operationManager.closeOperation(opHandle);
       throw e;
     } finally {
@@ -675,10 +681,11 @@ public class HiveSessionImpl implements HiveSession {
         catalogName, schemaName, tableName, columnName);
     OperationHandle opHandle = operation.getHandle();
     try {
-      operation.run();
       addOpHandle(opHandle);
+      operation.run();
       return opHandle;
     } catch (HiveSQLException e) {
+      removeOpHandle(opHandle);
       operationManager.closeOperation(opHandle);
       throw e;
     } finally {
@@ -692,6 +699,12 @@ public class HiveSessionImpl implements HiveSession {
     }
   }
 
+  private void removeOpHandle(OperationHandle opHandle) {
+    synchronized (opHandleSet) {
+      opHandleSet.remove(opHandle);
+    }
+  }
+
   @Override
   public OperationHandle getFunctions(String catalogName, String schemaName, String functionName)
       throws HiveSQLException {
@@ -702,10 +715,11 @@ public class HiveSessionImpl implements HiveSession {
         .newGetFunctionsOperation(getSession(), catalogName, schemaName, functionName);
     OperationHandle opHandle = operation.getHandle();
     try {
-      operation.run();
       addOpHandle(opHandle);
+      operation.run();
       return opHandle;
     } catch (HiveSQLException e) {
+      removeOpHandle(opHandle);
       operationManager.closeOperation(opHandle);
       throw e;
     } finally {
@@ -940,10 +954,11 @@ public class HiveSessionImpl implements HiveSession {
         .newGetPrimaryKeysOperation(getSession(), catalog, schema, table);
     OperationHandle opHandle = operation.getHandle();
     try {
-      operation.run();
       addOpHandle(opHandle);
+      operation.run();
       return opHandle;
     } catch (HiveSQLException e) {
+      removeOpHandle(opHandle);
       operationManager.closeOperation(opHandle);
       throw e;
     } finally {
@@ -964,10 +979,11 @@ public class HiveSessionImpl implements HiveSession {
          foreignSchema, foreignTable);
     OperationHandle opHandle = operation.getHandle();
     try {
-      operation.run();
       addOpHandle(opHandle);
+      operation.run();
       return opHandle;
     } catch (HiveSQLException e) {
+      removeOpHandle(opHandle);
       operationManager.closeOperation(opHandle);
       throw e;
     } finally {


Mime
View raw message