@Test public void testTruncatePreserveWithReplicaRegionAfterSplit() throws Exception { String[] families = new String[] { "f1", "f2" }; byte[][] splitKeys = new byte[][] { Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c") }; TableName tableName = TableName.valueOf(name.getMethodName()); // create a table with region replications TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName).setRegionReplication(3) .setColumnFamilies(Arrays.stream(families) .map(fam -> ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(fam)).build()) .collect(Collectors.toList())) .build(); RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, splitKeys); ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); long procId = ProcedureTestingUtility.submitAndWait(procExec, new CreateTableProcedure(procExec.getEnvironment(), htd, regions)); ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId)); splitAndTruncate(tableName, regions, 3); }
TableDescriptor td = TableDescriptorBuilder .newBuilder(TableName.valueOf("test")) .setColumnFamilies(Arrays.asList(cf1, cf2, cf3, cf4)) .build();
TableDescriptor td = TableDescriptorBuilder .newBuilder(TableName.valueOf("test")) .setColumnFamilies(Arrays.asList(cf1, cf2, cf3, cf4)) .build();
@Test public void testTruncatePreserveWithReplicaRegionAfterSplit() throws Exception { String[] families = new String[] { "f1", "f2" }; byte[][] splitKeys = new byte[][] { Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c") }; TableName tableName = TableName.valueOf(name.getMethodName()); // create a table with region replications TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName).setRegionReplication(3) .setColumnFamilies(Arrays.stream(families) .map(fam -> ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(fam)).build()) .collect(Collectors.toList())) .build(); RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, splitKeys); ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); long procId = ProcedureTestingUtility.submitAndWait(procExec, new CreateTableProcedure(procExec.getEnvironment(), htd, regions)); ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId)); splitAndTruncate(tableName, regions, 3); }