JConsole 中可见的 Coherence 节点 MBean 的 JMX 查询问题

发布于 2024-07-26 21:41:32 字数 1582 浏览 6 评论 0原文

我正在使用 JMX 构建一个自定义工具,用于监控工作中的远程 Coherence 集群。 我能够很好地连接并直接查询 MBean,并且我已经获得了几乎所有我需要的信息。 查询 MBean 以获取集群中的特定缓存时,我遇到了一个障碍,我可以在其中找到有关获取/放置总数、每次平均时间等的统计信息。

然而,当我尝试 当我使用 JConsole 连接到远程进程时,以编程方式访问是可见的,并且具有如下名称:

Coherence:type=Cache,service=SequenceQueue,name=SEQ%GENERATOR,nodeId=1,tier=back

如果我可以动态获取特定节点 ID 的所有 type=Cache MBean 而无需指定,它将使其更加灵活所有缓存。 我尝试像这样查询它们:

QueryExp specifiedNodeId = Query.eq(Query.attr("nodeId"), Query.value(nodeId));
QueryExp typeIsCache = Query.eq(Query.attr("type"), Query.value("Cache"));
QueryExp cacheNodes = Query.and(specifiedNodeId, typeIsCache);
ObjectName coherence = new ObjectName("Coherence:*");
Set<ObjectName> cacheMBeans = mBeanServer.queryMBeans(coherence, cacheNodes);

但是,无论我使用 queryMBeans() 还是 queryNames(),查询都会返回一个包含...的 Set

  • 。 .0 个对象(如果我传递上面显示的参数
  • )...0 个对象(如果我为第一个参数传递 null
  • ...中的所有 MBean如果我为第二个参数传递 null,则为 Coherence:* 域 (112)
  • ...如果我传递 null,则为每个 MBean (128)对于这两个参数

前两个结果都是意外的,并且在我传递的QueryExp中提出了一个问题,但我无法弄清楚问题是什么。 我什至尝试只传递 typeIsCachespecifiedNodeId 作为第二个参数(使用 coherencenull 作为第一个参数),我总是得到 0 个结果。

我对 JMX 很陌生——对问题出在哪里有了解吗? (仅供参考,监控工具将在 Java 5 上运行,因此 JMX 2.0 之类的东西此时对我没有帮助。)

I'm using JMX to build a custom tool for monitoring remote Coherence clusters at work. I'm able to connect just fine and query MBeans directly, and I've acquired nearly all the information I need. However, I've run into a snag when trying to query MBeans for specific caches within a cluster, which is where I can find stats about total number of gets/puts, average time for each, etc.

The MBeans I'm trying to access programatically are visible when I connect to the remote process using JConsole, and have names like this:

Coherence:type=Cache,service=SequenceQueue,name=SEQ%GENERATOR,nodeId=1,tier=back

It would make it more flexible if I can dynamically grab all type=Cache MBeans for a particular node ID without specifying all the caches. I'm trying to query them like this:

QueryExp specifiedNodeId = Query.eq(Query.attr("nodeId"), Query.value(nodeId));
QueryExp typeIsCache = Query.eq(Query.attr("type"), Query.value("Cache"));
QueryExp cacheNodes = Query.and(specifiedNodeId, typeIsCache);
ObjectName coherence = new ObjectName("Coherence:*");
Set<ObjectName> cacheMBeans = mBeanServer.queryMBeans(coherence, cacheNodes);

However, regardless of whether I use queryMBeans() or queryNames(), the query returns a Set containing...

  • ...0 objects if I pass the arguments shown above
  • ...0 objects if I pass null for the first argument
  • ...all MBeans in the Coherence:* domain (112) if I pass null for the second argument
  • ...every single MBean (128) if I pass null for both arguments

The first two results are the unexpected ones, and suggest a problem in the QueryExp I'm passing, but I can't figure out what the problem is. I even tried just passing typeIsCache or specifiedNodeId for the second parameter (with either coherence or null as the first parameter) and I always get 0 results.

I'm pretty green with JMX — any insight on what the problem is? (FYI, the monitoring tool will be run on Java 5, so things like JMX 2.0 won't help me at this point.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

战皆罪 2024-08-02 21:41:32

只是想为后代发布我的解决方案...

我已经能够通过更简单(但更陌生)的方法成功检索与指定特征匹配的 MBean 集。 我仍然不知道为什么 QueryExp 方法不起作用,但这是有效的(替换我问题中的最后一行代码):

Set<ObjectName> cacheMBeans = mBeanServer.queryNames(new ObjectName("Coherence:type=Cache,nodeId="+nodeId+",*"), null);

在添加片段 service 时它也有效ObjectName 构造函数字符串中的 =SequenceQueue 按 Coherence 服务(缓存)名称进行过滤。

只要它能以某种方式工作,就足以让我完成工作,但这似乎是 JMX 实现中的一个明显缺陷。 不要让我开始使用 JMX 和 RMI 创建工作 JMXServiceURL 的过程...

Just wanted to post my solution for posterity...

I have been able to successfully retrieve the set of MBeans matching the specified characteristics through a simpler (yet stranger) approach. I still don't know why the QueryExp approach doesn't work, but here's what does work (replaces the last line of code in my question):

Set<ObjectName> cacheMBeans = mBeanServer.queryNames(new ObjectName("Coherence:type=Cache,nodeId="+nodeId+",*"), null);

It also works when adding a fragment service=SequenceQueue in the ObjectName constructor string to filter by Coherence service (cache) name.

As long as it works somehow, it's enough for me to get my job done, but this seems like a glaring flaw in the JMX implementation. And don't get me started on the process for creating a working JMXServiceURL using JMX and RMI...

∝单色的世界 2024-08-02 21:41:32

我和你的情况一样,我认为 JDK 文档可能会更清楚。

Query.* 似乎只能匹配底层 MBean 的属性(即真正的 POJO getter),而 ObjectName 模式能够匹配 ObjectName 本身内的键/值。

如果能够灵活地在 ObjectName 域中执行更复杂的查询,那就太好了。

I fell down the same path as you, and I think the JDK docs could be clearer.

The Query.* appear to be only able to match attributes of the underlying MBean (i.e. real POJO getters), whereas ObjectName patterns is able to match against key/values within the ObjectName itself.

It would be nice to have the flexibility of doing more complex queries within the ObjectName domain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文