use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService in project netvirt by opendaylight.
the class VpnUtil method lockSubnet.
public static void lockSubnet(LockManagerService lockManager, String subnetId) {
TryLockInput input = new TryLockInputBuilder().setLockName(subnetId).setTime(3000L).setTimeUnit(TimeUnits.Milliseconds).build();
Future<RpcResult<Void>> result = lockManager.tryLock(input);
try {
if (result != null && result.get().isSuccessful()) {
LOG.debug("lockSubnet: Acquired lock for {}", subnetId);
} else {
LOG.error("Unable to get lock for subnet {}", subnetId);
throw new RuntimeException("Unable to get lock for subnet " + subnetId);
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Unable to get lock for subnet {}", subnetId, e);
throw new RuntimeException("Unable to get lock for subnet " + subnetId, e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService 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.LockManagerService 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.LockManagerService 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);
}
}
Aggregations