use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInputBuilder in project genius by opendaylight.
the class LockManagerTest method testAskTimeOutException.
@Test
public void testAskTimeOutException() throws InterruptedException, ExecutionException, TimeoutException {
String lockName = "testLock";
logCaptureRule.expectError("Unable to acquire lock for " + lockName + ", try 1", 1);
dbFailureSimulator.failButSubmitsAnyways();
LockInput lockInput = new LockInputBuilder().setLockName(lockName).build();
assertRpcErrorCause(lockManager.lock(lockInput), TransactionCommitFailedException.class, "caused by simulated AskTimeoutException");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInputBuilder in project genius by opendaylight.
the class LockManagerTest method testEternalTransactionCommitFailedExceptionOnLock.
@Test
public void testEternalTransactionCommitFailedExceptionOnLock() throws InterruptedException, ExecutionException, TimeoutException {
logCaptureRule.expectError("RPC lock() failed; input = LockInput{_lockName=testLock, augmentation=[]}");
dbFailureSimulator.failSubmits(new TransactionCommitFailedException("bada boum bam!"));
LockInput lockInput = new LockInputBuilder().setLockName("testLock").build();
assertRpcErrorCause(lockManager.lock(lockInput), TransactionCommitFailedException.class, "bada boum bam!");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInputBuilder in project genius by opendaylight.
the class LockManagerTest method test3sOptimisticLockFailedExceptionOnLock.
@Test
public void test3sOptimisticLockFailedExceptionOnLock() throws InterruptedException, ExecutionException, TimeoutException {
dbFailureSimulator.failSubmits(new OptimisticLockFailedException("bada boum bam!"));
LockInput lockInput = new LockInputBuilder().setLockName("testLock").build();
// see other tests above
runUnfailSubmitsTimerTask(3000);
assertVoidRpcSuccess(lockManager.lock(lockInput));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInputBuilder in project genius by opendaylight.
the class IdUtils method lock.
public void lock(LockManagerService lockManager, String poolName) throws IdManagerException {
LockInput input = new LockInputBuilder().setLockName(poolName).build();
Future<RpcResult<Void>> result = lockManager.lock(input);
try {
if (result != null && result.get().isSuccessful()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Acquired lock {}", poolName);
}
} else {
throw new IdManagerException(String.format("Unable to getLock for pool %s", poolName));
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Unable to getLock for pool {}", poolName, e);
throw new RuntimeException(String.format("Unable to getLock for pool %s", poolName), e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInputBuilder 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));
}
Aggregations