Search in sources :

Example 1 with ZNodePaths

use of org.apache.hadoop.hbase.zookeeper.ZNodePaths in project hbase by apache.

the class TestMasterStatusServlet method setupBasicMocks.

@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);
    Set<RegionState> regionsInTransition = new HashSet<>();
    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
    ZooKeeperWatcher zkw = Mockito.mock(ZooKeeperWatcher.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);
}
Also used : MetricsRegionServerWrapperStub(org.apache.hadoop.hbase.regionserver.MetricsRegionServerWrapperStub) MetricsRegionServer(org.apache.hadoop.hbase.regionserver.MetricsRegionServer) Admin(org.apache.hadoop.hbase.client.Admin) MasterAddressTracker(org.apache.hadoop.hbase.zookeeper.MasterAddressTracker) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) ZNodePaths(org.apache.hadoop.hbase.zookeeper.ZNodePaths) HashSet(java.util.HashSet) Before(org.junit.Before)

Aggregations

HashSet (java.util.HashSet)1 Admin (org.apache.hadoop.hbase.client.Admin)1 MetricsRegionServer (org.apache.hadoop.hbase.regionserver.MetricsRegionServer)1 MetricsRegionServerWrapperStub (org.apache.hadoop.hbase.regionserver.MetricsRegionServerWrapperStub)1 MasterAddressTracker (org.apache.hadoop.hbase.zookeeper.MasterAddressTracker)1 ZNodePaths (org.apache.hadoop.hbase.zookeeper.ZNodePaths)1 ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)1 Before (org.junit.Before)1