use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput in project netvirt by opendaylight.
the class NatEvpnUtil method getLPortTagForRouter.
static long getLPortTagForRouter(String routerIdKey, IdManagerService idManager) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(IfmConstants.IFM_IDPOOL_NAME).setIdKey(routerIdKey).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
return rpcResult.getResult().getIdValue();
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.error("getLPortTagForRouter : ID manager failed while allocating lport_tag for router {}.", routerIdKey, e);
}
return 0;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput in project netvirt by opendaylight.
the class AclServiceUtils method allocateId.
public static Integer allocateId(IdManagerService idManager, String poolName, String idKey, Integer defaultId) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
Integer allocatedId = rpcResult.getResult().getIdValue().intValue();
LOG.debug("Allocated ACL ID: {} with key: {} into pool: {}", allocatedId, idKey, poolName);
return allocatedId;
} else {
LOG.error("RPC Call to Get Unique Id for key {} from pool {} returned with Errors {}", idKey, poolName, rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception when getting Unique Id for key {} from pool {} ", idKey, poolName, e);
}
return defaultId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput in project netvirt by opendaylight.
the class NeutronvpnUtils method getUniqueRDId.
protected Integer getUniqueRDId(String poolName, String idKey) {
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
if (rpcResult.isSuccessful()) {
return rpcResult.getResult().getIdValue().intValue();
} else {
LOG.error("RPC call to get unique ID for pool name {} with ID key {} returned with errors {}", poolName, idKey, rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception when getting Unique Id for poolname {} and ID Key {}", poolName, idKey, e);
}
LOG.error("getUniqueRdId: Failed to return ID for poolname {} and ID Key {}", poolName, idKey);
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput in project netvirt by opendaylight.
the class PolicyIdManager method allocateId.
private long allocateId(String key, String poolName) {
Long id = idCache.get(poolName).get(key);
if (id != null) {
return id;
}
AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(poolName).setIdKey(key).build();
try {
Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
RpcResult<AllocateIdOutput> rpcResult = result.get();
Long idValue = rpcResult.getResult().getIdValue();
if (idValue != null) {
idCache.get(poolName).putIfAbsent(key, idValue);
return idValue;
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception thrown while allocating id for key {}", key);
}
return PolicyServiceConstants.INVALID_ID;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput in project genius by opendaylight.
the class IdManager method allocateId.
@Override
public Future<RpcResult<AllocateIdOutput>> allocateId(AllocateIdInput input) {
String idKey = input.getIdKey();
String poolName = input.getPoolName();
return FutureRpcResults.fromBuilder(LOG, "allocateId", input, () -> {
String localPoolName = idUtils.getLocalPoolName(poolName);
// allocateIdFromLocalPool method returns a list of IDs with one element. This element is obtained by get(0)
long newIdValue = allocateIdFromLocalPool(poolName, localPoolName, idKey, 1).get(0);
return new AllocateIdOutputBuilder().setIdValue(newIdValue);
}).onFailure(e -> completeExceptionallyIfPresent(poolName, idKey, e)).build();
}
Aggregations