2 Replies Latest reply on Nov 20, 2012 11:11 AM by crazycradd

    port from 4.2.3 to as7

    crazycradd

      When my application was deployed in a cluster the value for the provider url could be incorrect so I used the following to correct it

       

      HASessionState state = CPClusterHelper.getHASessionState();
      sb.append(state.getCurrentHAPartition().getClusterNode().getIpAddress().getHostName());
      sb.append(":");
      sb.append(state.getCurrentHAPartition().getClusterNode().getPort());

       

      I then used this to set the JNDI lookup PROVIDER_URL

      contextProps.put(Context.PROVIDER_URL, jndiURL);

       

      I dont seem to be able to get the same info from

       

      Object o = cnx.lookup("java:jboss/infinispan/container/web");
      return (EmbeddedCacheManager)o;

       

      or

      Object o = cnx.lookup("java:jboss/infinispan/container/cluster");
      return (EmbeddedCacheManager)o;

       

      Is it possible to get this info ?

        • 1. Re: port from 4.2.3 to as7
          rhusar

          Hey Peter,

           

          not sure what are you trying to achieve, sounds like you want the physical address out of cluster nodes and how to do that in AS7?

           

          Here is a quick code snippet, what you need to do is to ask JGroups transport what the logical cluster member names stand for in IP address terms:

           

            @Resource(lookup = "java:jboss/infinispan/container/web")

              private EmbeddedCacheManager container;


          ...


          info.append("Physical addresses: ");

                  JGroupsTransport transport = (JGroupsTransport) container.getTransport();

                  for (Address infinispanWrapAddr : container.getMembers()) {

                      JGroupsAddress jgroupsWrapAddr = (JGroupsAddress) infinispanWrapAddr;

                      org.jgroups.Address physAddr = (org.jgroups.Address) transport.getChannel().down(new Event(Event.GET_PHYSICAL_ADDRESS, jgroupsWrapAddr.getJGroupsAddress()));

                      IpAddress ipAddr = (IpAddress) physAddr;

                      info.append(ipAddr.getIpAddress().getHostAddress()).append(":").append(((IpAddress) physAddr).getPort()).append("; ");

                  }

          ...


           

           

          Or look at the code here: https://github.com/clusterbench/clusterbench/blob/master/clusterbench-ee6-web/src/main/java/org/jboss/test/clusterbench/web/debug/DebugServlet.java

           

          HTH,

          Rado

          1 of 1 people found this helpful
          • 2. Re: port from 4.2.3 to as7
            crazycradd

            Thanks for this its a step in the right direction.

             

            I'm trying to provide the client with a list or remote servers and ports that can be used to create a jndi PROVIDER_URL that I have read will be supported in 7.2

            https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project

             

            The port given in the sample above is the jgroups port is there anyway to get the remoting port ? I can assume its x +y since I use a tool to configure the appserver binding group but it would be nice to get this programatically rather than guess what it should be.