accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmil...@apache.org
Subject [accumulo] branch master updated: Create method for duplicate code in Tserver
Date Wed, 12 Dec 2018 20:43:52 GMT
This is an automated email from the ASF dual-hosted git repository.

mmiller pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new d705be9  Create method for duplicate code in Tserver
d705be9 is described below

commit d705be91fbf173d2a9819e441d8b27c408758f0f
Author: Mike Miller <mmiller@apache.org>
AuthorDate: Wed Dec 12 15:36:24 2018 -0500

    Create method for duplicate code in Tserver
---
 .../org/apache/accumulo/tserver/TabletServer.java  | 43 +++++++---------------
 1 file changed, 14 insertions(+), 29 deletions(-)

diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index c8651d7..51962bd 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -764,13 +764,7 @@ public class TabletServer implements Runnable {
 
       // check if user has permission to the tables
       for (Table.ID tableId : tables) {
-        Namespace.ID namespaceId;
-        try {
-          namespaceId = Tables.getNamespaceId(context, tableId);
-        } catch (TableNotFoundException e1) {
-          throw new ThriftSecurityException(credentials.getPrincipal(),
-              SecurityErrorCode.TABLE_DOESNT_EXIST);
-        }
+        Namespace.ID namespaceId = getNamespaceId(credentials, tableId);
         if (!security.canScan(credentials, tableId, namespaceId, tbatch, tcolumns, ssiList,
ssio,
             authorizations))
           throw new ThriftSecurityException(credentials.getPrincipal(),
@@ -1232,13 +1226,7 @@ public class TabletServer implements Runnable {
         throws NotServingTabletException, ConstraintViolationException, ThriftSecurityException
{
 
       final Table.ID tableId = Table.ID.of(new String(tkeyExtent.getTable(), UTF_8));
-      Namespace.ID namespaceId;
-      try {
-        namespaceId = Tables.getNamespaceId(context, tableId);
-      } catch (TableNotFoundException e1) {
-        throw new ThriftSecurityException(credentials.getPrincipal(),
-            SecurityErrorCode.TABLE_DOESNT_EXIST);
-      }
+      Namespace.ID namespaceId = getNamespaceId(credentials, tableId);
       if (!security.canWrite(credentials, tableId, namespaceId))
         throw new ThriftSecurityException(credentials.getPrincipal(),
             SecurityErrorCode.PERMISSION_DENIED);
@@ -1307,6 +1295,16 @@ public class TabletServer implements Runnable {
       }
     }
 
+    private Namespace.ID getNamespaceId(TCredentials credentials, Table.ID tableId)
+        throws ThriftSecurityException {
+      try {
+        return Tables.getNamespaceId(context, tableId);
+      } catch (TableNotFoundException e1) {
+        throw new ThriftSecurityException(credentials.getPrincipal(),
+            SecurityErrorCode.TABLE_DOESNT_EXIST);
+      }
+    }
+
     private void checkConditions(Map<KeyExtent,List<ServerConditionalMutation>>
updates,
         ArrayList<TCMResult> results, ConditionalSession cs, List<String> symbols)
         throws IOException {
@@ -1498,13 +1496,7 @@ public class TabletServer implements Runnable {
 
       Table.ID tableId = Table.ID.of(tableIdStr);
       Authorizations userauths = null;
-      Namespace.ID namespaceId;
-      try {
-        namespaceId = Tables.getNamespaceId(context, tableId);
-      } catch (TableNotFoundException e) {
-        throw new ThriftSecurityException(credentials.getPrincipal(),
-            SecurityErrorCode.TABLE_DOESNT_EXIST);
-      }
+      Namespace.ID namespaceId = getNamespaceId(credentials, tableId);
       if (!security.canConditionallyUpdate(credentials, tableId, namespaceId, authorizations))
         throw new ThriftSecurityException(credentials.getPrincipal(),
             SecurityErrorCode.PERMISSION_DENIED);
@@ -1598,14 +1590,7 @@ public class TabletServer implements Runnable {
         ByteBuffer splitPoint) throws NotServingTabletException, ThriftSecurityException
{
 
       Table.ID tableId = Table.ID.of(new String(ByteBufferUtil.toBytes(tkeyExtent.table)));
-      Namespace.ID namespaceId;
-      try {
-        namespaceId = Tables.getNamespaceId(context, tableId);
-      } catch (TableNotFoundException ex) {
-        // tableOperationsImpl catches ThriftSecurityException and checks for missing table
-        throw new ThriftSecurityException(credentials.getPrincipal(),
-            SecurityErrorCode.TABLE_DOESNT_EXIST);
-      }
+      Namespace.ID namespaceId = getNamespaceId(credentials, tableId);
 
       if (!security.canSplitTablet(credentials, tableId, namespaceId))
         throw new ThriftSecurityException(credentials.getPrincipal(),


Mime
View raw message