javax.management.Query.isInstanceOf()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中javax.management.Query.isInstanceOf方法的一些代码示例,展示了Query.isInstanceOf的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.isInstanceOf方法的具体详情如下:
包路径:javax.management.Query
类名称:Query
方法名:isInstanceOf

Query.isInstanceOf介绍

暂无

代码示例

代码示例来源:origin: apache/geode

private ObjectName getObjectName(Class<?> proxyClass, String beanQueryName)
  throws MalformedObjectNameException, IOException {
 ObjectName name = null;
 QueryExp query = null;
 if (proxyClass != null) {
  query = Query.isInstanceOf(Query.value(proxyClass.getName()));
 }
 if (beanQueryName != null) {
  name = ObjectName.getInstance(beanQueryName);
 }
 Set<ObjectInstance> beans = con.queryMBeans(name, query);
 assertEquals("failed to find only one instance of type " + proxyClass.getName() + " with name "
   + beanQueryName, 1, beans.size());
 return ((ObjectInstance) beans.toArray()[0]).getObjectName();
}

代码示例来源:origin: palantir/atlasdb

/**
   *
   * @param <T>
   * @param mbeanClazz
   * @return proxy interfaces to all beans registered to the server implementing the class mbeanClazz.
   */
  public static <T> Iterable<T> getInstanceBeanProxies(final Class<T> mbeanClazz){
    return Iterables.transform(
        ManagementFactory.getPlatformMBeanServer().queryNames(ObjectName.WILDCARD, Query.isInstanceOf(new StringValueExp(mbeanClazz.getName())))
        , obj -> JMXUtils.newMBeanProxy(ManagementFactory.getPlatformMBeanServer(), obj, mbeanClazz));
  }
}

代码示例来源:origin: com.palantir.atlasdb/atlasdb-commons

/**
   *
   * @param <T>
   * @param mbeanClazz
   * @return proxy interfaces to all beans registered to the server implementing the class mbeanClazz.
   */
  public static <T> Iterable<T> getInstanceBeanProxies(final Class<T> mbeanClazz){
    return Iterables.transform(
        ManagementFactory.getPlatformMBeanServer().queryNames(ObjectName.WILDCARD, Query.isInstanceOf(new StringValueExp(mbeanClazz.getName())))
        , obj -> JMXUtils.newMBeanProxy(ManagementFactory.getPlatformMBeanServer(), obj, mbeanClazz));
  }
}

代码示例来源:origin: spring-projects/sts4

protected Set<ObjectName> getNonBootSpringLiveMBeans() {
  if (this.nonBootLiveMBeanNames == null) {
    try {
      this.nonBootLiveMBeanNames = withTimeout(() -> withJmxConnector(jmxConnector -> {
        MBeanServerConnection connection = jmxConnector.getMBeanServerConnection();
        QueryExp queryExp = Query.isInstanceOf(Query.value("org.springframework.context.support.LiveBeansView"));
        return connection.queryNames(null, queryExp);
      }));
    } catch (Exception e) {
      e.printStackTrace();
      this.nonBootLiveMBeanNames = Collections.emptySet();
    }
  }
  return this.nonBootLiveMBeanNames;
}

代码示例来源:origin: apache/jackrabbit-oak

private Set<ObjectInstance> getMetricMbeans() throws MalformedObjectNameException {
  QueryExp q = Query.isInstanceOf(Query.value(JmxReporter.MetricMBean.class.getName()));
  return server.queryMBeans(new ObjectName("org.apache.jackrabbit.oak:*"), q);
}

代码示例来源:origin: apache/twill

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;
}

相关文章