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);
}
}
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());
}
}
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);
}
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));
}
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));
}
Aggregations