Search in sources :

Example 21 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 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 22 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 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)

Example 23 with Stats

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

the class TopologyStatsProviderImpl method updateStats.

@SuppressWarnings("checkstyle:IllegalCatch")
public synchronized void updateStats() {
    final TransactionChain chain = accessChain();
    if (chain == null) {
        // Already closed, do not bother
        return;
    }
    final WriteTransaction tx = chain.newWriteOnlyTransaction();
    try {
        for (Entry<KeyedInstanceIdentifier<Node, NodeKey>, PcepSessionState> entry : statsMap.entrySet()) {
            if (!statsPendingDelete.contains(entry.getKey())) {
                tx.put(LogicalDatastoreType.OPERATIONAL, entry.getKey().augmentation(PcepTopologyNodeStatsAug.class), new PcepTopologyNodeStatsAugBuilder().setPcepSessionState(new PcepSessionStateBuilder(entry.getValue()).build()).build());
            }
        }
    } catch (Exception e) {
        LOG.warn("Failed to prepare Tx for PCEP stats update", e);
        tx.cancel();
        return;
    }
    tx.commit().addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.debug("Successfully committed Topology stats update");
        }

        @Override
        public void onFailure(final Throwable ex) {
            LOG.error("Failed to commit Topology stats update", ex);
        }
    }, MoreExecutors.directExecutor());
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) PcepSessionState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.PcepSessionState) TransactionChain(org.opendaylight.mdsal.binding.api.TransactionChain) ExecutionException(java.util.concurrent.ExecutionException) PcepTopologyNodeStatsAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAugBuilder) PcepTopologyNodeStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAug) PcepSessionStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionStateBuilder) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 24 with Stats

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

the class TopologyStatsProviderImpl method unbind.

@Override
public synchronized void unbind(final KeyedInstanceIdentifier<Node, NodeKey> nodeId) {
    final TransactionChain chain = accessChain();
    if (chain == null) {
        // Already closed, do not bother
        LOG.debug("Ignoring unbind of Pcep Node {}", nodeId);
        return;
    }
    final PcepSessionState node = statsMap.remove(nodeId);
    if (node == null) {
        LOG.debug("Ignoring duplicate unbind of Pcep Node {}", nodeId);
        return;
    }
    statsPendingDelete.add(nodeId);
    final WriteTransaction wTx = chain.newWriteOnlyTransaction();
    wTx.delete(LogicalDatastoreType.OPERATIONAL, nodeId);
    wTx.commit().addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.debug("Successfully removed Pcep Node stats {}.", nodeId.getKey().getNodeId());
            statsPendingDelete.remove(nodeId);
        }

        @Override
        public void onFailure(final Throwable ex) {
            LOG.warn("Failed to remove Pcep Node stats {}.", nodeId.getKey().getNodeId(), ex);
            statsPendingDelete.remove(nodeId);
        }
    }, MoreExecutors.directExecutor());
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) PcepSessionState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.PcepSessionState) TransactionChain(org.opendaylight.mdsal.binding.api.TransactionChain) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 25 with Stats

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

the class TopologyStatsRpcServiceImpl method transformStatefulAugmentation.

/*
     * Replace stateful topology augmentations with ones for rpc in PCEP session
     * stats data
     */
private static PcepSessionState transformStatefulAugmentation(final PcepSessionState pcepSessionState) {
    if (pcepSessionState == null) {
        return null;
    }
    final PcepSessionStateBuilder sb = new PcepSessionStateBuilder(pcepSessionState);
    final Messages topoMessage = pcepSessionState.getMessages();
    if (topoMessage != null) {
        final StatefulMessagesStatsAug messageStatsAug = topoMessage.augmentation(StatefulMessagesStatsAug.class);
        if (messageStatsAug != null) {
            sb.setMessages(new MessagesBuilder(topoMessage).removeAugmentation(StatefulMessagesStatsAug.class).addAugmentation(new StatefulMessagesRpcAugBuilder().setLastReceivedRptMsgTimestamp(messageStatsAug.getLastReceivedRptMsgTimestamp()).setReceivedRptMsgCount(messageStatsAug.getReceivedRptMsgCount()).setSentInitMsgCount(messageStatsAug.getSentInitMsgCount()).setSentUpdMsgCount(messageStatsAug.getSentUpdMsgCount()).build()).build());
        }
    }
    final PeerCapabilities topoPeerCapability = pcepSessionState.getPeerCapabilities();
    if (topoPeerCapability != null) {
        final StatefulCapabilitiesStatsAug capabilityStatsAug = topoPeerCapability.augmentation(StatefulCapabilitiesStatsAug.class);
        if (capabilityStatsAug != null) {
            sb.setPeerCapabilities(new PeerCapabilitiesBuilder(topoPeerCapability).removeAugmentation(StatefulCapabilitiesStatsAug.class).addAugmentation(new StatefulCapabilitiesRpcAugBuilder().setActive(capabilityStatsAug.getActive()).setInstantiation(capabilityStatsAug.getInstantiation()).setStateful(capabilityStatsAug.getStateful()).build()).build());
        }
    }
    final LocalPref topoLocalPref = pcepSessionState.getLocalPref();
    if (topoLocalPref != null) {
        final PcepEntityIdStatsAug entityStatsAug = topoLocalPref.augmentation(PcepEntityIdStatsAug.class);
        if (entityStatsAug != null) {
            sb.setLocalPref(new LocalPrefBuilder(topoLocalPref).removeAugmentation(PcepEntityIdStatsAug.class).addAugmentation(new PcepEntityIdRpcAugBuilder().setSpeakerEntityIdValue(entityStatsAug.getSpeakerEntityIdValue()).build()).build());
        }
    }
    return sb.build();
}
Also used : LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPrefBuilder) StatefulCapabilitiesStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.StatefulCapabilitiesStatsAug) Messages(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages) PcepEntityIdRpcAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.PcepEntityIdRpcAugBuilder) StatefulCapabilitiesRpcAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.StatefulCapabilitiesRpcAugBuilder) MessagesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.MessagesBuilder) PcepEntityIdStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.PcepEntityIdStatsAug) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref) PcepSessionStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionStateBuilder) StatefulMessagesRpcAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.StatefulMessagesRpcAugBuilder) PeerCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerCapabilities) PeerCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerCapabilitiesBuilder) StatefulMessagesStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.StatefulMessagesStatsAug)

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