Search in sources :

Example 11 with View

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());
    }
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) View(org.jgroups.View)

Example 12 with View

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);
}
Also used : Address(org.jgroups.Address) MutableDigest(org.jgroups.util.MutableDigest) View(org.jgroups.View)

Example 13 with View

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));
}
Also used : JChannel(org.jgroups.JChannel) Address(org.jgroups.Address) GMS(org.jgroups.protocols.pbcast.GMS) View(org.jgroups.View)

Example 14 with View

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()));
    });
}
Also used : JChannel(org.jgroups.JChannel) GMS(org.jgroups.protocols.pbcast.GMS) View(org.jgroups.View) KeyStoreException(java.security.KeyStoreException)

Example 15 with View

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();
}
Also used : Digest(org.jgroups.util.Digest) View(org.jgroups.View)

Aggregations

View (org.jgroups.View)51 Address (org.jgroups.Address)24 JChannel (org.jgroups.JChannel)14 GMS (org.jgroups.protocols.pbcast.GMS)6 Event (org.jgroups.Event)5 Receiver (org.jgroups.Receiver)5 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 ViewId (org.jgroups.ViewId)3 IOException (java.io.IOException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 NetView (org.apache.geode.distributed.internal.membership.NetView)2 IpAddress (org.jgroups.stack.IpAddress)2 UUID (org.jgroups.util.UUID)2 java.io (java.io)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1