当前位置: 首页>>代码示例>>Java>>正文


Java MBeanRegistry类代码示例

本文整理汇总了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;
}
 
开发者ID:chtyim,项目名称:incubator-twill,代码行数:27,代码来源:SessionExpireTestRun.java

示例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);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:12,代码来源:JMXEnv.java

示例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;
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:12,代码来源:LearnerZooKeeperServer.java

示例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;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:13,代码来源:LearnerZooKeeperServer.java

示例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);
        }
    }

}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:13,代码来源:ServerCnxnFactory.java

示例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);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:12,代码来源:JMXEnv.java


注:本文中的org.apache.zookeeper.jmx.MBeanRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。