本文整理汇总了Java中org.apache.zookeeper.jmx.ZKMBeanInfo类的典型用法代码示例。如果您正苦于以下问题:Java ZKMBeanInfo类的具体用法?Java ZKMBeanInfo怎么用?Java ZKMBeanInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ZKMBeanInfo类属于org.apache.zookeeper.jmx包,在下文中一共展示了ZKMBeanInfo类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateAllMXBeanAreUnregistered
import org.apache.zookeeper.jmx.ZKMBeanInfo; //导入依赖的package包/类
/**
* <p>
* This test ensures that all JXM beans associated to a {@link QuorumPeer}
* are unregistered when shuted down ({@link QuorumUtil#shutdown(int)}). It
* allows a successfull restarting of several zookeeper servers (
* {@link QuorumPeer}) running on the same JVM.
* <p>
* See ZOOKEEPER-1214 for details.
*/
@Test
public void validateAllMXBeanAreUnregistered() throws IOException {
QuorumUtil qU = new QuorumUtil(1);
LOG.info(">-->> Starting up all servers...");
qU.startAll();
LOG.info(">-->> Servers up and running...");
int leaderIndex = qU.getLeaderServer();
int firstFollowerIndex = 0;
int secondFollowerIndex = 0;
switch (leaderIndex) {
case 1:
firstFollowerIndex = 2;
secondFollowerIndex = 3;
break;
case 2:
firstFollowerIndex = 1;
secondFollowerIndex = 3;
break;
case 3:
firstFollowerIndex = 1;
secondFollowerIndex = 2;
break;
default:
Assert.fail("Unexpected leaderIndex value: " + leaderIndex);
break;
}
LOG.info(">-->> Shuting down server [{}]", firstFollowerIndex);
qU.shutdown(firstFollowerIndex);
LOG.info(">-->> Shuting down server [{}]", secondFollowerIndex);
qU.shutdown(secondFollowerIndex);
LOG.info(">-->> Restarting server [{}]", firstFollowerIndex);
qU.restart(firstFollowerIndex);
LOG.info(">-->> Restarting server [{}]", secondFollowerIndex);
qU.restart(secondFollowerIndex);
qU.shutdownAll();
Set<ZKMBeanInfo> pending = MBeanRegistry.getInstance()
.getRegisteredBeans();
Assert.assertTrue("The following beans should have been unregistered: "
+ pending, pending.isEmpty());
}