This question arises out of https://jira.jboss.org/jira/browse/JOPR-254
JBAS5 now generates a file when it starts up which contains a jnp url which can be used by clients to connect to the JBAS instance. This was done to make it easier for the Jopr/JON agent to bootstrap its connection without have to go into the bowels of the app server and parse various configuration files to determine the url.
This all works great until someone binds the JBAS instance to 0.0.0.0, at which point the url in the file also contains 0.0.0.0 which is not very helpful for a client to connect to. So in this case what address should we be using?
a) default for the host (could be loopback or external address)
b) any loopback address
c) change the file to return all addresses
Since the Jopr/JON agent is the only client for this file so far, option b) is fine for us.
I'm wondering if we ever need to specify a non-loopback address in this case for any other future clients? The JON agent is almost always local so want's to go over the loopback address. If we don't hear any other opinions to the contrary will probably go with option b).
I don't think the following should drive this decision, but is just an FYI for anyone interested.
C is cleaner from a server-side design POV.
This URL String ultimately comes from org.jnp.server.Main, which exposes
public List getBootstrapURLs()
public String getBootstrapURL()
(The latter works by picking the first element in the list returned by the former, which is clunky.)
It's appropriate this info comes from Main, as it understands what the URL format is.
A separate class NamingServiceURLWriter actually writes the file. It (IMHO correctly) knows nothing about the URL format; it just gets a String and knows how to write it to the file.
To do a) or b) above, the logic to pick a) or b) from the overall list is either going to have to go in Main, which is a mixing of concerns, or in NamingServiceURLWriter, which forces that class to understand how to parse the URLs. Using c) avoids this kind of problem.
Again, not a huge issue.
We definitely don't want a), since connecting to the loopback address is probably going to provide a faster connection than an external address (though I guess that depends on how the OS does things).
As Charles said, b) works for us for the Jopr Agent's use case, but if you think c) is a better solution for other potential use cases (e.g. a remote client reading the jnp-service.url file via NFS and needing a non-loopback address), then we can work with that too. If you do c), the Jopr Agent would basically have to do the same logic you would have done to derive b) from c).