hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject svn commit: r1573947 - in /hbase/trunk: hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ClientSnapshotDescriptionUtils.java hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java
Date Tue, 04 Mar 2014 09:06:02 GMT
Author: mbertozzi
Date: Tue Mar  4 09:06:02 2014
New Revision: 1573947

URL: http://svn.apache.org/r1573947
Log:
HBASE-9708 Improve Snapshot Name Error Message (Esteban Gutierrez)

Modified:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ClientSnapshotDescriptionUtils.java
    hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ClientSnapshotDescriptionUtils.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ClientSnapshotDescriptionUtils.java?rev=1573947&r1=1573946&r2=1573947&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ClientSnapshotDescriptionUtils.java
(original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/snapshot/ClientSnapshotDescriptionUtils.java
Tue Mar  4 09:06:02 2014
@@ -39,7 +39,7 @@ public class ClientSnapshotDescriptionUt
   public static void assertSnapshotRequestIsValid(HBaseProtos.SnapshotDescription snapshot)
       throws IllegalArgumentException {
     // make sure the snapshot name is valid
-    TableName.isLegalTableQualifierName(Bytes.toBytes(snapshot.getName()));
+    TableName.isLegalTableQualifierName(Bytes.toBytes(snapshot.getName()), true);
     if(snapshot.hasTable()) {
       // make sure the table name is valid, this will implicitly check validity
       TableName tableName = TableName.valueOf(snapshot.getTable());

Modified: hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java?rev=1573947&r1=1573946&r2=1573947&view=diff
==============================================================================
--- hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java (original)
+++ hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java Tue Mar
 4 09:06:02 2014
@@ -145,11 +145,17 @@ public final class TableName implements 
     return tableName;
   }
 
-  public static byte [] isLegalTableQualifierName(final byte[] qualifierName){
-    isLegalTableQualifierName(qualifierName, 0, qualifierName.length);
+  public static byte [] isLegalTableQualifierName(final byte[] qualifierName) {
+    isLegalTableQualifierName(qualifierName, 0, qualifierName.length, false);
     return qualifierName;
   }
 
+  public static byte [] isLegalTableQualifierName(final byte[] qualifierName, boolean isSnapshot)
{
+    isLegalTableQualifierName(qualifierName, 0, qualifierName.length, isSnapshot);
+    return qualifierName;
+  }
+
+
   /**
    * Qualifier names can only contain 'word' characters
    * <code>[a-zA-Z_0-9]</code> or '_', '.' or '-'.
@@ -161,15 +167,23 @@ public final class TableName implements 
    */
   public static void isLegalTableQualifierName(final byte[] qualifierName,
                                                 int start,
-                                                int end){
+                                                int end) {
+      isLegalTableQualifierName(qualifierName, start, end, false);
+  }
+
+  public static void isLegalTableQualifierName(final byte[] qualifierName,
+                                                int start,
+                                                int end,
+                                                boolean isSnapshot) {
     if(end - start < 1) {
-      throw new IllegalArgumentException("Table qualifier must not be empty");
+      throw new IllegalArgumentException(isSnapshot ? "Snapshot" : "Table" + " qualifier
must not be empty");
     }
 
     if (qualifierName[start] == '.' || qualifierName[start] == '-') {
       throw new IllegalArgumentException("Illegal first character <" + qualifierName[0]
+
-          "> at 0. Namespaces can only start with alphanumeric " +
-          "characters': i.e. [a-zA-Z_0-9]: " + Bytes.toString(qualifierName));
+                                         "> at 0. Namespaces can only start with alphanumeric
" +
+                                         "characters': i.e. [a-zA-Z_0-9]: " +
+                                         Bytes.toString(qualifierName));
     }
     for (int i = start; i < end; i++) {
       if (Character.isLetterOrDigit(qualifierName[i]) ||
@@ -179,13 +193,13 @@ public final class TableName implements 
         continue;
       }
       throw new IllegalArgumentException("Illegal character code:" + qualifierName[i] +
-        ", <" + (char) qualifierName[i] + "> at " + i +
-          ". User-space table qualifiers can only contain " +
-        "'alphanumeric characters': i.e. [a-zA-Z_0-9-.]: " +
-          Bytes.toString(qualifierName, start, end));
+                                         ", <" + (char) qualifierName[i] + "> at "
+ i +
+                                         ". " + (isSnapshot ? "snapshot" : "User-space table")
+
+                                         " qualifiers can only contain " +
+                                         "'alphanumeric characters': i.e. [a-zA-Z_0-9-.]:
" +
+                                         Bytes.toString(qualifierName, start, end));
     }
   }
-
   public static void isLegalNamespaceName(byte[] namespaceName) {
     isLegalNamespaceName(namespaceName, 0, namespaceName.length);
   }



Mime
View raw message