tephra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From go...@apache.org
Subject incubator-tephra git commit: (TEPHRA-226) Use older API to run as login user
Date Mon, 06 Mar 2017 21:44:44 GMT
Repository: incubator-tephra
Updated Branches:
  refs/heads/release/0.11.0-incubating 808ed2e3f -> 95c6bfb6b


(TEPHRA-226) Use older API to run as login user

This closes #39 from GitHub.

Signed-off-by: Gokul Gunasekaran <gokul@cask.co>


Project: http://git-wip-us.apache.org/repos/asf/incubator-tephra/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tephra/commit/95c6bfb6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tephra/tree/95c6bfb6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tephra/diff/95c6bfb6

Branch: refs/heads/release/0.11.0-incubating
Commit: 95c6bfb6b4391686745499e19966a87c528b1ddd
Parents: 808ed2e
Author: Gokul Gunasekaran <gokul@cask.co>
Authored: Wed Mar 1 14:19:04 2017 -0800
Committer: Gokul Gunasekaran <gokul@cask.co>
Committed: Mon Mar 6 13:44:37 2017 -0800

----------------------------------------------------------------------
 .../hbase/txprune/PruneUpperBoundWriter.java      |  2 +-
 .../hbase/txprune/PruneUpperBoundWriter.java      | 18 +++++++++++++-----
 .../hbase/txprune/PruneUpperBoundWriter.java      | 18 +++++++++++++-----
 .../hbase/txprune/PruneUpperBoundWriter.java      | 18 +++++++++++++-----
 4 files changed, 40 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tephra/blob/95c6bfb6/tephra-hbase-compat-0.96/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
----------------------------------------------------------------------
diff --git a/tephra-hbase-compat-0.96/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
b/tephra-hbase-compat-0.96/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
index 7e4a0fa..1c26ef1 100644
--- a/tephra-hbase-compat-0.96/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
+++ b/tephra-hbase-compat-0.96/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
@@ -161,7 +161,7 @@ public class PruneUpperBoundWriter extends AbstractIdleService {
   private void handleException(Exception ex) {
     LOG.warn("Cannot record prune upper bound for a region to table " +
                tableName.getNamespaceAsString() + ":" + tableName.getNameAsString(), ex);
-    if (ex instanceof IOException) {
+    if (ex instanceof InterruptedException) {
       Thread.currentThread().interrupt();
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-tephra/blob/95c6bfb6/tephra-hbase-compat-0.98/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
----------------------------------------------------------------------
diff --git a/tephra-hbase-compat-0.98/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
b/tephra-hbase-compat-0.98/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
index 38c1a6f..1c26ef1 100644
--- a/tephra-hbase-compat-0.98/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
+++ b/tephra-hbase-compat-0.98/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
@@ -22,8 +22,8 @@ import com.google.common.util.concurrent.AbstractIdleService;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.security.UserGroupInformation;
 
 import java.io.IOException;
 import java.security.PrivilegedExceptionAction;
@@ -106,7 +106,7 @@ public class PruneUpperBoundWriter extends AbstractIdleService {
           if (now > (lastChecked + pruneFlushInterval)) {
             // should flush data
             try {
-              User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
+              UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Void>()
{
                 @Override
                 public Void run() throws Exception {
                   // Record prune upper bound
@@ -128,9 +128,9 @@ public class PruneUpperBoundWriter extends AbstractIdleService {
                   return null;
                 }
               });
-            } catch (IOException ex) {
-              LOG.warn("Cannot record prune upper bound for a region to table " +
-                         tableName.getNamespaceAsString() + ":" + tableName.getNameAsString(),
ex);
+            } catch (IOException | InterruptedException ex) {
+              // Handle any exception that might be thrown during HBase operation
+              handleException(ex);
             }
             lastChecked = now;
           }
@@ -157,4 +157,12 @@ public class PruneUpperBoundWriter extends AbstractIdleService {
                              Bytes.toStringBinary(regionName), isRunning() ? "alive" : "running"));
     }
   }
+
+  private void handleException(Exception ex) {
+    LOG.warn("Cannot record prune upper bound for a region to table " +
+               tableName.getNamespaceAsString() + ":" + tableName.getNameAsString(), ex);
+    if (ex instanceof InterruptedException) {
+      Thread.currentThread().interrupt();
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tephra/blob/95c6bfb6/tephra-hbase-compat-1.0-cdh/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
----------------------------------------------------------------------
diff --git a/tephra-hbase-compat-1.0-cdh/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
b/tephra-hbase-compat-1.0-cdh/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
index 6bd8bab..1c26ef1 100644
--- a/tephra-hbase-compat-1.0-cdh/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
+++ b/tephra-hbase-compat-1.0-cdh/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
@@ -22,8 +22,8 @@ import com.google.common.util.concurrent.AbstractIdleService;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.security.UserGroupInformation;
 
 import java.io.IOException;
 import java.security.PrivilegedExceptionAction;
@@ -106,7 +106,7 @@ public class PruneUpperBoundWriter extends AbstractIdleService {
           if (now > (lastChecked + pruneFlushInterval)) {
             // should flush data
             try {
-              User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
+              UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Void>()
{
                 @Override
                 public Void run() throws Exception {
                   // Record prune upper bound
@@ -128,9 +128,9 @@ public class PruneUpperBoundWriter extends AbstractIdleService {
                   return null;
                 }
               });
-            } catch (IOException ex) {
-              LOG.warn("Cannot record prune upper bound for a region to table " +
-                         tableName.getNameWithNamespaceInclAsString(), ex);
+            } catch (IOException | InterruptedException ex) {
+              // Handle any exception that might be thrown during HBase operation
+              handleException(ex);
             }
             lastChecked = now;
           }
@@ -157,4 +157,12 @@ public class PruneUpperBoundWriter extends AbstractIdleService {
                              Bytes.toStringBinary(regionName), isRunning() ? "alive" : "running"));
     }
   }
+
+  private void handleException(Exception ex) {
+    LOG.warn("Cannot record prune upper bound for a region to table " +
+               tableName.getNamespaceAsString() + ":" + tableName.getNameAsString(), ex);
+    if (ex instanceof InterruptedException) {
+      Thread.currentThread().interrupt();
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tephra/blob/95c6bfb6/tephra-hbase-compat-1.0/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
----------------------------------------------------------------------
diff --git a/tephra-hbase-compat-1.0/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
b/tephra-hbase-compat-1.0/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
index 38c1a6f..1c26ef1 100644
--- a/tephra-hbase-compat-1.0/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
+++ b/tephra-hbase-compat-1.0/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java
@@ -22,8 +22,8 @@ import com.google.common.util.concurrent.AbstractIdleService;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.security.UserGroupInformation;
 
 import java.io.IOException;
 import java.security.PrivilegedExceptionAction;
@@ -106,7 +106,7 @@ public class PruneUpperBoundWriter extends AbstractIdleService {
           if (now > (lastChecked + pruneFlushInterval)) {
             // should flush data
             try {
-              User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
+              UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Void>()
{
                 @Override
                 public Void run() throws Exception {
                   // Record prune upper bound
@@ -128,9 +128,9 @@ public class PruneUpperBoundWriter extends AbstractIdleService {
                   return null;
                 }
               });
-            } catch (IOException ex) {
-              LOG.warn("Cannot record prune upper bound for a region to table " +
-                         tableName.getNamespaceAsString() + ":" + tableName.getNameAsString(),
ex);
+            } catch (IOException | InterruptedException ex) {
+              // Handle any exception that might be thrown during HBase operation
+              handleException(ex);
             }
             lastChecked = now;
           }
@@ -157,4 +157,12 @@ public class PruneUpperBoundWriter extends AbstractIdleService {
                              Bytes.toStringBinary(regionName), isRunning() ? "alive" : "running"));
     }
   }
+
+  private void handleException(Exception ex) {
+    LOG.warn("Cannot record prune upper bound for a region to table " +
+               tableName.getNamespaceAsString() + ":" + tableName.getNameAsString(), ex);
+    if (ex instanceof InterruptedException) {
+      Thread.currentThread().interrupt();
+    }
+  }
 }


Mime
View raw message