Search in sources :

Example 31 with Monitor

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

the class TunnelMonitorChangeListener method update.

@Override
protected void update(InstanceIdentifier<TunnelMonitorParams> key, TunnelMonitorParams dataObjectModificationBefore, TunnelMonitorParams dataObjectModificationAfter) {
    LOG.debug("update TunnelMonitorChangeListener called with {}", dataObjectModificationAfter.isEnabled());
    Class<? extends TunnelMonitoringTypeBase> monitorProtocolBefore = dataObjectModificationBefore.getMonitorProtocol();
    Class<? extends TunnelMonitoringTypeBase> monitorProtocolAfter = dataObjectModificationAfter.getMonitorProtocol();
    Class<? extends TunnelMonitoringTypeBase> monitorProtocol = ITMConstants.DEFAULT_MONITOR_PROTOCOL;
    InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
    Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, broker);
    if (monitorProtocolAfter != null) {
        monitorProtocol = dataObjectModificationAfter.getMonitorProtocol();
    }
    if (monitorProtocolBefore != null && monitorProtocolAfter != null) {
        LOG.debug("TunnelMonitorChangeListener Update : Existing_MonitorProtocol {}, New_MonitorProtocol {} ", monitorProtocolBefore.getName(), monitorProtocolAfter.getName());
        if (!monitorProtocolAfter.getName().equalsIgnoreCase(monitorProtocolBefore.getName())) {
            LOG.error("Updation of monitor protocol not allowed");
        }
    }
    if (transportZonesOptional.isPresent()) {
        TransportZones tzones = transportZonesOptional.get();
        for (TransportZone tzone : tzones.getTransportZone()) {
            LOG.debug("Update - TunnelMonitorToggleWorker with tzone = {}, Enable = {}, MonitorProtocol = {}", tzone.getZoneName(), dataObjectModificationAfter.isEnabled(), monitorProtocol);
            ItmMonitorToggleWorker toggleWorker = new ItmMonitorToggleWorker(tzone.getZoneName(), dataObjectModificationAfter.isEnabled(), monitorProtocol, broker);
            jobCoordinator.enqueueJob(tzone.getZoneName(), toggleWorker);
        }
    }
}
Also used : ItmMonitorToggleWorker(org.opendaylight.genius.itm.confighelpers.ItmMonitorToggleWorker) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)

Example 32 with Monitor

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

the class AlivenessMonitorUtils method handleTunnelMonitorUpdates.

public void handleTunnelMonitorUpdates(Interface interfaceOld, Interface interfaceNew) {
    String interfaceName = interfaceNew.getName();
    IfTunnel ifTunnelNew = interfaceNew.getAugmentation(IfTunnel.class);
    if (!lldpMonitoringEnabled(ifTunnelNew)) {
        return;
    }
    LOG.debug("handling tunnel monitoring updates for interface {}", interfaceName);
    stopLLDPMonitoring(ifTunnelNew, interfaceOld.getName());
    if (ifTunnelNew.isMonitorEnabled()) {
        startLLDPMonitoring(ifTunnelNew, interfaceName);
        // Delete old profile from Aliveness Manager
        IfTunnel ifTunnelOld = interfaceOld.getAugmentation(IfTunnel.class);
        if (!ifTunnelNew.getMonitorInterval().equals(ifTunnelOld.getMonitorInterval())) {
            LOG.debug("deleting older monitor profile for interface {}", interfaceName);
            long profileId = allocateProfile(FAILURE_THRESHOLD, ifTunnelOld.getMonitorInterval(), MONITORING_WINDOW, EtherTypes.Lldp);
            MonitorProfileDeleteInput profileDeleteInput = new MonitorProfileDeleteInputBuilder().setProfileId(profileId).build();
            Future<RpcResult<Void>> future = alivenessMonitorService.monitorProfileDelete(profileDeleteInput);
            ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(future), LOG, "Delete monitor profile {}", interfaceName);
        }
    }
}
Also used : MonitorProfileDeleteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileDeleteInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) MonitorProfileDeleteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileDeleteInputBuilder)

Example 33 with Monitor

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.bmp.monitor.Monitor 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)

Aggregations

Optional (com.google.common.base.Optional)15 MonitorProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfile)15 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)10 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 Test (org.junit.Test)8 MonitoringInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.configs.MonitoringInfo)8 MonitoringState (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringState)8 MonitoringStateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringStateBuilder)8 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 FutureCallback (com.google.common.util.concurrent.FutureCallback)6 Nonnull (javax.annotation.Nonnull)6 EtherTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.EtherTypes)6 MonitorProfileCreateOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateOutput)6 ArrayList (java.util.ArrayList)5 Semaphore (java.util.concurrent.Semaphore)5 LivenessState (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.LivenessState)5 MonitorProfileDeleteInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileDeleteInput)5 MonitoringInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.configs.MonitoringInfoBuilder)5 MonitoridKeyEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitorid.key.map.MonitoridKeyEntry)5 MonitoridKeyEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitorid.key.map.MonitoridKeyEntryBuilder)5