Search in sources :

Example 1 with UnlockInput

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

the class IdUtils method unlock.

public void unlock(LockManagerService lockManager, String poolName) {
    UnlockInput input = new UnlockInputBuilder().setLockName(poolName).build();
    Future<RpcResult<Void>> result = lockManager.unlock(input);
    try {
        if (result != null && result.get().isSuccessful()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unlocked {}", poolName);
            }
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Unable to unlock pool {}", poolName);
            }
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Unable to unlock for pool {}", poolName, e);
        throw new RuntimeException(String.format("Unable to unlock pool %s", poolName), e);
    }
}
Also used : UnlockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UnlockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInputBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with UnlockInput

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

the class VpnUtil method unlockSubnet.

// We store the cause, which is what we really care about
@SuppressWarnings("checkstyle:AvoidHidingCauseException")
public static void unlockSubnet(LockManagerService lockManager, String subnetId) {
    UnlockInput input = new UnlockInputBuilder().setLockName(subnetId).build();
    Future<RpcResult<Void>> result = lockManager.unlock(input);
    try {
        if (result != null && result.get().isSuccessful()) {
            LOG.debug("unlockSubnet: Unlocked {}", subnetId);
        } else {
            LOG.debug("unlockSubnet: Unable to unlock subnet {}", subnetId);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("unlockSubnet: Unable to unlock subnet {}", subnetId);
        throw new RuntimeException(String.format("Unable to unlock subnetId %s", subnetId), e.getCause());
    }
}
Also used : UnlockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UnlockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInputBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with UnlockInput

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

the class LockManagerTest method runUnlockTimerTask.

// TODO testEternalReadFailedExceptionOnLock() throws InterruptedException, ExecutionException, TimeoutException {
// TODO test3sOptimisticLockFailedExceptionOnUnLock()
// TODO testEternalReadFailedExceptionOnUnLock()
// TODO testEternalTransactionCommitFailedExceptionOnUnLock()
// TODO test3sOptimisticLockFailedExceptionOnTryLock()
// TODO testEternalReadFailedExceptionOnTryLock()
// TODO testEternalTransactionCommitFailedExceptionOnTryLock()
private void runUnlockTimerTask(String lockKey, long delay) {
    Timer timer = new Timer();
    timer.schedule(new TimerTask() {

        @Override
        public void run() {
            UnlockInput unlockInput = new UnlockInputBuilder().setLockName(lockKey).build();
            try {
                assertVoidRpcSuccess(lockManager.unlock(unlockInput));
            } catch (InterruptedException | ExecutionException | TimeoutException e) {
                LOG.error("runUnlockTimerTask() failed", e);
            // throw new RuntimeException(e) is useless here, as this in a BG Thread, and it would go nowhere
            }
        }
    }, delay);
}
Also used : UnlockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInput) Timer(java.util.Timer) TimerTask(java.util.TimerTask) UnlockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInputBuilder)

Example 4 with UnlockInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInput 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 5 with UnlockInput

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

the class LockManagerTest method testUnLockOfUnknownShouldNotFail.

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

Aggregations

UnlockInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInput)5 UnlockInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.UnlockInputBuilder)5 ExecutionException (java.util.concurrent.ExecutionException)2 Test (org.junit.Test)2 AbstractConcurrentDataBrokerTest (org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 LockInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInput)1 LockInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInputBuilder)1 TryLockInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInput)1 TryLockInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInputBuilder)1