1 Reply Latest reply on Dec 16, 2015 4:35 PM by pferraro

    How to monitor the master of cluster-ha-singleton nodes

    rbattenfeld

      Hi

       

      I am using the cluster-ha-singleton feature in Wildfly heavily. Now, I would like to to know how an EJB client can find the master node.

      I found this link: http://www.mastertheboss.com/jboss-server/jboss-cluster/monitoring-a-cluster-using-wildfly-api

       

      It is what I am looking for but I am not sure if this approach also works for the cluster-ha-singleton feature.

       

      Thanks for any help,

      Ralf

        • 1. Re: How to monitor the master of cluster-ha-singleton nodes
          pferraro

          You can use the CommandDispatcher to invoke a Command on the cluster that returns whether a given node is the active provider of some singleton service.  e.g.

          public class IsMasterCommand implements Command<Boolean, ServiceRegistry> {
             private final ServiceName name;
          
              public IsMasterCommand(ServiceName name) {
                 this.name = name;
             }
          
              @Override
             public Boolean execute(ServiceRegistry registry) {
                 ServiceController<Singleton> controller = registry.getService(this.name.append("singleton");
                 return (controller != null) ? controller.getValue().isMaster() : false;
             }
          }