Search in sources :

Example 36 with ServerMetrics

use of org.apache.hadoop.hbase.ServerMetrics in project hbase by apache.

the class TestReplicationStatusSink method getLatestSinkMetric.

private ReplicationLoadSink getLatestSinkMetric(Admin admin, ServerName server) throws IOException {
    ClusterMetrics metrics = admin.getClusterMetrics(EnumSet.of(ClusterMetrics.Option.LIVE_SERVERS));
    ServerMetrics sm = metrics.getLiveServerMetrics().get(server);
    return sm.getReplicationLoadSink();
}
Also used : ClusterMetrics(org.apache.hadoop.hbase.ClusterMetrics) ServerMetrics(org.apache.hadoop.hbase.ServerMetrics)

Example 37 with ServerMetrics

use of org.apache.hadoop.hbase.ServerMetrics in project hbase by apache.

the class TestRegionsRecoveryChore method testRegionReopensWithStoreRefConfig.

@Test
public void testRegionReopensWithStoreRefConfig() throws Exception {
    regionNo = 0;
    ClusterMetrics clusterMetrics = TestRegionsRecoveryChore.getClusterMetrics(4);
    final Map<ServerName, ServerMetrics> serverMetricsMap = clusterMetrics.getLiveServerMetrics();
    LOG.debug("All Region Names with refCount....");
    for (ServerMetrics serverMetrics : serverMetricsMap.values()) {
        Map<byte[], RegionMetrics> regionMetricsMap = serverMetrics.getRegionMetrics();
        for (RegionMetrics regionMetrics : regionMetricsMap.values()) {
            LOG.debug("name: " + new String(regionMetrics.getRegionName()) + " refCount: " + regionMetrics.getStoreRefCount());
        }
    }
    Mockito.when(hMaster.getClusterMetrics()).thenReturn(clusterMetrics);
    Mockito.when(hMaster.getAssignmentManager()).thenReturn(assignmentManager);
    for (byte[] regionName : REGION_NAME_LIST) {
        Mockito.when(assignmentManager.getRegionInfo(regionName)).thenReturn(TestRegionsRecoveryChore.getRegionInfo(regionName));
    }
    Stoppable stoppable = new StoppableImplementation();
    Configuration configuration = getCustomConf();
    configuration.setInt("hbase.regions.recovery.store.file.ref.count", 300);
    regionsRecoveryChore = new RegionsRecoveryChore(stoppable, configuration, hMaster);
    regionsRecoveryChore.chore();
    // Verify that we need to reopen regions of 2 tables
    Mockito.verify(hMaster, Mockito.times(2)).reopenRegions(Mockito.any(), Mockito.anyList(), Mockito.anyLong(), Mockito.anyLong());
    Mockito.verify(hMaster, Mockito.times(1)).getClusterMetrics();
    // Verify that we need to reopen total 3 regions that have refCount > 300
    Mockito.verify(hMaster, Mockito.times(3)).getAssignmentManager();
    Mockito.verify(assignmentManager, Mockito.times(3)).getRegionInfo(Mockito.any());
}
Also used : ClusterMetrics(org.apache.hadoop.hbase.ClusterMetrics) Configuration(org.apache.hadoop.conf.Configuration) ServerName(org.apache.hadoop.hbase.ServerName) ServerMetrics(org.apache.hadoop.hbase.ServerMetrics) Stoppable(org.apache.hadoop.hbase.Stoppable) RegionMetrics(org.apache.hadoop.hbase.RegionMetrics) Test(org.junit.Test)

Aggregations

ServerMetrics (org.apache.hadoop.hbase.ServerMetrics)37 ServerName (org.apache.hadoop.hbase.ServerName)27 RegionMetrics (org.apache.hadoop.hbase.RegionMetrics)19 ClusterMetrics (org.apache.hadoop.hbase.ClusterMetrics)18 HashMap (java.util.HashMap)13 List (java.util.List)11 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)10 Test (org.junit.Test)10 IOException (java.io.IOException)7 TreeMap (java.util.TreeMap)6 TableName (org.apache.hadoop.hbase.TableName)6 Configuration (org.apache.hadoop.conf.Configuration)5 Collections (java.util.Collections)4 Collectors (java.util.stream.Collectors)4 InterfaceAudience (org.apache.yetus.audience.InterfaceAudience)4 InterruptedIOException (java.io.InterruptedIOException)3 Arrays (java.util.Arrays)3 HashSet (java.util.HashSet)3