2 Replies Latest reply on Dec 27, 2011 10:42 AM by amalrajvinoth

    convert logical address into equivalent physical address?

    amalrajvinoth

      Hi,

       

      Is there a way to convert logical address into equivalent physical address?

       

      I want to get the members of the cluster(CacheManager.getMemebers()) as Physical addresses instead of logical address(returned by default). Could someone please help regarding this.

       

       

      thanks in advance,

      Amal Raj

        • 1. Re: convert logical address into equivalent physical address?
          dan.berindei

          It's probably more involved than it needs to be, but you can do it:

           

          {code:java}

                EmbeddedCacheManager cm = c1.getCacheManager();       org.infinispan.remoting.transport.Address a = cm.getCoordinator();       org.jgroups.Address ja = ((JGroupsAddress)a).getJGroupsAddress();       PhysicalAddress pa = (PhysicalAddress) ((JGroupsTransport)cm.getTransport()).getChannel().down(new Event(Event.GET_PHYSICAL_ADDRESS, ja));       if (pa instanceof IpAddress) {          System.out.println(((IpAddress) pa).getIpAddress());       }

          {code}

          1 of 1 people found this helpful
          • 2. Re: convert logical address into equivalent physical address?
            amalrajvinoth

            Thanks a lot Dan,

            Using above code snippet, It is working as expected with minimal changes. Please find below the modified code.

                 List<Address> memberAddr = cacheCluster.getMembers();
                 List<String> memberStr = new ArrayList<String>(memberAddr.size());
                 IpAddress physicalIp = null;
                 org.jgroups.Address jgroupAddr = null;
                 PhysicalAddress physicalAddr = null;
                 for (Address addr : memberAddr) {
                      jgroupAddr = ((JGroupsAddress) addr).getJGroupsAddress();
                      physicalAddr = (PhysicalAddress) ((JGroupsTransport) ispnCache.getAdvancedCache().getRpcManager().getTransport())
                                  .getChannel().downcall(new Event(Event.GET_PHYSICAL_ADDRESS, jgroupAddr));
                      if (physicalAddr instanceof IpAddress) {
                           physicalIp = ((IpAddress) physicalAddr);
                           String ipPort = new StringBuffer(FWD_SLASH).append(physicalIp.getIpAddress()).append(COLON)
                                    .append(physicalIp.getPort()).toString();
                             memberStr.add(ipPort);
                      }
                  }
                return memberStr;
            

             

            thanks, Amal raj