1 Reply Latest reply on Aug 29, 2012 10:42 AM by pferraro

    Programatically identifying master/slave nodes in JBoss AS 7.1


      Is there an API available, which can tell me if the current node (on which this piece of code is running) is a master or a slave? Probably, in most cases, you dont care, but say if you dont implement a ha singleton service, but want to execute some code only on the master (or only on the salve) node(s), how do you do it? How do the various UIs for JBoss monitoring get this information from JBoss AS?


      Similarly, how to identify whether the node is running in a standalone mode or a domain cluster mode? Does JBoss make this information available?


      I looked at JBoss AS clustering code and I couldnt find and API that can give this information. I looked at the GroupCommunicationService class and the MBeanServer class and they dont have this information. Is there any way I could query and get this information from JBOSS?



        • 1. Re: Programatically identifying master/slave nodes in JBoss AS 7.1

          There isn't really a master/slave distinction in AS7, except for usage of SingletonService.  You could, given some channel, indicate which node is the cluster coordinator.  The easiest way to do this is via Infinispan.



          @Resource(lookup = "java:jboss/infinispan/container/some-container-name")

          private EmbeddedCacheManager container;


          public boolean isCoordinator() {

              return this.container.isCoordinator();



          As for determining whether the node is running in standalone or domain mode, I'm not entirely sure.  Try asking on the main AS7 user forum.