Search in sources :

Example 1 with Datastore

use of org.opendaylight.mdsal.binding.util.Datastore in project netvirt by opendaylight.

the class IpMonitorStopTask method call.

@Override
public List<ListenableFuture<Void>> call() {
    final List<ListenableFuture<Void>> futures = new ArrayList<>();
    java.util.Optional<Uint32> monitorIdOptional = alivenessMonitorUtils.getMonitorIdFromInterface(macEntry);
    if (monitorIdOptional.isPresent()) {
        alivenessMonitorUtils.stopIpMonitoring(monitorIdOptional.get());
    } else {
        LOG.warn("MonitorId not available for IP {} interface {}. IpMonitoring not stopped", macEntry.getIpAddress(), macEntry.getInterfaceName());
    }
    String learntIp = macEntry.getIpAddress().getHostAddress();
    if (this.isRemoveMipAdjAndLearntIp) {
        String vpnName = macEntry.getVpnName();
        LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
        if (vpnVipToPort != null && !Objects.equals(vpnVipToPort.getCreationTime(), macEntry.getCreatedTime())) {
            LOG.warn("The MIP {} over vpn {} has been learnt again and processed. " + "Ignoring this remove event.", learntIp, vpnName);
            return futures;
        }
        vpnUtil.removeLearntVpnVipToPort(macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
        vpnUtil.removeVpnPortFixedIpToPort(dataBroker, macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress(), null);
        LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, tx -> vpnUtil.removeMipAdjacency(macEntry.getVpnName(), macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), tx)), LOG, "ArpMonitorStopTask: Error writing to datastore for Vpn {} IP  {}", macEntry.getVpnName(), macEntry.getIpAddress().getHostAddress());
    } else {
        // Delete only MIP adjacency
        vpnUtil.removeMipAdjacency(macEntry.getInterfaceName(), learntIp);
    }
    return futures;
}
Also used : VpnUtil(org.opendaylight.netvirt.vpnmanager.VpnUtil) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LoggerFactory(org.slf4j.LoggerFactory) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Callable(java.util.concurrent.Callable) ArrayList(java.util.ArrayList) Objects(java.util.Objects) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) MacEntry(org.opendaylight.netvirt.vpnmanager.iplearn.model.MacEntry) Datastore(org.opendaylight.mdsal.binding.util.Datastore) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LearntVpnVipToPort(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 2 with Datastore

use of org.opendaylight.mdsal.binding.util.Datastore in project netvirt by opendaylight.

the class MergeCommandsAggregator method mergeUpdate.

@SuppressWarnings("illegalcatch")
public <D extends Datastore> void mergeUpdate(InstanceIdentifier<Node> dstPath, DataObjectModification mod, Class<D> datastoreType, TypedReadWriteTransaction<D> transaction, ManagedNewTransactionRunner txRunner) {
    BatchedTransaction tx = null;
    if (mod == null || mod.getModifiedChildren() == null) {
        return;
    }
    if (!(transaction instanceof BatchedTransaction)) {
        return;
    } else {
        tx = (BatchedTransaction) transaction;
    }
    final BatchedTransaction transaction1 = tx;
    String srcNodeId = transaction1.getSrcNodeId().getValue();
    String dstNodeId = dstPath.firstKeyOf(Node.class).getNodeId().getValue();
    Collection<DataObjectModification> modifications = mod.getModifiedChildren();
    modifications.stream().filter(modification -> skipCopy.negate().test(datastoreType, modification.getDataType())).filter(modification -> commands.get(modification.getDataType()) != null).peek(modification -> LOG.debug("Received {} modification {} copy/delete to {}", datastoreType, modification, dstPath)).forEach(modification -> {
        try {
            copyModification(dstPath, datastoreType, transaction1, srcNodeId, dstNodeId, modification, txRunner);
        } catch (Exception e) {
            LOG.error("Failed to copy mod from {} to {} {} {} id  {}", srcNodeId, dstNodeId, modification.getDataType().getSimpleName(), modification, modification.getIdentifier(), e);
        }
    });
}
Also used : CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) LoggerFactory(org.slf4j.LoggerFactory) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) HashMap(java.util.HashMap) RemoteUcastCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.RemoteUcastCmd) RemoteMcastCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.RemoteMcastCmd) Tunnels(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical._switch.attributes.Tunnels) BiPredicate(java.util.function.BiPredicate) Map(java.util.Map) Datastore(org.opendaylight.mdsal.binding.util.Datastore) LocalUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs) Builder(org.opendaylight.yangtools.concepts.Builder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) DataObjectModification(org.opendaylight.mdsal.binding.api.DataObjectModification) BatchedTransaction(org.opendaylight.netvirt.elan.l2gw.ha.BatchedTransaction) TunnelIpCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.TunnelIpCmd) Logger(org.slf4j.Logger) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) Collection(java.util.Collection) Configuration(org.opendaylight.mdsal.binding.util.Datastore.Configuration) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) Operational(org.opendaylight.mdsal.binding.util.Datastore.Operational) SuperTypeUtil(org.opendaylight.genius.utils.SuperTypeUtil) LocalUcastCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.LocalUcastCmd) FutureCallback(com.google.common.util.concurrent.FutureCallback) RemoteUcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs) LocalMcastCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.LocalMcastCmd) MergeCommand(org.opendaylight.netvirt.elan.l2gw.ha.commands.MergeCommand) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) Futures(com.google.common.util.concurrent.Futures) RemoteMcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs) TerminationPointCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.TerminationPointCmd) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) PhysicalLocatorCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.PhysicalLocatorCmd) LocalMcastMacs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalMcastMacs) Optional(java.util.Optional) TunnelCmd(org.opendaylight.netvirt.elan.l2gw.ha.commands.TunnelCmd) CacheBuilder(com.google.common.cache.CacheBuilder) TypedReadWriteTransaction(org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction) Cache(com.google.common.cache.Cache) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) BatchedTransaction(org.opendaylight.netvirt.elan.l2gw.ha.BatchedTransaction) DataObjectModification(org.opendaylight.mdsal.binding.api.DataObjectModification)

Aggregations

Objects (java.util.Objects)2 Datastore (org.opendaylight.mdsal.binding.util.Datastore)2 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Cache (com.google.common.cache.Cache)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Callable (java.util.concurrent.Callable)1 TimeUnit (java.util.concurrent.TimeUnit)1 BiPredicate (java.util.function.BiPredicate)1