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());
}
}
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;
}
}
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;
}
}
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);
}
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();
}
Aggregations