private void testScanner(HBaseTestingUtility util, String snapshotName, int numRegions, boolean shutdownCluster) throws Exception { setupCluster(); TableName tableName = TableName.valueOf("testScanner"); try { createTableAndSnapshot(util, tableName, snapshotName, numRegions); if (shutdownCluster) { util.shutdownMiniHBaseCluster(); } Path restoreDir = util.getDataTestDirOnTestFS(snapshotName); Scan scan = new Scan(bbb, yyy); // limit the scan TableSnapshotScanner scanner = new TableSnapshotScanner(UTIL.getConfiguration(), restoreDir, snapshotName, scan); verifyScanner(scanner, bbb, yyy); scanner.close(); } finally { if (!shutdownCluster) { util.getAdmin().deleteSnapshot(snapshotName); util.deleteTable(tableName); tearDownCluster(); } } }
@Test public void testWithOfflineHBaseMultiRegion() throws Exception { testScanner(UTIL, "testWithMultiRegion", 20, true); }
private void verifyScanner(ResultScanner scanner, byte[] startRow, byte[] stopRow) throws IOException, InterruptedException { HBaseTestingUtility.SeenRowTracker rowTracker = new HBaseTestingUtility.SeenRowTracker(startRow, stopRow); while (true) { Result result = scanner.next(); if (result == null) { break; } verifyRow(result); rowTracker.addRow(result.getRow()); } // validate all rows are seen rowTracker.validate(); }
@Test public void testNoDuplicateResultsWhenSplitting() throws Exception { setupCluster(); TableName tableName = TableName.valueOf("testNoDuplicateResultsWhenSplitting"); String snapshotName = "testSnapshotBug"; blockUntilSplitFinished(UTIL, tableName, 2); new TableSnapshotScanner(UTIL.getConfiguration(), restoreDir, snapshotName, scan); verifyScanner(scanner, bbb, yyy); scanner.close(); } finally { UTIL.getAdmin().deleteSnapshot(snapshotName); UTIL.deleteTable(tableName); tearDownCluster();
TestTableSnapshotScanner.blockUntilSplitFinished(UTIL, tableName, 2);
public void setupCluster() throws Exception { setupConf(UTIL.getConfiguration()); StartMiniClusterOption option = StartMiniClusterOption.builder() .numRegionServers(NUM_REGION_SERVERS).numDataNodes(NUM_REGION_SERVERS) .createRootDir(true).build(); UTIL.startMiniCluster(option); rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir(); fs = rootDir.getFileSystem(UTIL.getConfiguration()); }
@Test public void testNoDuplicateResultsWhenSplitting() throws Exception { setupCluster(); TableName tableName = TableName.valueOf("testNoDuplicateResultsWhenSplitting"); String snapshotName = "testSnapshotBug"; blockUntilSplitFinished(UTIL, tableName, 2); new TableSnapshotScanner(UTIL.getConfiguration(), restoreDir, snapshotName, scan); verifyScanner(scanner, bbb, yyy); scanner.close(); } finally { UTIL.getAdmin().deleteSnapshot(snapshotName); UTIL.deleteTable(tableName); tearDownCluster();
TestTableSnapshotScanner.blockUntilSplitFinished(UTIL, tableName, 2);
public void setupCluster() throws Exception { setupConf(UTIL.getConfiguration()); UTIL.startMiniCluster(NUM_REGION_SERVERS, true); rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir(); fs = rootDir.getFileSystem(UTIL.getConfiguration()); }
@Test public void testScannerWithRestoreScanner() throws Exception { setupCluster(); TableName tableName = TableName.valueOf("testScanner"); String snapshotName = "testScannerWithRestoreScanner"; try { createTableAndSnapshot(UTIL, tableName, snapshotName, 50); Path restoreDir = UTIL.getDataTestDirOnTestFS(snapshotName); Scan scan = new Scan(bbb, yyy); // limit the scan verifyScanner(scanner0, bbb, yyy); scanner0.close(); verifyScanner(scanner, bbb, yyy); scanner.close(); verifyScanner(scanner, bbb, yyy); scanner.close(); verifyScanner(scanner, bbb, yyy); scanner.close(); } finally { UTIL.getAdmin().deleteSnapshot(snapshotName); UTIL.deleteTable(tableName); tearDownCluster();
TestTableSnapshotScanner.blockUntilSplitFinished(UTIL, tableName, 2);
@Test public void testWithMultiRegion() throws Exception { testScanner(UTIL, "testWithMultiRegion", 10, false); }
private void verifyScanner(ResultScanner scanner, byte[] startRow, byte[] stopRow) throws IOException, InterruptedException { HBaseTestingUtility.SeenRowTracker rowTracker = new HBaseTestingUtility.SeenRowTracker(startRow, stopRow); while (true) { Result result = scanner.next(); if (result == null) { break; } verifyRow(result); rowTracker.addRow(result.getRow()); } // validate all rows are seen rowTracker.validate(); }
private void testScanner(HBaseTestingUtility util, String snapshotName, int numRegions, boolean shutdownCluster) throws Exception { setupCluster(); TableName tableName = TableName.valueOf("testScanner"); try { createTableAndSnapshot(util, tableName, snapshotName, numRegions); if (shutdownCluster) { util.shutdownMiniHBaseCluster(); } Path restoreDir = util.getDataTestDirOnTestFS(snapshotName); Scan scan = new Scan(bbb, yyy); // limit the scan TableSnapshotScanner scanner = new TableSnapshotScanner(UTIL.getConfiguration(), restoreDir, snapshotName, scan); verifyScanner(scanner, bbb, yyy); scanner.close(); } finally { if (!shutdownCluster) { util.getAdmin().deleteSnapshot(snapshotName); util.deleteTable(tableName); tearDownCluster(); } } }
@Test public void testWithSingleRegion() throws Exception { testScanner(UTIL, "testWithSingleRegion", 1, false); }
@Test public void testScannerWithRestoreScanner() throws Exception { setupCluster(); TableName tableName = TableName.valueOf("testScanner"); String snapshotName = "testScannerWithRestoreScanner"; try { createTableAndSnapshot(UTIL, tableName, snapshotName, 50); Path restoreDir = UTIL.getDataTestDirOnTestFS(snapshotName); Scan scan = new Scan(bbb, yyy); // limit the scan verifyScanner(scanner0, bbb, yyy); scanner0.close(); verifyScanner(scanner, bbb, yyy); scanner.close(); verifyScanner(scanner, bbb, yyy); scanner.close(); verifyScanner(scanner, bbb, yyy); scanner.close(); } finally { UTIL.getAdmin().deleteSnapshot(snapshotName); UTIL.deleteTable(tableName); tearDownCluster();
@Test public void testWithMultiRegion() throws Exception { testScanner(UTIL, "testWithMultiRegion", 10, false); }
@Test public void testWithOfflineHBaseMultiRegion() throws Exception { testScanner(UTIL, "testWithMultiRegion", 20, true); }
@Test public void testWithSingleRegion() throws Exception { testScanner(UTIL, "testWithSingleRegion", 1, false); }