Search in sources :

Example 1 with LockService

use of org.jgroups.blocks.locking.LockService in project JGroups by belaban.

the class LockServiceTest method init.

@BeforeClass
protected void init() throws Exception {
    c1 = createChannel("A");
    s1 = new LockService(c1);
    c1.connect("LockServiceTest");
    c2 = createChannel("B");
    s2 = new LockService(c2);
    c2.connect("LockServiceTest");
    c3 = createChannel("C");
    s3 = new LockService(c3);
    c3.connect("LockServiceTest");
    Util.waitUntilAllChannelsHaveSameView(10000, 1000, c1, c2, c3);
    lock = s1.getLock(LOCK);
}
Also used : LockService(org.jgroups.blocks.locking.LockService) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with LockService

use of org.jgroups.blocks.locking.LockService 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 3 with LockService

use of org.jgroups.blocks.locking.LockService 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 4 with LockService

use of org.jgroups.blocks.locking.LockService in project JGroups by belaban.

the class LockServiceDemo method start.

public void start() throws Exception {
    ch = new JChannel(props);
    if (name != null)
        ch.setName(name);
    lock_service = new LockService(ch);
    lock_service.addLockListener(this);
    ch.connect("lock-cluster");
    JmxConfigurator.registerChannel(ch, Util.getMBeanServer(), "lock-service", ch.getClusterName(), true);
    try {
        loop();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        Util.close(ch);
    }
}
Also used : JChannel(org.jgroups.JChannel) LockService(org.jgroups.blocks.locking.LockService)

Example 5 with LockService

use of org.jgroups.blocks.locking.LockService in project JGroups by belaban.

the class LockServiceDemo method start.

public void start(JChannel ch) throws Exception {
    this.ch = ch;
    lock_service = new LockService(ch);
    lock_service.addLockListener(this);
    ch.connect("lock-cluster");
    JmxConfigurator.registerChannel(ch, Util.getMBeanServer(), "lock-service", ch.getClusterName(), true);
    try {
        loop();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        Util.close(ch);
    }
}
Also used : LockService(org.jgroups.blocks.locking.LockService)

Aggregations

LockService (org.jgroups.blocks.locking.LockService)7 JChannel (org.jgroups.JChannel)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 CENTRAL_LOCK (org.jgroups.protocols.CENTRAL_LOCK)2 Lock (java.util.concurrent.locks.Lock)1 Protocol (org.jgroups.stack.Protocol)1 BeforeClass (org.testng.annotations.BeforeClass)1