Java 类org.apache.hadoop.hbase.regionserver.MetricsRegionServerWrapperStub 实例源码

项目:DominoHBase    文件:TestMetricsRegionServer.java   
@Test
public void testWrapperSource() {
  MetricsRegionServer rsm = new MetricsRegionServer(new MetricsRegionServerWrapperStub());
  MetricsRegionServerSource serverSource = rsm.getMetricsSource();
  HELPER.assertTag("serverName", "test", serverSource);
  HELPER.assertTag("clusterId", "tClusterId", serverSource);
  HELPER.assertTag("zookeeperQuorum", "zk", serverSource);
  HELPER.assertGauge("regionServerStartTime", 100, serverSource);
  HELPER.assertGauge("regionCount", 101, serverSource);
  HELPER.assertGauge("storeCount", 2, serverSource);
  HELPER.assertGauge("storeFileCount", 300, serverSource);
  HELPER.assertGauge("memstoreSize", 1025, serverSource);
  HELPER.assertGauge("storeFileSize", 1900, serverSource);
  HELPER.assertCounter("totalRequestCount", 899, serverSource);
  HELPER.assertCounter("readRequestCount", 997, serverSource);
  HELPER.assertCounter("writeRequestCount", 707, serverSource);
  HELPER.assertCounter("checkMutateFailedCount", 401, serverSource);
  HELPER.assertCounter("checkMutatePassedCount", 405, serverSource);
  HELPER.assertGauge("storeFileIndexSize", 406, serverSource);
  HELPER.assertGauge("staticIndexSize", 407, serverSource);
  HELPER.assertGauge("staticBloomSize", 408, serverSource);
  HELPER.assertGauge("putsWithoutWALCount", 409, serverSource);
  HELPER.assertGauge("putsWithoutWALSize", 410, serverSource);
  HELPER.assertGauge("percentFilesLocal", 99, serverSource);
  HELPER.assertGauge("compactionQueueLength", 411, serverSource);
  HELPER.assertGauge("flushQueueLength", 412, serverSource);
  HELPER.assertGauge("blockCacheFreeSize", 413, serverSource);
  HELPER.assertGauge("blockCacheCount", 414, serverSource);
  HELPER.assertGauge("blockCacheSize", 415, serverSource);
  HELPER.assertCounter("blockCacheHitCount", 416, serverSource);
  HELPER.assertCounter("blockCacheMissCount", 417, serverSource);
  HELPER.assertCounter("blockCacheEvictionCount", 418, serverSource);
  HELPER.assertGauge("blockCountHitPercent", 98, serverSource);
  HELPER.assertGauge("blockCacheExpressHitPercent", 97, serverSource);
  HELPER.assertCounter("updatesBlockedTime", 419, serverSource);
}
项目:DominoHBase    文件:TestMetricsRegionServer.java   
@Test
public void testSlowCount() {
  MetricsRegionServer rsm = new MetricsRegionServer(new MetricsRegionServerWrapperStub());
  MetricsRegionServerSource serverSource = rsm.getMetricsSource();
  for (int i=0; i < 12; i ++) {
    rsm.updateAppend(12);
    rsm.updateAppend(1002);
  }
  for (int i=0; i < 13; i ++) {
    rsm.updateDelete(13);
    rsm.updateDelete(1003);
  }
  for (int i=0; i < 14; i ++) {
    rsm.updateGet(14);
    rsm.updateGet(1004);
  }
  for (int i=0; i < 15; i ++) {
    rsm.updateIncrement(15);
    rsm.updateIncrement(1005);
  }
  for (int i=0; i < 16; i ++) {
    rsm.updatePut(16);
    rsm.updatePut(1006);
  }

  HELPER.assertCounter("appendNumOps", 24, serverSource);
  HELPER.assertCounter("deleteNumOps", 26, serverSource);
  HELPER.assertCounter("getNumOps", 28, serverSource);
  HELPER.assertCounter("incrementNumOps", 30, serverSource);
  HELPER.assertCounter("mutateNumOps", 32, serverSource);


  HELPER.assertCounter("slowAppendCount", 12, serverSource);
  HELPER.assertCounter("slowDeleteCount", 13, serverSource);
  HELPER.assertCounter("slowGetCount", 14, serverSource);
  HELPER.assertCounter("slowIncrementCount", 15, serverSource);
  HELPER.assertCounter("slowPutCount", 16, serverSource);
}
项目:ditb    文件:TestMasterStatusServlet.java   
@Before
public void setupBasicMocks() {
  conf = HBaseConfiguration.create();

  master = Mockito.mock(HMaster.class);
  Mockito.doReturn(FAKE_HOST).when(master).getServerName();
  Mockito.doReturn(conf).when(master).getConfiguration();

  //Fake DeadServer
  DeadServer deadServer = Mockito.mock(DeadServer.class);
  // Fake serverManager
  ServerManager serverManager = Mockito.mock(ServerManager.class);
  Mockito.doReturn(1.0).when(serverManager).getAverageLoad();
  Mockito.doReturn(serverManager).when(master).getServerManager();
  Mockito.doReturn(deadServer).when(serverManager).getDeadServers();

  // Fake AssignmentManager and RIT
  AssignmentManager am = Mockito.mock(AssignmentManager.class);
  RegionStates rs = Mockito.mock(RegionStates.class);
  NavigableMap<String, RegionState> regionsInTransition =
    Maps.newTreeMap();
  regionsInTransition.put("r1",
    new RegionState(FAKE_HRI, RegionState.State.CLOSING, 12345L, FAKE_HOST));
  Mockito.doReturn(rs).when(am).getRegionStates();
  Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();
  Mockito.doReturn(am).when(master).getAssignmentManager();
  Mockito.doReturn(serverManager).when(master).getServerManager();

  // Fake ZKW
  ZooKeeperWatcher zkw = Mockito.mock(ZooKeeperWatcher.class);
  Mockito.doReturn("fakequorum").when(zkw).getQuorum();
  Mockito.doReturn(zkw).when(master).getZooKeeper();

  // Fake MasterAddressTracker
  MasterAddressTracker tracker = Mockito.mock(MasterAddressTracker.class);
  Mockito.doReturn(tracker).when(master).getMasterAddressTracker();
  Mockito.doReturn(FAKE_HOST).when(tracker).getMasterAddress();

  MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class);
  Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper();
  Mockito.doReturn(rms).when(master).getRegionServerMetrics();

  // Mock admin
  admin = Mockito.mock(HBaseAdmin.class);
}
项目:pbase    文件:TestMasterStatusServlet.java   
@Before
public void setupBasicMocks() {
  conf = HBaseConfiguration.create();

  master = Mockito.mock(HMaster.class);
  Mockito.doReturn(FAKE_HOST).when(master).getServerName();
  Mockito.doReturn(conf).when(master).getConfiguration();

  //Fake DeadServer
  DeadServer deadServer = Mockito.mock(DeadServer.class);
  // Fake serverManager
  ServerManager serverManager = Mockito.mock(ServerManager.class);
  Mockito.doReturn(1.0).when(serverManager).getAverageLoad();
  Mockito.doReturn(serverManager).when(master).getServerManager();
  Mockito.doReturn(deadServer).when(serverManager).getDeadServers();

  // Fake AssignmentManager and RIT
  AssignmentManager am = Mockito.mock(AssignmentManager.class);
  RegionStates rs = Mockito.mock(RegionStates.class);
  NavigableMap<String, RegionState> regionsInTransition =
    Maps.newTreeMap();
  regionsInTransition.put("r1",
    new RegionState(FAKE_HRI, RegionState.State.CLOSING, 12345L, FAKE_HOST));
  Mockito.doReturn(rs).when(am).getRegionStates();
  Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();
  Mockito.doReturn(am).when(master).getAssignmentManager();
  Mockito.doReturn(serverManager).when(master).getServerManager();

  // Fake ZKW
  ZooKeeperWatcher zkw = Mockito.mock(ZooKeeperWatcher.class);
  Mockito.doReturn("fakequorum").when(zkw).getQuorum();
  Mockito.doReturn(zkw).when(master).getZooKeeper();

  // Fake MasterAddressTracker
  MasterAddressTracker tracker = Mockito.mock(MasterAddressTracker.class);
  Mockito.doReturn(tracker).when(master).getMasterAddressTracker();
  Mockito.doReturn(FAKE_HOST).when(tracker).getMasterAddress();

  MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class);
  Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper();
  Mockito.doReturn(rms).when(master).getRegionServerMetrics();

  // Mock admin
  admin = Mockito.mock(HBaseAdmin.class);
}
项目:hbase    文件:TestMasterStatusServlet.java   
@Before
public void setupBasicMocks() {
  conf = HBaseConfiguration.create();

  master = Mockito.mock(HMaster.class);
  Mockito.doReturn(FAKE_HOST).when(master).getServerName();
  Mockito.doReturn(conf).when(master).getConfiguration();

  //Fake DeadServer
  DeadServer deadServer = Mockito.mock(DeadServer.class);
  // Fake serverManager
  ServerManager serverManager = Mockito.mock(ServerManager.class);
  Mockito.doReturn(1.0).when(serverManager).getAverageLoad();
  Mockito.doReturn(serverManager).when(master).getServerManager();
  Mockito.doReturn(deadServer).when(serverManager).getDeadServers();

  // Fake AssignmentManager and RIT
  AssignmentManager am = Mockito.mock(AssignmentManager.class);
  RegionStates rs = Mockito.mock(RegionStates.class);
  List<RegionState> regionsInTransition = new ArrayList<>();
  regionsInTransition.add(new RegionState(FAKE_HRI, RegionState.State.CLOSING, 12345L, FAKE_HOST));
  Mockito.doReturn(rs).when(am).getRegionStates();
  Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();
  Mockito.doReturn(am).when(master).getAssignmentManager();
  Mockito.doReturn(serverManager).when(master).getServerManager();

  // Fake ZKW
  ZKWatcher zkw = Mockito.mock(ZKWatcher.class);
  Mockito.doReturn(new ZNodePaths(conf)).when(zkw).getZNodePaths();
  Mockito.doReturn("fakequorum").when(zkw).getQuorum();
  Mockito.doReturn(zkw).when(master).getZooKeeper();

  // Fake MasterAddressTracker
  MasterAddressTracker tracker = Mockito.mock(MasterAddressTracker.class);
  Mockito.doReturn(tracker).when(master).getMasterAddressTracker();
  Mockito.doReturn(FAKE_HOST).when(tracker).getMasterAddress();

  MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class);
  Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper();
  Mockito.doReturn(rms).when(master).getRegionServerMetrics();

  // Mock admin
  admin = Mockito.mock(Admin.class);
}
项目:PyroDB    文件:TestMasterStatusServlet.java   
@Before
public void setupBasicMocks() {
  conf = HBaseConfiguration.create();

  master = Mockito.mock(HMaster.class);
  Mockito.doReturn(FAKE_HOST).when(master).getServerName();
  Mockito.doReturn(conf).when(master).getConfiguration();

  //Fake DeadServer
  DeadServer deadServer = Mockito.mock(DeadServer.class);
  // Fake serverManager
  ServerManager serverManager = Mockito.mock(ServerManager.class);
  Mockito.doReturn(1.0).when(serverManager).getAverageLoad();
  Mockito.doReturn(serverManager).when(master).getServerManager();
  Mockito.doReturn(deadServer).when(serverManager).getDeadServers();

  // Fake AssignmentManager and RIT
  AssignmentManager am = Mockito.mock(AssignmentManager.class);
  RegionStates rs = Mockito.mock(RegionStates.class);
  NavigableMap<String, RegionState> regionsInTransition =
    Maps.newTreeMap();
  regionsInTransition.put("r1",
    new RegionState(FAKE_HRI, RegionState.State.CLOSING, 12345L, FAKE_HOST));
  Mockito.doReturn(rs).when(am).getRegionStates();
  Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();
  Mockito.doReturn(am).when(master).getAssignmentManager();
  Mockito.doReturn(serverManager).when(master).getServerManager();

  // Fake ZKW
  ZooKeeperWatcher zkw = Mockito.mock(ZooKeeperWatcher.class);
  Mockito.doReturn("fakequorum").when(zkw).getQuorum();
  Mockito.doReturn(zkw).when(master).getZooKeeper();

  // Fake MasterAddressTracker
  MasterAddressTracker tracker = Mockito.mock(MasterAddressTracker.class);
  Mockito.doReturn(tracker).when(master).getMasterAddressTracker();
  Mockito.doReturn(FAKE_HOST).when(tracker).getMasterAddress();

  MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class);
  Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper();
  Mockito.doReturn(rms).when(master).getRegionServerMetrics();

  // Mock admin
  admin = Mockito.mock(HBaseAdmin.class); 
}
项目:DominoHBase    文件:TestMetricsRegionServer.java   
@Test
public void testConstuctor() {
  MetricsRegionServer rsm = new MetricsRegionServer(new MetricsRegionServerWrapperStub());
  assertNotNull("There should be a hadoop1/hadoop2 metrics source", rsm.getMetricsSource() );
  assertNotNull("The RegionServerMetricsWrapper should be accessable", rsm.getRegionServerWrapper());
}