Search in sources :

Example 21 with AllocateIdInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder in project netvirt by opendaylight.

the class AbstractSnatService method createGroupId.

protected long createGroupId(String groupIdKey) {
    AllocateIdInput getIdInput = new AllocateIdInputBuilder().setPoolName(NatConstants.SNAT_IDPOOL_NAME).setIdKey(groupIdKey).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("createGroupId: Exception while creating group with key : {}", groupIdKey, e);
    }
    return 0;
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)

Example 22 with AllocateIdInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder 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;
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)

Example 23 with AllocateIdInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder 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;
}
Also used : BigInteger(java.math.BigInteger) AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)

Example 24 with AllocateIdInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder 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;
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)

Example 25 with AllocateIdInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder 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;
}
Also used : AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ExecutionException(java.util.concurrent.ExecutionException) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)

Aggregations

AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)30 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)26 ExecutionException (java.util.concurrent.ExecutionException)19 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)19 AllocateIdOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)18 Test (org.junit.Test)8 CreateIdPoolInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput)5 CreateIdPoolInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 IdPool (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool)3 IdPoolBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder)3 IdPoolKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolKey)3 DPNTEPsInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoBuilder)3 DPNTEPsInfoKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey)3 TunnelEndPointsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder)3 ArrayList (java.util.ArrayList)2 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)2 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)2 ExternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey)2 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)2