类javax.management.StringValueExp源码实例Demo

下面列出了怎么用javax.management.StringValueExp的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: twill   文件: SessionExpireTestRun.java
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();
  stopwatch.start();
  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;
        }
      }
    }
    Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
  } while (stopwatch.elapsedTime(timeoutUnit) < timeout);

  return false;
}
 
 类所在包
 类方法
 同包方法