use of org.jgroups.protocols.Locking in project JGroups by belaban.
the class LockServiceConcurrencyTest method printLocks.
protected static void printLocks(JChannel... channels) {
for (JChannel ch : channels) {
Locking l = ch.getProtocolStack().findProtocol(Locking.class);
System.out.printf("**** server locks on %s: %s\n", ch.getAddress(), l.printServerLocks());
}
}
use of org.jgroups.protocols.Locking in project JGroups by belaban.
the class LockServiceDuplicateLockTest method setup.
@BeforeMethod
protected void setup() throws Exception {
for (int i = 0; i < channels.length; i++) {
channels[i] = create(i + 1).connect(LockServiceDuplicateLockTest.class.getSimpleName());
lock_services[i] = new LockService(channels[i]);
}
Util.waitUntilAllChannelsHaveSameView(10000, 1000, channels);
System.out.printf("channels:\n%s", Stream.of(channels).map(ch -> String.format("%s: %s\n", ch.getAddress(), ch.getView())).collect(Collectors.joining("\n")));
lock_3 = lock_services[2].getLock(LOCK_NAME);
lock_6 = lock_services[5].getLock(LOCK_NAME);
for (JChannel ch : channels) {
Locking l = ch.getProtocolStack().findProtocol(Locking.class);
l.addLockListener(this);
}
}
use of org.jgroups.protocols.Locking in project JGroups by belaban.
the class LockServiceDuplicateLockTest method assertClientLocks.
protected void assertClientLocks(int num, int... indices) {
for (int index : indices) {
JChannel ch = channels[index];
Locking lock = ch.getProtocolStack().findProtocol(Locking.class);
assert lock.getNumClientLocks() == num : String.format("expected %d client locks but found %d in %s", num, lock.getNumClientLocks(), ch.getAddress());
}
}
use of org.jgroups.protocols.Locking in project JGroups by belaban.
the class LockServiceTest method setProp.
protected static void setProp(Class<? extends Locking> clazz, boolean value, JChannel... channels) {
for (JChannel ch : channels) {
Locking prot = ch.getProtocolStack().findProtocol(clazz);
prot.useThreadIdForLockOwner(value);
}
}
use of org.jgroups.protocols.Locking 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());
}
Aggregations