use of org.apache.hadoop.hbase.RegionMetrics in project hbase by apache.
the class TestAsyncClusterAdminApi method compareRegionLoads.
private void compareRegionLoads(Collection<RegionMetrics> regionLoadCluster, Collection<RegionMetrics> regionLoads) {
assertEquals("No of regionLoads from clusterStatus and regionloads from RS doesn't match", regionLoadCluster.size(), regionLoads.size());
for (RegionMetrics loadCluster : regionLoadCluster) {
boolean matched = false;
for (RegionMetrics load : regionLoads) {
if (Bytes.equals(loadCluster.getRegionName(), load.getRegionName())) {
matched = true;
continue;
}
}
assertTrue("The contents of region load from cluster and server should match", matched);
}
}
use of org.apache.hadoop.hbase.RegionMetrics in project hbase by apache.
the class TestAsyncClusterAdminApi method checkRegionsAndRegionLoads.
private void checkRegionsAndRegionLoads(Collection<RegionInfo> regions, Collection<RegionMetrics> regionLoads) {
assertEquals("No of regions and regionloads doesn't match", regions.size(), regionLoads.size());
Map<byte[], RegionMetrics> regionLoadMap = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
for (RegionMetrics regionLoad : regionLoads) {
regionLoadMap.put(regionLoad.getRegionName(), regionLoad);
}
for (RegionInfo info : regions) {
assertTrue("Region not in regionLoadMap region:" + info.getRegionNameAsString() + " regionMap: " + regionLoadMap, regionLoadMap.containsKey(info.getRegionName()));
}
}
use of org.apache.hadoop.hbase.RegionMetrics in project hbase by apache.
the class TestSimpleRegionNormalizer method setupMocksForNormalizer.
@SuppressWarnings("MockitoCast")
private void setupMocksForNormalizer(Map<byte[], Integer> regionSizes, List<RegionInfo> regionInfoList) {
masterServices = Mockito.mock(MasterServices.class, RETURNS_DEEP_STUBS);
tableDescriptor = Mockito.mock(TableDescriptor.class, RETURNS_DEEP_STUBS);
// for simplicity all regions are assumed to be on one server; doesn't matter to us
ServerName sn = ServerName.valueOf("localhost", 0, 0L);
when(masterServices.getAssignmentManager().getRegionStates().getRegionsOfTable(any())).thenReturn(regionInfoList);
when(masterServices.getAssignmentManager().getRegionStates().getRegionServerOfRegion(any())).thenReturn(sn);
when(masterServices.getAssignmentManager().getRegionStates().getRegionState(any(RegionInfo.class))).thenReturn(RegionState.createForTesting(null, RegionState.State.OPEN));
for (Map.Entry<byte[], Integer> region : regionSizes.entrySet()) {
RegionMetrics regionLoad = Mockito.mock(RegionMetrics.class);
when(regionLoad.getRegionName()).thenReturn(region.getKey());
when(regionLoad.getStoreFileSize()).thenReturn(new Size(region.getValue(), Size.Unit.MEGABYTE));
// this is possibly broken with jdk9, unclear if false positive or not
// suppress it for now, fix it when we get to running tests on 9
// see: http://errorprone.info/bugpattern/MockitoCast
when((Object) masterServices.getServerManager().getLoad(sn).getRegionMetrics().get(region.getKey())).thenReturn(regionLoad);
}
when(masterServices.isSplitOrMergeEnabled(any())).thenReturn(true);
when(tableDescriptor.getTableName()).thenReturn(name.getTableName());
normalizer = new SimpleRegionNormalizer();
normalizer.setConf(conf);
normalizer.setMasterServices(masterServices);
}
use of org.apache.hadoop.hbase.RegionMetrics in project hbase by apache.
the class TestSimpleRegionNormalizerOnCluster method getRegionSizeMB.
private static double getRegionSizeMB(final MasterServices masterServices, final RegionInfo regionInfo) {
final ServerName sn = masterServices.getAssignmentManager().getRegionStates().getRegionServerOfRegion(regionInfo);
final RegionMetrics regionLoad = masterServices.getServerManager().getLoad(sn).getRegionMetrics().get(regionInfo.getRegionName());
if (regionLoad == null) {
LOG.debug("{} was not found in RegionsLoad", regionInfo.getRegionNameAsString());
return -1;
}
return regionLoad.getStoreFileSize().get(Size.Unit.MEGABYTE);
}
use of org.apache.hadoop.hbase.RegionMetrics in project hbase by apache.
the class TestRegionServerReadRequestMetrics method testReadRequests.
private void testReadRequests(byte[] regionName, int expectedReadRequests) throws Exception {
for (ServerName serverName : serverNames) {
ServerMetrics serverMetrics = admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)).getLiveServerMetrics().get(serverName);
Map<byte[], RegionMetrics> regionMetrics = serverMetrics.getRegionMetrics();
RegionMetrics regionMetric = regionMetrics.get(regionName);
if (regionMetric != null) {
LOG.debug("server read request is " + serverMetrics.getRegionMetrics().get(regionName).getReadRequestCount() + ", region read request is " + regionMetric.getReadRequestCount());
assertEquals(3, serverMetrics.getRegionMetrics().get(regionName).getReadRequestCount());
assertEquals(3, regionMetric.getReadRequestCount());
}
}
}
Aggregations