是否可以使用JMX在一个中央MBean服务器中注册或显示不同VM的MBean? [英] Is it possible with JMX to register or show the MBeans form different VMs in one central MBean server?

查看:120
本文介绍了是否可以使用JMX在一个中央MBean服务器中注册或显示不同VM的MBean?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种解决方案,从中央MBean Server中的不同Java VM注册MBean或整个MBean Servers本身,这也应该在一个单独的VM中运行。目标是只有一个中央MBean Server,它包含整个系统的所有MBean。
另外一个要求就是难度:-),客户端MBean服务器必须连接/注册到中央MBean Server而不是其他方式。中央MBean Server不需要任何客户端MBean服务器的知识来注册。

I'm looking for a solution to register the MBeans or the whole MBean Servers itself from different Java VMs in a central MBean Server which should also run in a separate VM. The goal is to have only one central MBean Server which contains all MBeans of the whole System. One additional requirement is and thats the difficulty :-), that the "client" MBean Servers must connect/register to the central MBean Server and not the other way. The central MBean Server don't need any knowledge of the "client" MBean Servers to register.

我刚刚找到了JMX示例,其中主MBean服务器连接到客户端MBean服务器并且注册了他们的注册MBean但不是其他方式。遗憾的是,用于注册自己的MBean的registerMBean()方法仅适用于本地MBean服务器,但不适用于MBeanServerConnection上的远程MBean服务器。在那里,只能使用createMbean()方法,问题在于它在远程MBean Server中注册MBean,但是你必须在远程MBean Server中使用不同的对象,一个本地和另一个。所以现在的问题是,当本地对象上的某些内容发生更改时,只有那里的更改,远程MBean Server中的已注册MBean不会获得这些更改(变量的新值...)。到目前为止,我唯一的解决方案是创建一个循环来取消注册远程服务器中的MBean并创建它们,以获取对象的实际值。这非常难看,也不太好。

I have only found JMX examples in which the "master" MBean Server connects to the "client" MBean Servers and geht their registred MBeans but not the other way. Unfortunately the registerMBean() method which is used to register your own MBeans, only exists for local MBean Servers but not for remote MBean Servers on a MBeanServerConnection. There, it is only possible to use the createMbean() method, problem here is, that it worked to register the MBean in the remote MBean Server but then you have to different Objects, one local und another in the remote MBean Server. So the Problem now is, that when something changes on the local object the changes are only there, the registered MBean in the remote MBean Server doesen't get these changes (new values of variables ...). The only solution I have so far, is to create a loop to unregister the MBeans in the remote Server and create them new, to get the actual values of the object. Thats very ugly and also not so good for the performance.

我希望有人能给我一个提示,我怎么能以更好的方式做到这一点。

I hope someone can give me a hint, how I can do this in a better way.

推荐答案

OpenDMK 使用级联服务提供了完整的方法。从文档:

The OpenDMK provides a complete way to do this using the Cascading Service. From the documentation:


级联服务使您可以直接通过主服务器的MBean服务器访问子代理$ MB $ b的MBean剂。级联的
服务已经在Java动态管理工具包
(Java DMK)5.1中进行了全面改进,以允许它通过Java Management Extensions(JMX)Remote API定义的连接器协议
进行操作。旧的
级联服务现已弃用。遗留
级联服务的示例已在第25章中保留,原因是
向后兼容性。但是,在使用旧版Java DMK
连接器时,应使用带有
旧连接器的新CasdingServiceMBean,而不是依赖于已弃用的旧版
级联代理API。

The cascading service enables you to access the MBeans of a subagent directly through the MBean server of a master agent. The cascading service has been completely overhauled in Java Dynamic Management Kit (Java DMK) 5.1 to allow it to operate over the connector protocols defined by the Java Management Extensions (JMX) Remote API. The legacy cascading service is now deprecated. The examples of the legacy cascading service have been retained in Chapter 25, for reasons of backwards compatibility. However, when using legacy Java DMK connectors, you should use the new CasdingServiceMBean with wrapped legacy connectors rather than relying on the deprecated legacy cascading agent API.

这个库中有一些有趣的部分内容可以归入JMX 2.0中的标准Java SE。我认为,级联服务就是其中之一。一旦你理解它是如何工作的,你可以得出结论,你可以自己实现它,尽管OpenDMK确实有几个棘手的角落案例。我不确定该项目有多活跃,但软件似乎是稳定的。

There are some interesting bits-and-pieces in this library that were slated to be naturalized into the standard Java SE in JMX 2.0. The cascading service, I think, was one of them. Once you understand how it works, you may conclude it is something you can implement yourself, although there are several thorny corner cases that the OpenDMK does account for. I am not sure how active the project is, but the software as is seems stable.

你可以找到文档集此处。另外,我创建了一个mavenized项目版本的软件包这里

You can find the documentation set here. Additionally, I created a mavenized project build of the packages here.

// Nicholas

//Nicholas

这篇关于是否可以使用JMX在一个中央MBean服务器中注册或显示不同VM的MBean?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆