Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #13899 > unrolled thread
| Started by | Sebastian <sebastian@undisclosed.invalid> |
|---|---|
| First post | 2012-04-25 15:38 +0200 |
| Last post | 2012-07-05 04:17 -0700 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.java.programmer
Registering MBeans in a central MBeanServer Sebastian <sebastian@undisclosed.invalid> - 2012-04-25 15:38 +0200
Re: Registering MBeans in a central MBeanServer Sebastian <sebastian@undisclosed.invalid> - 2012-04-30 16:05 +0200
Re: Registering MBeans in a central MBeanServer Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-01 10:37 -0300
Re: Registering MBeans in a central MBeanServer ratornado@gmail.com - 2012-07-05 04:17 -0700
| From | Sebastian <sebastian@undisclosed.invalid> |
|---|---|
| Date | 2012-04-25 15:38 +0200 |
| Subject | Registering MBeans in a central MBeanServer |
| Message-ID | <jn8up9$122$1@news.albasani.net> |
Hello there, I'd like to register MBeans that are local to several applications - each running in their own JVM - in a central MBeanServer. An operation invocation on that registered bean (e. g. using a jconsole connected to the central server) should result in a remote callback (probably via RMI) to the local bean, which would be registered in its platform MBeanServer. In other words, instead of creating a local bean on the central server, I'd like to create a remote proxy to my application-local bean and register that, and I'd like the whole remoting stuff to be transparent. By that I mean I don't want to explicitly start RMI registries in each application, keep track of the ports in case they run on the same machine etc. There used to be (in the year 2005) a "JMXRemote" project on java net, cf. http://today.java.net/pub/a/today/2005/12/20/introduction-to-jmxremote.html but that seems defunct. This must be a common requirement, however, I haven't found anything useful with Google, nor in any of the JMX tutorials online. -- Sebastian
[toc] | [next] | [standalone]
| From | Sebastian <sebastian@undisclosed.invalid> |
|---|---|
| Date | 2012-04-30 16:05 +0200 |
| Message-ID | <jnm66f$4b3$1@news.albasani.net> |
| In reply to | #13899 |
Am 25.04.2012 15:38, schrieb Sebastian:
> Hello there,
>
> I'd like to register MBeans that are local to several applications -
> each running in their own JVM - in a central MBeanServer. An operation
> invocation on that registered bean (e. g. using a jconsole connected to
> the central server) should result in a remote callback (probably via
> RMI) to the local bean, which would be registered in its platform
> MBeanServer.
>
> In other words, instead of creating a local bean on the central server,
> I'd like to create a remote proxy to my application-local bean and
> register that
[snip]
I ascribe the lack of response to my not actually having asked a
question. Meanwhile, I have implemented something, which has a
surprising behavior. I'll describe the code in some detail below (and
ask a question about it, too).
Consider two JVMs, one "local" and one "central". The local JVM has an
MBean server listening on port 7777 (defined by the system property
com.sun.management.jmxremote.port=7777), the central one has port 6666.
String localUrl = "service:jmx:rmi:///jndi/rmi://"
+ InetAddress.getLocalHost().getHostAddress() + ":7777"
+ "/jmxrmi";
String remoteUrl = "service:jmx:rmi:///jndi/rmi://"
+ "centralServer:6666"
+ "/jmxrmi";
On the local side, I simply register an MBean in the platform MBS:
StandardMBean mbean = new StandardMBean( this,
ComponentController.class, false );
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean( mbean, oname() );
When I connect with JConsole to port 7777 and call one of the operations
exposed by ComponentController, evertyhing works as expected.
Things start going wrong when I create a bean on the central server.
That bean gets passed the service URL for my local MBS and the local
bean's object name. Here's the code on the local side:
JMXServiceURL centralUrl = new JMXServiceURL( remoteUrl );
JMXConnector connector = JMXConnectorFactory.connect( centralUrl );
MBeanServerConnection conn = connector.getMBeanServerConnection();
conn.createMBean(
"com.test.ComponentControllerCallback",
oname(),
new Object[] { localUrl, oname() },
new String[] { "java.lang.String", "javax.management.ObjectName" } )
The methods in ComponentControllerCallback (which also implements
ComponentController) are supposed to use that information to obtain the
necessary connection to my local bean and call it back.
The very strange thing is that the simple presence of the above code to
create an MBean on a different JVM wreaks havoc with my local MBS. That
is, even if I connect again directly to the MBS on port 7777 (bypassing
the central server), the methods that worked before will now throw
ClassNotFoundExceptions for RMI-based classes. Deleting the above code
snippet will restore correct behavior.
Unfortunately, the class loading behavior of my application is too
complicated to reproduce or describe briefly. It is a composite
application developed with the SCA implementation of Apache Tuscany.
But anyway: Does anyone have any idea what it is about JMX and the above
code that could possibly throw the remote classloading mechanism into
disarray?
I did try reversing the order of local bean registration and remote bean
creation, but to no avail. Could it be the fact that both JVMs run on
the same host? I'm stumped. Perhaps there is an entirely different and
better way to implement my requirement?
-- Sebastian
[toc] | [prev] | [next] | [standalone]
| From | Arved Sandstrom <asandstrom3minus1@eastlink.ca> |
|---|---|
| Date | 2012-05-01 10:37 -0300 |
| Message-ID | <rGRnr.6310$tH5.5376@newsfe11.iad> |
| In reply to | #14055 |
On 12-04-30 11:05 AM, Sebastian wrote: > Am 25.04.2012 15:38, schrieb Sebastian: >> Hello there, >> >> I'd like to register MBeans that are local to several applications - >> each running in their own JVM - in a central MBeanServer. An operation >> invocation on that registered bean (e. g. using a jconsole connected to >> the central server) should result in a remote callback (probably via >> RMI) to the local bean, which would be registered in its platform >> MBeanServer. >> >> In other words, instead of creating a local bean on the central server, >> I'd like to create a remote proxy to my application-local bean and >> register that > [snip] > > I ascribe the lack of response to my not actually having asked a > question. Meanwhile, I have implemented something, which has a > surprising behavior. I'll describe the code in some detail below (and > ask a question about it, too). [ SNIP ] Well, no, I saw a question in the first post. :-) I use JMX a lot and so it was an interesting problem. I verified that there are commercial offerings that do this: e.g. Oracle Coherence. I'm also thinking that Open DMK with its Cascading (see http://docs.oracle.com/cd/E19698-01/816-7607/components-35/index.html) does what you want. I'll play with your code snippets some, it's interesting stuff. AHS -- A fly was very close to being called a "land," cause that's what they do half the time. -- Mitch Hedberg
[toc] | [prev] | [next] | [standalone]
| From | ratornado@gmail.com |
|---|---|
| Date | 2012-07-05 04:17 -0700 |
| Message-ID | <e8205d8f-90b1-408b-8ab7-55c93d50da6b@googlegroups.com> |
| In reply to | #13899 |
Hi Im also stuck with a problem of registering the mbeans in central mbeanserver.however i think that my problem is not too complex. Earlier i used to use my local mbeanserver, and thus used registermbean to register my object, but now i have to use creatembean, which uses classname as a parameter.now im trying to save an array in my mbean object, but as it is accepting class name as its parameter the array wont show up on jconsole. Plz Help.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web