Search in sources :

Example 1 with Stats

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

the class AclLiveStatisticsRpcServiceTest method getStatsTwoPortBothDirection.

/**
 * Test stats for two ports and both direction. <br>
 * port1 is valid <br>
 * port2 is invalid <br>
 * Expectation: Error expected for port2
 *
 * @throws Exception the exception
 */
@Test
public void getStatsTwoPortBothDirection() throws Exception {
    List<String> lstInterfaces = Arrays.asList(PORT_1, PORT_2);
    Direction direction = Direction.Both;
    GetAclPortStatisticsInput input = new GetAclPortStatisticsInputBuilder().setDirection(direction).setInterfaceNames(lstInterfaces).build();
    Future<RpcResult<GetAclPortStatisticsOutput>> rpcResultFuture = aclStatsService.getAclPortStatistics(input);
    RpcResult<GetAclPortStatisticsOutput> output = rpcResultFuture.get();
    LOG.info("getStatsTwoPortBothDirection output = {}", output);
    assertStatsOutput(output, direction);
}
Also used : GetAclPortStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetAclPortStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsInput) Direction(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction) GetAclPortStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsInputBuilder) Test(org.junit.Test)

Example 2 with Stats

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

the class AclLiveStatisticsHelper method getAclPortStats.

/**
 * Gets the acl port stats.
 *
 * @param direction the direction
 * @param interfaceNames the interface names
 * @param odlDirectStatsService the odl direct stats service
 * @param dataBroker the data broker
 * @return the acl port stats
 */
public static List<AclPortStats> getAclPortStats(Direction direction, List<String> interfaceNames, OpendaylightDirectStatisticsService odlDirectStatsService, DataBroker dataBroker) {
    LOG.trace("Get ACL port stats for direction {} and interfaces {}", direction, interfaceNames);
    List<AclPortStats> lstAclPortStats = new ArrayList<>();
    Short tableId = getTableId(direction);
    FlowCookie aclDropFlowCookie = new FlowCookie(AclConstants.COOKIE_ACL_DROP_FLOW);
    FlowCookie aclDropFlowCookieMask = new FlowCookie(COOKIE_ACL_DROP_FLOW_MASK);
    for (String interfaceName : interfaceNames) {
        AclPortStatsBuilder aclStatsBuilder = new AclPortStatsBuilder().setInterfaceName(interfaceName);
        Interface interfaceState = AclServiceUtils.getInterfaceStateFromOperDS(dataBroker, interfaceName);
        if (interfaceState == null) {
            String errMsg = "Interface not found in datastore.";
            addError(lstAclPortStats, aclStatsBuilder, errMsg);
            continue;
        }
        BigInteger dpId = AclServiceUtils.getDpIdFromIterfaceState(interfaceState);
        if (dpId == null) {
            String errMsg = "Failed to find device for the interface.";
            addError(lstAclPortStats, aclStatsBuilder, errMsg);
            continue;
        }
        NodeRef nodeRef = buildNodeRef(dpId);
        Integer lportTag = interfaceState.getIfIndex();
        Match metadataMatch = buildMetadataMatch(lportTag);
        GetFlowStatisticsInputBuilder input = new GetFlowStatisticsInputBuilder().setNode(nodeRef).setCookie(aclDropFlowCookie).setCookieMask(aclDropFlowCookieMask).setMatch(metadataMatch).setStoreStats(false);
        if (direction != Direction.Both) {
            input.setTableId(tableId);
        }
        Future<RpcResult<GetFlowStatisticsOutput>> rpcResultFuture = odlDirectStatsService.getFlowStatistics(input.build());
        RpcResult<GetFlowStatisticsOutput> rpcResult = null;
        try {
            rpcResult = rpcResultFuture.get();
        } catch (InterruptedException | ExecutionException e) {
            String errMsg = "Unable to retrieve drop counts due to error: " + e.getMessage();
            addError(lstAclPortStats, aclStatsBuilder, errMsg);
            LOG.error("Exception occurred during get flow statistics for interface {}", interfaceName, e);
        }
        if (rpcResult != null && rpcResult.isSuccessful() && rpcResult.getResult() != null) {
            GetFlowStatisticsOutput flowStatsOutput = rpcResult.getResult();
            getAclDropStats(direction, aclStatsBuilder, flowStatsOutput);
            lstAclPortStats.add(aclStatsBuilder.build());
        } else {
            handleRpcErrors(lstAclPortStats, aclStatsBuilder, rpcResult);
        }
    }
    return lstAclPortStats;
}
Also used : AclPortStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.AclPortStatsBuilder) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) BigInteger(java.math.BigInteger) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) GetFlowStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInputBuilder) AclPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.AclPortStats) BigInteger(java.math.BigInteger) GetFlowStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput) ExecutionException(java.util.concurrent.ExecutionException) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 3 with Stats

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

the class GroupStatsResponseConvertorTest method testEmptyGroupStats.

/**
 * Test empty GroupStats conversion.
 */
@Test
public void testEmptyGroupStats() {
    List<GroupStats> groupStats = new ArrayList<>();
    Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats>> salGroupStats = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    Assert.assertFalse("Group stats response should be not present", salGroupStats.isPresent());
}
Also used : ArrayList(java.util.ArrayList) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 4 with Stats

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

the class GroupStatsResponseConvertorTest method testSingleGroupStat.

/**
 * Test single GroupStat conversion.
 */
@Test
public void testSingleGroupStat() {
    GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
    statsBuilder.setByteCount(new BigInteger("12345"));
    statsBuilder.setDurationNsec(1000000L);
    statsBuilder.setDurationSec(5000L);
    statsBuilder.setGroupId(new GroupId(42L));
    statsBuilder.setPacketCount(new BigInteger("54321"));
    statsBuilder.setRefCount(24L);
    statsBuilder.setBucketStats(new ArrayList<BucketStats>());
    List<GroupStats> groupStats = new ArrayList<>();
    groupStats.add(statsBuilder.build());
    Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> salGroupStats = salGroupStatsOptional.get();
    Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());
    org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = salGroupStats.get(0);
    Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
    Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
    Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
    Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
}
Also used : ArrayList(java.util.ArrayList) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) BigInteger(java.math.BigInteger) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) ArrayList(java.util.ArrayList) List(java.util.List) BucketStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats) Test(org.junit.Test)

Example 5 with Stats

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

the class LispSouthboundRPC method createGetStatsOutput.

private static GetStatsOutput createGetStatsOutput(ConcurrentLispSouthboundStats stats) {
    long[] rxStats = stats.getRx();
    long[] txStats = stats.getTx();
    ControlMessageStatsBuilder cmsb = new ControlMessageStatsBuilder();
    cmsb.setRxUnknown(stats.getRxUnknown());
    cmsb.setTxErrors(stats.getTxErrors());
    List<ControlMessage> messages = new ArrayList<ControlMessage>();
    for (int i = 0; i <= ConcurrentLispSouthboundStats.MAX_LISP_TYPES; i++) {
        if (MessageType.forValue(i) == null) {
            continue;
        }
        ControlMessageBuilder cmb = new ControlMessageBuilder();
        cmb.setMsgType(MessageType.forValue(i));
        cmb.setRxCount(rxStats[i]);
        cmb.setTxCount(txStats[i]);
        messages.add(cmb.build());
    }
    cmsb.setControlMessage(messages);
    MapRegisterCacheStatsBuilder mrcsb = new MapRegisterCacheStatsBuilder();
    mrcsb.setHits(stats.getCacheHits());
    mrcsb.setMisses(stats.getCacheMisses());
    return new GetStatsOutputBuilder().setControlMessageStats(cmsb.build()).setMapRegisterCacheStats(mrcsb.build()).build();
}
Also used : ControlMessageStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.ControlMessageStatsBuilder) MapRegisterCacheStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.MapRegisterCacheStatsBuilder) ArrayList(java.util.ArrayList) ControlMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ctrl.msg.stats.ControlMessageBuilder) ControlMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ctrl.msg.stats.ControlMessage) GetStatsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.GetStatsOutputBuilder)

Aggregations

ArrayList (java.util.ArrayList)14 Test (org.junit.Test)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 BigInteger (java.math.BigInteger)7 List (java.util.List)7 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 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 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)5 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)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