Java源码示例:org.jgroups.stack.Protocol
示例1
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;
}
示例2
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);
}
}
示例3
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());
}
示例4
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;
}
示例5
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();
}
}
示例6
protected Protocol createPing() {
return new FILE_PING();
}
示例7
protected abstract Protocol createPing();