use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder in project netvirt by opendaylight.
the class NatOverVxlanUtil method getIdPoolInstance.
private static InstanceIdentifier<IdPool> getIdPoolInstance(String poolName) {
InstanceIdentifier.InstanceIdentifierBuilder<IdPool> idPoolBuilder = InstanceIdentifier.builder(IdPools.class).child(IdPool.class, new IdPoolKey(poolName));
InstanceIdentifier<IdPool> id = idPoolBuilder.build();
return id;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder in project genius by opendaylight.
the class IdUtils method createGlobalPool.
protected IdPool createGlobalPool(String poolName, long low, long high, long blockSize) {
AvailableIdsHolder availableIdsHolder = createAvailableIdsHolder(low, high, low - 1);
ReleasedIdsHolder releasedIdsHolder = createReleasedIdsHolder(DEFAULT_AVAILABLE_ID_COUNT, 0);
int size = (int) blockSize;
return new IdPoolBuilder().setKey(new IdPoolKey(poolName)).setBlockSize(size).setPoolName(poolName).setAvailableIdsHolder(availableIdsHolder).setReleasedIdsHolder(releasedIdsHolder).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder in project genius by opendaylight.
the class IdManagerTest method getUpdatedActualChildPool.
private IdPool getUpdatedActualChildPool() throws ReadFailedException {
String localPoolName = idUtils.getLocalPoolName(ID_POOL_NAME);
IdPool idPoolChildFromDS = singleTxdataBroker.syncRead(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(IdPools.class).child(IdPool.class, new IdPoolKey(localPoolName)).build());
List<DelayedIdEntries> actualDelayedIdEntries = idPoolChildFromDS.getReleasedIdsHolder().getDelayedIdEntries();
IdPool actualIdPoolChild = idPoolChildFromDS;
if (actualDelayedIdEntries != null) {
List<DelayedIdEntries> updatedDelayedIdEntries = actualDelayedIdEntries.stream().map(delayedIdEntry -> new DelayedIdEntriesBuilder().setId(delayedIdEntry.getId()).setReadyTimeSec(0L).build()).collect(Collectors.toList());
ReleasedIdsHolder releasedId = new ReleasedIdsHolderBuilder(idPoolChildFromDS.getReleasedIdsHolder()).setDelayedIdEntries(updatedDelayedIdEntries).build();
actualIdPoolChild = new IdPoolBuilder(idPoolChildFromDS).setReleasedIdsHolder(releasedId).build();
}
return actualIdPoolChild;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder in project genius by opendaylight.
the class IdManagerTest method testMultithreadedIdAllocationForSameKeyFromReleasedIds.
@Test
// OK as exceptionInExecutor can't be Exception & AssertionFailedError
@SuppressWarnings("checkstyle:IllegalThrows")
public void testMultithreadedIdAllocationForSameKeyFromReleasedIds() throws Throwable {
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(Collections.emptyList())).build();
IdPool childPool = new IdPoolBuilder().setPoolName(localPoolName).setKey(new IdPoolKey(localPoolName)).setReleasedIdsHolder(createReleaseIdHolder(Arrays.asList(1L, 2L, 3L))).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();
requestIdsConcurrently(true);
coordinatorEventsWaiter.awaitEventsConsumption();
validateIdPools(ExpectedAllocateIdFromReleasedId.idPoolParent(), ExpectedAllocateIdFromReleasedId.idPoolChild());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder in project genius by opendaylight.
the class IdManagerTest method getUpdatedActualParentPool.
private IdPool getUpdatedActualParentPool() throws ReadFailedException {
IdPool idPoolParentFromDS = singleTxdataBroker.syncRead(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(IdPools.class).child(IdPool.class, new IdPoolKey(ID_POOL_NAME)).build());
List<ChildPools> childPool = idPoolParentFromDS.getChildPools();
List<ChildPools> updatedChildPool = childPool.stream().map(child -> new ChildPoolsBuilder(child).setLastAccessTime(0L).build()).collect(Collectors.toList());
List<IdEntries> idEntries = idPoolParentFromDS.getIdEntries();
IdPoolBuilder idPoolBuilder = new IdPoolBuilder(idPoolParentFromDS);
if (idEntries != null) {
List<IdEntries> sortedIdEntries = idEntries.stream().sorted(comparing(IdEntries::getIdKey)).collect(Collectors.toList());
idPoolBuilder.setIdEntries(sortedIdEntries);
}
IdPool actualIdPoolParent = idPoolBuilder.setChildPools(updatedChildPool).build();
return actualIdPoolParent;
}
Aggregations