org.jgroups.demos.ViewDemo Maven / Gradle / Ivy
Go to download
This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including
all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and
JMS 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.demos;
import org.jgroups.*;
import org.jgroups.util.Util;
/**
* Demos the reception of views using a PullPushAdapter. Just start a number of members, and kill them
* randomly. The view should always be correct.
*/
public class ViewDemo extends ReceiverAdapter {
private JChannel channel;
public void viewAccepted(View new_view) {
System.out.println("** New view: " + new_view);
}
/**
* Called when a member is suspected
*/
public void suspect(Address suspected_mbr) {
System.out.println("Suspected(" + suspected_mbr + ')');
}
public void start(String props) throws Exception {
channel=new JChannel(props);
channel.setReceiver(this);
channel.connect("ViewDemo");
while(true) {
Util.sleep(10000);
}
}
public static void main(String args[]) {
ViewDemo t=new ViewDemo();
String props="udp.xml";
for(int i=0; i < args.length; i++) {
if("-help".equals(args[i])) {
help();
return;
}
if("-props".equals(args[i])) {
props=args[++i];
continue;
}
help();
return;
}
try {
t.start(props);
}
catch(Exception e) {
e.printStackTrace();
}
}
static void help() {
System.out.println("ViewDemo [-props ] [-help] [-use_additional_data ]");
}
}