Search in sources :

Example 1 with DeadServer

use of org.apache.hadoop.hbase.master.DeadServer 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);
    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 ActiveMaster
    Mockito.doReturn(Optional.of(FAKE_HOST)).when(master).getActiveMaster();
    // Mock admin
    admin = Mockito.mock(Admin.class);
}
Also used : ServerManager(org.apache.hadoop.hbase.master.ServerManager) RegionState(org.apache.hadoop.hbase.master.RegionState) RegionStates(org.apache.hadoop.hbase.master.assignment.RegionStates) ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) HMaster(org.apache.hadoop.hbase.master.HMaster) AssignmentManager(org.apache.hadoop.hbase.master.assignment.AssignmentManager) ArrayList(java.util.ArrayList) ZNodePaths(org.apache.hadoop.hbase.zookeeper.ZNodePaths) Admin(org.apache.hadoop.hbase.client.Admin) DeadServer(org.apache.hadoop.hbase.master.DeadServer) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)1 Admin (org.apache.hadoop.hbase.client.Admin)1 DeadServer (org.apache.hadoop.hbase.master.DeadServer)1 HMaster (org.apache.hadoop.hbase.master.HMaster)1 RegionState (org.apache.hadoop.hbase.master.RegionState)1 ServerManager (org.apache.hadoop.hbase.master.ServerManager)1 AssignmentManager (org.apache.hadoop.hbase.master.assignment.AssignmentManager)1 RegionStates (org.apache.hadoop.hbase.master.assignment.RegionStates)1 ZKWatcher (org.apache.hadoop.hbase.zookeeper.ZKWatcher)1 ZNodePaths (org.apache.hadoop.hbase.zookeeper.ZNodePaths)1 Before (org.junit.Before)1