Search in sources :

Example 11 with RegionMetrics

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);
    }
}
Also used : RegionMetrics(org.apache.hadoop.hbase.RegionMetrics)

Example 12 with RegionMetrics

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()));
    }
}
Also used : RegionMetrics(org.apache.hadoop.hbase.RegionMetrics)

Example 13 with RegionMetrics

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);
}
Also used : Size(org.apache.hadoop.hbase.Size) ServerName(org.apache.hadoop.hbase.ServerName) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) MasterServices(org.apache.hadoop.hbase.master.MasterServices) Map(java.util.Map) HashMap(java.util.HashMap) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) RegionMetrics(org.apache.hadoop.hbase.RegionMetrics)

Example 14 with RegionMetrics

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);
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) RegionMetrics(org.apache.hadoop.hbase.RegionMetrics)

Example 15 with RegionMetrics

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());
        }
    }
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) ServerMetrics(org.apache.hadoop.hbase.ServerMetrics) RegionMetrics(org.apache.hadoop.hbase.RegionMetrics)

Aggregations

RegionMetrics (org.apache.hadoop.hbase.RegionMetrics)25 ServerMetrics (org.apache.hadoop.hbase.ServerMetrics)18 ServerName (org.apache.hadoop.hbase.ServerName)16 ClusterMetrics (org.apache.hadoop.hbase.ClusterMetrics)7 HashMap (java.util.HashMap)6 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)5 Test (org.junit.Test)5 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 Size (org.apache.hadoop.hbase.Size)4 ArrayList (java.util.ArrayList)3 Configuration (org.apache.hadoop.conf.Configuration)3 Stoppable (org.apache.hadoop.hbase.Stoppable)3 IOException (java.io.IOException)2 List (java.util.List)2 TableName (org.apache.hadoop.hbase.TableName)2 UserMetrics (org.apache.hadoop.hbase.UserMetrics)2 InterruptedIOException (java.io.InterruptedIOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 UnknownHostException (java.net.UnknownHostException)1