This content has been marked as final.
Show 1 reply
-
1. Re: How to monitor the master of cluster-ha-singleton nodes
pferraro Dec 16, 2015 4:35 PM (in response to rbattenfeld)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; } }