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  package org.apache.hadoop.hbase;
19  
20  import java.util.ArrayList;
21  import java.util.Arrays;
22  import java.util.List;
23  
24  import org.apache.hadoop.hbase.io.hfile.HFile;
25  import org.apache.hadoop.hbase.testclassification.IntegrationTests;
26  import org.apache.hadoop.hbase.util.LoadTestDataGeneratorWithTags;
27  import org.apache.hadoop.hbase.util.LoadTestTool;
28  import org.junit.experimental.categories.Category;
29  
30  @Category(IntegrationTests.class)
31  public class IntegrationTestIngestWithTags extends IntegrationTestIngest {
32  
33    private static final char COLON = ':';
34  
35    private int minTagsPerKey = 1, maxTagsPerKey = 10;
36    private int minTagLength = 16, maxTagLength = 512;
37  
38    @Override
39    public void setUpCluster() throws Exception {
40      getTestingUtil(conf).getConfiguration().setInt(HFile.FORMAT_VERSION_KEY, 3);
41      super.setUpCluster();
42    }
43  
44    @Override
45    protected String[] getArgsForLoadTestTool(String mode, String modeSpecificArg, long startKey,
46        long numKeys) {
47      String[] args = super.getArgsForLoadTestTool(mode, modeSpecificArg, startKey, numKeys);
48      List<String> tmp = new ArrayList<String>(Arrays.asList(args));
49      // LoadTestDataGeneratorWithTags:minNumTags:maxNumTags:minTagLength:maxTagLength
50      tmp.add(HIPHEN + LoadTestTool.OPT_GENERATOR);
51      StringBuilder sb = new StringBuilder(LoadTestDataGeneratorWithTags.class.getName());
52      sb.append(COLON);
53      sb.append(minTagsPerKey);
54      sb.append(COLON);
55      sb.append(maxTagsPerKey);
56      sb.append(COLON);
57      sb.append(minTagLength);
58      sb.append(COLON);
59      sb.append(maxTagLength);
60      tmp.add(sb.toString());
61      return tmp.toArray(new String[tmp.size()]);
62    }
63  }