Search in sources :

Example 6 with LockInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInput in project genius by opendaylight.

the class LockManagerTest method testLockAndUnLock.

@Test
public void testLockAndUnLock() throws InterruptedException, ExecutionException, TimeoutException {
    LockInput lockInput = new LockInputBuilder().setLockName("testLock").build();
    assertVoidRpcSuccess(lockManager.lock(lockInput));
    UnlockInput unlockInput = new UnlockInputBuilder().setLockName("testLock").build();
    assertVoidRpcSuccess(lockManager.unlock(unlockInput));
}
Also used : UnlockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInput) TryLockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInput) LockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInput) UnlockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInputBuilder) TryLockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInputBuilder) LockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInputBuilder) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 7 with LockInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInput in project genius by opendaylight.

the class LockManagerTest method testLockAndReLockSameAgain.

@Test
public // lock() RPC will infinitely retry, and it will only come out when the key is unlocked
void testLockAndReLockSameAgain() throws InterruptedException, ExecutionException, TimeoutException {
    LockInput lockInput = new LockInputBuilder().setLockName("testLock").build();
    assertVoidRpcSuccess(lockManager.lock(lockInput));
    runUnlockTimerTask("testLock", 3000);
    // This will retry infinitely since the other lock is not released!
    // After 5 seconds, the parallel thread will unlock the key, and the below TC will pass
    assertVoidRpcSuccess(lockManager.lock(lockInput));
}
Also used : TryLockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInput) LockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInput) TryLockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInputBuilder) LockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInputBuilder) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 AbstractConcurrentDataBrokerTest (org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest)6 LockInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInput)6 LockInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInputBuilder)6 TryLockInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInput)6 TryLockInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInputBuilder)6 ExecutionException (java.util.concurrent.ExecutionException)1 OptimisticLockFailedException (org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException)1 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 UnlockInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInput)1 UnlockInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInputBuilder)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1