accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [accumulo] branch 1.9 updated: fix #1141 adding checks for extra FATE RPC arguments (#1145)
Date Mon, 06 May 2019 21:18:16 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/1.9 by this push:
     new c56eada  fix #1141 adding checks for extra FATE RPC arguments (#1145)
c56eada is described below

commit c56eadabf913f981fa10a51f9f874b4f6287351a
Author: Keith Turner <kturner@apache.org>
AuthorDate: Mon May 6 17:18:11 2019 -0400

    fix #1141 adding checks for extra FATE RPC arguments (#1145)
---
 .../apache/accumulo/master/FateServiceHandler.java | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

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 0f088a3..c9b20cf 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
@@ -103,6 +103,7 @@ class FateServiceHandler implements FateService.Iface {
     switch (op) {
       case NAMESPACE_CREATE: {
         TableOperation tableOp = TableOperation.CREATE;
+        validateArgumentCount(arguments, tableOp, 1);
         String namespace = validateNamespaceArgument(arguments.get(0), tableOp, null);
 
         if (!master.security.canCreateNamespace(c, namespace))
@@ -115,6 +116,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case NAMESPACE_RENAME: {
         TableOperation tableOp = TableOperation.RENAME;
+        validateArgumentCount(arguments, tableOp, 2);
         String oldName = validateNamespaceArgument(arguments.get(0), tableOp,
             Namespaces.NOT_DEFAULT.and(Namespaces.NOT_ACCUMULO));
         String newName = validateNamespaceArgument(arguments.get(1), tableOp, null);
@@ -130,6 +132,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case NAMESPACE_DELETE: {
         TableOperation tableOp = TableOperation.DELETE;
+        validateArgumentCount(arguments, tableOp, 1);
         String namespace = validateNamespaceArgument(arguments.get(0), tableOp,
             Namespaces.NOT_DEFAULT.and(Namespaces.NOT_ACCUMULO));
 
@@ -144,6 +147,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_CREATE: {
         TableOperation tableOp = TableOperation.CREATE;
+        validateArgumentCount(arguments, tableOp, 2);
         String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM);
         TimeType timeType = TimeType.valueOf(ByteBufferUtil.toString(arguments.get(1)));
 
@@ -169,6 +173,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_RENAME: {
         TableOperation tableOp = TableOperation.RENAME;
+        validateArgumentCount(arguments, tableOp, 2);
         final String oldTableName =
             validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM);
         String newTableName =
@@ -218,6 +223,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_CLONE: {
         TableOperation tableOp = TableOperation.CLONE;
+        validateArgumentCount(arguments, tableOp, 2);
         String srcTableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_ID);
         String tableName = validateTableNameArgument(arguments.get(1), tableOp, NOT_SYSTEM);
         String namespaceId;
@@ -269,6 +275,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_DELETE: {
         TableOperation tableOp = TableOperation.DELETE;
+        validateArgumentCount(arguments, tableOp, 1);
         String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM);
 
         final String tableId =
@@ -291,6 +298,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_ONLINE: {
         TableOperation tableOp = TableOperation.ONLINE;
+        validateArgumentCount(arguments, tableOp, 1);
         final String tableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_ID);
         String namespaceId = getNamespaceIdFromTableId(tableOp, tableId);
 
@@ -312,6 +320,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_OFFLINE: {
         TableOperation tableOp = TableOperation.OFFLINE;
+        validateArgumentCount(arguments, tableOp, 1);
         final String tableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_ID);
         String namespaceId = getNamespaceIdFromTableId(tableOp, tableId);
 
@@ -333,6 +342,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_MERGE: {
         TableOperation tableOp = TableOperation.MERGE;
+        validateArgumentCount(arguments, tableOp, 3);
         String tableName = validateTableNameArgument(arguments.get(0), tableOp, null);
         Text startRow = ByteBufferUtil.toText(arguments.get(1));
         Text endRow = ByteBufferUtil.toText(arguments.get(2));
@@ -360,6 +370,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_DELETE_RANGE: {
         TableOperation tableOp = TableOperation.DELETE_RANGE;
+        validateArgumentCount(arguments, tableOp, 3);
         String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_METADATA);
         Text startRow = ByteBufferUtil.toText(arguments.get(1));
         Text endRow = ByteBufferUtil.toText(arguments.get(2));
@@ -387,6 +398,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_BULK_IMPORT: {
         TableOperation tableOp = TableOperation.BULK_IMPORT;
+        validateArgumentCount(arguments, tableOp, 4);
         String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM);
         String dir = ByteBufferUtil.toString(arguments.get(1));
         String failDir = ByteBufferUtil.toString(arguments.get(2));
@@ -415,6 +427,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_COMPACT: {
         TableOperation tableOp = TableOperation.COMPACT;
+        validateArgumentCount(arguments, tableOp, 5);
         String tableId = validateTableIdArgument(arguments.get(0), tableOp, null);
         byte[] startRow = ByteBufferUtil.toBytes(arguments.get(1));
         byte[] endRow = ByteBufferUtil.toBytes(arguments.get(2));
@@ -441,6 +454,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_CANCEL_COMPACT: {
         TableOperation tableOp = TableOperation.COMPACT_CANCEL;
+        validateArgumentCount(arguments, tableOp, 1);
         String tableId = validateTableIdArgument(arguments.get(0), tableOp, null);
         String namespaceId = getNamespaceIdFromTableId(tableOp, tableId);
 
@@ -461,6 +475,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_IMPORT: {
         TableOperation tableOp = TableOperation.IMPORT;
+        validateArgumentCount(arguments, tableOp, 2);
         String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM);
         String exportDir = ByteBufferUtil.toString(arguments.get(1));
         String namespaceId;
@@ -490,6 +505,7 @@ class FateServiceHandler implements FateService.Iface {
       }
       case TABLE_EXPORT: {
         TableOperation tableOp = TableOperation.EXPORT;
+        validateArgumentCount(arguments, tableOp, 2);
         String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM);
         String exportDir = ByteBufferUtil.toString(arguments.get(1));
 
@@ -622,6 +638,14 @@ class FateServiceHandler implements FateService.Iface {
     return _validateArgument(tableName, op, VALID_NAME.and(userValidator));
   }
 
+  private void validateArgumentCount(List<ByteBuffer> arguments, TableOperation op,
int expected)
+      throws ThriftTableOperationException {
+    if (arguments.size() != expected) {
+      throw new ThriftTableOperationException(null, null, op, TableOperationExceptionType.OTHER,
+          "Unexpected number of arguments : " + expected + " != " + arguments.size());
+    }
+  }
+
   // Verify namespace arguments are valid, and match any additional restrictions
   private String validateNamespaceArgument(ByteBuffer namespaceArg, TableOperation op,
       Validator<String> userValidator) throws ThriftTableOperationException {


Mime
View raw message