Frage

Consider this setup: JMX Server with multiple clients

So there's a JMX Server and we want it to be reachable from different JMX Clients, but the problem is that these different JMX clients knows HostX by different names/addresses. For the sake of the example lets say that HostA knows HostX by the name of hostx but HostB knows HostX by the name of hostxshadow.

I'm looking for recommendations on how to solve this problem under the following scenarios:

  1. Where I have control over the source code of the JMX Clients and JMX Server.

  2. Where I have no control over the source code, i.e. I can set System Properties on the JVM, but that's it.

The basic problem to be solved is that in the RMI world the server-side decides how a client should connect (right?). So setting e.g. java.rmi.server.hostname on HostX isn't going to help. As I see it I can only make either HostA happy or HostB happy, but not both at the same time.

Is the conclusion really that any RMI Server can only work if all clients would use the same name to access it?

War es hilfreich?

Lösung

Your conclusion is correct. It's a design flaw in RMI. There is an underlying assumption that there is a single 'most public' hostname or IP address by which the server host can be contacted by everybody.

Your statement about the host embedding its own name or address in the stub is also correct.

Andere Tipps

RMI is one possible transport of JMX. Another solution is JMXMP and switching to it is very simple, check at http://meteatamel.wordpress.com/2012/02/13/jmx-rmi-vs-jmxmp/ or http://blog.markfeeney.com/2010/10/jmx-through-ssh-tunnel.html.

The basic problem to be solved is that in the RMI world the server-side decides how a client should connect (right?). So setting e.g. java.rmi.server.hostname on HostX isn't going to help. As I see it I can only make either HostA happy or HostB happy, but not both at the same time.

This is not going to help you but for others, the trick to do is to set the java.rmi.server.hostname system property to a name that means something on HostA which is inside of the firewall but another thing to HostB which is outside.

For example, in EC2 land we set the hostname property to be the EC2 node's "public hostname" which we get by doing a:

wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname

This resolves to be some like:

ec2-54-1-2-3.compute-1.amazonaws.com

On the box itself and any others that are inside of EC2 this resolves to be 10.1.2.3 while on the outside world it resolves to the externally facing IP 54.1.2.3. Amazon does this DNS work by default. You may need to adjust the /etc/hosts file as necessary to get the names to be correct.

For more details on EC2 and JMX, see: How to connect to Java instances running on EC2 using JMX

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top