use of org.jgroups.protocols.relay.SiteMaster in project JGroups by belaban.
the class UnicastTestRpc method getReceiver.
private Address getReceiver() {
try {
List<Address> mbrs = new ArrayList<>(channel.getView().getMembers());
List<String> site_names = getSites(channel);
for (String site_name : site_names) {
try {
SiteMaster sm = new SiteMaster(site_name);
mbrs.add(sm);
} catch (Throwable t) {
System.err.println("failed creating site master: " + t);
}
}
System.out.println("pick receiver from the following members:");
int i = 0;
for (Address mbr : mbrs) {
if (mbr.equals(channel.getAddress()))
System.out.println("[" + i + "]: " + mbr + " (self)");
else
System.out.println("[" + i + "]: " + mbr);
i++;
}
System.out.flush();
System.in.skip(System.in.available());
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str = reader.readLine().trim();
int index = Integer.parseInt(str);
// index out of bounds caught below
return mbrs.get(index);
} catch (Exception e) {
System.err.println("UnicastTest.getReceiver(): " + e);
return null;
}
}
use of org.jgroups.protocols.relay.SiteMaster in project JGroups by belaban.
the class Relay2Test method testSenderOrderWithMultipleSiteMasters.
/**
* Cluster A,B,C in LON and X,Y,Z in SFO. A, B, X and Y are site masters (max_site_masters: 2).
* Verifies that messages sent by C in the LON site are received in the correct order by all members of the SFO site
* despite using multiple site masters. JIRA: https://issues.jboss.org/browse/JGRP-2112
*/
public void testSenderOrderWithMultipleSiteMasters() throws Exception {
MyReceiver rx = new MyReceiver(), ry = new MyReceiver(), rz = new MyReceiver();
final int NUM = 512;
final String sm_picker_impl = SiteMasterPickerImpl.class.getName();
a = createNode(LON, "A", LON_CLUSTER, 2, sm_picker_impl, null);
b = createNode(LON, "B", LON_CLUSTER, 2, sm_picker_impl, null);
c = createNode(LON, "C", LON_CLUSTER, 2, sm_picker_impl, null);
Util.waitUntilAllChannelsHaveSameView(10000, 1000, a, b, c);
x = createNode(SFO, "X", SFO_CLUSTER, 2, sm_picker_impl, rx);
y = createNode(SFO, "Y", SFO_CLUSTER, 2, sm_picker_impl, ry);
z = createNode(SFO, "Z", SFO_CLUSTER, 2, sm_picker_impl, rz);
Util.waitUntilAllChannelsHaveSameView(10000, 1000, x, y, z);
waitForBridgeView(4, 10000, 1000, a, b, x, y);
// C in LON sends messages to the site master of SFO (via either SM A or B); everyone in SFO (x,y,z)
// must receive them in correct order
SiteMaster target_sm = new SiteMaster(SFO);
System.out.printf("%s: sending %d messages to %s:\n", c.getAddress(), NUM, target_sm);
for (int i = 1; i <= NUM; i++) {
// the seqno is in the payload of the message
Message msg = new Message(target_sm, i);
c.send(msg);
}
boolean running = true;
for (int i = 0; running && i < 10; i++) {
for (MyReceiver r : Arrays.asList(rx, ry, rz)) {
if (r.getList().size() >= NUM) {
running = false;
break;
}
}
Util.sleep(1000);
}
System.out.printf("X: size=%d\nY: size=%d\nZ: size=%d\n", rx.getList().size(), ry.getList().size(), rz.getList().size());
assert rx.getList().size() == NUM || ry.getList().size() == NUM;
assert rz.getList().isEmpty();
}
use of org.jgroups.protocols.relay.SiteMaster in project JGroups by belaban.
the class SizeTest method testRelay2Header.
public static void testRelay2Header() throws Exception {
Address dest = new SiteMaster("sfo");
RELAY2.Relay2Header hdr = new RELAY2.Relay2Header(RELAY2.Relay2Header.DATA, dest, null);
_testSize(hdr);
Address sender = new SiteUUID(UUID.randomUUID(), "dummy", "sfo");
hdr = new RELAY2.Relay2Header(RELAY2.Relay2Header.DATA, dest, sender);
_testSize(hdr);
}
use of org.jgroups.protocols.relay.SiteMaster in project JGroups by belaban.
the class SizeTest method testWriteAddress.
public static void testWriteAddress() throws Exception {
Address uuid = UUID.randomUUID();
_testWriteAddress(uuid);
Address addr = new IpAddress(7500);
_testWriteAddress(addr);
addr = new IpAddress("127.0.0.1", 5678);
_testWriteAddress(addr);
addr = new SiteMaster("sfo");
_testWriteAddress(addr);
}
use of org.jgroups.protocols.relay.SiteMaster in project JGroups by belaban.
the class RequestCorrelator method receive.
/**
* <b>Callback</b>.
* <p>
* Called by the protocol below when a message has been received. The algorithm should test whether the message
* is destined for us and, if not, pass it up to the next layer. Otherwise, it should remove the header and check
* whether the message is a request or response.
* In the first case, the message will be delivered to the request handler registered
* (calling its {@code handle()} method), in the second case, the corresponding response collector is looked up and
* the message delivered.
* @param evt The event to be received
* @return Whether or not the event was consumed. If true, don't pass message up, else pass it up
*/
public boolean receive(Event evt) {
switch(evt.getType()) {
case // adjust number of responses to wait for
Event.VIEW_CHANGE:
receiveView(evt.getArg());
break;
case Event.SET_LOCAL_ADDRESS:
setLocalAddress(evt.getArg());
break;
case Event.SITE_UNREACHABLE:
SiteMaster site_master = evt.getArg();
String site = site_master.getSite();
setSiteUnreachable(site);
// let others have a stab at this event, too
break;
}
return false;
}
Aggregations