Search in sources :

Example 41 with Counters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project netvirt by opendaylight.

the class QosAlertPortData method calculateAlertCondition.

private void calculateAlertCondition(NodeConnectorStatisticsAndPortNumberMap statsData) {
    Uint64 rxDiff = Uint64.valueOf(statsData.getPackets().getReceived().toJava().subtract(rxPackets.toJava()));
    Uint64 rxDroppedDiff = Uint64.valueOf(statsData.getReceiveDrops().toJava().subtract(rxDroppedPackets.toJava()));
    if ((rxDiff.toJava().signum() < 0) || (rxDroppedDiff.toJava().signum() < 0)) {
        LOG.debug("Port {} counters reset", port.getUuid().getValue());
        // counters wrapped. wait for one more poll.
        initPortData();
        return;
    }
    Uint64 rxTotalDiff = Uint64.valueOf(rxDiff.toJava().add(rxDroppedDiff.toJava()));
    LOG.trace("Port {} rxDiff:{} rxDropped diff:{} total diff:{}", port.getUuid().getValue(), rxDiff, rxDroppedDiff, rxTotalDiff);
    QosPolicy qosPolicy = qosNeutronUtils.getQosPolicy(port);
    if (qosPolicy == null) {
        return;
    }
    if (rxDroppedDiff.toJava().multiply(BIG_HUNDRED.toJava()).compareTo(rxTotalDiff.toJava().multiply(alertThreshold.get().toJava())) > 0) {
        LOG.trace(QosConstants.ALERT_MSG_FORMAT, qosPolicy.getName(), qosPolicy.getUuid().getValue(), port.getUuid().getValue(), port.getNetworkId().getValue(), statsData.getPackets().getReceived(), statsData.getReceiveDrops());
        QosAlertGenerator.raiseAlert(qosPolicy.getName(), qosPolicy.getUuid().getValue(), port.getUuid().getValue(), port.getNetworkId().getValue(), statsData.getPackets().getReceived(), statsData.getReceiveDrops());
    }
}
Also used : Uint64(org.opendaylight.yangtools.yang.common.Uint64) QosPolicy(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.qos.rev160613.qos.attributes.qos.policies.QosPolicy)

Example 42 with Counters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project netvirt by opendaylight.

the class CounterRetriever method getSwitchFlowCountersDirect.

public CounterResultDataStructure getSwitchFlowCountersDirect(BigInteger dpId, Match match) {
    NodeRef nodeRef = new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(CountersUtils.getNodeId(dpId)))).build());
    GetFlowStatisticsInputBuilder gfsib = new GetFlowStatisticsInputBuilder();
    gfsib.setNode(nodeRef);
    gfsib.setMatch(match);
    gfsib.setStoreStats(false);
    Future<RpcResult<GetFlowStatisticsOutput>> rpcResultFuture = odlDirectStatsService.getFlowStatistics(gfsib.build());
    RpcResult<GetFlowStatisticsOutput> rpcResult = null;
    try {
        rpcResult = rpcResultFuture.get();
    } catch (InterruptedException | ExecutionException e) {
        statisticsCounters.failedGettingFlowCounters();
        LOG.warn("Unable to retrieve flow counters for match {}", match);
        return null;
    }
    if (rpcResult != null && rpcResult.isSuccessful() && rpcResult.getResult() != null) {
        GetFlowStatisticsOutput flowStatsOutput = rpcResult.getResult();
        return createSwitchFlowResultMapDirect(flowStatsOutput);
    } else {
        statisticsCounters.failedGettingFlowCounters();
        LOG.warn("Unable to retrieve flow counters for match {}", match);
        return null;
    }
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) GetFlowStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInputBuilder) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetFlowStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput) ExecutionException(java.util.concurrent.ExecutionException) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Example 43 with Counters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project netvirt by opendaylight.

the class CounterRetriever method getNodeConnectorCountersDirect.

public CounterResultDataStructure getNodeConnectorCountersDirect(NodeId nodeId, NodeConnectorId nodeConnectorId) {
    GetNodeConnectorStatisticsInput gncsi = getNodeConnectorStatisticsInputBuilder(nodeId, nodeConnectorId);
    Future<RpcResult<GetNodeConnectorStatisticsOutput>> rpcResultFuture = odlDirectStatsService.getNodeConnectorStatistics(gncsi);
    RpcResult<GetNodeConnectorStatisticsOutput> rpcResult = null;
    try {
        rpcResult = rpcResultFuture.get();
    } catch (InterruptedException | ExecutionException e) {
        statisticsCounters.failedGettingNodeConnectorCounters();
        LOG.warn("Unable to retrieve node connector counters for port {}", nodeConnectorId);
        return null;
    }
    if (rpcResult != null && rpcResult.isSuccessful() && rpcResult.getResult() != null) {
        GetNodeConnectorStatisticsOutput nodeConnectorStatsOutput = rpcResult.getResult();
        return createNodeConnectorResultMapDirect(nodeConnectorStatsOutput, nodeConnectorId);
    } else {
        statisticsCounters.failedGettingRpcResultForNodeConnectorCounters();
        LOG.warn("Unable to retrieve node connector counters for port {}", nodeConnectorId);
        return null;
    }
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) GetNodeConnectorStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput) ExecutionException(java.util.concurrent.ExecutionException)

Example 44 with Counters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project netvirt by opendaylight.

the class IngressCountersServiceImpl method bind.

@Override
public void bind(String interfaceId) {
    int instructionKey = 0;
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.INGRESS_COUNTERS_TABLE, ++instructionKey));
    BoundServices serviceInfo = CountersServiceUtils.getBoundServices(String.format("%s.%s", "counters-ingress", interfaceId), CountersServiceUtils.INGRESS_COUNTERS_SERVICE_INDEX, CountersServiceUtils.INGRESS_COUNTERS_DEFAULT_FLOW_PRIORITY, CountersServiceUtils.COOKIE_COUNTERS_BASE, instructions);
    InstanceIdentifier<BoundServices> serviceId = CountersServiceUtils.buildServiceId(interfaceId, CountersServiceUtils.INGRESS_COUNTERS_SERVICE_INDEX, ServiceModeIngress.class);
    MDSALUtil.syncWrite(db, LogicalDatastoreType.CONFIGURATION, serviceId, serviceInfo);
}
Also used : BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) ArrayList(java.util.ArrayList) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Example 45 with Counters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project netvirt by opendaylight.

the class StatisticsImpl method getNodeAggregatedResult.

private boolean getNodeAggregatedResult(List<CounterResult> aggregatedCounters, BigInteger dpId) {
    InstanceIdentifier<Node> nodeInstanceIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(CountersUtils.getNodeId(dpId)))).build();
    Optional<Node> nodeOptional = MDSALUtil.read(db, LogicalDatastoreType.OPERATIONAL, nodeInstanceIdentifier);
    if (!nodeOptional.isPresent()) {
        return false;
    }
    Node node = nodeOptional.get();
    CounterResultDataStructure counters = counterRetriever.getNodeCountersDirect(node);
    if (counters == null || counters.isEmpty()) {
        return false;
    }
    CounterResultDataStructure aggregatedResultsDS = CountersUtils.aggregateCounters(counters, CountersUtils.getNodeId(dpId));
    createCounterResults(aggregatedCounters, aggregatedResultsDS);
    return !aggregatedCounters.isEmpty();
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Aggregations

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)23 ArrayList (java.util.ArrayList)17 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)17 ExecutionException (java.util.concurrent.ExecutionException)13 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 Test (org.junit.Test)11 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)11 Map (java.util.Map)10 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)10 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)10 InOrder (org.mockito.InOrder)9 BigInteger (java.math.BigInteger)8 List (java.util.List)8 CrudCounts (org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts)8 SyncCrudCounters (org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters)8 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)8 Futures (com.google.common.util.concurrent.Futures)7 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)7 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)6