org.jgroups.protocols.rules.CheckFDMonitor Maven / Gradle / Ivy
Go to download
This artifact provides a single jar that contains all classes required to use remote Jakarta Enterprise Beans and Jakarta Messaging, including
all dependencies. It is intended for use by those not using maven, maven users should just import the Jakarta Enterprise Beans and
Jakarta Messaging BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
package org.jgroups.protocols.rules;
import org.jgroups.View;
import org.jgroups.protocols.FD;
/**
* Rule which checks if the FD monitor is running when we have more than 1 member. If not, starts it.
* The rule uninstalls itself if no FD protocol is found.
* @author Bela Ban
* @since 3.3
*/
public class CheckFDMonitor extends Rule {
protected FD fd;
public String name() {
return getClass().getSimpleName();
}
public String description() {
return "Starts FD.Monitor if membership > 1 and monitor isn't running";
}
public void init() {
super.init();
fd=(FD)sv.getProtocolStack().findProtocol(FD.class);
if(fd == null) {
log.info("FD was not found, uninstalling myself (" + getClass().getSimpleName() + ")");
sv.uninstallRule(getClass().getSimpleName());
}
}
public boolean eval() {
return sv.getView() != null && sv.getView().size() > 1 && !fd.isMonitorRunning();
}
public String condition() {
View view=sv.getView();
return "Membership is " + (view != null? view.size() : "n/a") + ", FD.Monitor running=" + fd.isMonitorRunning();
}
public void trigger() throws Throwable {
System.out.println(sv.getLocalAddress() + ": starting failure detection");
fd.startFailureDetection();
}
public String toString() {
return CheckFDMonitor.class.getSimpleName() + ": " + condition();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy