Search in sources :

Example 21 with Updates

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project genius by opendaylight.

the class NodeConnectorStatsImpl method processFlowStatistics.

/**
 * This method processes FlowStatistics RPC result.
 * It performs:
 * - fetches all flows of node
 * - stores flows count per table in local map
 * - creates/updates Flow table counters using Infrautils metrics API
 * - set counter with values fetched from FlowStatistics
 */
private void processFlowStatistics(GetFlowStatisticsOutput flowStatsOutput, BigInteger dpid) {
    Map<Short, AtomicInteger> flowTableMap = new HashMap<>();
    // Get all flows for node from RPC result
    List<FlowAndStatisticsMapList> flowTableAndStatisticsMapList = flowStatsOutput.getFlowAndStatisticsMapList();
    for (FlowAndStatisticsMapList flowAndStatisticsMap : flowTableAndStatisticsMapList) {
        short tableId = flowAndStatisticsMap.getTableId();
        // populate map to maintain flow count per table
        flowTableMap.computeIfAbsent(tableId, key -> new AtomicInteger(0)).incrementAndGet();
    }
    LOG.trace("FlowTableStatistics (tableId:counter): {} for node: {}", flowTableMap.entrySet(), dpid.toString());
    for (Map.Entry<Short, AtomicInteger> flowTable : flowTableMap.entrySet()) {
        Short tableId = flowTable.getKey();
        AtomicInteger flowCount = flowTable.getValue();
        Counter counter = getCounter(CounterConstants.IFM_FLOW_TBL_COUNTER_FLOWS_PER_TBL, dpid, null, null, tableId.toString());
        // update counter value
        updateCounter(counter, flowCount.longValue());
    }
}
Also used : InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) ScheduledFuture(java.util.concurrent.ScheduledFuture) MetricDescriptor(org.opendaylight.infrautils.metrics.MetricDescriptor) UncheckedCloseable(org.opendaylight.infrautils.utils.UncheckedCloseable) LoggerFactory(org.slf4j.LoggerFactory) AsyncClusteredDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase) GetFlowStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput) PreDestroy(javax.annotation.PreDestroy) Future(java.util.concurrent.Future) InterfaceChildCache(org.opendaylight.genius.interfacemanager.listeners.InterfaceChildCache) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Optional(com.google.common.base.Optional) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Map(java.util.Map) BigInteger(java.math.BigInteger) ThreadFactory(java.util.concurrent.ThreadFactory) GetFlowStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInputBuilder) GetFlowStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput) GetNodeConnectorStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInputBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) EntityOwnershipUtils(org.opendaylight.genius.utils.clustering.EntityOwnershipUtils) IfmConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.config.rev160406.IfmConfig) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Set(java.util.Set) Executors(java.util.concurrent.Executors) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) OpendaylightDirectStatisticsService(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.OpendaylightDirectStatisticsService) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) List(java.util.List) GetNodeConnectorStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput) Labeled(org.opendaylight.infrautils.metrics.Labeled) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) IfmConstants(org.opendaylight.genius.interfacemanager.IfmConstants) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) MetricProvider(org.opendaylight.infrautils.metrics.MetricProvider) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) JdkFutureAdapters(com.google.common.util.concurrent.JdkFutureAdapters) Inject(javax.inject.Inject) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Nonnull(javax.annotation.Nonnull) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Logger(org.slf4j.Logger) FutureCallback(com.google.common.util.concurrent.FutureCallback) TimeUnit(java.util.concurrent.TimeUnit) Futures(com.google.common.util.concurrent.Futures) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) PortNameCache(org.opendaylight.genius.interfacemanager.listeners.PortNameCache) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Counter(org.opendaylight.infrautils.metrics.Counter) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) Counter(org.opendaylight.infrautils.metrics.Counter) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) HashMap(java.util.HashMap)

Example 22 with Updates

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project genius by opendaylight.

the class NodeConnectorStatsImpl method processNodeConnectorStatistics.

/**
 * This method processes NodeConnectorStatistics RPC result.
 * It performs:
 * - fetches various OF Port counters values
 * - creates/updates new OF Port counters using Infrautils metrics API
 * - set counter with values fetched from NodeConnectorStatistics
 */
private void processNodeConnectorStatistics(GetNodeConnectorStatisticsOutput nodeConnectorStatisticsOutput, BigInteger dpid) {
    String port = "";
    String portUuid = "";
    List<NodeConnectorStatisticsAndPortNumberMap> ncStatsAndPortMapList = nodeConnectorStatisticsOutput.getNodeConnectorStatisticsAndPortNumberMap();
    // Parse NodeConnectorStatistics and create/update counters for them
    for (NodeConnectorStatisticsAndPortNumberMap ncStatsAndPortMap : ncStatsAndPortMapList) {
        NodeConnectorId nodeConnector = ncStatsAndPortMap.getNodeConnectorId();
        LOG.trace("Create/update metric counter for NodeConnector: {} of node: {}", nodeConnector, dpid.toString());
        port = nodeConnector.getValue();
        // update port name as per port name maintained in portNameCache
        String portNameInCache = "openflow" + ":" + dpid.toString() + ":" + port;
        java.util.Optional<String> portName = portNameCache.get(portNameInCache);
        if (portName.isPresent()) {
            Optional<List<InterfaceChildEntry>> interfaceChildEntries = interfaceChildCache.getInterfaceChildEntries(portName.get());
            if (interfaceChildEntries.isPresent()) {
                if (!interfaceChildEntries.get().isEmpty()) {
                    portUuid = interfaceChildEntries.get().get(0).getChildInterface();
                    LOG.trace("Retrieved portUuid {} for portname {}", portUuid, portName.get());
                } else {
                    LOG.trace("PortUuid is not found for portname {}. Skipping IFM counters publish for this port.", portName.get());
                    continue;
                }
            } else {
                LOG.trace("PortUuid is not found for portname {}. Skipping IFM counters publish for this port.", portName.get());
                continue;
            }
        }
        Counter counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_DURATION, dpid, port, portUuid, null);
        long ofPortDuration = ncStatsAndPortMap.getDuration().getSecond().getValue();
        updateCounter(counter, ofPortDuration);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECVDROP, dpid, port, portUuid, null);
        long packetsPerOFPortReceiveDrop = ncStatsAndPortMap.getReceiveDrops().longValue();
        updateCounter(counter, packetsPerOFPortReceiveDrop);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECVERROR, dpid, port, portUuid, null);
        long packetsPerOFPortReceiveError = ncStatsAndPortMap.getReceiveErrors().longValue();
        updateCounter(counter, packetsPerOFPortReceiveError);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_SENT, dpid, port, portUuid, null);
        long packetsPerOFPortSent = ncStatsAndPortMap.getPackets().getTransmitted().longValue();
        updateCounter(counter, packetsPerOFPortSent);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECV, dpid, port, portUuid, null);
        long packetsPerOFPortReceive = ncStatsAndPortMap.getPackets().getReceived().longValue();
        updateCounter(counter, packetsPerOFPortReceive);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_BYTE_SENT, dpid, port, portUuid, null);
        long bytesPerOFPortSent = ncStatsAndPortMap.getBytes().getTransmitted().longValue();
        updateCounter(counter, bytesPerOFPortSent);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_BYTE_RECV, dpid, port, portUuid, null);
        long bytesPerOFPortReceive = ncStatsAndPortMap.getBytes().getReceived().longValue();
        updateCounter(counter, bytesPerOFPortReceive);
    }
}
Also used : Counter(org.opendaylight.infrautils.metrics.Counter) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) List(java.util.List) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)

Example 23 with Updates

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project netvirt by opendaylight.

the class InterVpnLinkUtil method updateInterVpnLinkState.

/**
 * Updates inter-VPN link state.
 *
 * @param vpnLinkName The name of the InterVpnLink
 * @param state Sets the state of the InterVpnLink to Active or Error
 * @param newFirstEndpointState Updates the lportTag and/or DPNs of the 1st endpoint of the InterVpnLink
 * @param newSecondEndpointState Updates the lportTag and/or DPNs of the 2nd endpoint of the InterVpnLink
 * @param interVpnLinkCache the InterVpnLinkCache
 */
void updateInterVpnLinkState(String vpnLinkName, InterVpnLinkState.State state, FirstEndpointState newFirstEndpointState, SecondEndpointState newSecondEndpointState, InterVpnLinkCache interVpnLinkCache) {
    Optional<InterVpnLinkState> optOldVpnLinkState = getInterVpnLinkState(vpnLinkName);
    if (optOldVpnLinkState.isPresent()) {
        InterVpnLinkState newVpnLinkState = new InterVpnLinkStateBuilder(optOldVpnLinkState.get()).setState(state).setFirstEndpointState(newFirstEndpointState).setSecondEndpointState(newSecondEndpointState).build();
        vpnUtil.syncUpdate(LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkStateIid(vpnLinkName), newVpnLinkState);
        interVpnLinkCache.addInterVpnLinkStateToCaches(newVpnLinkState);
    } else {
        InterVpnLinkState newIVpnLinkState = new InterVpnLinkStateBuilder().withKey(new InterVpnLinkStateKey(vpnLinkName)).setInterVpnLinkName(vpnLinkName).setFirstEndpointState(newFirstEndpointState).setSecondEndpointState(newSecondEndpointState).setState(InterVpnLinkState.State.Active).build();
        vpnUtil.syncWrite(LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkStateIid(vpnLinkName), newIVpnLinkState);
        interVpnLinkCache.addInterVpnLinkStateToCaches(newIVpnLinkState);
    }
}
Also used : InterVpnLinkState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkState) InterVpnLinkStateKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkStateKey) InterVpnLinkStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkStateBuilder)

Example 24 with Updates

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project netvirt by opendaylight.

the class QosNeutronPortChangeListener method update.

@Override
public void update(InstanceIdentifier<Port> instanceIdentifier, Port original, Port update) {
    qosNeutronUtils.addToPortCache(update);
    // check for QoS updates
    QosPortExtension updateQos = update.augmentation(QosPortExtension.class);
    QosPortExtension originalQos = original.augmentation(QosPortExtension.class);
    if (originalQos == null && updateQos != null) {
        // qosservice policy add
        qosNeutronUtils.addToQosPortsCache(updateQos.getQosPolicyId(), update);
        qosNeutronUtils.handleNeutronPortQosAdd(update, updateQos.getQosPolicyId());
    } else if (originalQos != null && updateQos != null && !Objects.equals(originalQos.getQosPolicyId(), updateQos.getQosPolicyId())) {
        // qosservice policy update
        qosNeutronUtils.removeFromQosPortsCache(originalQos.getQosPolicyId(), original);
        qosNeutronUtils.addToQosPortsCache(updateQos.getQosPolicyId(), update);
        qosNeutronUtils.handleNeutronPortQosUpdate(update, updateQos.getQosPolicyId(), originalQos.getQosPolicyId());
    } else if (originalQos != null && updateQos == null) {
        // qosservice policy delete
        qosNeutronUtils.handleNeutronPortQosRemove(original, originalQos.getQosPolicyId());
        qosNeutronUtils.removeFromQosPortsCache(originalQos.getQosPolicyId(), original);
    }
    if (qosEosHandler.isQosClusterOwner()) {
        checkForPortIpAddressUpdate(original, update);
    }
}
Also used : QosPortExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.ext.rev160613.QosPortExtension)

Example 25 with Updates

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates in project netvirt by opendaylight.

the class NeutronPortChangeListener method createOfPortInterface.

private String createOfPortInterface(Port port, TypedWriteTransaction<Datastore.Configuration> wrtConfigTxn) {
    Interface inf = createInterface(port);
    String infName = inf.getName();
    InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(infName);
    try {
        Optional<Interface> optionalInf = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier);
        if (!optionalInf.isPresent()) {
            wrtConfigTxn.put(interfaceIdentifier, inf);
        } else if (isInterfaceUpdated(inf, optionalInf.get())) {
            /*
                Case where an update DTCN wasn't received by this class due to node going down
                upon cluster reboot or any other unknown reason
                In such a case, updates contained in the missed DTCN won't be processed and have to be handled
                explicitly
                Update of subports (vlanId, splithorizon tag) is handled here
                Update of portSecurity (PortSecurityEnabled, SecurityGroups, AllowedAddressPairs) add is handled
                Update of portSecurity update/removed is not handled
                Update of parentrefs is not handled as parentrefs updation is handled by IFM Oxygen onwards
                */
            wrtConfigTxn.put(interfaceIdentifier, inf);
            LOG.error("Interface {} is already present and is updated", infName);
        } else {
            LOG.warn("Interface {} is already present", infName);
        }
    } catch (ExecutionException | InterruptedException e) {
        LOG.error("failed to create interface {}", infName, e);
    }
    return infName;
}
Also used : ExecutionException(java.util.concurrent.ExecutionException) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)

Aggregations

Uint32 (org.opendaylight.yangtools.yang.common.Uint32)4 ExecutionException (java.util.concurrent.ExecutionException)3 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)3 Updates (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.Updates)3 ByteBuf (io.netty.buffer.ByteBuf)2 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Test (org.junit.Test)2 Counter (org.opendaylight.infrautils.metrics.Counter)2 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)2 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)2 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)2 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)2 NetworkTopologyRef (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyRef)2 Updates (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.Updates)2 UpdatesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.UpdatesBuilder)2 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt)2 Pcupd (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcupd)2