Search in sources :

Example 1 with MetricsHBaseServerWrapperStub

use of org.apache.hadoop.hbase.ipc.MetricsHBaseServerWrapperStub in project hbase by apache.

the class TestRSStatusServlet method setupBasicMocks.

@Before
public void setupBasicMocks() throws IOException, ServiceException {
    rs = Mockito.mock(HRegionServer.class);
    rpcServices = Mockito.mock(RSRpcServices.class);
    rpcServer = Mockito.mock(RpcServerInterface.class);
    Mockito.doReturn(HBaseConfiguration.create()).when(rs).getConfiguration();
    Mockito.doReturn(rpcServices).when(rs).getRSRpcServices();
    Mockito.doReturn(rpcServer).when(rs).getRpcServer();
    Mockito.doReturn(fakeResponse).when(rpcServices).getServerInfo((RpcController) Mockito.any(), (GetServerInfoRequest) Mockito.any());
    // Fake ZKW
    ZooKeeperWatcher zkw = Mockito.mock(ZooKeeperWatcher.class);
    Mockito.doReturn("fakequorum").when(zkw).getQuorum();
    Mockito.doReturn(zkw).when(rs).getZooKeeper();
    // Fake CacheConfig
    LOG.warn("The " + HConstants.HFILE_BLOCK_CACHE_SIZE_KEY + " is set to 0");
    CacheConfig cacheConf = Mockito.mock(CacheConfig.class);
    Mockito.doReturn(null).when(cacheConf).getBlockCache();
    Mockito.doReturn(cacheConf).when(rs).getCacheConfig();
    // Fake MasterAddressTracker
    MasterAddressTracker mat = Mockito.mock(MasterAddressTracker.class);
    Mockito.doReturn(fakeMasterAddress).when(mat).getMasterAddress();
    Mockito.doReturn(mat).when(rs).getMasterAddressTracker();
    MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class);
    Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper();
    Mockito.doReturn(rms).when(rs).getRegionServerMetrics();
    MetricsHBaseServer ms = Mockito.mock(MetricsHBaseServer.class);
    Mockito.doReturn(new MetricsHBaseServerWrapperStub()).when(ms).getHBaseServerWrapper();
    Mockito.doReturn(ms).when(rpcServer).getMetrics();
}
Also used : MasterAddressTracker(org.apache.hadoop.hbase.zookeeper.MasterAddressTracker) ZooKeeperWatcher(org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher) RpcServerInterface(org.apache.hadoop.hbase.ipc.RpcServerInterface) CacheConfig(org.apache.hadoop.hbase.io.hfile.CacheConfig) MetricsHBaseServer(org.apache.hadoop.hbase.ipc.MetricsHBaseServer) MetricsHBaseServerWrapperStub(org.apache.hadoop.hbase.ipc.MetricsHBaseServerWrapperStub) Before(org.junit.Before)

Example 2 with MetricsHBaseServerWrapperStub

use of org.apache.hadoop.hbase.ipc.MetricsHBaseServerWrapperStub in project hbase by apache.

the class TestRSStatusServlet method setupBasicMocks.

@Before
public void setupBasicMocks() throws IOException, ServiceException {
    rs = Mockito.mock(HRegionServer.class);
    rpcServices = Mockito.mock(RSRpcServices.class);
    rpcServer = Mockito.mock(RpcServerInterface.class);
    Mockito.doReturn(HBaseConfiguration.create()).when(rs).getConfiguration();
    Mockito.doReturn(rpcServices).when(rs).getRSRpcServices();
    Mockito.doReturn(rpcServer).when(rs).getRpcServer();
    Mockito.doReturn(fakeResponse).when(rpcServices).getServerInfo(Mockito.any(), Mockito.any());
    // Fake ZKW
    ZKWatcher zkw = Mockito.mock(ZKWatcher.class);
    Mockito.doReturn("fakequorum").when(zkw).getQuorum();
    Mockito.doReturn(zkw).when(rs).getZooKeeper();
    // Fake BlockCache
    LOG.warn("The " + HConstants.HFILE_BLOCK_CACHE_SIZE_KEY + " is set to 0");
    Mockito.doReturn(Optional.empty()).when(rs).getBlockCache();
    // Fake MasterAddressTracker
    MasterAddressTracker mat = Mockito.mock(MasterAddressTracker.class);
    Mockito.doReturn(fakeMasterAddress).when(mat).getMasterAddress();
    Mockito.doReturn(mat).when(rs).getMasterAddressTracker();
    MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class);
    Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper();
    Mockito.doReturn(rms).when(rs).getMetrics();
    MetricsHBaseServer ms = Mockito.mock(MetricsHBaseServer.class);
    Mockito.doReturn(new MetricsHBaseServerWrapperStub()).when(ms).getHBaseServerWrapper();
    Mockito.doReturn(ms).when(rpcServer).getMetrics();
    Mockito.doReturn(ByteBuffAllocator.HEAP).when(rpcServer).getByteBuffAllocator();
}
Also used : MetricsRegionServerWrapperStub(org.apache.hadoop.hbase.regionserver.MetricsRegionServerWrapperStub) MasterAddressTracker(org.apache.hadoop.hbase.zookeeper.MasterAddressTracker) ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) RpcServerInterface(org.apache.hadoop.hbase.ipc.RpcServerInterface) RSRpcServices(org.apache.hadoop.hbase.regionserver.RSRpcServices) MetricsRegionServer(org.apache.hadoop.hbase.regionserver.MetricsRegionServer) MetricsHBaseServer(org.apache.hadoop.hbase.ipc.MetricsHBaseServer) HRegionServer(org.apache.hadoop.hbase.regionserver.HRegionServer) MetricsHBaseServerWrapperStub(org.apache.hadoop.hbase.ipc.MetricsHBaseServerWrapperStub) Before(org.junit.Before)

Aggregations

MetricsHBaseServer (org.apache.hadoop.hbase.ipc.MetricsHBaseServer)2 MetricsHBaseServerWrapperStub (org.apache.hadoop.hbase.ipc.MetricsHBaseServerWrapperStub)2 RpcServerInterface (org.apache.hadoop.hbase.ipc.RpcServerInterface)2 MasterAddressTracker (org.apache.hadoop.hbase.zookeeper.MasterAddressTracker)2 Before (org.junit.Before)2 CacheConfig (org.apache.hadoop.hbase.io.hfile.CacheConfig)1 HRegionServer (org.apache.hadoop.hbase.regionserver.HRegionServer)1 MetricsRegionServer (org.apache.hadoop.hbase.regionserver.MetricsRegionServer)1 MetricsRegionServerWrapperStub (org.apache.hadoop.hbase.regionserver.MetricsRegionServerWrapperStub)1 RSRpcServices (org.apache.hadoop.hbase.regionserver.RSRpcServices)1 ZKWatcher (org.apache.hadoop.hbase.zookeeper.ZKWatcher)1 ZooKeeperWatcher (org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher)1