コード例 #1
0
  /**
   * A set up method to start the test cluster. AggregateProtocolImpl is registered and will be
   * loaded during region startup.
   *
   * @throws Exception
   */
  @BeforeClass
  public static void setupBeforeClass() throws Exception {

    conf.set(
        CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
        "org.apache.hadoop.hbase.coprocessor.AggregateImplementation");

    util.startMiniCluster(2);
    HTable table = util.createTable(TEST_TABLE, TEST_FAMILY);
    util.createMultiRegions(
        util.getConfiguration(),
        table,
        TEST_FAMILY,
        new byte[][] {HConstants.EMPTY_BYTE_ARRAY, ROWS[rowSeperator1], ROWS[rowSeperator2]});
    /**
     * The testtable has one CQ which is always populated and one variable CQ for each row rowkey1:
     * CF:CQ CF:CQ1 rowKey2: CF:CQ CF:CQ2
     */
    for (int i = 0; i < ROWSIZE; i++) {
      Put put = new Put(ROWS[i]);
      put.setWriteToWAL(false);
      Long l = new Long(i);
      put.add(TEST_FAMILY, TEST_QUALIFIER, Bytes.toBytes(l));
      table.put(put);
      Put p2 = new Put(ROWS[i]);
      put.setWriteToWAL(false);
      p2.add(TEST_FAMILY, Bytes.add(TEST_MULTI_CQ, Bytes.toBytes(l)), Bytes.toBytes(l * 10));
      table.put(p2);
    }
    table.close();
  }
コード例 #2
0
 /**
  * Start up a mini cluster and put a small table of many empty regions into it.
  *
  * @throws Exception
  */
 @BeforeClass
 public static void beforeAllTests() throws Exception {
   TEST_UTIL.getConfiguration().setBoolean("dfs.support.append", true);
   TEST_UTIL.startMiniCluster(2);
   // Create a table of three families.  This will assign a region.
   TEST_UTIL.createTable(Bytes.toBytes(TABLENAME), FAMILIES);
   HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
   int countOfRegions = TEST_UTIL.createMultiRegions(t, getTestFamily());
   TEST_UTIL.waitUntilAllRegionsAssigned(countOfRegions);
   addToEachStartKey(countOfRegions);
   t.close();
 }