本文整理汇总了Java中org.apache.hadoop.hbase.zookeeper.MasterAddressTracker类的典型用法代码示例。如果您正苦于以下问题:Java MasterAddressTracker类的具体用法?Java MasterAddressTracker怎么用?Java MasterAddressTracker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MasterAddressTracker类属于org.apache.hadoop.hbase.zookeeper包,在下文中一共展示了MasterAddressTracker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testMasterAddressTrackerFromZK
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
/**
* Unit tests that uses ZooKeeper but does not use the master-side methods
* but rather acts directly on ZK.
* @throws Exception
*/
@Test
public void testMasterAddressTrackerFromZK() throws Exception {
// Create the master node with a dummy address
final int infoPort = 1235;
final ServerName sn = ServerName.valueOf("localhost", 1234, System.currentTimeMillis());
final MasterAddressTracker addressTracker = setupMasterTracker(sn, infoPort);
try {
assertTrue(addressTracker.hasMaster());
ServerName pulledAddress = addressTracker.getMasterAddress();
assertTrue(pulledAddress.equals(sn));
assertEquals(infoPort, addressTracker.getMasterInfoPort());
} finally {
assertTrue("Couldn't clean up master",
MasterAddressTracker.deleteIfEquals(addressTracker.getWatcher(), sn.toString()));
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:TestMasterAddressTracker.java
示例2: setupBasicMocks
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
@Before
public void setupBasicMocks() throws IOException, ServiceException {
rs = Mockito.mock(HRegionServer.class);
Mockito.doReturn(HBaseConfiguration.create())
.when(rs).getConfiguration();
Mockito.doReturn(fakeResponse).when(rs).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 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();
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:22,代码来源:TestRSStatusServlet.java
示例3: setupBasicMocks
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
@Before
public void setupBasicMocks() throws IOException, ServiceException {
rs = Mockito.mock(HRegionServer.class);
rpcServices = Mockito.mock(RSRpcServices.class);
Mockito.doReturn(HBaseConfiguration.create())
.when(rs).getConfiguration();
Mockito.doReturn(rpcServices).when(rs).getRSRpcServices();
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 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();
}
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:24,代码来源:TestRSStatusServlet.java
示例4: setupBasicMocks
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
@Before
public void setupBasicMocks() throws IOException, ServiceException {
rs = Mockito.mock(HRegionServer.class);
Mockito.doReturn(HBaseConfiguration.create())
.when(rs).getConfiguration();
Mockito.doReturn(fakeResponse).when(rs).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 MasterAddressTracker
MasterAddressTracker mat = Mockito.mock(MasterAddressTracker.class);
Mockito.doReturn(fakeMasterAddress).when(mat).getMasterAddress();
Mockito.doReturn(mat).when(rs).getMasterAddressManager();
MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class);
Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper();
Mockito.doReturn(rms).when(rs).getMetrics();
}
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:22,代码来源:TestRSStatusServlet.java
示例5: assertMaster
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
/**
* Assert there is an active master and that it has the specified address.
* @param zk
* @param thisMasterAddress
* @throws KeeperException
* @throws IOException
*/
private void assertMaster(ZooKeeperWatcher zk,
ServerName expectedAddress)
throws KeeperException, IOException {
ServerName readAddress = MasterAddressTracker.getMasterAddress(zk);
assertNotNull(readAddress);
assertTrue(expectedAddress.equals(readAddress));
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:TestActiveMasterManager.java
示例6: setupBasicMocks
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
@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();
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:TestRSStatusServlet.java
示例7: testDeleteIfEquals
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
@Test
public void testDeleteIfEquals() throws Exception {
final ServerName sn = ServerName.valueOf("localhost", 1234, System.currentTimeMillis());
final MasterAddressTracker addressTracker = setupMasterTracker(sn, 1772);
try {
assertFalse("shouldn't have deleted wrong master server.",
MasterAddressTracker.deleteIfEquals(addressTracker.getWatcher(), "some other string."));
} finally {
assertTrue("Couldn't clean up master",
MasterAddressTracker.deleteIfEquals(addressTracker.getWatcher(), sn.toString()));
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:TestMasterAddressTracker.java
示例8: setupMasterTracker
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
/**
* create an address tracker instance
* @param sn if not-null set the active master
* @param infoPort if there is an active master, set its info port.
*/
private MasterAddressTracker setupMasterTracker(final ServerName sn, final int infoPort)
throws Exception {
ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
name.getMethodName(), null);
ZKUtil.createAndFailSilent(zk, zk.baseZNode);
// Should not have a master yet
MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
addressTracker.start();
assertFalse(addressTracker.hasMaster());
zk.registerListener(addressTracker);
// Use a listener to capture when the node is actually created
NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
zk.registerListener(listener);
if (sn != null) {
LOG.info("Creating master node");
MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn, infoPort);
// Wait for the node to be created
LOG.info("Waiting for master address manager to be notified");
listener.waitForCreation();
LOG.info("Master node created");
}
return addressTracker;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:TestMasterAddressTracker.java
示例9: testNoBackups
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
@Test
public void testNoBackups() throws Exception {
final ServerName sn = ServerName.valueOf("localhost", 1234, System.currentTimeMillis());
final MasterAddressTracker addressTracker = setupMasterTracker(sn, 1772);
try {
assertEquals("Should receive 0 for backup not found.", 0,
addressTracker.getBackupMasterInfoPort(
ServerName.valueOf("doesnotexist.example.com", 1234, System.currentTimeMillis())));
} finally {
assertTrue("Couldn't clean up master",
MasterAddressTracker.deleteIfEquals(addressTracker.getWatcher(), sn.toString()));
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:TestMasterAddressTracker.java
示例10: testNoMaster
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
@Test
public void testNoMaster() throws Exception {
final MasterAddressTracker addressTracker = setupMasterTracker(null, 1772);
assertFalse(addressTracker.hasMaster());
assertNull("should get null master when none active.", addressTracker.getMasterAddress());
assertEquals("Should receive 0 for backup not found.", 0, addressTracker.getMasterInfoPort());
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:TestMasterAddressTracker.java
示例11: getMasterInfoPort
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
@Override
public int getMasterInfoPort() throws IOException {
// TODO: Fix! Reaching into internal implementation!!!!
ConnectionManager.HConnectionImplementation connection =
(ConnectionManager.HConnectionImplementation)this.connection;
ZooKeeperKeepAliveConnection zkw = connection.getKeepAliveZooKeeperWatcher();
try {
return MasterAddressTracker.getMasterInfoPort(zkw);
} catch (KeeperException e) {
throw new IOException("Failed to get master info port from MasterAddressTracker", e);
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:HBaseAdmin.java
示例12: makeStubNoRetries
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
/**
* Create a stub. Try once only. It is not typed because there is no common type to
* protobuf services nor their interfaces. Let the caller do appropriate casting.
* @return A stub for master services.
* @throws IOException
* @throws KeeperException
* @throws ServiceException
*/
private Object makeStubNoRetries() throws IOException, KeeperException, ServiceException {
ZooKeeperKeepAliveConnection zkw;
try {
zkw = getKeepAliveZooKeeperWatcher();
} catch (IOException e) {
ExceptionUtil.rethrowIfInterrupt(e);
throw new ZooKeeperConnectionException("Can't connect to ZooKeeper", e);
}
try {
checkIfBaseNodeAvailable(zkw);
ServerName sn = MasterAddressTracker.getMasterAddress(zkw);
if (sn == null) {
String msg = "ZooKeeper available but no active master location found";
LOG.info(msg);
throw new MasterNotRunningException(msg);
}
if (isDeadServer(sn)) {
throw new MasterNotRunningException(sn + " is dead.");
}
// Use the security info interface name as our stub key
String key = getStubKey(getServiceName(),
sn.getHostname(), sn.getPort(), hostnamesCanChange);
connectionLock.putIfAbsent(key, key);
Object stub = null;
synchronized (connectionLock.get(key)) {
stub = stubs.get(key);
if (stub == null) {
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sn, user, rpcTimeout);
stub = makeStub(channel);
isMasterRunning();
stubs.put(key, stub);
}
}
return stub;
} finally {
zkw.close();
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:47,代码来源:ConnectionManager.java
示例13: setupBasicMocks
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
@Before
public void setupBasicMocks() throws IOException, ServiceException {
rs = Mockito.mock(HRegionServer.class);
rpcServices = Mockito.mock(RSRpcServices.class);
Mockito.doReturn(HBaseConfiguration.create())
.when(rs).getConfiguration();
Mockito.doReturn(rpcServices).when(rs).getRSRpcServices();
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();
}
开发者ID:grokcoder,项目名称:pbase,代码行数:30,代码来源:TestRSStatusServlet.java
示例14: testMasterAddressTrackerFromZK
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
/**
* Unit tests that uses ZooKeeper but does not use the master-side methods
* but rather acts directly on ZK.
* @throws Exception
*/
@Test
public void testMasterAddressTrackerFromZK() throws Exception {
ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
"testMasterAddressTrackerFromZK", null);
ZKUtil.createAndFailSilent(zk, zk.baseZNode);
// Should not have a master yet
MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
addressTracker.start();
assertFalse(addressTracker.hasMaster());
zk.registerListener(addressTracker);
// Use a listener to capture when the node is actually created
NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
zk.registerListener(listener);
// Create the master node with a dummy address
String host = "localhost";
int port = 1234;
int infoPort = 1235;
ServerName sn = ServerName.valueOf(host, port, System.currentTimeMillis());
LOG.info("Creating master node");
MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn, infoPort);
// Wait for the node to be created
LOG.info("Waiting for master address manager to be notified");
listener.waitForCreation();
LOG.info("Master node created");
assertTrue(addressTracker.hasMaster());
ServerName pulledAddress = addressTracker.getMasterAddress();
assertTrue(pulledAddress.equals(sn));
assertEquals(infoPort, addressTracker.getMasterInfoPort());
}
开发者ID:grokcoder,项目名称:pbase,代码行数:40,代码来源:TestMasterAddressTracker.java
示例15: makeStubNoRetries
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
/**
* Create a stub. Try once only. It is not typed because there is no common type to
* protobuf services nor their interfaces. Let the caller do appropriate casting.
*
* @return A stub for master services.
* @throws IOException
* @throws KeeperException
* @throws ServiceException
*/
private Object makeStubNoRetries() throws IOException, KeeperException, ServiceException {
ZooKeeperKeepAliveConnection zkw;
try {
zkw = getKeepAliveZooKeeperWatcher();
} catch (IOException e) {
ExceptionUtil.rethrowIfInterrupt(e);
throw new ZooKeeperConnectionException("Can't connect to ZooKeeper", e);
}
try {
checkIfBaseNodeAvailable(zkw);
ServerName sn = MasterAddressTracker.getMasterAddress(zkw);
if (sn == null) {
String msg = "ZooKeeper available but no active master location found";
LOG.info(msg);
throw new MasterNotRunningException(msg);
}
if (isDeadServer(sn)) {
throw new MasterNotRunningException(sn + " is dead.");
}
// Use the security info interface name as our stub key
String key = getStubKey(getServiceName(), sn.getHostAndPort());
connectionLock.putIfAbsent(key, key);
Object stub = null;
synchronized (connectionLock.get(key)) {
stub = stubs.get(key);
if (stub == null) {
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sn, user, rpcTimeout);
stub = makeStub(channel);
isMasterRunning();
stubs.put(key, stub);
}
}
return stub;
} finally {
zkw.close();
}
}
开发者ID:grokcoder,项目名称:pbase,代码行数:47,代码来源:ConnectionManager.java
示例16: testMasterAddressTrackerFromZK
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
/**
* Unit tests that uses ZooKeeper but does not use the master-side methods
* but rather acts directly on ZK.
* @throws Exception
*/
@Test
public void testMasterAddressTrackerFromZK() throws Exception {
ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
"testMasterAddressTrackerFromZK", null);
ZKUtil.createAndFailSilent(zk, zk.baseZNode);
// Should not have a master yet
MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
addressTracker.start();
assertFalse(addressTracker.hasMaster());
zk.registerListener(addressTracker);
// Use a listener to capture when the node is actually created
NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
zk.registerListener(listener);
// Create the master node with a dummy address
String host = "localhost";
int port = 1234;
ServerName sn = ServerName.valueOf(host, port, System.currentTimeMillis());
LOG.info("Creating master node");
MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn);
// Wait for the node to be created
LOG.info("Waiting for master address manager to be notified");
listener.waitForCreation();
LOG.info("Master node created");
assertTrue(addressTracker.hasMaster());
ServerName pulledAddress = addressTracker.getMasterAddress();
assertTrue(pulledAddress.equals(sn));
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:39,代码来源:TestMasterAddressTracker.java
示例17: makeStubNoRetries
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
/**
* Create a stub. Try once only. It is not typed because there is no common type to
* protobuf services nor their interfaces. Let the caller do appropriate casting.
* @return A stub for master services.
* @throws IOException
* @throws KeeperException
* @throws ServiceException
*/
private Object makeStubNoRetries() throws IOException, KeeperException, ServiceException {
ZooKeeperKeepAliveConnection zkw;
try {
zkw = getKeepAliveZooKeeperWatcher();
} catch (IOException e) {
ExceptionUtil.rethrowIfInterrupt(e);
throw new ZooKeeperConnectionException("Can't connect to ZooKeeper", e);
}
try {
checkIfBaseNodeAvailable(zkw);
ServerName sn = MasterAddressTracker.getMasterAddress(zkw);
if (sn == null) {
String msg = "ZooKeeper available but no active master location found";
LOG.info(msg);
throw new MasterNotRunningException(msg);
}
if (isDeadServer(sn)) {
throw new MasterNotRunningException(sn + " is dead.");
}
// Use the security info interface name as our stub key
String key = getStubKey(getServiceName(), sn.getHostAndPort());
connectionLock.putIfAbsent(key, key);
Object stub = null;
synchronized (connectionLock.get(key)) {
stub = stubs.get(key);
if (stub == null) {
BlockingRpcChannel channel = rpcClient.createBlockingRpcChannel(sn,
user, rpcTimeout);
stub = makeStub(channel);
isMasterRunning();
stubs.put(key, stub);
}
}
return stub;
} finally {
zkw.close();
}
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:47,代码来源:HConnectionManager.java
示例18: getHBaseMasterUrl
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
private String getHBaseMasterUrl() throws IOException, KeeperException {
String host = conf.get("hbase.master.info.bindAddress");
if (host.equals("0.0.0.0")) {
host = MasterAddressTracker.getMasterAddress(new ZooKeeperWatcher(conf, null, null)).getHostname();
}
String port = conf.get("hbase.master.info.port");
return "http://" + host + ":" + port + "/";
}
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:HBaseUsageExtractor.java
示例19: assertMaster
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
/**
* Assert there is an active master and that it has the specified address.
* @param zk
* @param thisMasterAddress
* @throws KeeperException
* @throws IOException
*/
private void assertMaster(ZKWatcher zk,
ServerName expectedAddress)
throws KeeperException, IOException {
ServerName readAddress = MasterAddressTracker.getMasterAddress(zk);
assertNotNull(readAddress);
assertTrue(expectedAddress.equals(readAddress));
}
开发者ID:apache,项目名称:hbase,代码行数:15,代码来源:TestActiveMasterManager.java
示例20: setupBasicMocks
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入依赖的package包/类
@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
ZKWatcher zkw = Mockito.mock(ZKWatcher.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();
}
开发者ID:apache,项目名称:hbase,代码行数:36,代码来源:TestRSStatusServlet.java
注:本文中的org.apache.hadoop.hbase.zookeeper.MasterAddressTracker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论