Search in sources :

Example 41 with View

use of org.jgroups.View in project JGroups by belaban.

the class FD_HOST method down.

public Object down(Event evt) {
    switch(evt.getType()) {
        case Event.VIEW_CHANGE:
            View view = evt.getArg();
            handleView(view);
            break;
        case Event.CONNECT:
        case Event.CONNECT_USE_FLUSH:
        case Event.CONNECT_WITH_STATE_TRANSFER:
        case Event.CONNECT_WITH_STATE_TRANSFER_USE_FLUSH:
            local_host = getHostFor(local_addr);
            break;
        case Event.DISCONNECT:
            Object retval = down_prot.down(evt);
            local_host = null;
            return retval;
        case Event.UNSUSPECT:
            Address mbr = evt.getArg();
            unsuspect(mbr);
            break;
    }
    return down_prot.down(evt);
}
Also used : IpAddress(org.jgroups.stack.IpAddress) InetAddress(java.net.InetAddress) PhysicalAddress(org.jgroups.PhysicalAddress) Address(org.jgroups.Address) View(org.jgroups.View)

Example 42 with View

use of org.jgroups.View in project JGroups by belaban.

the class TCPGOSSIP_Test method testConnectThreeChannelsWithGRDown.

public void testConnectThreeChannelsWithGRDown() throws Exception {
    JChannel third = null;
    try {
        coordinator = createTcpgossipChannel("A");
        channel = createTcpgossipChannel("B");
        coordinator.connect("testConnectThreeChannelsWithGRDown");
        channel.connect("testConnectThreeChannelsWithGRDown");
        // kill router
        gossipRouter.stop();
        // cannot discover others since GR is down
        third = createTcpgossipChannel("C");
        third.connect("testConnectThreeChannelsWithGRDown");
        // restart and....
        gossipRouter.start();
        Util.waitUntilAllChannelsHaveSameView(60000, 1000, coordinator, channel, third);
        // confirm they found each other
        View view = channel.getView();
        assert channel.getView().size() == 3;
        assert third.getView().size() == 3;
        assert view.containsMember(channel.getAddress());
        assert view.containsMember(coordinator.getAddress());
    } finally {
        Util.close(third);
    }
}
Also used : JChannel(org.jgroups.JChannel) View(org.jgroups.View)

Example 43 with View

use of org.jgroups.View in project JGroups by belaban.

the class TCPGOSSIP_Test method testConnectThree.

public void testConnectThree() throws Exception {
    JChannel third = null;
    try {
        coordinator = createTcpgossipChannel("A");
        channel = createTcpgossipChannel("B");
        coordinator.connect(GROUP);
        channel.connect(GROUP);
        third = createTcpgossipChannel("C");
        third.connect(GROUP);
        Util.waitUntilAllChannelsHaveSameView(10000, 500, coordinator, channel, third);
        View view = channel.getView();
        assert channel.getView().size() == 3 : String.format("expected view size of 3 but got %d: %s", channel.getView().size(), channel.getView());
        assert third.getView().size() == 3;
        assert view.containsMember(channel.getAddress());
        assert view.containsMember(coordinator.getAddress());
    } finally {
        Util.close(third);
    }
}
Also used : JChannel(org.jgroups.JChannel) View(org.jgroups.View)

Example 44 with View

use of org.jgroups.View in project JGroups by belaban.

the class TCPGOSSIP_Test method testAddInitialHosts.

public void testAddInitialHosts() throws Exception {
    coordinator = createTcpgossipChannel("A");
    channel = createTcpgossipChannel("B");
    coordinator.connect(GROUP);
    channel.connect(GROUP);
    TCPGOSSIP p = channel.getProtocolStack().findProtocol(TCPGOSSIP.class);
    String tmp_bind_addr = bind_addr.getHostAddress();
    assert p.removeInitialHost(tmp_bind_addr, gossip_router_port);
    p.addInitialHost(tmp_bind_addr, gossip_router_port);
    View view = channel.getView();
    assert view.size() == 2;
    assert view.containsMember(channel.getAddress());
    assert view.containsMember(coordinator.getAddress());
}
Also used : View(org.jgroups.View)

Example 45 with View

use of org.jgroups.View in project JGroups by belaban.

the class ViewTest method testSameMembers.

public void testSameMembers() {
    View one = View.create(a, 1, a, b, c, d, e);
    View two = View.create(a, 2, a, b, c);
    assert !View.sameMembers(one, two);
    two = View.create(a, 20, a, b, c, d, e);
    assert View.sameMembers(one, two);
    assert View.sameMembers(two, one);
    one = two;
    assert View.sameMembers(one, two);
    one = View.create(b, 5, a, b, c);
    two = View.create(c, 5, b, a, c);
    assert View.sameMembers(one, two);
    two = View.create(c, 5, b, a, c, d);
    assert !View.sameMembers(one, two);
    one = View.create(b, 5, d, b, c, a);
    two = View.create(c, 5, b, a, c);
    assert !View.sameMembers(one, two);
    assert !View.sameMembers(two, one);
}
Also used : 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