Search in sources :

Example 21 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project genius by opendaylight.

the class AlivenessMonitorUtils method removeMonitorIdFromInterfaceMonitorIdMap.

private void removeMonitorIdFromInterfaceMonitorIdMap(ReadWriteTransaction tx, String infName, long monitorId) throws ReadFailedException {
    InstanceIdentifier<InterfaceMonitorId> id = InstanceIdentifier.builder(InterfaceMonitorIdMap.class).child(InterfaceMonitorId.class, new InterfaceMonitorIdKey(infName)).build();
    Optional<InterfaceMonitorId> interfaceMonitorIdMap = tx.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet();
    if (interfaceMonitorIdMap.isPresent()) {
        InterfaceMonitorId interfaceMonitorIdInstance = interfaceMonitorIdMap.get();
        List<Long> existingMonitorIds = interfaceMonitorIdInstance.getMonitorId();
        if (existingMonitorIds != null && existingMonitorIds.contains(monitorId)) {
            existingMonitorIds.remove(monitorId);
            InterfaceMonitorIdBuilder interfaceMonitorIdBuilder = new InterfaceMonitorIdBuilder();
            interfaceMonitorIdInstance = interfaceMonitorIdBuilder.setKey(new InterfaceMonitorIdKey(infName)).setMonitorId(existingMonitorIds).build();
            tx.merge(LogicalDatastoreType.OPERATIONAL, id, interfaceMonitorIdInstance, WriteTransaction.CREATE_MISSING_PARENTS);
        }
    }
}
Also used : InterfaceMonitorId(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.monitor.id.map.InterfaceMonitorId) InterfaceMonitorIdKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.monitor.id.map.InterfaceMonitorIdKey) InterfaceMonitorIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.monitor.id.map.InterfaceMonitorIdBuilder)

Example 22 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project genius by opendaylight.

the class AlivenessMonitorUtils method stopLLDPMonitoring.

public void stopLLDPMonitoring(IfTunnel ifTunnel, String trunkInterface) {
    if (!lldpMonitoringEnabled(ifTunnel)) {
        return;
    }
    LOG.debug("stop LLDP monitoring for {}", trunkInterface);
    ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
        List<Long> monitorIds = getMonitorIdForInterface(tx, trunkInterface);
        if (monitorIds == null) {
            LOG.error("Monitor Id doesn't exist for Interface {}", trunkInterface);
            return;
        }
        for (Long monitorId : monitorIds) {
            String interfaceName = getInterfaceFromMonitorId(tx, monitorId);
            if (interfaceName != null) {
                MonitorStopInput input = new MonitorStopInputBuilder().setMonitorId(monitorId).build();
                Future<RpcResult<Void>> future = alivenessMonitorService.monitorStop(input);
                ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(future), LOG, "Stop LLDP monitoring for {}", trunkInterface);
                removeMonitorIdInterfaceMap(tx, monitorId);
                removeMonitorIdFromInterfaceMonitorIdMap(tx, interfaceName, monitorId);
                return;
            }
        }
    }), LOG, "Error stopping LLDP monitoring for {}", trunkInterface);
}
Also used : ProfileBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profile.create.input.ProfileBuilder) LoggerFactory(org.slf4j.LoggerFactory) ReadTransaction(org.opendaylight.controller.md.sal.binding.api.ReadTransaction) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) TunnelMonitoringTypeLldp(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelMonitoringTypeLldp) Future(java.util.concurrent.Future) Optional(com.google.common.base.Optional) MonitorIdInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceKey) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) InterfaceMonitorIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.monitor.id.map.InterfaceMonitorIdBuilder) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) InterfaceMonitorIdKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.monitor.id.map.InterfaceMonitorIdKey) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) MonitorStartInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInputBuilder) MonitorIdInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterface) List(java.util.List) MonitorProfileCreateOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateOutput) AlivenessMonitorService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.AlivenessMonitorService) MonitorProfileGetOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetOutput) MonitorProfileDeleteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileDeleteInput) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) MonitorProfileGetInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetInputBuilder) MonitorIdInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Singleton(javax.inject.Singleton) JdkFutureAdapters(com.google.common.util.concurrent.JdkFutureAdapters) SourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.params.SourceBuilder) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) Profile(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profile.create.input.Profile) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) InterfaceMonitorId(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.monitor.id.map.InterfaceMonitorId) EtherTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.EtherTypes) MonitorIdInterfaceMap(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.MonitorIdInterfaceMap) Logger(org.slf4j.Logger) ConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.start.input.ConfigBuilder) MonitorProfileCreateInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateInputBuilder) MonitorStartOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartOutput) ExecutionException(java.util.concurrent.ExecutionException) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) MonitorStopInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInput) MonitorStartInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInput) MonitoringMode(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitoringMode) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) MonitorStopInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInputBuilder) MonitorProfileDeleteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileDeleteInputBuilder) MonitorProfileGetInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileGetInput) InterfaceMonitorIdMap(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.InterfaceMonitorIdMap) MonitorProfileCreateInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateInput) MonitorStopInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInput) MonitorStopInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInputBuilder) Future(java.util.concurrent.Future) List(java.util.List) ArrayList(java.util.ArrayList)

Example 23 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project genius by opendaylight.

the class AlivenessMonitorUtils method createOrUpdateMonitorIdInterfaceMap.

private static void createOrUpdateMonitorIdInterfaceMap(ReadWriteTransaction tx, String infName, long monitorId) throws ReadFailedException {
    MonitorIdInterface monitorIdInterfaceInstance;
    String existinginterfaceName;
    MonitorIdInterfaceBuilder monitorIdInterfaceBuilder = new MonitorIdInterfaceBuilder();
    InstanceIdentifier<MonitorIdInterface> id = InstanceIdentifier.builder(MonitorIdInterfaceMap.class).child(MonitorIdInterface.class, new MonitorIdInterfaceKey(monitorId)).build();
    Optional<MonitorIdInterface> monitorIdInterfaceMap = tx.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet();
    if (monitorIdInterfaceMap.isPresent()) {
        monitorIdInterfaceInstance = monitorIdInterfaceMap.get();
        existinginterfaceName = monitorIdInterfaceInstance.getInterfaceName();
        if (!existinginterfaceName.equals(infName)) {
            monitorIdInterfaceInstance = monitorIdInterfaceBuilder.setKey(new MonitorIdInterfaceKey(monitorId)).setInterfaceName(infName).build();
            tx.merge(LogicalDatastoreType.OPERATIONAL, id, monitorIdInterfaceInstance, WriteTransaction.CREATE_MISSING_PARENTS);
        }
    } else {
        monitorIdInterfaceInstance = monitorIdInterfaceBuilder.setMonitorId(monitorId).setKey(new MonitorIdInterfaceKey(monitorId)).setInterfaceName(infName).build();
        tx.merge(LogicalDatastoreType.OPERATIONAL, id, monitorIdInterfaceInstance, WriteTransaction.CREATE_MISSING_PARENTS);
    }
}
Also used : MonitorIdInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceBuilder) MonitorIdInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterface) MonitorIdInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceKey)

Example 24 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId 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 25 with MonitorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId in project bgpcep by opendaylight.

the class BmpMonitorImplTest method deploySecondInstance.

@Test
public void deploySecondInstance() throws Exception {
    final BmpMonitoringStation monitoringStation2 = new BmpMonitoringStationImpl(getDomBroker(), dispatcher, ribExtension, mappingService.currentSerializer(), clusterSSProv2, new MonitorId("monitor2"), new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS_2), MONITOR_LOCAL_PORT), null);
    readDataOperational(getDataBroker(), BMP_II, monitor -> {
        assertEquals(2, monitor.nonnullMonitor().size());
        return monitor;
    });
    monitoringStation2.close();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) BmpMonitoringStation(org.opendaylight.protocol.bmp.impl.spi.BmpMonitoringStation) MonitorId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Aggregations

Optional (com.google.common.base.Optional)10 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)8 EtherTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.EtherTypes)7 MonitorProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfile)7 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)7 ArrayList (java.util.ArrayList)6 ExecutionException (java.util.concurrent.ExecutionException)6 MonitorStartInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartInput)6 MonitorStartOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStartOutput)6 MonitorStopInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorStopInput)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 List (java.util.List)5 FutureCallback (com.google.common.util.concurrent.FutureCallback)4 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)4 Future (java.util.concurrent.Future)4 Nonnull (javax.annotation.Nonnull)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)4