10 Replies Latest reply: Nov 14, 2011 7:46 PM by Mitchell Ackerman RSS

InetAddress from JGroup Address

Mitchell Ackerman Newbie

Does anyone know how to convert a JGroups/Infinispan Address to an InetAddress?  e.g., if i have an address such as




how can i convert it to a normal ip address.


I have found an approach which involves changing the DefaultCacheManager to expose the Transport, and then use the Transport channel protocol stack to return the IP address, however, I would prefer not to do that unless the signature of the getTransport method be changed in the distribution.  If there is no other good way, can the signature of


private Transport getTransport()


be changed to public???


thanks, Mitchell

  • 1. Re: InetAddress from JGroup Address
    Galder Zamarreño Master

    What's your use case for requiring the InetAddress of a node?


    Also, are you looking for the IP address of a remote node? Or of the node running locally? Or both?

  • 2. Re: InetAddress from JGroup Address
    Erik Salter Newbie

    Here's something I used to get the primary data owner's address.



    JGroupsTransport t = (JGroupsTransport) getCache().getAdvancedCache().getRpcManager().getTransport();
    if (t.getChannel() != null) {
        // The main data owner's address is always at the head of the list.
        JGroupsAddress jAddr = (JGroupsAddress) locations.get(0);
        org.jgroups.Address phys = (org.jgroups.Address) t.getChannel().down(new Event(Event.GET_PHYSICAL_ADDRESS, jAddr.getJGroupsAddress()));
         if (phys instanceof org.jgroups.stack.IpAddress) {
           bindAddress = ((org.jgroups.stack.IpAddress) phys).getIpAddress();


  • 3. Re: InetAddress from JGroup Address
    Galder Zamarreño Master

    Sure, I can imagine the type of code you used, that's not my question.


    My question is: why do you want this? what for? not how are you are retrieving it

  • 4. Re: InetAddress from JGroup Address
    Erik Salter Newbie

    I used it intially for finding the primary data owner's address so I could use the eagerLockSingleNode optimization without incurring RPC calls (like remote locks) until transaction commit time. 


    This was before the days of the Distributed Executors where I could now pass in the affected keys and let the framework execute the task on the primary data owner.

  • 5. Re: InetAddress from JGroup Address
    Galder Zamarreño Master

    Hmmm, so that explains what you used it for in the past, what about now? You still use it to get the primary data owner's IP address?


    My point is this, if you know your local logical address, i.e. your node name plus a number, and you know the logical addresses of other nodes, assuming that you give them different node names, you should be able to figure out whether you'll stay local or not, without the need of IP addresses.


    So tell us exactly what you're planning to do it now with this data and we'll be able to help you further.

  • 6. Re: InetAddress from JGroup Address
    Mitchell Ackerman Newbie

    My use case is that I need to know the IP address of remote nodes joining the Infinispan cluster so that i can use it to add nodes to a HornetQ cluster.  I'm running in an environment where multicast is not an option (Amazon), and Infinispan is configured using a Gossip Router, which allows us to discover nodes joining the cluster.  HornetQ does not support that kind of dynamic discovery (it only supports multicast discovery & static clustering), so i'm trying to piggy back off of the Infinispan Cluster membership to configure HornetQ.


    The solution I used was similar to that Posted by Erik.  It looks like I could use


    JGroupsTransport t = (JGroupsTransport) getCache().getAdvancedCache().getRpcManager().getTransport();


    rather than changing DefaultCacheManager::getTransport to public.  I'll give that a try.


    thanks, Mitchell

  • 7. Re: InetAddress from JGroup Address
    Erik Salter Newbie

    I don't plan on doing anything with this block of code now.  I needed the primary address to bridge the gap between JGroups node naming convention and my own HTTP scheme.  If anything, I use this for testing utilities for use in customer and QA labs (and that's probably code I haven't touched in a while)


    But I wasn't the one asking the original question.

  • 8. Re: InetAddress from JGroup Address
    Mitchell Ackerman Newbie

    Thanks, using


         JGroupsTransport t = (JGroupsTransport) DefaultCacheManager.getCache("acachename").getAdvancedCache().getRpcManager().getTransport();


    does work.  However, I think the API would be easier to use if




    were public.

  • 9. Re: InetAddress from JGroup Address
    Galder Zamarreño Master

    Hmmm, if you're having to maintain a cluster for Infinispan and then a cluster for HornetQ, where there appears to be an overlapp between the two, wouldn't you be better off by running AS7 instances that can run both Infinispan and HornetQ and they can simplify the cluster management by running a single cluster? Just a thought...


    Well spotted Mitchell, I had forgotten that transport was accessible via the RpcManager. If you want a more simplified API (I don't see why that'd be a problem), could you open a jira?

  • 10. Re: InetAddress from JGroup Address
    Mitchell Ackerman Newbie

    I would LOVE to do as you suggest, use AS7 cluster configuration to manage both Infinispan & HornetQ, but so far we can't figure out how to configure both of those products adequately in AS7 using the domain manager xml configuration, and have been forced to revert to embedded configuration.  See earlier posts for issues that I was encountering, but as I recall there was the issue of configuring a gossip router for infinispan, and we were unable to configure Rest for HornetQ.  If and when we can do that we will do so.


    Thanks, I'll open i Jira issue for the api change.