Search in sources :

Example 1 with SplitAlgorithm

use of org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm in project hbase by apache.

the class TestRegionSplitter method testUserInput.

@Test
public void testUserInput() {
    SplitAlgorithm algo = new HexStringSplit();
    // default settings are fine
    assertFalse(splitFailsPrecondition(algo));
    // custom is fine
    assertFalse(splitFailsPrecondition(algo, "00", "AA"));
    // range error
    assertTrue(splitFailsPrecondition(algo, "AA", "00"));
    // range error
    assertTrue(splitFailsPrecondition(algo, "AA", "AA"));
    // should be fine
    assertFalse(splitFailsPrecondition(algo, "0", "2", 3));
    // should be fine
    assertFalse(splitFailsPrecondition(algo, "0", "A", 11));
    // too granular
    assertTrue(splitFailsPrecondition(algo, "0", "A", 12));
    algo = new UniformSplit();
    // default settings are fine
    assertFalse(splitFailsPrecondition(algo));
    // custom is fine
    assertFalse(splitFailsPrecondition(algo, "\\x00", "\\xAA"));
    // range error
    assertTrue(splitFailsPrecondition(algo, "\\xAA", "\\x00"));
    // range error
    assertTrue(splitFailsPrecondition(algo, "\\xAA", "\\xAA"));
    // should be fine
    assertFalse(splitFailsPrecondition(algo, "\\x00", "\\x02", 3));
    // should be fine
    assertFalse(splitFailsPrecondition(algo, "\\x00", "\\x0A", 11));
    // should be fine
    assertFalse(splitFailsPrecondition(algo, "\\x00", "\\x0A", 12));
}
Also used : SplitAlgorithm(org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm) UniformSplit(org.apache.hadoop.hbase.util.RegionSplitter.UniformSplit) HexStringSplit(org.apache.hadoop.hbase.util.RegionSplitter.HexStringSplit) Test(org.junit.Test)

Example 2 with SplitAlgorithm

use of org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm in project hbase by apache.

the class TestRegionSplitter method preSplitTableAndVerify.

/**
     * Creates a pre-split table with expectedBounds.size()+1 regions, then
     * verifies that the region boundaries are the same as the expected
     * region boundaries in expectedBounds.
     * @throws Various junit assertions
     */
private void preSplitTableAndVerify(List<byte[]> expectedBounds, String splitClass, TableName tableName) throws Exception {
    final int numRegions = expectedBounds.size() - 1;
    final Configuration conf = UTIL.getConfiguration();
    conf.setInt("split.count", numRegions);
    SplitAlgorithm splitAlgo = RegionSplitter.newSplitAlgoInstance(conf, splitClass);
    RegionSplitter.createPresplitTable(tableName, splitAlgo, new String[] { CF_NAME }, conf);
    verifyBounds(expectedBounds, tableName);
}
Also used : SplitAlgorithm(org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm) Configuration(org.apache.hadoop.conf.Configuration)

Example 3 with SplitAlgorithm

use of org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm in project hbase by apache.

the class TestRegionSplitter method rollingSplitAndVerify.

private void rollingSplitAndVerify(TableName tableName, String splitClass, List<byte[]> expectedBounds) throws Exception {
    final Configuration conf = UTIL.getConfiguration();
    // Set this larger than the number of splits so RegionSplitter won't block
    conf.setInt("split.outstanding", 5);
    SplitAlgorithm splitAlgo = RegionSplitter.newSplitAlgoInstance(conf, splitClass);
    RegionSplitter.rollingSplit(tableName, splitAlgo, conf);
    verifyBounds(expectedBounds, tableName);
}
Also used : SplitAlgorithm(org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm) Configuration(org.apache.hadoop.conf.Configuration)

Example 4 with SplitAlgorithm

use of org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm in project hbase by apache.

the class IntegrationTestManyRegions method testCreateTableWithRegions.

@Test
public void testCreateTableWithRegions() throws Exception {
    HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);
    desc.addFamily(new HColumnDescriptor("cf"));
    SplitAlgorithm algo = new RegionSplitter.HexStringSplit();
    byte[][] splits = algo.split(REGION_COUNT);
    LOG.info(String.format("Creating table %s with %d splits.", TABLE_NAME, REGION_COUNT));
    long startTime = System.currentTimeMillis();
    try {
        admin.createTable(desc, splits);
        LOG.info(String.format("Pre-split table created successfully in %dms.", (System.currentTimeMillis() - startTime)));
    } catch (IOException e) {
        LOG.error("Failed to create table", e);
    }
}
Also used : SplitAlgorithm(org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

SplitAlgorithm (org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm)4 Configuration (org.apache.hadoop.conf.Configuration)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 HexStringSplit (org.apache.hadoop.hbase.util.RegionSplitter.HexStringSplit)1 UniformSplit (org.apache.hadoop.hbase.util.RegionSplitter.UniformSplit)1