Search in sources :

Example 1 with IdPools

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

the class IdManager method populateCache.

private void populateCache() throws ReadFailedException {
    // If IP changes during reboot, then there will be orphaned child pools.
    InstanceIdentifier<IdPools> idPoolsInstance = idUtils.getIdPools();
    Optional<IdPools> idPoolsOptional = singleTxDB.syncReadOptional(CONFIGURATION, idPoolsInstance);
    if (!idPoolsOptional.isPresent()) {
        return;
    }
    IdPools idPools = idPoolsOptional.get();
    List<IdPool> idPoolList = idPools.getIdPool();
    idPoolList.stream().filter(idPool -> idPool.getParentPoolName() != null && !idPool.getParentPoolName().isEmpty() && idUtils.getLocalPoolName(idPool.getParentPoolName()).equals(idPool.getPoolName())).forEach(idPool -> updateLocalIdPoolCache(idPool, idPool.getParentPoolName()));
}
Also used : SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) LoggerFactory(org.slf4j.LoggerFactory) CONFIGURATION(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION) Timer(java.util.Timer) DataImportBootReady(org.opendaylight.daexim.DataImportBootReady) PreDestroy(javax.annotation.PreDestroy) Future(java.util.concurrent.Future) CleanUpJob(org.opendaylight.genius.idmanager.jobs.CleanUpJob) Optional(com.google.common.base.Optional) Map(java.util.Map) IdPoolKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolKey) TimerTask(java.util.TimerTask) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) ReleaseIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.ReleaseIdInput) ChildPools(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.id.pool.ChildPools) AllocateIdRangeInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdRangeInput) AvailableIdsHolderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.id.pool.AvailableIdsHolderBuilder) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) OsgiService(org.ops4j.pax.cdi.api.OsgiService) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) AllocateIdInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput) OperationFailedException(org.opendaylight.yangtools.yang.common.OperationFailedException) IdHolderSyncJob(org.opendaylight.genius.idmanager.jobs.IdHolderSyncJob) CountDownLatch(java.util.concurrent.CountDownLatch) IdManagerMonitor(org.opendaylight.genius.idmanager.api.IdManagerMonitor) List(java.util.List) PostConstruct(javax.annotation.PostConstruct) AllocateIdOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutputBuilder) DelayedIdEntry(org.opendaylight.genius.idmanager.ReleasedIdHolder.DelayedIdEntry) IdEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.id.pool.IdEntries) AllocateIdRangeOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdRangeOutputBuilder) AllocateIdOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput) FutureRpcResults(org.opendaylight.genius.infra.FutureRpcResults) DelayedIdEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.released.ids.DelayedIdEntries) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) Inject(javax.inject.Inject) Collectors.toCollection(java.util.stream.Collectors.toCollection) UpdateIdEntryJob(org.opendaylight.genius.idmanager.jobs.UpdateIdEntryJob) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) Comparator.comparing(java.util.Comparator.comparing) LinkedList(java.util.LinkedList) LockManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockManagerService) AllocateIdRangeOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdRangeOutput) Logger(org.slf4j.Logger) IdPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) ReleasedIdsHolder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.id.pool.ReleasedIdsHolder) LocalPoolCreateJob(org.opendaylight.genius.idmanager.jobs.LocalPoolCreateJob) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) IdPools(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdPools) Futures(com.google.common.util.concurrent.Futures) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) LocalPoolDeleteJob(org.opendaylight.genius.idmanager.jobs.LocalPoolDeleteJob) DeleteIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.DeleteIdPoolInput) ReleasedIdsHolderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.id.pool.ReleasedIdsHolderBuilder) AvailableIdsHolder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.id.pool.AvailableIdsHolder) IdPoolBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPoolBuilder) Collections(java.util.Collections) LogLevel(org.opendaylight.genius.infra.FutureRpcResults.LogLevel) IdPools(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdPools) IdPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.id.pools.IdPool)

Aggregations

Optional (com.google.common.base.Optional)1 Futures (com.google.common.util.concurrent.Futures)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator.comparing (java.util.Comparator.comparing)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors.toCollection (java.util.stream.Collectors.toCollection)1 PostConstruct (javax.annotation.PostConstruct)1