use of org.jgroups.View in project JGroups by belaban.
the class FrozenCoordinatorTest method testFrozenCoord.
/**
* Writes the entry of the coordinator to the file, but sets coord to 'F' (false). Also, assigns the lowest possible
* UUID to the coord (A), so that it will always be at the head of the sorted set. Then B is started, who will
* not find a coord, but still receive A's info, but never become coord as A's UUID is lower. This leads to a
* never-ending loop, only terminated by @invocationTimeOut. See JGRP-2262 for details.
*/
public void testFrozenCoord() throws Exception {
try (OutputStream out = new FileOutputStream(file)) {
out.write(INFO.getBytes());
}
b = create("B");
b.connect(CLUSTER);
View view = b.getView();
System.out.println("view = " + view);
assert view.size() == 1;
assert view.containsMember(b.getAddress());
c = create("C");
c.connect(CLUSTER);
System.out.printf("B's view: %s\nC's view: %s\n", b.getView(), c.getView());
for (View v : Arrays.asList(b.getView(), c.getView())) {
assert v.size() == 2;
assert v.containsMember(b.getAddress()) && v.containsMember(c.getAddress());
}
}
use of org.jgroups.View in project JGroups by belaban.
the class DigestTest method testNonConflictingMerge.
public void testNonConflictingMerge() {
Address ip1 = Util.createRandomAddress("x"), ip2 = Util.createRandomAddress("y");
View tmp_view = View.create(a1, 1, a1, a2, a3, ip1, ip2);
MutableDigest cons_d = new MutableDigest(tmp_view.getMembersRaw());
cons_d.set(ip1, 10, 10);
cons_d.set(ip2, 20, 20);
cons_d.merge(d);
Assert.assertEquals(cons_d.capacity(), 5);
Assert.assertEquals(cons_d.get(ip1)[0], 10);
Assert.assertEquals(cons_d.get(ip2)[0], 20);
Assert.assertEquals(cons_d.get(a1)[0], 500);
Assert.assertEquals(cons_d.get(a2)[0], 26);
Assert.assertEquals(cons_d.get(a3)[0], 25);
Assert.assertEquals(cons_d.get(ip1)[1], 10);
Assert.assertEquals(cons_d.get(ip2)[1], 20);
Assert.assertEquals(cons_d.get(a1)[1], 501);
Assert.assertEquals(cons_d.get(a2)[1], 26);
Assert.assertEquals(cons_d.get(a3)[1], 33);
}
use of org.jgroups.View in project JGroups by belaban.
the class FILE_PING_Test method injectView.
protected static void injectView(JChannel... channels) {
Address coord = channels[0].getAddress();
long current_view_id = ((GMS) channels[0].getProtocolStack().findProtocol(GMS.class)).view().getViewId().getId();
View v = View.create(coord, current_view_id + 1, Stream.of(channels).map(JChannel::getAddress).collect(Collectors.toList()));
Stream.of(channels).forEach(ch -> ((GMS) ch.getProtocolStack().findProtocol(GMS.class)).installView(v));
}
use of org.jgroups.View in project JGroups by belaban.
the class TLSTest method verifyForbiddenJoiner.
private void verifyForbiddenJoiner(String name) throws Exception {
JChannel channel = create(name);
GMS gms = channel.getProtocolStack().findProtocol(GMS.class);
gms.setMaxJoinAttempts(1);
try {
channel.connect(cluster_name);
} catch (Exception ex) {
}
for (int i = 0; i < 10; i++) {
if (a.getView().size() > 3)
break;
Util.sleep(500);
}
Arrays.asList(a, b, c).forEach(ch -> {
View view = ch.getView();
assertEquals(3, view.size());
assertTrue(view.containsMembers(a.getAddress(), b.getAddress(), c.getAddress()));
});
}
use of org.jgroups.View in project JGroups by belaban.
the class JoinRsp method readFrom.
@Override
public void readFrom(DataInput in) throws IOException, ClassNotFoundException {
byte flags = in.readByte();
// 1. view
if ((flags & VIEW_PRESENT) == VIEW_PRESENT) {
view = new View();
view.readFrom(in);
}
// 2. digest
if ((flags & DIGEST_PRESENT) == DIGEST_PRESENT) {
digest = new Digest(view.getMembersRaw());
digest.readFrom(in, false);
}
// 3. fail_reason
if ((flags & FAIL_REASON_PRESENT) == FAIL_REASON_PRESENT)
fail_reason = in.readUTF();
}
Aggregations