HBASE-12393 The regionserver web will throw exception if we disable block cache (ChiaPing Tsai)

This commit is contained in:
Enis Soztutar 2015-01-21 17:22:10 -08:00
parent ba2d05e148
commit 54f6cae41c
2 changed files with 12 additions and 1 deletions

View File

@ -210,7 +210,7 @@ org.apache.hadoop.util.StringUtils;
<%args>
CacheConfig cacheConfig;
</%args>
<%if cacheConfig == null %>
<%if cacheConfig == null || cacheConfig.getBlockCache() == null %>
<p>CacheConfig is null</p>
<%else>
<table class="table table-striped">

View File

@ -44,12 +44,17 @@ import org.mockito.Mockito;
import com.google.common.collect.Lists;
import com.google.protobuf.RpcController;
import com.google.protobuf.ServiceException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
/**
* Tests for the region server status page and its template.
*/
@Category(SmallTests.class)
public class TestRSStatusServlet {
private static final Log LOG = LogFactory.getLog(TestRSStatusServlet.class);
private HRegionServer rs;
private RSRpcServices rpcServices;
@ -78,6 +83,12 @@ public class TestRSStatusServlet {
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();