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 */
018package org.apache.hadoop.hbase;
019
020import java.util.ArrayList;
021import java.util.Arrays;
022import java.util.List;
023import org.apache.hadoop.hbase.io.hfile.HFile;
024import org.apache.hadoop.hbase.testclassification.IntegrationTests;
025import org.apache.hadoop.hbase.util.LoadTestDataGeneratorWithTags;
026import org.apache.hadoop.hbase.util.LoadTestTool;
027import org.junit.experimental.categories.Category;
028
029@Category(IntegrationTests.class)
030public class IntegrationTestIngestWithTags extends IntegrationTestIngest {
031
032  private static final char COLON = ':';
033
034  private int minTagsPerKey = 1, maxTagsPerKey = 10;
035  private int minTagLength = 16, maxTagLength = 512;
036
037  @Override
038  public void setUpCluster() throws Exception {
039    getTestingUtil(conf).getConfiguration().setInt(HFile.FORMAT_VERSION_KEY, 3);
040    super.setUpCluster();
041  }
042
043  @Override
044  protected String[] getArgsForLoadTestTool(String mode, String modeSpecificArg, long startKey,
045    long numKeys) {
046    String[] args = super.getArgsForLoadTestTool(mode, modeSpecificArg, startKey, numKeys);
047    List<String> tmp = new ArrayList<>(Arrays.asList(args));
048    // LoadTestDataGeneratorWithTags:minNumTags:maxNumTags:minTagLength:maxTagLength
049    tmp.add(HIPHEN + LoadTestTool.OPT_GENERATOR);
050    StringBuilder sb = new StringBuilder(LoadTestDataGeneratorWithTags.class.getName());
051    sb.append(COLON);
052    sb.append(minTagsPerKey);
053    sb.append(COLON);
054    sb.append(maxTagsPerKey);
055    sb.append(COLON);
056    sb.append(minTagLength);
057    sb.append(COLON);
058    sb.append(maxTagLength);
059    tmp.add(sb.toString());
060    return tmp.toArray(new String[tmp.size()]);
061  }
062}