use of org.jgroups.View in project JGroups by belaban.
the class FILE_PING method down.
public Object down(Event evt) {
switch(evt.getType()) {
case Event.VIEW_CHANGE:
View old_view = view;
boolean previous_coord = is_coord;
Object retval = super.down(evt);
View new_view = evt.getArg();
handleView(new_view, old_view, previous_coord != is_coord);
return retval;
}
return super.down(evt);
}
use of org.jgroups.View in project JGroups by belaban.
the class ConnectStressTest method testConcurrentJoining.
public void testConcurrentJoining() throws Exception {
for (int i = 0; i < NUM; i++) {
threads[i] = new MyThread(channels[i], i + 1, barrier);
threads[i].start();
}
// causes all threads to call Channel.connect()
barrier.await();
System.out.println("*** Starting the connect phase ***");
long target_time = System.currentTimeMillis() + 60000L;
while (System.currentTimeMillis() < target_time) {
View view = channels[0].getView();
if (view != null) {
int size = view.size();
System.out.println("channel[0].view has " + size + " members (expected: " + NUM + ")");
if (size >= NUM)
break;
}
Util.sleep(1000L);
}
for (JChannel ch : channels) {
View view = ch.getView();
if (view != null)
System.out.println(ch.getName() + ": size=" + view.size() + ", view-id: " + view.getViewId());
}
for (JChannel ch : channels) {
View view = ch.getView();
int size = view != null ? view.size() : 0;
assert view != null && size == NUM : "view doesn't have size of " + NUM + " (has " + size + "): " + view;
}
}
use of org.jgroups.View in project JGroups by belaban.
the class MergeTest5 method testSplitWithNoCoordinator.
/**
* Tests https://issues.jboss.org/browse/JGRP-2092:
* <pre>
* Host A view: B,A,C (where B should be coordinator)
* Host B view: C,A,B (where C should be coordinator)
* Host C view: A,B,C (where A should be coordinator)
* </pre>
*/
public void testSplitWithNoCoordinator() throws Exception {
System.out.printf("Initial views:\n%s\n", printViews(a, b, c));
View v1 = createView(5, b, a, c);
View v2 = createView(5, c, a, b);
System.out.printf("Injecting view %s into %s and %s into %s\n", v1, a.getName(), v2, b.getName());
injectView(v1, a);
injectView(v2, b);
System.out.printf("\nViews after injection:\n%s\n", printViews(a, b, c));
for (int x = 0; x < 20; x++) {
View first = a.getView();
if (first.equals(b.getView()) && first.equals(c.getView()))
break;
for (JChannel ch : Arrays.asList(a, b, c)) {
MERGE3 merge = ch.getProtocolStack().findProtocol(MERGE3.class);
// multicasts an INFO msg to everybody else
merge.sendInfo();
}
Util.sleep(1000);
}
System.out.printf("\nFinal views:\n%s\n", printViews(a, b, c));
Util.assertAllChannelsHaveSameView(a, b, c);
}
use of org.jgroups.View in project JGroups by belaban.
the class Topology method start.
public void start() throws Exception {
channel = new JChannel(props).name(name);
channel.setReceiver(new Receiver() {
public void viewAccepted(View view) {
setInternalState(view.getMembers());
}
public void setInternalState(java.util.List<Address> mbrs) {
members.clear();
for (Address mbr : mbrs) addNode(mbr);
coordinator = mbrs.size() <= 1 || (mbrs.size() > 1 && mbrs.iterator().next().equals(my_addr));
repaint();
}
});
channel.connect(channel_name);
my_addr = channel.getAddress();
if (my_addr != null)
setTitle(my_addr.toString());
pack();
setVisible(true);
}
use of org.jgroups.View in project JGroups by belaban.
the class CounterServiceDemo method start.
public void start(JChannel ch) throws Exception {
this.ch = ch;
ch.setReceiver(new Receiver() {
public void viewAccepted(View view) {
System.out.println("-- view: " + view);
}
});
loop();
}
Aggregations