@Override public void run() { long startTime, endTime; HTableDescriptor desc = new HTableDescriptor(TABLE_NAME); desc.addFamily(new HColumnDescriptor(COLUMN_NAME)); 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)); startTime = System.currentTimeMillis(); try { admin.createTable(desc, splits); endTime = System.currentTimeMillis(); success = true; LOG.info(String.format("Pre-split table created successfully in %dms.", (endTime - startTime))); } catch (IOException e) { LOG.error("Failed to create table", e); } finally { doneSignal.countDown(); } }
@Override public void run() { long startTime, endTime; HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(TABLE_NAME)); desc.addFamily(new HColumnDescriptor(COLUMN_NAME)); 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)); startTime = System.currentTimeMillis(); try { admin.createTable(desc, splits); endTime = System.currentTimeMillis(); success = true; LOG.info(String.format("Pre-split table created successfully in %dms.", (endTime - startTime))); } catch (IOException e) { LOG.error("Failed to create table", e); } finally { doneSignal.countDown(); } }
@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); } }
/** * 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); }
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); }
/** * 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, String 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); }
private void rollingSplitAndVerify(String 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); }
/** * 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); }
private boolean splitFailsPrecondition(SplitAlgorithm algo) { return splitFailsPrecondition(algo, 100); }
private boolean splitFailsPrecondition(SplitAlgorithm algo, String firstRow, String lastRow) { return splitFailsPrecondition(algo, firstRow, lastRow, 100); }
private boolean splitFailsPrecondition(SplitAlgorithm algo, String firstRow, String lastRow, int numRegions) { algo.setFirstRow(firstRow); algo.setLastRow(lastRow); return splitFailsPrecondition(algo, numRegions); }