accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] mikewalch closed pull request #567: Removed more usage of Instance
Date Fri, 20 Jul 2018 15:25:20 GMT
mikewalch closed pull request #567: Removed more usage of Instance
URL: https://github.com/apache/accumulo/pull/567
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java b/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
index 94d60671dc..c9a4e93ff0 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
@@ -300,6 +300,11 @@ public static String qualified(String tableName, String defaultNamespace)
{
     return new Pair<>(defaultNamespace, tableName);
   }
 
+  public static Namespace.ID getNamespaceId(ClientContext context, Table.ID tableId)
+      throws TableNotFoundException {
+    return getNamespaceId(context.getInstance(), tableId);
+  }
+
   /**
    * Returns the namespace id for a given table ID.
    *
diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
index a1b9356ca3..d1c6be0bcc 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
@@ -30,7 +30,6 @@
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.NamespaceNotFoundException;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.client.impl.ClientContext;
@@ -77,7 +76,6 @@
   private static final Logger log = LoggerFactory.getLogger(ClientServiceHandler.class);
   protected final TransactionWatcher transactionWatcher;
   private final AccumuloServerContext context;
-  private final Instance instance;
   private final VolumeManager fs;
   private final SecurityOperation security;
   private final ServerBulkImportStatus bulkImportStatus = new ServerBulkImportStatus();
@@ -85,7 +83,6 @@
   public ClientServiceHandler(AccumuloServerContext context, TransactionWatcher transactionWatcher,
       VolumeManager fs) {
     this.context = context;
-    this.instance = context.getInstance();
     this.transactionWatcher = transactionWatcher;
     this.fs = fs;
     this.security = AuditedSecurityOperation.getInstance(context);
@@ -219,7 +216,7 @@ public void grantTablePermission(TInfo tinfo, TCredentials credentials,
String u
     Table.ID tableId = checkTableId(context, tableName, TableOperation.PERMISSION);
     Namespace.ID namespaceId;
     try {
-      namespaceId = Tables.getNamespaceId(instance, tableId);
+      namespaceId = Tables.getNamespaceId(context, tableId);
     } catch (TableNotFoundException e) {
       throw new TException(e);
     }
@@ -249,7 +246,7 @@ public void revokeTablePermission(TInfo tinfo, TCredentials credentials,
String
     Table.ID tableId = checkTableId(context, tableName, TableOperation.PERMISSION);
     Namespace.ID namespaceId;
     try {
-      namespaceId = Tables.getNamespaceId(instance, tableId);
+      namespaceId = Tables.getNamespaceId(context, tableId);
     } catch (TableNotFoundException e) {
       throw new TException(e);
     }
@@ -466,7 +463,7 @@ public boolean checkNamespaceClass(TInfo tinfo, TCredentials credentials,
String
         // ensure that table table exists
         Table.ID tableId = checkTableId(context, table, null);
         tableIds.add(tableId);
-        Namespace.ID namespaceId = Tables.getNamespaceId(instance, tableId);
+        Namespace.ID namespaceId = Tables.getNamespaceId(context, tableId);
         if (!security.canScan(credentials, tableId, namespaceId))
           throw new ThriftSecurityException(credentials.getPrincipal(),
               SecurityErrorCode.PERMISSION_DENIED);
diff --git a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
index 4b6c68c102..864beefb87 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
@@ -543,7 +543,7 @@ public String invalidMessage(String argument) {
       throws ThriftTableOperationException {
     Namespace.ID namespaceId;
     try {
-      namespaceId = Tables.getNamespaceId(master.getInstance(), tableId);
+      namespaceId = Tables.getNamespaceId(master, tableId);
     } catch (TableNotFoundException e) {
       throw new ThriftTableOperationException(tableId.canonicalID(), null, tableOp,
           TableOperationExceptionType.NOTFOUND, e.getMessage());
diff --git a/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
b/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
index 600d61d5d6..2e8dfbfe53 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
@@ -276,7 +276,7 @@ public void waitForFlush(TInfo tinfo, TCredentials c, String tableIdStr,
ByteBuf
       throws ThriftTableOperationException {
     Namespace.ID namespaceId;
     try {
-      namespaceId = Tables.getNamespaceId(master.getInstance(), tableId);
+      namespaceId = Tables.getNamespaceId(master, tableId);
     } catch (TableNotFoundException e) {
       throw new ThriftTableOperationException(tableId.canonicalID(), null, tableOp,
           TableOperationExceptionType.NOTFOUND, e.getMessage());
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 1e56ed848b..86f51660ac 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
@@ -566,7 +566,7 @@ public InitialScan startScan(TInfo tinfo, TCredentials credentials, TKeyExtent
t
       Table.ID tableId = Table.ID.of(new String(textent.getTable(), UTF_8));
       Namespace.ID namespaceId;
       try {
-        namespaceId = Tables.getNamespaceId(getInstance(), tableId);
+        namespaceId = Tables.getNamespaceId(TabletServer.this, tableId);
       } catch (TableNotFoundException e1) {
         throw new NotServingTabletException(textent);
       }
@@ -755,7 +755,7 @@ public InitialMultiScan startMultiScan(TInfo tinfo, TCredentials credentials,
       for (Table.ID tableId : tables) {
         Namespace.ID namespaceId;
         try {
-          namespaceId = Tables.getNamespaceId(getInstance(), tableId);
+          namespaceId = Tables.getNamespaceId(TabletServer.this, tableId);
         } catch (TableNotFoundException e1) {
           throw new ThriftSecurityException(credentials.getPrincipal(),
               SecurityErrorCode.TABLE_DOESNT_EXIST);
@@ -914,7 +914,7 @@ private void setUpdateTablet(UpdateSession us, KeyExtent keyExtent) {
             && (us.currentTablet.getExtent().getTableId().equals(keyExtent.getTableId()));
         tableId = keyExtent.getTableId();
         if (sameTable || security.canWrite(us.getCredentials(), tableId,
-            Tables.getNamespaceId(getInstance(), tableId))) {
+            Tables.getNamespaceId(TabletServer.this, tableId))) {
           long t2 = System.currentTimeMillis();
           us.authTimes.addStat(t2 - t1);
           us.currentTablet = onlineTablets.get(keyExtent);
@@ -1222,7 +1222,7 @@ public void update(TInfo tinfo, TCredentials credentials, TKeyExtent
tkeyExtent,
       final Table.ID tableId = Table.ID.of(new String(tkeyExtent.getTable(), UTF_8));
       Namespace.ID namespaceId;
       try {
-        namespaceId = Tables.getNamespaceId(getInstance(), tableId);
+        namespaceId = Tables.getNamespaceId(TabletServer.this, tableId);
       } catch (TableNotFoundException e1) {
         throw new ThriftSecurityException(credentials.getPrincipal(),
             SecurityErrorCode.TABLE_DOESNT_EXIST);
@@ -1488,7 +1488,7 @@ public TConditionalSession startConditionalUpdate(TInfo tinfo, TCredentials
cred
       Authorizations userauths = null;
       Namespace.ID namespaceId;
       try {
-        namespaceId = Tables.getNamespaceId(getInstance(), tableId);
+        namespaceId = Tables.getNamespaceId(TabletServer.this, tableId);
       } catch (TableNotFoundException e) {
         throw new ThriftSecurityException(credentials.getPrincipal(),
             SecurityErrorCode.TABLE_DOESNT_EXIST);
@@ -1588,7 +1588,7 @@ public void splitTablet(TInfo tinfo, TCredentials credentials, TKeyExtent
tkeyEx
       Table.ID tableId = Table.ID.of(new String(ByteBufferUtil.toBytes(tkeyExtent.table)));
       Namespace.ID namespaceId;
       try {
-        namespaceId = Tables.getNamespaceId(getInstance(), tableId);
+        namespaceId = Tables.getNamespaceId(TabletServer.this, tableId);
       } catch (TableNotFoundException ex) {
         // tableOperationsImpl catches ThriftSeccurityException and checks for missing table
         throw new ThriftSecurityException(credentials.getPrincipal(),
@@ -2054,7 +2054,7 @@ public TSummaries startGetSummaries(TInfo tinfo, TCredentials credentials,
       Namespace.ID namespaceId;
       Table.ID tableId = Table.ID.of(request.getTableId());
       try {
-        namespaceId = Tables.getNamespaceId(TabletServer.this.getInstance(), tableId);
+        namespaceId = Tables.getNamespaceId(TabletServer.this, tableId);
       } catch (TableNotFoundException e1) {
         throw new ThriftTableOperationException(tableId.canonicalID(), null, null,
             TableOperationExceptionType.NOTFOUND, null);
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ConfigCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ConfigCommand.java
index d6aa017eaa..9c09da81f4 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/ConfigCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ConfigCommand.java
@@ -168,7 +168,7 @@ public int execute(final String fullCommand, final CommandLine cl, final
Shell s
       final TreeMap<String,String> namespaceConfig = new TreeMap<>();
       if (tableName != null) {
         String n = Namespaces.getNamespaceName(shellState.getContext(), Tables.getNamespaceId(
-            shellState.getInstance(), Tables.getTableId(shellState.getContext(), tableName)));
+            shellState.getContext(), Tables.getTableId(shellState.getContext(), tableName)));
         for (Entry<String,String> e : shellState.getConnector().namespaceOperations()
             .getProperties(n)) {
           namespaceConfig.put(e.getKey(), e.getValue());


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message