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 <mmil...@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(),