Search in sources :

Example 51 with Stats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.

the class OpendaylightFlowTableStatisticsServiceImpl method buildRequest.

@Override
protected OfHeader buildRequest(final Xid xid, final GetFlowTablesStatisticsInput input) throws ServiceException {
    // Create multipart request body for fetch all the group stats
    final MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
    final MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
    multipartRequestTableBuilder.setEmpty(true);
    multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
    // Set request body to main multipart request
    final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(MultipartType.OFPMPTABLE, xid.getValue(), getVersion());
    mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
    return mprInput.build();
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder) MultipartRequestTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder)

Example 52 with Stats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.

the class TestFlowHelper method createFlowAndStatisticsMapListBuilder.

/**
 * Creates flow and statistics builder.
 * @param index data seed
 * @return flow stats builder with dummy content
 */
protected static FlowAndStatisticsMapListBuilder createFlowAndStatisticsMapListBuilder(int index) {
    FlowAndStatisticsMapListBuilder flowAndStatisticsMapListBuilder = new FlowAndStatisticsMapListBuilder();
    flowAndStatisticsMapListBuilder.setPriority(index);
    flowAndStatisticsMapListBuilder.setTableId((short) index);
    flowAndStatisticsMapListBuilder.setCookie(new FlowCookie(BigInteger.TEN));
    EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
    EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
    MacAddress macAddress = new MacAddress("00:00:00:00:00:0" + index);
    ethernetSourceBuilder.setAddress(macAddress);
    ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
    EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
    ethernetDestinationBuilder.setAddress(new MacAddress("00:00:00:0" + index + ":00:00"));
    ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
    MatchBuilder matchBuilder = new MatchBuilder();
    matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
    flowAndStatisticsMapListBuilder.setMatch(matchBuilder.build());
    return flowAndStatisticsMapListBuilder;
}
Also used : FlowAndStatisticsMapListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder) EthernetDestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) EthernetSourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 53 with Stats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project lispflowmapping by opendaylight.

the class LispSouthboundRpcTest method getStatsTest.

/**
 * Tests {@link LispSouthboundRPC#getStats} method.
 */
@Test
public void getStatsTest() throws ExecutionException, InterruptedException {
    final ConcurrentLispSouthboundStats stats = new ConcurrentLispSouthboundStats();
    incrementAll(stats);
    Mockito.when(lispSouthboundPlugin.getStats()).thenReturn(stats);
    // result
    final ControlMessageStats resultStats = lispSouthboundRPC.getStats().get().getResult().getControlMessageStats();
    assertEquals(stats.getRx()[0], (long) resultStats.getControlMessage().get(0).getRxCount());
    assertEquals(stats.getRx()[1], (long) resultStats.getControlMessage().get(1).getRxCount());
    assertEquals(stats.getRx()[2], (long) resultStats.getControlMessage().get(2).getRxCount());
    assertEquals(stats.getRx()[3], (long) resultStats.getControlMessage().get(3).getRxCount());
    assertEquals(stats.getRx()[4], (long) resultStats.getControlMessage().get(4).getRxCount());
    assertEquals(stats.getRx()[6], (long) resultStats.getControlMessage().get(5).getRxCount());
    assertEquals(stats.getRx()[7], (long) resultStats.getControlMessage().get(6).getRxCount());
    assertEquals(stats.getRx()[8], (long) resultStats.getControlMessage().get(7).getRxCount());
}
Also used : ControlMessageStats(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.ControlMessageStats) Test(org.junit.Test)

Example 54 with Stats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project netvirt by opendaylight.

the class QosAlertManager method pollDirectStatisticsForAllNodes.

private void pollDirectStatisticsForAllNodes() {
    LOG.trace("Polling direct statistics from nodes");
    for (Entry<Uint64, ConcurrentMap<String, QosAlertPortData>> entry : qosAlertDpnPortNumberMap.entrySet()) {
        Uint64 dpn = entry.getKey();
        LOG.trace("Polling DPN ID {}", dpn);
        GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder().setNode(new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(IfmConstants.OF_URI_PREFIX + dpn))).build())).setStoreStats(false);
        Future<RpcResult<GetNodeConnectorStatisticsOutput>> rpcResultFuture = odlDirectStatisticsService.getNodeConnectorStatistics(input.build());
        RpcResult<GetNodeConnectorStatisticsOutput> rpcResult = null;
        try {
            rpcResult = rpcResultFuture.get();
        } catch (InterruptedException | ExecutionException e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Could not get Direct-Statistics for node {} Exception occurred ", dpn, e);
            } else {
                LOG.info("Could not get Direct-Statistics for node {}", dpn);
            }
        }
        if (rpcResult != null && rpcResult.isSuccessful() && rpcResult.getResult() != null) {
            GetNodeConnectorStatisticsOutput nodeConnectorStatisticsOutput = rpcResult.getResult();
            Map<NodeConnectorStatisticsAndPortNumberMapKey, NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsAndPortNumberMap = nodeConnectorStatisticsOutput.nonnullNodeConnectorStatisticsAndPortNumberMap();
            ConcurrentMap<String, QosAlertPortData> portDataMap = entry.getValue();
            for (NodeConnectorStatisticsAndPortNumberMap stats : nodeConnectorStatisticsAndPortNumberMap.values()) {
                QosAlertPortData portData = portDataMap.get(stats.getNodeConnectorId().getValue());
                if (portData != null) {
                    portData.updatePortStatistics(stats);
                }
            }
        } else {
            LOG.info("Direct-Statistics not available for node {}", dpn);
        }
    }
}
Also used : GetNodeConnectorStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInputBuilder) ConcurrentMap(java.util.concurrent.ConcurrentMap) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) NodeConnectorStatisticsAndPortNumberMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) ExecutionException(java.util.concurrent.ExecutionException) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Uint64(org.opendaylight.yangtools.yang.common.Uint64) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)

Example 55 with Stats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project netvirt by opendaylight.

the class AclLiveStatisticsHelper method getAclDropStats.

/**
 * Gets the acl drop stats.
 *
 * @param direction the direction
 * @param aclStatsBuilder the acl stats builder
 * @param flowStatsOutput the flow stats output
 */
private static void getAclDropStats(Direction direction, AclPortStatsBuilder aclStatsBuilder, GetFlowStatisticsOutput flowStatsOutput) {
    List<FlowAndStatisticsMapList> flowAndStatisticsMapList = flowStatsOutput.getFlowAndStatisticsMapList();
    if (flowAndStatisticsMapList == null || flowAndStatisticsMapList.isEmpty()) {
        String errMsg = "Unable to retrieve drop counts as interface is not configured for statistics collection.";
        aclStatsBuilder.setError(new ErrorBuilder().setErrorMessage(errMsg).build());
        return;
    }
    BytesBuilder portEgressBytesBuilder = new BytesBuilder();
    BytesBuilder portIngressBytesBuilder = new BytesBuilder();
    PacketsBuilder portEgressPacketsBuilder = new PacketsBuilder();
    PacketsBuilder portIngressPacketsBuilder = new PacketsBuilder();
    for (FlowAndStatisticsMapList flowStats : flowAndStatisticsMapList) {
        switch(flowStats.getTableId().toJava()) {
            case NwConstants.INGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE:
                if (AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY.equals(flowStats.getPriority().toJava())) {
                    portEgressBytesBuilder.setInvalidDropCount(flowStats.getByteCount().getValue());
                    portEgressPacketsBuilder.setInvalidDropCount(flowStats.getPacketCount().getValue());
                } else if (AclConstants.ACL_PORT_SPECIFIC_DROP_PRIORITY.equals(flowStats.getPriority().toJava()) || AclConstants.ACE_LAST_REMOTE_ACL_PRIORITY.equals(flowStats.getPriority().toJava())) {
                    BigInteger portEgressBytesBuilderDropCount = BigInteger.valueOf(0);
                    BigInteger portEgressPacketsBuilderDropCount = BigInteger.valueOf(0);
                    if (portEgressBytesBuilder.getDropCount() != null) {
                        portEgressBytesBuilderDropCount = portEgressBytesBuilder.getDropCount().toJava().add(flowStats.getByteCount().getValue().toJava());
                        portEgressPacketsBuilderDropCount = portEgressPacketsBuilder.getDropCount().toJava().add(flowStats.getPacketCount().getValue().toJava());
                    } else {
                        portEgressBytesBuilderDropCount = flowStats.getByteCount().getValue().toJava();
                        portEgressPacketsBuilderDropCount = flowStats.getPacketCount().getValue().toJava();
                    }
                    portEgressBytesBuilder.setDropCount(portEgressBytesBuilderDropCount);
                    portEgressPacketsBuilder.setDropCount(portEgressPacketsBuilderDropCount);
                }
                // TODO: Update stats for other drops
                break;
            case NwConstants.EGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE:
                if (AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY.equals(flowStats.getPriority().toJava())) {
                    portIngressBytesBuilder.setInvalidDropCount(flowStats.getByteCount().getValue());
                    portIngressPacketsBuilder.setInvalidDropCount(flowStats.getPacketCount().getValue());
                } else if (AclConstants.ACL_PORT_SPECIFIC_DROP_PRIORITY.equals(flowStats.getPriority().toJava()) || AclConstants.ACE_LAST_REMOTE_ACL_PRIORITY.equals(flowStats.getPriority().toJava())) {
                    BigInteger portIngressBytesBuilderDropCount = BigInteger.valueOf(0);
                    BigInteger portIngressPacketsBuilderDropCount = BigInteger.valueOf(0);
                    if (portIngressBytesBuilder.getDropCount() != null) {
                        portIngressBytesBuilderDropCount = portIngressBytesBuilder.getDropCount().toJava().add(flowStats.getByteCount().getValue().toJava());
                        portIngressPacketsBuilderDropCount = portIngressPacketsBuilder.getDropCount().toJava().add(flowStats.getPacketCount().getValue().toJava());
                    } else {
                        portIngressBytesBuilderDropCount = flowStats.getByteCount().getValue().toJava();
                        portIngressPacketsBuilderDropCount = flowStats.getPacketCount().getValue().toJava();
                    }
                    portIngressBytesBuilder.setDropCount(portIngressBytesBuilderDropCount);
                    portIngressPacketsBuilder.setDropCount(portIngressPacketsBuilderDropCount);
                }
                // TODO: Update stats for other drops
                break;
            case NwConstants.INGRESS_ACL_COMMITTER_TABLE:
                if (AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY.equals(flowStats.getPriority().toJava())) {
                    portEgressBytesBuilder.setAntiSpoofDropCount(flowStats.getByteCount().getValue());
                    portEgressPacketsBuilder.setAntiSpoofDropCount(flowStats.getPacketCount().getValue());
                }
                break;
            case NwConstants.EGRESS_ACL_COMMITTER_TABLE:
                if (AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY.equals(flowStats.getPriority().toJava())) {
                    portIngressBytesBuilder.setAntiSpoofDropCount(flowStats.getByteCount().getValue());
                    portIngressPacketsBuilder.setAntiSpoofDropCount(flowStats.getPacketCount().getValue());
                }
                break;
            default:
                LOG.warn("Invalid table ID filtered for Acl flow stats: {}", flowStats);
                break;
        }
    }
    List<AclDropStats> lstAclDropStats = new ArrayList<>();
    if (direction == Direction.Egress || direction == Direction.Both) {
        updateTotalDropCount(portEgressBytesBuilder, portEgressPacketsBuilder);
        AclDropStats aclEgressDropStats = new AclDropStatsBuilder().setDirection(Direction.Egress).setBytes(portEgressBytesBuilder.build()).setPackets(portEgressPacketsBuilder.build()).build();
        lstAclDropStats.add(aclEgressDropStats);
    }
    if (direction == Direction.Ingress || direction == Direction.Both) {
        updateTotalDropCount(portIngressBytesBuilder, portIngressPacketsBuilder);
        AclDropStats aclIngressDropStats = new AclDropStatsBuilder().setDirection(Direction.Ingress).setBytes(portIngressBytesBuilder.build()).setPackets(portIngressPacketsBuilder.build()).build();
        lstAclDropStats.add(aclIngressDropStats);
    }
    aclStatsBuilder.setAclDropStats(lstAclDropStats);
}
Also used : AclDropStats(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.AclDropStats) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) PacketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.acl.drop.stats.PacketsBuilder) AclDropStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.AclDropStatsBuilder) ErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.ErrorBuilder) BytesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.acl.drop.stats.BytesBuilder)

Aggregations

Test (org.junit.Test)15 ArrayList (java.util.ArrayList)14 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)11 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)10 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)10 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)10 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)10 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)10 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)9 List (java.util.List)8 BigInteger (java.math.BigInteger)6 GroupStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 GetFlowStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput)5 GetNodeConnectorStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput)5 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)5 GetGroupStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput)4 GetMeterStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput)4 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)4 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)4