Index: src/test/org/apache/hadoop/hbase/client/TestForceSplit.java =================================================================== --- src/test/org/apache/hadoop/hbase/client/TestForceSplit.java (revision 929367) +++ src/test/org/apache/hadoop/hbase/client/TestForceSplit.java (working copy) @@ -110,6 +110,7 @@ HTableDescriptor htd = new HTableDescriptor(tableName); htd.addFamily(new HColumnDescriptor(columnName)); HBaseAdmin admin = new HBaseAdmin(conf); + System.out.println("create table"); admin.createTable(htd); final HTable table = new HTable(conf, tableName); byte[] k = new byte[3]; @@ -168,4 +169,78 @@ scanner.close(); assertEquals(rowCount, rows); } + + private static byte [] multiTable = Bytes.toBytes("multiTable"); + private static byte [] familyOne = Bytes.toBytes("family1"); + private static byte [] familyTwo = Bytes.toBytes("family2"); + + /** + * Tests forcing split from client and having scanners successfully ride over split. + * @throws Exception + * @throws IOException + */ + public void testForceSplitMultiFamily() throws Exception { + // create the test table + HTableDescriptor htd = new HTableDescriptor(multiTable); + htd.addFamily(new HColumnDescriptor(familyOne)); + htd.addFamily(new HColumnDescriptor(familyTwo)); + HBaseAdmin admin = new HBaseAdmin(conf); + admin.createTable(htd); + final HTable table = new HTable(conf, multiTable); + byte[] k = new byte[3]; + int rowCount = 0; + for (byte b1 = 'a'; b1 < 'z'; b1++) { + for (byte b2 = 'a'; b2 < 'z'; b2++) { + for (byte b3 = 'a'; b3 < 'z'; b3++) { + k[0] = b1; + k[1] = b2; + k[2] = b3; + Put put = new Put(k); + put.add(familyOne, null, k); + table.put(put); + rowCount++; + } + } + } + System.out.println("hai"); + + // get the initial layout (should just be one region) + Map m = table.getRegionsInfo(); + System.out.println("Initial regions (" + m.size() + "): " + m); + assertTrue(m.size() == 1); + + // Verify row count + Scan scan = new Scan(); + ResultScanner scanner = table.getScanner(scan); + int rows = 0; + for(Result result : scanner) { + rows++; + } + scanner.close(); + assertEquals(rowCount, rows); + + // Have an outstanding scan going on to make sure we can scan over splits. + scan = new Scan(); + scanner = table.getScanner(scan); + // Scan first row so we are into first region before split happens. + scanner.next(); + + Thread t = new WaitOnSplit(table); + t.start(); + // tell the master to split the table + admin.split(Bytes.toString(tableName)); + t.join(); + + // Verify row count + rows = 1; // We counted one row above. + for (Result result : scanner) { + rows++; + if (rows > rowCount) { + scanner.close(); + assertTrue("Scanned more than expected (" + rowCount + ")", false); + } + } + scanner.close(); + assertEquals(rowCount, rows); + } } \ No newline at end of file