本文整理汇总了Java中org.apache.zookeeper.jmx.MBeanRegistry类的典型用法代码示例。如果您正苦于以下问题:Java MBeanRegistry类的具体用法?Java MBeanRegistry怎么用?Java MBeanRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MBeanRegistry类属于org.apache.zookeeper.jmx包,在下文中一共展示了MBeanRegistry类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expireAppMasterZKSession
import org.apache.zookeeper.jmx.MBeanRegistry; //导入依赖的package包/类
private boolean expireAppMasterZKSession(TwillController controller, long timeout, TimeUnit timeoutUnit) {
MBeanServer mbeanServer = MBeanRegistry.getInstance().getPlatformMBeanServer();
QueryExp query = Query.isInstanceOf(new StringValueExp(ConnectionMXBean.class.getName()));
Stopwatch stopwatch = new Stopwatch();
do {
// Find the AM session and expire it
Set<ObjectName> connectionBeans = mbeanServer.queryNames(ObjectName.WILDCARD, query);
for (ObjectName objectName : connectionBeans) {
ConnectionMXBean connectionBean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName,
ConnectionMXBean.class, false);
for (String node : connectionBean.getEphemeralNodes()) {
if (node.endsWith("/instances/" + controller.getRunId().getId())) {
// This is the AM, expire the session.
LOG.info("Kill AM session {}", connectionBean.getSessionId());
connectionBean.terminateSession();
return true;
}
}
}
} while (stopwatch.elapsedTime(timeoutUnit) < timeout);
return false;
}
示例2: setUp
import org.apache.zookeeper.jmx.MBeanRegistry; //导入依赖的package包/类
public static void setUp() throws IOException {
MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
cs.start();
JMXServiceURL addr = cs.getAddress();
cc = JMXConnectorFactory.connect(addr);
}
示例3: registerJMX
import org.apache.zookeeper.jmx.MBeanRegistry; //导入依赖的package包/类
@Override
protected void registerJMX() {
// register with JMX
try {
jmxDataTreeBean = new DataTreeBean(getZKDatabase().getDataTree());
MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
} catch (Exception e) {
LOG.warn("Failed to register with JMX", e);
jmxDataTreeBean = null;
}
}
示例4: unregisterJMX
import org.apache.zookeeper.jmx.MBeanRegistry; //导入依赖的package包/类
@Override
protected void unregisterJMX() {
// unregister from JMX
try {
if (jmxDataTreeBean != null) {
MBeanRegistry.getInstance().unregister(jmxDataTreeBean);
}
} catch (Exception e) {
LOG.warn("Failed to unregister with JMX", e);
}
jmxDataTreeBean = null;
}
示例5: registerConnection
import org.apache.zookeeper.jmx.MBeanRegistry; //导入依赖的package包/类
public void registerConnection(ServerCnxn serverCnxn) {
if (zkServer != null) {
ConnectionBean jmxConnectionBean = new ConnectionBean(serverCnxn, zkServer);
try {
MBeanRegistry.getInstance().register(jmxConnectionBean, zkServer.jmxServerBean);
connectionBeans.put(serverCnxn, jmxConnectionBean);
} catch (JMException e) {
LOG.warn("Could not register connection", e);
}
}
}
示例6: setUp
import org.apache.zookeeper.jmx.MBeanRegistry; //导入依赖的package包/类
public static void setUp() throws IOException {
MBeanServer mbs = MBeanRegistry.getInstance().getPlatformMBeanServer();
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://127.0.0.1");
cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
cs.start();
JMXServiceURL addr = cs.getAddress();
cc = JMXConnectorFactory.connect(addr);
}