Search in sources :

Example 1 with GossipRouter

use of org.jgroups.stack.GossipRouter in project JGroups by belaban.

the class GossipRouterTest method testLateStart.

/**
 * Tests the following scenario (http://jira.jboss.com/jira/browse/JGRP-682):
 * - First node is started with tunnel.xml, cannot connect
 * - Second node is started *with* GossipRouter
 * - Now first node should be able to connect and first and second node should be able to merge into a group
 * - SUCCESS: a view of 2
 */
public void testLateStart() throws Exception {
    final Lock lock = new ReentrantLock();
    final Condition cond = lock.newCondition();
    AtomicBoolean done = new AtomicBoolean(false);
    System.out.println("-- starting first channel");
    a = createTunnelChannel("A");
    a.setReceiver(new MyReceiver("c1", done, lock, cond));
    a.connect("demo");
    System.out.println("-- starting second channel");
    b = createTunnelChannel("B");
    b.setReceiver(new MyReceiver("c2", done, lock, cond));
    b.connect("demo");
    System.out.println("-- starting GossipRouter");
    router = new GossipRouter(bind_addr_str, gossip_router_port);
    router.start();
    System.out.println("-- waiting for merge to happen --");
    long target_time = System.currentTimeMillis() + 40000;
    lock.lock();
    try {
        while (System.currentTimeMillis() < target_time && !done.get()) {
            cond.await(1000, TimeUnit.MILLISECONDS);
        }
    } finally {
        lock.unlock();
    }
    Util.sleep(500);
    View view = a.getView();
    System.out.println("view=" + view);
    assert view.size() == 2 : "view=" + view;
    Util.close(b, a);
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) Condition(java.util.concurrent.locks.Condition) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) GossipRouter(org.jgroups.stack.GossipRouter) View(org.jgroups.View) ReentrantLock(java.util.concurrent.locks.ReentrantLock) Lock(java.util.concurrent.locks.Lock)

Example 2 with GossipRouter

use of org.jgroups.stack.GossipRouter in project wildfly by wildfly.

the class SingletonTunnelTestCase method startGossipRouter.

private static void startGossipRouter() {
    log.trace("Starting gossip router.");
    try {
        String address = System.getProperty("node0");
        if (address == null || address.trim().isEmpty()) {
            address = "127.0.0.1";
        }
        if (gossipRouter == null) {
            log.trace("Assigning address " + address + " to gossip router.");
            gossipRouter = new GossipRouter(address, 12001);
        }
        gossipRouter.start();
    } catch (Exception e) {
        log.error("Caught exception: ", e);
        Assert.fail("Couldn't start GossipRouter: " + e.getMessage());
    }
}
Also used : GossipRouter(org.jgroups.stack.GossipRouter) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 3 with GossipRouter

use of org.jgroups.stack.GossipRouter in project JGroups by belaban.

the class TCPGOSSIP_Test method startRouter.

@BeforeClass
void startRouter() throws Exception {
    bind_addr = Util.getLoopback();
    gossip_router_port = ResourceManager.getNextTcpPort(bind_addr);
    gossipRouter = new GossipRouter(bind_addr, gossip_router_port);
    gossipRouter.start();
}
Also used : GossipRouter(org.jgroups.stack.GossipRouter) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with GossipRouter

use of org.jgroups.stack.GossipRouter in project JGroups by belaban.

the class TUNNEL_Test method startRouter.

@BeforeClass
void startRouter() throws Exception {
    gossip_router_bind_addr = Util.getLoopback();
    gossip_router_port = ResourceManager.getNextTcpPort(gossip_router_bind_addr);
    gossip_router_hosts = gossip_router_bind_addr.getHostAddress() + "[" + gossip_router_port + "]";
    gossipRouter = new GossipRouter(gossip_router_bind_addr, gossip_router_port);
    gossipRouter.start();
}
Also used : GossipRouter(org.jgroups.stack.GossipRouter) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with GossipRouter

use of org.jgroups.stack.GossipRouter in project JGroups by belaban.

the class TUNNELDeadLockTest method setUp.

@BeforeMethod
void setUp() throws Exception {
    StackType type = Util.getIpStackType();
    if (type == StackType.IPv6)
        bind_addr = "::1";
    else
        bind_addr = "127.0.0.1";
    promise = new Promise<>();
    gossip_router_port = ResourceManager.getNextTcpPort(InetAddress.getByName(bind_addr));
    gossip_router_hosts = bind_addr + "[" + gossip_router_port + "]";
    gossipRouter = new GossipRouter(bind_addr, gossip_router_port).useNio(false);
    gossipRouter.start();
}
Also used : StackType(org.jgroups.util.StackType) GossipRouter(org.jgroups.stack.GossipRouter) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

GossipRouter (org.jgroups.stack.GossipRouter)5 BeforeClass (org.testng.annotations.BeforeClass)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Condition (java.util.concurrent.locks.Condition)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 View (org.jgroups.View)1 StackType (org.jgroups.util.StackType)1 BeforeMethod (org.testng.annotations.BeforeMethod)1