5 Replies Latest reply on Sep 5, 2012 7:32 AM by rhusar

    jboss 7 How to get All ClusterNodes

    bsudhananthan

      In previous jboss version i.e in jboss 5, i followed below steps to get the cluster node details.

       

                 Context ctx = new InitialContext();

                  HAPartition partition = (HAPartition) ctx.lookup("HAPartition/" + getClusterName());

       

                  if (partition != null)

                  {

                      return partition.getClusterNodes();

                  }

       

      In jboss 7 HAPartition is not present and cluster nodes are identified by its unique multicast address (refer https://community.jboss.org/thread/177877).

       

      So please  provide me steps to get all the clusternodes in jboss 7.

       

      Thanks in advance,

      Sudhananathan B

        • 1. Re: jboss 7 How to get All ClusterNodes
          jaysensharma

          Hi sudhananthan,

           

              Please refer to the following link which has a JMX code sample in order to lest the Cluster Member details in JBoss AS7

           

              http://middlewaremagic.com/jboss/?p=2428

           

           

          Thanks

          Jay SenSharma

          • 2. Re: jboss 7 How to get All ClusterNodes
            bsudhananthan

            Thanks

            Jay Kumar SenSharma ,

             

            In the link you specified contains example to retreve node information for specified host and port. But i need to get entire node information lists which falls under cluster.

             

            In above jboss 5 code partition.getClusterNodes(); will return ClusterNode[ ] . So please anyone help me to get ClusterNodes info in jboss 7 .

            • 3. Re: jboss 7 How to get All ClusterNodes
              jaysensharma

              Hi,

               

                  The   following attribute if invoked on any Cluster member (Which is part of cluster) then it will return the Whole Cluster view,. (Means the List of servers which are part of the cluster)

               

                 String webClusterObjectName="jgroups:type=channel,cluster=\"web\"";

                 ObjectName objectName = new ObjectName(webClusterObjectName);

                String clusterView = (String) connection.getAttribute(objectName,"View");

               

              Example: 

              [node2/web, node1/web]

              • 4. Re: jboss 7 How to get All ClusterNodes
                bsudhananthan

                Jay Kumar SenSharma

                I got it pal.

                 

                Only view attribute will gives all the node names. All other attributes are specific to node through which JMXConnectorFactory connects.

                 

                For example my two server instance "server1" and "server2". I connect to "server1" to get all those details.

                 

                clusterView = [server1/web|1] [server1/web, server2/web]

                receivedMessages = 9

                name = server1/web

                clusterName = web

                So you can see only clusterView gives info of all the nodes in cluster and all other details are specific to node which i connected.

                 

                My output should contain nodename, ipaddress of all nodes that are connected to cluster (i.e one like org.jboss.as.clustering.ClusterNode).

                • 5. Re: jboss 7 How to get All ClusterNodes
                  rhusar

                  I personally dont like the JMX way very much, I find using Java directly is much nicer and as simple as:

                   

                      Channel channel = (Channel) CurrentServiceContainer.getServiceContainer().getService(ServiceName.JBOSS.append("jgroups", "channel", "web")).getValue();
                      List<Address> members = channel.getView().getMembers();
                              log.log(Level.INFO, "Addresses: {0}.", members);

                   

                  HTH,

                  Rado