accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [2/6] accumulo git commit: ACCUMULO-3354 call deleteRows on offline table contains table name in TableOfflineException
Date Mon, 04 May 2015 17:36:19 GMT
ACCUMULO-3354 call deleteRows on offline table contains table name in TableOfflineException

TableOperationsImpl.doFateOperation(...) is the only method that passed an explicitly null
tableId to
the TableOfflineException constructor. Now checks the table's tableId and passes that to the
exception constructor.

Refactored doFateOperation(FateOperation op, List<ByteBuffer> args, Map<String,String>
opts, boolean wait)
to doFateOperation(FateOperation op, List<ByteBuffer> args, Map<String,String>
opts,
String tableOrNamespaceName, boolean wait). The table/namespace name is then pushed down explicitly.

Signed-off-by: Josh Elser <elserj@apache.org>


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

Branch: refs/heads/1.7
Commit: a506c0bedb5a6b5794e995b68a7710bd8bfb69eb
Parents: bbcc6da
Author: Jacob Meisler <jacob.meisler@gmail.com>
Authored: Tue Apr 28 20:42:17 2015 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Mon May 4 11:41:22 2015 -0400

----------------------------------------------------------------------
 .../client/impl/NamespaceOperationsImpl.java    | 11 +++----
 .../core/client/impl/TableOperationsImpl.java   | 30 +++++++++-----------
 2 files changed, 20 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a506c0be/core/src/main/java/org/apache/accumulo/core/client/impl/NamespaceOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/NamespaceOperationsImpl.java
b/core/src/main/java/org/apache/accumulo/core/client/impl/NamespaceOperationsImpl.java
index 19bc232..9a66fef 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/NamespaceOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/NamespaceOperationsImpl.java
@@ -90,7 +90,8 @@ public class NamespaceOperationsImpl extends NamespaceOperationsHelper {
     ArgumentChecker.notNull(namespace);
 
     try {
-      doNamespaceFateOperation(FateOperation.NAMESPACE_CREATE, Arrays.asList(ByteBuffer.wrap(namespace.getBytes())),
Collections.<String,String> emptyMap());
+      doNamespaceFateOperation(FateOperation.NAMESPACE_CREATE, Arrays.asList(ByteBuffer.wrap(namespace.getBytes())),
Collections.<String,String> emptyMap(),
+          namespace);
     } catch (NamespaceNotFoundException e) {
       // should not happen
       throw new AssertionError(e);
@@ -115,7 +116,7 @@ public class NamespaceOperationsImpl extends NamespaceOperationsHelper
{
     Map<String,String> opts = new HashMap<String,String>();
 
     try {
-      doNamespaceFateOperation(FateOperation.NAMESPACE_DELETE, args, opts);
+      doNamespaceFateOperation(FateOperation.NAMESPACE_DELETE, args, opts, namespace);
     } catch (NamespaceExistsException e) {
       // should not happen
       throw new AssertionError(e);
@@ -129,7 +130,7 @@ public class NamespaceOperationsImpl extends NamespaceOperationsHelper
{
 
     List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(oldNamespaceName.getBytes()),
ByteBuffer.wrap(newNamespaceName.getBytes()));
     Map<String,String> opts = new HashMap<String,String>();
-    doNamespaceFateOperation(FateOperation.NAMESPACE_RENAME, args, opts);
+    doNamespaceFateOperation(FateOperation.NAMESPACE_RENAME, args, opts, oldNamespaceName);
   }
 
   @Override
@@ -229,10 +230,10 @@ public class NamespaceOperationsImpl extends NamespaceOperationsHelper
{
     return super.addConstraint(namespace, constraintClassName);
   }
 
-  private String doNamespaceFateOperation(FateOperation op, List<ByteBuffer> args,
Map<String,String> opts) throws AccumuloSecurityException,
+  private String doNamespaceFateOperation(FateOperation op, List<ByteBuffer> args,
Map<String,String> opts, String namespace) throws AccumuloSecurityException,
       AccumuloException, NamespaceExistsException, NamespaceNotFoundException {
     try {
-      return tableOps.doFateOperation(op, args, opts);
+      return tableOps.doFateOperation(op, args, opts, namespace);
     } catch (TableExistsException e) {
       // should not happen
       throw new AssertionError(e);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/a506c0be/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java
b/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java
index 75dda1f..6e6ca19 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TableOperationsImpl.java
@@ -95,7 +95,6 @@ import org.apache.accumulo.core.security.Credentials;
 import org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException;
 import org.apache.accumulo.core.tabletserver.thrift.TabletClientService;
 import org.apache.accumulo.core.util.ArgumentChecker;
-import org.apache.accumulo.core.util.ByteBufferUtil;
 import org.apache.accumulo.core.util.CachedConfiguration;
 import org.apache.accumulo.core.util.LocalityGroupUtil;
 import org.apache.accumulo.core.util.MapCounter;
@@ -290,13 +289,13 @@ public class TableOperationsImpl extends TableOperationsHelper {
     }
   }
 
-  String doFateOperation(FateOperation op, List<ByteBuffer> args, Map<String,String>
opts) throws AccumuloSecurityException, TableExistsException,
-      TableNotFoundException, AccumuloException, NamespaceExistsException, NamespaceNotFoundException
{
-    return doFateOperation(op, args, opts, true);
+  String doFateOperation(FateOperation op, List<ByteBuffer> args, Map<String,String>
opts, String tableOrNamespaceName) throws AccumuloSecurityException,
+      TableExistsException, TableNotFoundException, AccumuloException, NamespaceExistsException,
NamespaceNotFoundException {
+    return doFateOperation(op, args, opts, tableOrNamespaceName, true);
   }
 
-  String doFateOperation(FateOperation op, List<ByteBuffer> args, Map<String,String>
opts, boolean wait) throws AccumuloSecurityException,
-      TableExistsException, TableNotFoundException, AccumuloException, NamespaceExistsException,
NamespaceNotFoundException {
+  String doFateOperation(FateOperation op, List<ByteBuffer> args, Map<String,String>
opts, String tableOrNamespaceName, boolean wait)
+      throws AccumuloSecurityException, TableExistsException, TableNotFoundException, AccumuloException,
NamespaceExistsException, NamespaceNotFoundException {
     Long opid = null;
 
     try {
@@ -309,14 +308,13 @@ public class TableOperationsImpl extends TableOperationsHelper {
       String ret = waitForFateOperation(opid);
       return ret;
     } catch (ThriftSecurityException e) {
-      String tableName = ByteBufferUtil.toString(args.get(0));
       switch (e.getCode()) {
         case TABLE_DOESNT_EXIST:
-          throw new TableNotFoundException(null, tableName, "Target table does not exist");
+          throw new TableNotFoundException(null, tableOrNamespaceName, "Target table does
not exist");
         case NAMESPACE_DOESNT_EXIST:
-          throw new NamespaceNotFoundException(null, tableName, "Target namespace does not
exist");
+          throw new NamespaceNotFoundException(null, tableOrNamespaceName, "Target namespace
does not exist");
         default:
-          String tableInfo = Tables.getPrintableTableInfoFromName(instance, tableName);
+          String tableInfo = Tables.getPrintableTableInfoFromName(instance, tableOrNamespaceName);
           throw new AccumuloSecurityException(e.user, e.code, tableInfo, e);
       }
     } catch (ThriftTableOperationException e) {
@@ -330,7 +328,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
         case NAMESPACE_NOTFOUND:
           throw new NamespaceNotFoundException(e);
         case OFFLINE:
-          throw new TableOfflineException(instance, null);
+          throw new TableOfflineException(instance, Tables.getTableId(instance, tableOrNamespaceName));
         default:
           throw new AccumuloException(e.description, e);
       }
@@ -796,7 +794,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
 
     Map<String,String> opts = new HashMap<String,String>();
     try {
-      doFateOperation(FateOperation.TABLE_COMPACT, args, opts, wait);
+      doFateOperation(FateOperation.TABLE_COMPACT, args, opts, tableName, wait);
     } catch (TableExistsException e) {
       // should not happen
       throw new AssertionError(e);
@@ -1588,10 +1586,10 @@ public class TableOperationsImpl extends TableOperationsHelper {
     return super.addConstraint(tableName, constraintClassName);
   }
 
-  private void doTableFateOperation(String tableName, Class<? extends Exception> namespaceNotFoundExceptionClass,
FateOperation op, List<ByteBuffer> args,
-      Map<String,String> opts) throws AccumuloSecurityException, AccumuloException,
TableExistsException, TableNotFoundException {
+  private void doTableFateOperation(String tableOrNamespaceName, Class<? extends Exception>
namespaceNotFoundExceptionClass, FateOperation op,
+      List<ByteBuffer> args, Map<String,String> opts) throws AccumuloSecurityException,
AccumuloException, TableExistsException, TableNotFoundException {
     try {
-      doFateOperation(op, args, opts);
+      doFateOperation(op, args, opts, tableOrNamespaceName);
     } catch (NamespaceExistsException e) {
       // should not happen
       throw new AssertionError(e);
@@ -1602,7 +1600,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
       } else if (AccumuloException.class.isAssignableFrom(namespaceNotFoundExceptionClass))
{
         throw new AccumuloException("Cannot create table in non-existent namespace", e);
       } else if (TableNotFoundException.class.isAssignableFrom(namespaceNotFoundExceptionClass))
{
-        throw new TableNotFoundException(null, tableName, "Namespace not found", e);
+        throw new TableNotFoundException(null, tableOrNamespaceName, "Namespace not found",
e);
       } else {
         // should not happen
         throw new AssertionError(e);


Mime
View raw message