Search in sources :

Example 11 with Futures

use of com.google.common.util.concurrent.Futures in project android_packages_apps_Dialer by LineageOS.

the class DialerFutureSerializer method submitAsync.

/**
 * Enqueues a task to run when the previous task (if any) completes.
 *
 * <p>Cancellation does not propagate from the output future to the future returned from {@code
 * callable}, but if the output future is cancelled before {@link AsyncCallable#call()} is
 * invoked, {@link AsyncCallable#call()} will not be invoked.
 */
public <T> ListenableFuture<T> submitAsync(final AsyncCallable<T> callable, Executor executor) {
    AtomicBoolean wasCancelled = new AtomicBoolean(false);
    final AsyncCallable<T> task = () -> {
        if (wasCancelled.get()) {
            return immediateCancelledFuture();
        }
        return callable.call();
    };
    /*
     * Three futures are at play here:
     * taskFuture is the future that comes from the callable.
     * newFuture is the future we use to track the serialization of our task.
     * oldFuture is the previous task's newFuture.
     *
     * newFuture is guaranteed to only complete once all tasks previously submitted to this instance
     * once the futures returned from those submissions have completed.
     */
    final SettableFuture<Object> newFuture = SettableFuture.create();
    final ListenableFuture<?> oldFuture = ref.getAndSet(newFuture);
    // Invoke our task once the previous future completes.
    final ListenableFuture<T> taskFuture = Futures.nonCancellationPropagating(Futures.submitAsync(task, runnable -> oldFuture.addListener(runnable, executor)));
    // newFuture's lifetime is determined by taskFuture, unless taskFuture is cancelled, in which
    // case it falls back to oldFuture's. This is to ensure that if the future we return is
    // cancelled, we don't begin execution of the next task until after oldFuture completes.
    taskFuture.addListener(() -> {
        if (taskFuture.isCancelled()) {
            // Since the value of oldFuture can only ever be immediateFuture(null) or setFuture of a
            // future that eventually came from immediateFuture(null), this doesn't leak throwables
            // or completion values.
            wasCancelled.set(true);
            newFuture.setFuture(oldFuture);
        } else {
            newFuture.set(null);
        }
    }, directExecutor());
    return taskFuture;
}
Also used : Futures.immediateFuture(com.google.common.util.concurrent.Futures.immediateFuture) Futures(com.google.common.util.concurrent.Futures) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Executor(java.util.concurrent.Executor) Futures.immediateCancelledFuture(com.google.common.util.concurrent.Futures.immediateCancelledFuture) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Callable(java.util.concurrent.Callable) SettableFuture(com.google.common.util.concurrent.SettableFuture) AtomicReference(java.util.concurrent.atomic.AtomicReference) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) AsyncCallable(com.google.common.util.concurrent.AsyncCallable) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 12 with Futures

use of com.google.common.util.concurrent.Futures in project netvirt by opendaylight.

the class VrfEntryListener method cleanUpDpnForVpn.

public void cleanUpDpnForVpn(final Uint64 dpnId, final Uint32 vpnId, final String rd, final FutureCallback<List<?>> callback) {
    LOG.trace("cleanUpDpnForVpn: Remove dpn {} for vpn {} : cleanUpDpnForVpn", dpnId, rd);
    jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, dpnId), () -> {
        InstanceIdentifier<VrfTables> id = buildVrfId(rd);
        final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
        List<SubTransaction> txnObjects = new ArrayList<>();
        final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
        List<ListenableFuture<?>> futures = new ArrayList<>();
        if (!vrfTable.isPresent()) {
            LOG.error("cleanUpDpnForVpn: VRF Table not available for RD {}", rd);
            if (callback != null) {
                ListenableFuture<List<Object>> listenableFuture = Futures.allAsList(futures);
                Futures.addCallback(listenableFuture, callback, MoreExecutors.directExecutor());
            }
            return futures;
        }
        final ReentrantLock lock = lockFor(vpnInstance);
        lock.lock();
        try {
            futures.add(retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
                String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
                for (final VrfEntry vrfEntry : vrfTable.get().nonnullVrfEntry().values()) {
                    /* parentRd is only filled for external PNF cases where the interface on the external
                             * network VPN are used to cleanup the flows. For all other cases, use "rd" for
                             * #fibUtil.isInterfacePresentInDpn().
                             * */
                    String parentRd = vrfEntry.getParentVpnRd() != null ? vrfEntry.getParentVpnRd() : rd;
                    /* Handle subnet routes here */
                    SubnetRoute subnetRoute = vrfEntry.augmentation(SubnetRoute.class);
                    if (subnetRoute != null && !fibUtil.isInterfacePresentInDpn(parentRd, dpnId)) {
                        LOG.trace("SUBNETROUTE: cleanUpDpnForVpn: Cleaning subnetroute {} on dpn {}" + " for vpn {}", vrfEntry.getDestPrefix(), dpnId, rd);
                        baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, null, NwConstants.DEL_FLOW, TransactionAdapter.toWriteTransaction(tx), null);
                        Map<RoutePathsKey, RoutePaths> keyRoutePathsMap = vrfEntry.getRoutePaths();
                        if (keyRoutePathsMap != null) {
                            for (RoutePaths routePath : keyRoutePathsMap.values()) {
                                makeLFibTableEntry(dpnId, routePath.getLabel(), null, DEFAULT_FIB_FLOW_PRIORITY, NwConstants.DEL_FLOW, tx);
                                LOG.trace("SUBNETROUTE: cleanUpDpnForVpn: Released subnetroute label {}" + " for rd {} prefix {}", routePath.getLabel(), rd, vrfEntry.getDestPrefix());
                            }
                        }
                        installSubnetBroadcastAddrDropRule(dpnId, rd, vpnId, vrfEntry, NwConstants.DEL_FLOW, tx);
                        continue;
                    }
                    // ping responder for router interfaces
                    RouterInterface routerInt = vrfEntry.augmentation(RouterInterface.class);
                    if (routerInt != null) {
                        LOG.trace("Router augmented vrfentry found for rd:{}, uuid:{}, ip:{}, mac:{}", rd, routerInt.getUuid(), routerInt.getIpAddress(), routerInt.getMacAddress());
                        routerInterfaceVrfEntryHandler.installRouterFibEntry(vrfEntry, dpnId, vpnId, routerInt.getIpAddress(), new MacAddress(routerInt.getMacAddress()), NwConstants.DEL_FLOW);
                        continue;
                    }
                    // Handle local flow deletion for imports
                    if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.SELF_IMPORTED) {
                        java.util.Optional<Uint32> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
                        if (optionalLabel.isPresent()) {
                            List<String> nextHopList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
                            LabelRouteInfo lri = getLabelRouteInfo(optionalLabel.get());
                            if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopList, lri) && Objects.equals(lri.getDpnId(), dpnId)) {
                                deleteLocalFibEntry(vpnId, rd, vrfEntry);
                            }
                        }
                    }
                    // Passing null as we don't know the dpn
                    // to which prefix is attached at this point
                    List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
                    Optional<Routes> extraRouteOptional;
                    // an adjacency in the vpn
                    if (usedRds != null && !usedRds.isEmpty()) {
                        if (usedRds.size() > 1) {
                            LOG.error("The extra route prefix is still present in some DPNs");
                            return;
                        } else {
                            extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, vpnName, usedRds.get(0), vrfEntry.getDestPrefix());
                        }
                    } else {
                        extraRouteOptional = Optional.empty();
                    }
                    if (RouteOrigin.BGP.getValue().equals(vrfEntry.getOrigin())) {
                        bgpRouteVrfEntryHandler.deleteRemoteRoute(null, dpnId, vpnId, vrfTable.get().key(), vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx), txnObjects);
                    } else {
                        if (subnetRoute == null || !fibUtil.isInterfacePresentInDpn(parentRd, dpnId)) {
                            baseVrfEntryHandler.deleteRemoteRoute(null, dpnId, vpnId, vrfTable.get().key(), vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
                        }
                    }
                }
            }));
        } finally {
            lock.unlock();
        }
        if (callback != null) {
            ListenableFuture<List<Object>> listenableFuture = Futures.allAsList(futures);
            Futures.addCallback(listenableFuture, callback, MoreExecutors.directExecutor());
        }
        return futures;
    });
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) Arrays(java.util.Arrays) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) InetAddress(java.net.InetAddress) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Map(java.util.Map) Datastore(org.opendaylight.mdsal.binding.util.Datastore) BigInteger(java.math.BigInteger) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) UpgradeState(org.opendaylight.serviceutils.upgrade.UpgradeState) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) VpnHelper(org.opendaylight.netvirt.vpnmanager.api.VpnHelper) SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) TypedWriteTransaction(org.opendaylight.mdsal.binding.util.TypedWriteTransaction) TypedReadWriteTransaction(org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction) NWUtil.isIpv4Address(org.opendaylight.genius.mdsalutil.NWUtil.isIpv4Address) NonNull(org.eclipse.jdt.annotation.NonNull) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) LabelRouteMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.LabelRouteMap) RoutePathsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePathsKey) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Callable(java.util.concurrent.Callable) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder) Lists(com.google.common.collect.Lists) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) RouterInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) UnknownHostException(java.net.UnknownHostException) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) AdjacencyResult(org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) LoggerFactory(org.slf4j.LoggerFactory) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) Nullable(org.eclipse.jdt.annotation.Nullable) DataTreeEventCallbackRegistrar(org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar) RetryingManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.RetryingManagedNewTransactionRunner) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) Configuration(org.opendaylight.mdsal.binding.util.Datastore.Configuration) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder) Objects(java.util.Objects) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) Optional(java.util.Optional) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) NWUtil(org.opendaylight.genius.mdsalutil.NWUtil) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) TransactionAdapter(org.opendaylight.mdsal.binding.util.TransactionAdapter) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) Inject(javax.inject.Inject) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) Objects.requireNonNull(java.util.Objects.requireNonNull) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) ReentrantLock(java.util.concurrent.locks.ReentrantLock) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Operational(org.opendaylight.mdsal.binding.util.Datastore.Operational) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) Collections(java.util.Collections) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) JvmGlobalLocks(org.opendaylight.genius.utils.JvmGlobalLocks) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) Optional(java.util.Optional) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RouterInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) List(java.util.List) Map(java.util.Map) LabelRouteMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.LabelRouteMap)

Example 13 with Futures

use of com.google.common.util.concurrent.Futures in project netvirt by opendaylight.

the class VrfEntryListener method populateFibOnNewDpn.

public void populateFibOnNewDpn(final Uint64 dpnId, final Uint32 vpnId, final String rd, final FutureCallback<List<?>> callback) {
    LOG.trace("New dpn {} for vpn {} : populateFibOnNewDpn", dpnId, rd);
    jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, dpnId), () -> {
        InstanceIdentifier<VrfTables> id = buildVrfId(rd);
        final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
        final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
        List<ListenableFuture<?>> futures = new ArrayList<>();
        if (!vrfTable.isPresent()) {
            LOG.info("populateFibOnNewDpn: dpn: {}: VRF Table not yet available for RD {}", dpnId, rd);
            if (callback != null) {
                ListenableFuture<List<Object>> listenableFuture = Futures.allAsList(futures);
                Futures.addCallback(listenableFuture, callback, MoreExecutors.directExecutor());
            }
            return futures;
        }
        final ReentrantLock lock = lockFor(vpnInstance);
        lock.lock();
        try {
            futures.add(retryingTxRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
                for (final VrfEntry vrfEntry : vrfTable.get().nonnullVrfEntry().values()) {
                    SubnetRoute subnetRoute = vrfEntry.augmentation(SubnetRoute.class);
                    if (subnetRoute != null) {
                        long elanTag = subnetRoute.getElantag().toJava();
                        installSubnetRouteInFib(dpnId, elanTag, rd, vpnId, vrfEntry, tx);
                        installSubnetBroadcastAddrDropRule(dpnId, rd, vpnId, vrfEntry, NwConstants.ADD_FLOW, tx);
                        continue;
                    }
                    RouterInterface routerInt = vrfEntry.augmentation(RouterInterface.class);
                    if (routerInt != null) {
                        LOG.trace("Router augmented vrfentry found rd:{}, uuid:{}, ip:{}, mac:{}", rd, routerInt.getUuid(), routerInt.getIpAddress(), routerInt.getMacAddress());
                        routerInterfaceVrfEntryHandler.installRouterFibEntry(vrfEntry, dpnId, vpnId, routerInt.getIpAddress(), new MacAddress(routerInt.getMacAddress()), NwConstants.ADD_FLOW);
                        continue;
                    }
                    // Handle local flow creation for imports
                    if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.SELF_IMPORTED) {
                        java.util.Optional<Uint32> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
                        if (optionalLabel.isPresent()) {
                            List<String> nextHopList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
                            LabelRouteInfo lri = getLabelRouteInfo(optionalLabel.get());
                            if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopList, lri)) {
                                if (Objects.equals(lri.getDpnId(), dpnId)) {
                                    try {
                                        int etherType = NWUtil.getEtherTypeFromIpPrefix(vrfEntry.getDestPrefix());
                                        createLocalFibEntry(vpnId, rd, vrfEntry, etherType);
                                    } catch (IllegalArgumentException ex) {
                                        LOG.warn("Unable to get etherType for IP Prefix {}", vrfEntry.getDestPrefix());
                                    }
                                    continue;
                                }
                            }
                        }
                    }
                    boolean shouldCreateRemoteFibEntry = shouldCreateFibEntryForVrfAndVpnIdOnDpn(vpnId, vrfEntry, dpnId);
                    if (shouldCreateRemoteFibEntry) {
                        LOG.trace("Will create remote FIB entry for vrfEntry {} on DPN {}", vrfEntry, dpnId);
                        if (RouteOrigin.BGP.getValue().equals(vrfEntry.getOrigin())) {
                            List<SubTransaction> txnObjects = new ArrayList<>();
                            bgpRouteVrfEntryHandler.createRemoteFibEntry(dpnId, vpnId, vrfTable.get().getRouteDistinguisher(), vrfEntry, TransactionAdapter.toWriteTransaction(tx), txnObjects);
                        } else {
                            createRemoteFibEntry(dpnId, vpnId, vrfTable.get().getRouteDistinguisher(), vrfEntry, tx);
                        }
                    }
                }
            }));
            if (callback != null) {
                ListenableFuture<List<Object>> listenableFuture = Futures.allAsList(futures);
                Futures.addCallback(listenableFuture, callback, MoreExecutors.directExecutor());
            }
        } finally {
            lock.unlock();
        }
        return futures;
    });
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) Arrays(java.util.Arrays) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) InetAddress(java.net.InetAddress) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Map(java.util.Map) Datastore(org.opendaylight.mdsal.binding.util.Datastore) BigInteger(java.math.BigInteger) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) UpgradeState(org.opendaylight.serviceutils.upgrade.UpgradeState) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) VpnHelper(org.opendaylight.netvirt.vpnmanager.api.VpnHelper) SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) TypedWriteTransaction(org.opendaylight.mdsal.binding.util.TypedWriteTransaction) TypedReadWriteTransaction(org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction) NWUtil.isIpv4Address(org.opendaylight.genius.mdsalutil.NWUtil.isIpv4Address) NonNull(org.eclipse.jdt.annotation.NonNull) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) LabelRouteMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.LabelRouteMap) RoutePathsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePathsKey) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Callable(java.util.concurrent.Callable) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder) Lists(com.google.common.collect.Lists) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) RouterInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) UnknownHostException(java.net.UnknownHostException) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) AdjacencyResult(org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) LoggerFactory(org.slf4j.LoggerFactory) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) Nullable(org.eclipse.jdt.annotation.Nullable) DataTreeEventCallbackRegistrar(org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar) RetryingManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.RetryingManagedNewTransactionRunner) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) Configuration(org.opendaylight.mdsal.binding.util.Datastore.Configuration) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder) Objects(java.util.Objects) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) Optional(java.util.Optional) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) NWUtil(org.opendaylight.genius.mdsalutil.NWUtil) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) TransactionAdapter(org.opendaylight.mdsal.binding.util.TransactionAdapter) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) Inject(javax.inject.Inject) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) Objects.requireNonNull(java.util.Objects.requireNonNull) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) ReentrantLock(java.util.concurrent.locks.ReentrantLock) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Operational(org.opendaylight.mdsal.binding.util.Datastore.Operational) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) Collections(java.util.Collections) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) JvmGlobalLocks(org.opendaylight.genius.utils.JvmGlobalLocks) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) Optional(java.util.Optional) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RouterInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) List(java.util.List)

Example 14 with Futures

use of com.google.common.util.concurrent.Futures in project thingsboard by thingsboard.

the class BaseAssetService method findAssetsByQuery.

@Override
public ListenableFuture<List<Asset>> findAssetsByQuery(TenantId tenantId, AssetSearchQuery query) {
    ListenableFuture<List<EntityRelation>> relations = relationService.findByQuery(tenantId, query.toEntitySearchQuery());
    ListenableFuture<List<Asset>> assets = Futures.transformAsync(relations, r -> {
        EntitySearchDirection direction = query.toEntitySearchQuery().getParameters().getDirection();
        List<ListenableFuture<Asset>> futures = new ArrayList<>();
        for (EntityRelation relation : r) {
            EntityId entityId = direction == EntitySearchDirection.FROM ? relation.getTo() : relation.getFrom();
            if (entityId.getEntityType() == EntityType.ASSET) {
                futures.add(findAssetByIdAsync(tenantId, new AssetId(entityId.getId())));
            }
        }
        return Futures.successfulAsList(futures);
    }, MoreExecutors.directExecutor());
    assets = Futures.transform(assets, assetList -> assetList == null ? Collections.emptyList() : assetList.stream().filter(asset -> query.getAssetTypes().contains(asset.getType())).collect(Collectors.toList()), MoreExecutors.directExecutor());
    return assets;
}
Also used : EntityId(org.thingsboard.server.common.data.id.EntityId) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) Edge(org.thingsboard.server.common.data.edge.Edge) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Cacheable(org.springframework.cache.annotation.Cacheable) EntitySearchDirection(org.thingsboard.server.common.data.relation.EntitySearchDirection) AssetId(org.thingsboard.server.common.data.id.AssetId) Autowired(org.springframework.beans.factory.annotation.Autowired) CacheEvict(org.springframework.cache.annotation.CacheEvict) Validator.validatePageLink(org.thingsboard.server.dao.service.Validator.validatePageLink) TenantId(org.thingsboard.server.common.data.id.TenantId) DataValidator(org.thingsboard.server.dao.service.DataValidator) EntityRelation(org.thingsboard.server.common.data.relation.EntityRelation) ArrayList(java.util.ArrayList) Validator.validateId(org.thingsboard.server.dao.service.Validator.validateId) Validator.validateString(org.thingsboard.server.dao.service.Validator.validateString) Service(org.springframework.stereotype.Service) EntityId(org.thingsboard.server.common.data.id.EntityId) EntityType(org.thingsboard.server.common.data.EntityType) EdgeId(org.thingsboard.server.common.data.id.EdgeId) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) PageLink(org.thingsboard.server.common.data.page.PageLink) DaoUtil.toUUIDs(org.thingsboard.server.dao.DaoUtil.toUUIDs) EntitiesCacheManager(org.thingsboard.server.dao.cache.EntitiesCacheManager) Validator.validateIds(org.thingsboard.server.dao.service.Validator.validateIds) Collectors(java.util.stream.Collectors) AssetSearchQuery(org.thingsboard.server.common.data.asset.AssetSearchQuery) ExecutionException(java.util.concurrent.ExecutionException) EntityView(org.thingsboard.server.common.data.EntityView) DataValidationException(org.thingsboard.server.dao.exception.DataValidationException) Futures(com.google.common.util.concurrent.Futures) Slf4j(lombok.extern.slf4j.Slf4j) AbstractEntityService(org.thingsboard.server.dao.entity.AbstractEntityService) List(java.util.List) AssetInfo(org.thingsboard.server.common.data.asset.AssetInfo) PageData(org.thingsboard.server.common.data.page.PageData) ASSET_CACHE(org.thingsboard.server.common.data.CacheConstants.ASSET_CACHE) PaginatedRemover(org.thingsboard.server.dao.service.PaginatedRemover) RelationTypeGroup(org.thingsboard.server.common.data.relation.RelationTypeGroup) EntitySubtype(org.thingsboard.server.common.data.EntitySubtype) Comparator(java.util.Comparator) Collections(java.util.Collections) Asset(org.thingsboard.server.common.data.asset.Asset) CustomerId(org.thingsboard.server.common.data.id.CustomerId) EntityRelation(org.thingsboard.server.common.data.relation.EntityRelation) EntitySearchDirection(org.thingsboard.server.common.data.relation.EntitySearchDirection) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ArrayList(java.util.ArrayList) List(java.util.List) AssetId(org.thingsboard.server.common.data.id.AssetId)

Example 15 with Futures

use of com.google.common.util.concurrent.Futures in project thingsboard by thingsboard.

the class TbAbstractSubCtx method resolve.

public void resolve(TenantId tenantId, CustomerId customerId, UserId userId) {
    List<ListenableFuture<DynamicValueKeySub>> futures = new ArrayList<>();
    for (DynamicValueKey key : dynamicValues.keySet()) {
        switch(key.getSourceType()) {
            case CURRENT_TENANT:
                futures.add(resolveEntityValue(tenantId, tenantId, key));
                break;
            case CURRENT_CUSTOMER:
                if (customerId != null && !customerId.isNullUid()) {
                    futures.add(resolveEntityValue(tenantId, customerId, key));
                }
                break;
            case CURRENT_USER:
                if (userId != null && !userId.isNullUid()) {
                    futures.add(resolveEntityValue(tenantId, userId, key));
                }
                break;
        }
    }
    try {
        Map<EntityId, Map<String, DynamicValueKeySub>> tmpSubMap = new HashMap<>();
        for (DynamicValueKeySub sub : Futures.successfulAsList(futures).get()) {
            tmpSubMap.computeIfAbsent(sub.getEntityId(), tmp -> new HashMap<>()).put(sub.getKey().getSourceAttribute(), sub);
        }
        for (EntityId entityId : tmpSubMap.keySet()) {
            Map<String, Long> keyStates = new HashMap<>();
            Map<String, DynamicValueKeySub> dynamicValueKeySubMap = tmpSubMap.get(entityId);
            dynamicValueKeySubMap.forEach((k, v) -> keyStates.put(k, v.getLastUpdateTs()));
            int subIdx = sessionRef.getSessionSubIdSeq().incrementAndGet();
            TbAttributeSubscription sub = TbAttributeSubscription.builder().serviceId(serviceId).sessionId(sessionRef.getSessionId()).subscriptionId(subIdx).tenantId(sessionRef.getSecurityCtx().getTenantId()).entityId(entityId).updateConsumer((s, subscriptionUpdate) -> dynamicValueSubUpdate(s, subscriptionUpdate, dynamicValueKeySubMap)).allKeys(false).keyStates(keyStates).scope(TbAttributeSubscriptionScope.SERVER_SCOPE).build();
            subToDynamicValueKeySet.add(subIdx);
            localSubscriptionService.addSubscription(sub);
        }
    } catch (InterruptedException | ExecutionException e) {
        log.info("[{}][{}][{}] Failed to resolve dynamic values: {}", tenantId, customerId, userId, dynamicValues.keySet());
    }
}
Also used : MoreExecutors(com.google.common.util.concurrent.MoreExecutors) Setter(lombok.Setter) DynamicValue(org.thingsboard.server.common.data.query.DynamicValue) ScheduledFuture(java.util.concurrent.ScheduledFuture) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Getter(lombok.Getter) TsValue(org.thingsboard.server.common.data.query.TsValue) FilterPredicateType(org.thingsboard.server.common.data.query.FilterPredicateType) HashMap(java.util.HashMap) EntityCountQuery(org.thingsboard.server.common.data.query.EntityCountQuery) DynamicValueSourceType(org.thingsboard.server.common.data.query.DynamicValueSourceType) KeyFilter(org.thingsboard.server.common.data.query.KeyFilter) TenantId(org.thingsboard.server.common.data.id.TenantId) ArrayList(java.util.ArrayList) AttributeKvEntry(org.thingsboard.server.common.data.kv.AttributeKvEntry) KeyFilterPredicate(org.thingsboard.server.common.data.query.KeyFilterPredicate) Map(java.util.Map) EntityId(org.thingsboard.server.common.data.id.EntityId) EntityService(org.thingsboard.server.dao.entity.EntityService) AttributesService(org.thingsboard.server.dao.attributes.AttributesService) ComplexFilterPredicate(org.thingsboard.server.common.data.query.ComplexFilterPredicate) EntityKeyType(org.thingsboard.server.common.data.query.EntityKeyType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) TelemetryWebSocketSessionRef(org.thingsboard.server.service.telemetry.TelemetryWebSocketSessionRef) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) Slf4j(lombok.extern.slf4j.Slf4j) UserId(org.thingsboard.server.common.data.id.UserId) List(java.util.List) SimpleKeyFilterPredicate(org.thingsboard.server.common.data.query.SimpleKeyFilterPredicate) Data(lombok.Data) Optional(java.util.Optional) TelemetrySubscriptionUpdate(org.thingsboard.server.service.telemetry.sub.TelemetrySubscriptionUpdate) TelemetryWebSocketService(org.thingsboard.server.service.telemetry.TelemetryWebSocketService) CustomerId(org.thingsboard.server.common.data.id.CustomerId) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ArrayList(java.util.ArrayList) EntityId(org.thingsboard.server.common.data.id.EntityId) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ExecutionException(java.util.concurrent.ExecutionException) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

Futures (com.google.common.util.concurrent.Futures)42 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)42 List (java.util.List)38 ArrayList (java.util.ArrayList)32 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)26 Map (java.util.Map)21 ExecutionException (java.util.concurrent.ExecutionException)21 Collectors (java.util.stream.Collectors)21 Set (java.util.Set)19 Nullable (javax.annotation.Nullable)19 FutureCallback (com.google.common.util.concurrent.FutureCallback)18 Collections (java.util.Collections)18 Collection (java.util.Collection)17 Optional (java.util.Optional)17 Logger (org.slf4j.Logger)16 LoggerFactory (org.slf4j.LoggerFactory)16 HashSet (java.util.HashSet)15 TimeUnit (java.util.concurrent.TimeUnit)15 Inject (javax.inject.Inject)15 Lists (com.google.common.collect.Lists)14