org.jgroups.stack.Protocol Java Examples

The following examples show how to use org.jgroups.stack.Protocol. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerTestBase.java    From openshift-ping with Apache License 2.0 5 votes vote down vote up
protected Protocol createPing() {
    KubePing ping = new TestKubePing();
    ping.setMasterProtocol("http");
    ping.setMasterHost("localhost");
    ping.setMasterPort(8080);
    ping.setNamespace("default");
    applyConfig(ping);
    pinger = (TestKubePing) ping;
    return ping;
}
 
Example #2
Source File: OpenshiftPing.java    From openshift-ping with Apache License 2.0 5 votes vote down vote up
public OpenshiftPing(String systemEnvPrefix) {
    super();
    _systemEnvPrefix = trimToNull(systemEnvPrefix);
    try {
        if(CompatibilityUtils.isJGroups4()) {
            sendDownMethod = Protocol.class.getMethod("down", Message.class);
        } else {
            sendDownMethod = Protocol.class.getMethod("down", Event.class);
        }
    } catch (Exception e) {
        throw new CompatibilityException("Could not find suitable 'up' method.", e);
    }
}
 
Example #3
Source File: ELECTION.java    From jgroups-raft with Apache License 2.0 5 votes vote down vote up
protected <T extends Protocol> T findProtocol(Class<T> clazz) {
    for(Protocol p=up_prot; p != null; p=p.getUpProtocol()) {
        if(clazz.isAssignableFrom(p.getClass()))
            return (T)p;
    }
    throw new IllegalStateException(clazz.getSimpleName() + " not found above " + this.getClass().getSimpleName());
}
 
Example #4
Source File: RAFT.java    From jgroups-raft with Apache License 2.0 5 votes vote down vote up
public static <T> T findProtocol(Class<T> clazz, final Protocol start, boolean down) {
    Protocol prot=start;
    while(prot != null && clazz != null) {
        if(clazz.isAssignableFrom(prot.getClass()))
            return (T)prot;
        prot=down? prot.getDownProtocol() : prot.getUpProtocol();
    }
    return null;
}
 
Example #5
Source File: PropsToAsciidoc.java    From jgroups-raft with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    if (args.length != 1) {
        help();
        System.err.println("args[0]=" + args[0]);
        return;
    }
    String prot_file = args[0];
    String temp_file = prot_file + ".tmp";

    try {
        // first copy protocols.adoc file into protocols.adoc.xml
        File f = new File(temp_file);
        copy(new FileReader(new File(prot_file)), new FileWriter(f));
        String s = fileToString(f);

        Set<Class<Protocol>> classes = Util.findClassesAssignableFrom("org.jgroups.protocols.raft", Protocol.class);
        // classes.addAll(Util.findClassesAssignableFrom("org.jgroups.protocols.pbcast",Protocol.class));
        Properties props = new Properties();
        for (Class<Protocol> clazz : classes)
            convertProtocolToAsciidocTable(props,clazz);
        String result = Util.substituteVariable(s, props);
        FileWriter fw = new FileWriter(f, false);
        fw.write(result);
        fw.flush();
        fw.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #6
Source File: SimplePingTest.java    From openshift-ping with Apache License 2.0 4 votes vote down vote up
protected Protocol createPing() {
    return new FILE_PING();
}
 
Example #7
Source File: TestBase.java    From openshift-ping with Apache License 2.0 votes vote down vote up
protected abstract Protocol createPing();