001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.apache.hadoop.hbase.test;
020
021import java.util.List;
022
023import org.apache.hadoop.conf.Configuration;
024import org.apache.hadoop.hbase.HBaseConfiguration;
025import org.apache.hadoop.hbase.IntegrationTestingUtility;
026import org.apache.hadoop.hbase.testclassification.IntegrationTests;
027import org.apache.hadoop.hbase.util.LoadTestTool;
028import org.apache.hadoop.util.ToolRunner;
029import org.junit.experimental.categories.Category;
030
031import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
032
033/**
034 * Extends {@link IntegrationTestTimeBoundedRequestsWithRegionReplicas} for multi-gets
035 * Besides the options already talked about in IntegrationTestTimeBoundedRequestsWithRegionReplicas
036 * the addition options here are:
037 * <pre>
038 * -DIntegrationTestTimeBoundedMultiGetRequestsWithRegionReplicas.multiget_batchsize=100
039 * -DIntegrationTestTimeBoundedMultiGetRequestsWithRegionReplicas.num_regions_per_server=5
040 * </pre>
041 * The multiget_batchsize when set to 1 will issue normal GETs.
042 * The num_regions_per_server argument indirectly impacts the region size (for a given number of
043 * num_keys_per_server). That in conjunction with multiget_batchsize would have different behaviors
044 * - the batch of gets goes to the same region or to multiple regions.
045 */
046@Category(IntegrationTests.class)
047public class IntegrationTestTimeBoundedMultiGetRequestsWithRegionReplicas
048    extends IntegrationTestTimeBoundedRequestsWithRegionReplicas {
049
050  @Override
051  protected String[] getArgsForLoadTestTool(String mode, String modeSpecificArg, long startKey,
052      long numKeys) {
053    List<String> args = Lists.newArrayList(super.getArgsForLoadTestTool(
054      mode, modeSpecificArg, startKey, numKeys));
055    String clazz = this.getClass().getSimpleName();
056    args.add("-" + LoadTestTool.OPT_MULTIGET);
057    args.add(conf.get(String.format("%s.%s", clazz, LoadTestTool.OPT_MULTIGET), "100"));
058
059    args.add("-" + LoadTestTool.OPT_NUM_REGIONS_PER_SERVER);
060    args.add(conf.get(String.format("%s.%s", clazz, LoadTestTool.OPT_NUM_REGIONS_PER_SERVER),
061        Integer.toString(LoadTestTool.DEFAULT_NUM_REGIONS_PER_SERVER)));
062
063    return args.toArray(new String[args.size()]);
064  }
065
066  public static void main(String args[]) throws Exception {
067    Configuration conf = HBaseConfiguration.create();
068    IntegrationTestingUtility.setUseDistributedCluster(conf);
069    int ret = ToolRunner.run(conf,
070        new IntegrationTestTimeBoundedMultiGetRequestsWithRegionReplicas(), args);
071    System.exit(ret);
072  }
073}