Search in sources :

Example 11 with CreateIdPoolInput

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

the class IdManagerTest method testCreateIdPool.

@Test
public void testCreateIdPool() throws Exception {
    CreateIdPoolInput createIdPoolInput = new CreateIdPoolInputBuilder().setHigh(ID_HIGH).setLow(ID_LOW).setPoolName(ID_POOL_NAME).build();
    assertTrue(idManagerService.createIdPool(createIdPoolInput).get().isSuccessful());
    coordinatorEventsWaiter.awaitEventsConsumption();
    validateIdPools(ExpectedCreateIdPoolObjects.idPoolCreateParent(), ExpectedCreateIdPoolObjects.idPoolCreateChild());
}
Also used : CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder) Test(org.junit.Test)

Example 12 with CreateIdPoolInput

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

the class VpnManagerImpl method createIdPool.

private void createIdPool() {
    CreateIdPoolInput createPool = new CreateIdPoolInputBuilder().setPoolName(VpnConstants.VPN_IDPOOL_NAME).setLow(VpnConstants.VPN_IDPOOL_LOW).setHigh(VpnConstants.VPN_IDPOOL_HIGH).build();
    try {
        Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
        if (result != null && result.get().isSuccessful()) {
            LOG.info("Created IdPool for VPN Service");
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Failed to create idPool for VPN Service", e);
    }
    // Now an IdPool for InterVpnLink endpoint's pseudo ports
    CreateIdPoolInput createPseudoLporTagPool = new CreateIdPoolInputBuilder().setPoolName(VpnConstants.PSEUDO_LPORT_TAG_ID_POOL_NAME).setLow(VpnConstants.LOWER_PSEUDO_LPORT_TAG).setHigh(VpnConstants.UPPER_PSEUDO_LPORT_TAG).build();
    try {
        Future<RpcResult<Void>> result = idManager.createIdPool(createPseudoLporTagPool);
        if (result.get().isSuccessful()) {
            LOG.debug("Created IdPool for Pseudo Port tags");
        } else {
            Collection<RpcError> errors = result.get().getErrors();
            StringBuilder errMsg = new StringBuilder();
            for (RpcError err : errors) {
                errMsg.append(err.getMessage()).append("\n");
            }
            LOG.error("IdPool creation for PseudoPort tags failed. Reasons: {}", errMsg);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Failed to create idPool for Pseudo Port tags", e);
    }
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) ExecutionException(java.util.concurrent.ExecutionException) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder)

Example 13 with CreateIdPoolInput

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

the class IdManagerTest method testMultithreadedIdAllocationFromAvailableIds.

@Test
// OK as exceptionInExecutor can't be Exception & AssertionFailedError
@SuppressWarnings("checkstyle:IllegalThrows")
public void testMultithreadedIdAllocationFromAvailableIds() throws Throwable {
    CreateIdPoolInput createIdPoolInput = new CreateIdPoolInputBuilder().setHigh(ID_HIGH).setLow(ID_LOW).setPoolName(ID_POOL_NAME).build();
    idManagerService.createIdPool(createIdPoolInput);
    requestIdsConcurrently(false);
    coordinatorEventsWaiter.awaitEventsConsumption();
    IdPool actualIdPoolChild = getUpdatedActualChildPool();
    IdPool actualIdPoolParent = getUpdatedActualParentPool();
    // Cannot compare the idEntries since we cannot guarantee which idKey gets what value.
    // However the allocated id values uniqueness is verified in requestIdsConcurrently method.
    AssertDataObjects.assertEqualBeans(ExpectedAllocateIdMultipleRequestsFromAvailableIds.idPoolParent().getAvailableIdsHolder(), actualIdPoolParent.getAvailableIdsHolder());
    AssertDataObjects.assertEqualBeans(ExpectedAllocateIdMultipleRequestsFromAvailableIds.idPoolChild(), actualIdPoolChild);
}
Also used : CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder) IdPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool) Test(org.junit.Test)

Example 14 with CreateIdPoolInput

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

the class IdManagerTest method testMultithreadedIdAllocationForSameKeyFromAvailableIds.

@Test
// OK as exceptionInExecutor can't be Exception & AssertionFailedError
@SuppressWarnings("checkstyle:IllegalThrows")
public void testMultithreadedIdAllocationForSameKeyFromAvailableIds() throws Throwable {
    CreateIdPoolInput createIdPoolInput = new CreateIdPoolInputBuilder().setHigh(ID_HIGH).setLow(ID_LOW).setPoolName(ID_POOL_NAME).build();
    idManagerService.createIdPool(createIdPoolInput);
    requestIdsConcurrently(true);
    coordinatorEventsWaiter.awaitEventsConsumption();
    validateIdPools(ExpectedAllocateIdObjects.idPoolParent(), ExpectedAllocateIdObjects.idPoolChild());
}
Also used : CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder) Test(org.junit.Test)

Example 15 with CreateIdPoolInput

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

the class IdManagerTest method testAllocateIdBlockFromReleasedIds.

@Test
public void testAllocateIdBlockFromReleasedIds() throws Exception {
    CreateIdPoolInput createIdPoolInput = new CreateIdPoolInputBuilder().setHigh(ID_HIGH).setLow(ID_LOW).setPoolName(ID_POOL_NAME).build();
    AllocateIdInput allocateIdInput = new AllocateIdInputBuilder().setIdKey(TEST_KEY2).setPoolName(ID_POOL_NAME).build();
    idManagerService.createIdPool(createIdPoolInput);
    idManagerService.allocateId(allocateIdInput);
    coordinatorEventsWaiter.awaitEventsConsumption();
    asyncEventsWaiter.awaitEventsConsumption();
    String localPoolName = idUtils.getLocalPoolName(ID_POOL_NAME);
    IdPool parentIdPool = new IdPoolBuilder().setPoolName(ID_POOL_NAME).setKey(new IdPoolKey(ID_POOL_NAME)).setAvailableIdsHolder(createAvailableIdHolder(ID_LOW, ID_HIGH, ID_HIGH + 1)).setReleasedIdsHolder(createReleaseIdHolder(Arrays.asList(1L, 2L, 3L))).build();
    IdPool childPool = new IdPoolBuilder().setPoolName(localPoolName).setKey(new IdPoolKey(localPoolName)).setAvailableIdsHolder(createAvailableIdHolder(0L, 9L, 10L)).build();
    WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
    tx.merge(LogicalDatastoreType.CONFIGURATION, getIdPoolIdentifier(ID_POOL_NAME), parentIdPool);
    tx.merge(LogicalDatastoreType.CONFIGURATION, getIdPoolIdentifier(localPoolName), childPool);
    tx.submit().get();
    AllocateIdInput allocateIdInput2 = new AllocateIdInputBuilder().setIdKey(TEST_KEY1).setPoolName(ID_POOL_NAME).build();
    assertEquals(idManagerService.allocateId(allocateIdInput2).get().getResult().getIdValue().longValue(), 1L);
    coordinatorEventsWaiter.awaitEventsConsumption();
    validateIdPools(ExpectedAllocateIdFromReleasedId.idPoolParent(), ExpectedAllocateIdFromReleasedId.idPoolChild());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) AllocateIdInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) IdPoolBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder) IdPoolKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolKey) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder) IdPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool) Test(org.junit.Test)

Aggregations

CreateIdPoolInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput)17 CreateIdPoolInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder)17 Test (org.junit.Test)9 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)8 ExecutionException (java.util.concurrent.ExecutionException)5 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)5 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)5 IdPool (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool)5 IdPoolKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolKey)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 IdPoolBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder)3 UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)1 DeleteIdPoolInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.DeleteIdPoolInput)1 DeleteIdPoolInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.DeleteIdPoolInputBuilder)1 IdPools (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdPools)1 ReleaseIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput)1 ReleaseIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInputBuilder)1 RpcError (org.opendaylight.yangtools.yang.common.RpcError)1