throws IOException { for (int i = 0; i < regionEncodedName.size(); ++i) { HRegion regionToClose = this.getRegion(regionEncodedName.get(i)); if (regionToClose != null) { Map<byte[], List<HStoreFile>> hstoreFiles = null;
public static void checkRegionIsClosed(HBaseTestingUtility HTU, HRegionServer rs, HRegionInfo hri) throws Exception { while (!rs.getRegionsInTransitionInRS().isEmpty()) { Thread.sleep(1); } try { Assert.assertFalse(rs.getRegion(hri.getRegionName()).isAvailable()); } catch (NotServingRegionException expected) { // That's how it work: if the region is closed we have an exception. } }
@Test public void testRegionReplicaGets() throws Exception { try { //load some data to primary HTU.loadNumericRows(table, f, 0, 1000); // assert that we can read back from primary Assert.assertEquals(1000, HTU.countRows(table)); // flush so that region replica can read HRegion region = getRS().getRegionByEncodedName(hriPrimary.getEncodedName()); region.flush(true); openRegion(HTU, getRS(), hriSecondary); // first try directly against region region = getRS().getRegion(hriSecondary.getEncodedName()); assertGet(region, 42, true); assertGetRpc(hriSecondary, 42, true); } finally { HTU.deleteNumericRows(table, HConstants.CATALOG_FAMILY, 0, 1000); closeRegion(HTU, getRS(), hriSecondary); } }
/** * Find the HRegion based on a region specifier * * @param regionSpecifier the region specifier * @return the corresponding region * @throws IOException if the specifier is not null, * but failed to find the region */ @VisibleForTesting public HRegion getRegion( final RegionSpecifier regionSpecifier) throws IOException { return regionServer.getRegion(regionSpecifier.getValue().toByteArray()); }
public static void checkRegionIsOpened(HBaseTestingUtility HTU, HRegionServer rs, HRegionInfo hri) throws Exception { while (!rs.getRegionsInTransitionInRS().isEmpty()) { Thread.sleep(1); } Assert.assertTrue(rs.getRegion(hri.getRegionName()).isAvailable()); }
@Override public boolean evaluate() throws Exception { return rs.getRegion(region.getEncodedName()) != null; }
String encodedName = region.getEncodedName(); byte[] encodedNameBytes = region.getEncodedNameAsBytes(); final HRegion onlineRegion = regionServer.getRegion(encodedName);
/** * Find the List of HRegions based on a list of region specifiers * * @param regionSpecifiers the list of region specifiers * @return the corresponding list of regions * @throws IOException if any of the specifiers is not null, * but failed to find the region */ private List<HRegion> getRegions(final List<RegionSpecifier> regionSpecifiers, final CacheEvictionStatsBuilder stats) { List<HRegion> regions = Lists.newArrayListWithCapacity(regionSpecifiers.size()); for (RegionSpecifier regionSpecifier: regionSpecifiers) { try { regions.add(regionServer.getRegion(regionSpecifier.getValue().toByteArray())); } catch (NotServingRegionException e) { stats.addException(regionSpecifier.getValue().toByteArray(), e); } } return regions; }
while (lastRefreshTimesIter.hasNext()) { String encodedName = lastRefreshTimesIter.next(); if (regionServer.getRegion(encodedName) == null) { lastRefreshTimesIter.remove();
HRegion region = null; try { region = regionServer.getRegion(s.getRegionInfo().getRegionName()); if (region != null && region.getCoprocessorHost() != null) { region.getCoprocessorHost().preScannerClose(s);
String regionName = locator.getAllRegionLocations().get(0).getRegionInfo().getEncodedName(); HRegion region = TEST_UTIL.getRSForFirstRegionInTable(tableName).getRegion(regionName); HStore store = region.getStores().iterator().next(); CacheConfig cacheConf = store.getCacheConfig();
.setWalGroupId(fakeWalGroupId)); Region region = rs0.getRegion(hriSecondary.getEncodedName()); HTU.verifyNumericRows(region, f, 0, 1000);
String regionName = locator.getAllRegionLocations().get(0).getRegionInfo().getEncodedName(); HRegion region = TEST_UTIL.getRSForFirstRegionInTable(tableName).getRegion(regionName); HStore store = region.getStores().iterator().next(); CacheConfig cacheConf = store.getCacheConfig();
@BeforeClass public static void setUp() throws Exception { conf = hbaseTestingUtility.getConfiguration(); hbaseTestingUtility.startMiniCluster(); t1 = hbaseTestingUtility.createTable(TABLE1, COLUMN_FAMILY1); try (RegionLocator locator = hbaseTestingUtility.getConnection().getRegionLocator(TABLE1)) { HRegionInfo firstHRI = locator.getAllRegionLocations().get(0).getRegionInfo(); r1name = firstHRI.getRegionName(); rs1 = hbaseTestingUtility.getHBaseCluster().getRegionServer( hbaseTestingUtility.getHBaseCluster().getServerWith(r1name)); r1 = rs1.getRegion(r1name); } }
@Test public void testReplayCallable() throws Exception { // tests replaying the edits to a secondary region replica using the Callable directly openRegion(HTU, rs0, hriSecondary); ClusterConnection connection = (ClusterConnection) ConnectionFactory.createConnection(HTU.getConfiguration()); //load some data to primary HTU.loadNumericRows(table, f, 0, 1000); Assert.assertEquals(1000, entries.size()); // replay the edits to the secondary using replay callable replicateUsingCallable(connection, entries); Region region = rs0.getRegion(hriSecondary.getEncodedName()); HTU.verifyNumericRows(region, f, 0, 1000); HTU.deleteNumericRows(table, f, 0, 1000); closeRegion(HTU, rs0, hriSecondary); connection.close(); }
@Test public void testReplayCallableWithRegionMove() throws Exception { // tests replaying the edits to a secondary region replica using the Callable directly while // the region is moved to another location.It tests handling of RME. openRegion(HTU, rs0, hriSecondary); ClusterConnection connection = (ClusterConnection) ConnectionFactory.createConnection(HTU.getConfiguration()); //load some data to primary HTU.loadNumericRows(table, f, 0, 1000); Assert.assertEquals(1000, entries.size()); // replay the edits to the secondary using replay callable replicateUsingCallable(connection, entries); Region region = rs0.getRegion(hriSecondary.getEncodedName()); HTU.verifyNumericRows(region, f, 0, 1000); HTU.loadNumericRows(table, f, 1000, 2000); // load some more data to primary // move the secondary region from RS0 to RS1 closeRegion(HTU, rs0, hriSecondary); openRegion(HTU, rs1, hriSecondary); // replicate the new data replicateUsingCallable(connection, entries); region = rs1.getRegion(hriSecondary.getEncodedName()); // verify the new data. old data may or may not be there HTU.verifyNumericRows(region, f, 1000, 2000); HTU.deleteNumericRows(table, f, 0, 2000); closeRegion(HTU, rs1, hriSecondary); connection.close(); }
public void assertRegionMetrics(String metric, long expectedValue) throws Exception { try (RegionLocator locator = connection.getRegionLocator(tableName)) { for ( HRegionLocation location: locator.getAllRegionLocations()) { HRegionInfo hri = location.getRegionInfo(); MetricsRegionAggregateSource agg = rs.getRegion(hri.getRegionName()).getMetrics().getSource().getAggregateSource(); String prefix = "namespace_" + NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR + "_table_" + tableName.getNameAsString() + "_region_" + hri.getEncodedName()+ "_metric_"; metricsHelper.assertCounter(prefix + metric, expectedValue, agg); } } }
Assert.assertTrue(getRS().getRegion(regionName).isAvailable());