View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.hadoop.hbase.test;
20  
21  import java.util.List;
22  
23  import org.apache.hadoop.conf.Configuration;
24  import org.apache.hadoop.hbase.HBaseConfiguration;
25  import org.apache.hadoop.hbase.IntegrationTestingUtility;
26  import org.apache.hadoop.hbase.testclassification.IntegrationTests;
27  import org.apache.hadoop.hbase.util.LoadTestTool;
28  import org.apache.hadoop.util.ToolRunner;
29  import org.junit.experimental.categories.Category;
30  
31  import com.google.common.collect.Lists;
32  
33  /**
34   * Extends {@link IntegrationTestTimeBoundedRequestsWithRegionReplicas} for multi-gets
35   * Besides the options already talked about in IntegrationTestTimeBoundedRequestsWithRegionReplicas
36   * the addition options here are:
37   * <pre>
38   * -DIntegrationTestTimeBoundedMultiGetRequestsWithRegionReplicas.multiget_batchsize=100
39   * -DIntegrationTestTimeBoundedMultiGetRequestsWithRegionReplicas.num_regions_per_server=5
40   * </pre>
41   * The multiget_batchsize when set to 1 will issue normal GETs.
42   * The num_regions_per_server argument indirectly impacts the region size (for a given number of
43   * num_keys_per_server). That in conjunction with multiget_batchsize would have different behaviors
44   * - the batch of gets goes to the same region or to multiple regions.
45   */
46  @Category(IntegrationTests.class)
47  public class IntegrationTestTimeBoundedMultiGetRequestsWithRegionReplicas
48      extends IntegrationTestTimeBoundedRequestsWithRegionReplicas {
49  
50    @Override
51    protected String[] getArgsForLoadTestTool(String mode, String modeSpecificArg, long startKey,
52        long numKeys) {
53      List<String> args = Lists.newArrayList(super.getArgsForLoadTestTool(
54        mode, modeSpecificArg, startKey, numKeys));
55      String clazz = this.getClass().getSimpleName();
56      args.add("-" + LoadTestTool.OPT_MULTIGET);
57      args.add(conf.get(String.format("%s.%s", clazz, LoadTestTool.OPT_MULTIGET), "100"));
58  
59      args.add("-" + LoadTestTool.OPT_NUM_REGIONS_PER_SERVER);
60      args.add(conf.get(String.format("%s.%s", clazz, LoadTestTool.OPT_NUM_REGIONS_PER_SERVER),
61          Integer.toString(LoadTestTool.DEFAULT_NUM_REGIONS_PER_SERVER)));
62  
63      return args.toArray(new String[args.size()]);
64    }
65  
66    public static void main(String args[]) throws Exception {
67      Configuration conf = HBaseConfiguration.create();
68      IntegrationTestingUtility.setUseDistributedCluster(conf);
69      int ret = ToolRunner.run(conf,
70          new IntegrationTestTimeBoundedMultiGetRequestsWithRegionReplicas(), args);
71      System.exit(ret);
72    }
73  }