hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkris...@apache.org
Subject svn commit: r1576015 - in /hbase/branches/0.98: hbase-it/src/test/java/org/apache/hadoop/hbase/ hbase-server/src/test/java/org/apache/hadoop/hbase/util/ hbase-server/src/test/java/org/apache/hadoop/hbase/util/test/
Date Mon, 10 Mar 2014 17:45:55 GMT
Author: ramkrishna
Date: Mon Mar 10 17:45:54 2014
New Revision: 1576015

URL: http://svn.apache.org/r1576015
Log:
HBASE-10675 - IntegrationTestIngestWithACL should allow User to be passed as Parameter (Ram)

Modified:
    hbase/branches/0.98/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngest.java
    hbase/branches/0.98/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngestWithACL.java
    hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
    hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedReaderWithACL.java
    hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdater.java
    hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdaterWithACL.java
    hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/test/LoadTestDataGeneratorWithACL.java

Modified: hbase/branches/0.98/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngest.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngest.java?rev=1576015&r1=1576014&r2=1576015&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngest.java
(original)
+++ hbase/branches/0.98/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngest.java
Mon Mar 10 17:45:54 2014
@@ -104,7 +104,6 @@ public class IntegrationTestIngest exten
       util.deleteTable(Bytes.toBytes(getTablename()));
     }
   }
-
   protected void runIngestTest(long defaultRunTime, int keysPerServerPerIter, int colsPerKey,
       int recordSize, int writeThreads) throws Exception {
     LOG.info("Running ingest");

Modified: hbase/branches/0.98/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngestWithACL.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngestWithACL.java?rev=1576015&r1=1576014&r2=1576015&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngestWithACL.java
(original)
+++ hbase/branches/0.98/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngestWithACL.java
Mon Mar 10 17:45:54 2014
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.commons.cli.CommandLine;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.io.hfile.HFile;
 import org.apache.hadoop.hbase.security.access.AccessController;
@@ -41,10 +42,11 @@ public class IntegrationTestIngestWithAC
 
   private static final char COLON = ':';
   public static final char HYPHEN = '-';
-  private static final char COMMA = ',';
   private static final int SPECIAL_PERM_CELL_INSERTION_FACTOR = 100;
-  public static final String[] userNames = { "user1", "user2", "user3", "user4" };
-
+  public static final String OPT_SUPERUSER = "superuser";
+  public static final String OPT_USERS = "userlist";
+  private String superUser = "owner";
+  private String userNames = "user1,user2,user3,user4"; 
   @Override
   public void setUpCluster() throws Exception {
     util = getTestingUtil(null);
@@ -64,12 +66,33 @@ public class IntegrationTestIngestWithAC
     tmp.add(HYPHEN + LoadTestTool.OPT_GENERATOR);
     StringBuilder sb = new StringBuilder(LoadTestDataGeneratorWithACL.class.getName());
     sb.append(COLON);
-    sb.append(asCommaSeperatedString(userNames));
+    sb.append(superUser);
+    sb.append(COLON);
+    sb.append(userNames);
     sb.append(COLON);
     sb.append(Integer.toString(SPECIAL_PERM_CELL_INSERTION_FACTOR));
     tmp.add(sb.toString());
     return tmp.toArray(new String[tmp.size()]);
   }
+  @Override
+  protected void addOptions() {
+    super.addOptions();
+    super.addOptWithArg(OPT_SUPERUSER,
+        "Super user name used to add the ACL permissions");
+    super.addOptWithArg(OPT_USERS,
+        "List of users to be added with the ACLs.  Should be comma seperated.");
+  }
+
+  @Override
+  protected void processOptions(CommandLine cmd) {
+    super.processOptions(cmd);
+    if (cmd.hasOption(OPT_SUPERUSER)) {
+      superUser = cmd.getOptionValue(OPT_SUPERUSER);
+    }
+    if (cmd.hasOption(OPT_USERS)) {
+      userNames = cmd.getOptionValue(OPT_USERS);
+    }
+  }
 
   public static void main(String[] args) throws Exception {
     Configuration conf = HBaseConfiguration.create();
@@ -77,17 +100,4 @@ public class IntegrationTestIngestWithAC
     int ret = ToolRunner.run(conf, new IntegrationTestIngestWithACL(), args);
     System.exit(ret);
   }
-
-  private static String asCommaSeperatedString(String[] list) {
-    StringBuilder sb = new StringBuilder();
-    for (String item : list) {
-      sb.append(item);
-      sb.append(COMMA);
-    }
-    if (sb.length() > 0) {
-      // Remove the trailing ,
-      sb.deleteCharAt(sb.length() - 1);
-    }
-    return sb.toString();
-  }
 }

Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java?rev=1576015&r1=1576014&r2=1576015&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
(original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java
Mon Mar 10 17:45:54 2014
@@ -39,7 +39,6 @@ import org.apache.hadoop.hbase.HTableDes
 import org.apache.hadoop.hbase.PerformanceEvaluation;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.io.compress.Compression;
 import org.apache.hadoop.hbase.io.crypto.Cipher;
 import org.apache.hadoop.hbase.io.crypto.Encryption;
@@ -180,6 +179,10 @@ public class LoadTestTool extends Abstra
 
   private int numTables = 1;
 
+  private String superUser;
+
+  private String userNames = "user1, user2, user3, user4";
+
   // TODO: refactor LoadTestToolImpl somewhere to make the usage from tests less bad,
   //       console tool itself should only be used from console.
   protected boolean isSkipInit = false;
@@ -456,12 +459,18 @@ public class LoadTestTool extends Abstra
     if (cmd.hasOption(OPT_GENERATOR)) {
       String[] clazzAndArgs = cmd.getOptionValue(OPT_GENERATOR).split(COLON);
       dataGen = getLoadGeneratorInstance(clazzAndArgs[0]);
-      if(dataGen instanceof LoadTestDataGeneratorWithACL) {
+      String args[];
+      if (dataGen instanceof LoadTestDataGeneratorWithACL) {
         LOG.info("ACL is on");
-        userOwner = User.createUserForTesting(conf, "owner", new String[0]);
+        superUser = clazzAndArgs[1];
+        userNames = clazzAndArgs[2];
+        args = Arrays.copyOfRange(clazzAndArgs, 1,
+            clazzAndArgs.length);
+        userOwner = User.createUserForTesting(conf, superUser, new String[0]);
+      } else {
+        args = clazzAndArgs.length == 1 ? new String[0] : Arrays.copyOfRange(clazzAndArgs,
1,
+            clazzAndArgs.length);
       }
-      String[] args = clazzAndArgs.length == 1 ? new String[0] : Arrays.copyOfRange(clazzAndArgs,
-          1, clazzAndArgs.length);
       dataGen.initialize(args);
     } else {
       // Default DataGenerator is MultiThreadedAction.DefaultDataGenerator
@@ -500,7 +509,7 @@ public class LoadTestTool extends Abstra
     if (isUpdate) {
       if (userOwner != null) {
         updaterThreads = new MultiThreadedUpdaterWithACL(dataGen, conf, tableName, updatePercent,
-            userOwner);
+            userOwner, userNames);
       } else {
         updaterThreads = new MultiThreadedUpdater(dataGen, conf, tableName, updatePercent);
       }
@@ -510,7 +519,8 @@ public class LoadTestTool extends Abstra
 
     if (isRead) {
       if (userOwner != null) {
-        readerThreads = new MultiThreadedReaderWithACL(dataGen, conf, tableName, verifyPercent);
+        readerThreads = new MultiThreadedReaderWithACL(dataGen, conf, tableName, verifyPercent,
+            userNames);
       } else {
         readerThreads = new MultiThreadedReader(dataGen, conf, tableName, verifyPercent);
       }

Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedReaderWithACL.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedReaderWithACL.java?rev=1576015&r1=1576014&r2=1576015&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedReaderWithACL.java
(original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedReaderWithACL.java
Mon Mar 10 17:45:54 2014
@@ -48,9 +48,9 @@ public class MultiThreadedReaderWithACL 
   private String[] userNames;
 
   public MultiThreadedReaderWithACL(LoadTestDataGenerator dataGen, Configuration conf,
-      TableName tableName, double verifyPercent) {
+      TableName tableName, double verifyPercent, String userNames) {
     super(dataGen, conf, tableName, verifyPercent);
-    userNames = dataGenerator.getArgs()[0].split(COMMA);
+    this.userNames = userNames.split(COMMA);
   }
 
   @Override
@@ -97,7 +97,7 @@ public class MultiThreadedReaderWithACL 
           try {
             get.setACLStrategy(true);
             Result result = null;
-            int specialPermCellInsertionFactor = Integer.parseInt(dataGenerator.getArgs()[1]);
+            int specialPermCellInsertionFactor = Integer.parseInt(dataGenerator.getArgs()[2]);
             int mod = ((int) keyToRead % userNames.length);
             if (userVsTable.get(userNames[mod]) == null) {
               localTable = new HTable(conf, tableName);

Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdater.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdater.java?rev=1576015&r1=1576014&r2=1576015&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdater.java
(original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdater.java
Mon Mar 10 17:45:54 2014
@@ -174,7 +174,7 @@ public class MultiThreadedUpdater extend
               Map<byte[], byte[]> columnValues =
                 result != null ? result.getFamilyMap(cf) : null;
               if (columnValues == null) {
-                int specialPermCellInsertionFactor = Integer.parseInt(dataGenerator.getArgs()[1]);
+                int specialPermCellInsertionFactor = Integer.parseInt(dataGenerator.getArgs()[2]);
                 if (((int) rowKeyBase % specialPermCellInsertionFactor == 0)) {
                   LOG.info("Null result expected for the rowkey " + Bytes.toString(rowKey));
                 } else {

Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdaterWithACL.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdaterWithACL.java?rev=1576015&r1=1576014&r2=1576015&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdaterWithACL.java
(original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/MultiThreadedUpdaterWithACL.java
Mon Mar 10 17:45:54 2014
@@ -22,7 +22,6 @@ import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
@@ -59,10 +58,10 @@ public class MultiThreadedUpdaterWithACL
   private String[] userNames;
 
   public MultiThreadedUpdaterWithACL(LoadTestDataGenerator dataGen, Configuration conf,
-      TableName tableName, double updatePercent, User userOwner) {
+      TableName tableName, double updatePercent, User userOwner, String userNames) {
     super(dataGen, conf, tableName, updatePercent);
     this.userOwner = userOwner;
-    userNames = dataGenerator.getArgs()[0].split(COMMA);
+    this.userNames = userNames.split(COMMA);
   }
 
   @Override

Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/test/LoadTestDataGeneratorWithACL.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/test/LoadTestDataGeneratorWithACL.java?rev=1576015&r1=1576014&r2=1576015&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/test/LoadTestDataGeneratorWithACL.java
(original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/util/test/LoadTestDataGeneratorWithACL.java
Mon Mar 10 17:45:54 2014
@@ -41,17 +41,17 @@ public class LoadTestDataGeneratorWithAC
   @Override
   public void initialize(String[] args) {
     super.initialize(args);
-    if (args.length != 2) {
+    if (args.length != 3) {
       throw new IllegalArgumentException(
           "LoadTestDataGeneratorWithACL can have "
-              + "1st arguement which would be the user list and the 2nd argument "
-              + "should be the factor representing "
+              + "1st arguement which would be super user, the 2nd argument "
+              + "would be the user list and the 3rd argument should be the factor representing
"
               + "the row keys for which only write ACLs will be added.");
     }
-    String temp = args[0];
+    String temp = args[1];
     // This will be comma separated list of expressions.
     this.userNames = temp.split(COMMA);
-    this.specialPermCellInsertionFactor = Integer.parseInt(args[1]);
+    this.specialPermCellInsertionFactor = Integer.parseInt(args[2]);
   }
 
   @Override



Mime
View raw message