Search in sources :

Example 1 with CENTRAL_LOCK

use of org.jgroups.protocols.CENTRAL_LOCK in project JGroups by belaban.

the class LockServiceConcurrencyTest method init.

@BeforeMethod
protected void init() throws Exception {
    a = new JChannel(Util.getTestStack(new CENTRAL_LOCK())).name("A");
    ls_a = new LockService(a);
    a.connect("LockServiceConcurrencyTest");
    b = new JChannel(Util.getTestStack(new CENTRAL_LOCK())).name("B");
    ls_b = new LockService(b);
    b.connect("LockServiceConcurrencyTest");
    Util.waitUntilAllChannelsHaveSameView(10000, 1000, a, b);
}
Also used : JChannel(org.jgroups.JChannel) LockService(org.jgroups.blocks.locking.LockService) CENTRAL_LOCK(org.jgroups.protocols.CENTRAL_LOCK) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with CENTRAL_LOCK

use of org.jgroups.protocols.CENTRAL_LOCK in project JGroups by belaban.

the class ClusterSplitLockTest method setUp.

@BeforeMethod
protected void setUp() throws Exception {
    for (int i = 0; i < MEMBERS; i++) {
        Protocol[] stack = Util.getTestStack(new CENTRAL_LOCK().level("debug").setValue("num_backups", 2));
        channels[i] = new JChannel(stack);
        lockServices[i] = new LockService(channels[i]);
        channels[i].setName(memberName(i));
        channels[i].connect("TEST");
        execs[i] = Executors.newCachedThreadPool();
        if (i == 0) {
            Util.sleep(500);
        }
    }
    Util.waitUntilAllChannelsHaveSameView(10000, 1000, channels);
    // Make sure A is coordinator, because we blindly assume it is in the tests below.
    assertTrue(channels[0].getView().getCoord().equals(channels[0].getAddress()));
}
Also used : JChannel(org.jgroups.JChannel) LockService(org.jgroups.blocks.locking.LockService) Protocol(org.jgroups.stack.Protocol) CENTRAL_LOCK(org.jgroups.protocols.CENTRAL_LOCK) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with CENTRAL_LOCK

use of org.jgroups.protocols.CENTRAL_LOCK in project JGroups by belaban.

the class ClusterSplitLockTest method setUp.

protected void setUp(Class<? extends Locking> locking_class) throws Exception {
    for (int i = 0; i < MEMBERS; i++) {
        Locking lock_prot = locking_class.getDeclaredConstructor().newInstance().level("debug");
        if (lock_prot instanceof CENTRAL_LOCK)
            ((CENTRAL_LOCK) lock_prot).setNumberOfBackups(2);
        Protocol[] stack = Util.getTestStack(lock_prot);
        channels[i] = new JChannel(stack);
        lockServices[i] = new LockService(channels[i]);
        channels[i].setName(memberName(i));
        channels[i].connect("TEST");
        execs[i] = Executors.newCachedThreadPool();
        if (i == 0)
            Util.sleep(500);
    }
    Util.waitUntilAllChannelsHaveSameView(10000, 1000, channels);
    // Make sure A is coordinator, because we blindly assume it is in the tests below.
    assertEquals(channels[0].getAddress(), channels[0].getView().getCoord());
}
Also used : JChannel(org.jgroups.JChannel) LockService(org.jgroups.blocks.locking.LockService) Protocol(org.jgroups.stack.Protocol) CENTRAL_LOCK(org.jgroups.protocols.CENTRAL_LOCK) Locking(org.jgroups.protocols.Locking)

Aggregations

JChannel (org.jgroups.JChannel)3 LockService (org.jgroups.blocks.locking.LockService)3 CENTRAL_LOCK (org.jgroups.protocols.CENTRAL_LOCK)3 Protocol (org.jgroups.stack.Protocol)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Locking (org.jgroups.protocols.Locking)1