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 acquireElementCountersRequestHandler.
@Override
public ListenableFuture<RpcResult<AcquireElementCountersRequestHandlerOutput>> acquireElementCountersRequestHandler(AcquireElementCountersRequestHandlerInput input) {
AcquireElementCountersRequestHandlerOutputBuilder aecrhob = new AcquireElementCountersRequestHandlerOutputBuilder();
UUID randomNumber = UUID.randomUUID();
Integer intRequestKey = allocateId(randomNumber.toString());
if (intRequestKey == null) {
LOG.warn("failed generating unique request identifier");
statisticsCounters.failedGeneratingUniqueRequestId();
return RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed generating unique request identifier").buildFuture();
}
String requestKey = String.valueOf(intRequestKey);
SettableFuture<RpcResult<AcquireElementCountersRequestHandlerOutput>> result = SettableFuture.create();
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(transaction -> {
if (input.getIncomingTraffic() != null) {
Optional<EgressElementCountersRequestConfig> eecrcOpt = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER).get();
if (!eecrcOpt.isPresent()) {
LOG.warn("failed creating incoming traffic counter request data container in DB");
statisticsCounters.failedCreatingEgressCounterDataConfig();
result.setFuture(RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed creating egress counter request data container in DB").buildFuture());
return;
}
if (!isIdenticalCounterRequestExist(input.getPortId(), ElementCountersDirection.EGRESS.toString(), input.getIncomingTraffic().getFilters(), eecrcOpt.get().getCounterRequests())) {
installCounterSpecificRules(input.getPortId(), getLportTag(input.getPortId()), getDpn(input.getPortId()), ElementCountersDirection.EGRESS, input.getIncomingTraffic().getFilters());
}
putEgressElementCounterRequestInConfig(input, ElementCountersDirection.EGRESS, transaction, requestKey, CountersServiceUtils.EECRC_IDENTIFIER, eecrcOpt, randomNumber.toString());
aecrhob.setIncomingTrafficHandler(requestKey);
bindCountersServiceIfUnbound(input.getPortId(), ElementCountersDirection.EGRESS);
}
if (input.getOutgoingTraffic() != null) {
Optional<IngressElementCountersRequestConfig> iecrcOpt = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER).get();
if (!iecrcOpt.isPresent()) {
LOG.warn("failed creating outgoing traffc counter request data container in DB");
statisticsCounters.failedCreatingIngressCounterDataConfig();
result.setFuture(RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed creating ingress counter request data container in DB").buildFuture());
return;
}
if (!isIdenticalCounterRequestExist(input.getPortId(), ElementCountersDirection.INGRESS.toString(), input.getOutgoingTraffic().getFilters(), iecrcOpt.get().getCounterRequests())) {
installCounterSpecificRules(input.getPortId(), getLportTag(input.getPortId()), getDpn(input.getPortId()), ElementCountersDirection.INGRESS, input.getOutgoingTraffic().getFilters());
}
putIngressElementCounterRequestInConfig(input, ElementCountersDirection.INGRESS, transaction, requestKey, CountersServiceUtils.IECRC_IDENTIFIER, iecrcOpt, randomNumber.toString());
aecrhob.setIncomingTrafficHandler(requestKey);
bindCountersServiceIfUnbound(input.getPortId(), ElementCountersDirection.INGRESS);
result.setFuture(RpcResultBuilder.success(aecrhob.build()).buildFuture());
}
}), LOG, "Error acquiring element counters");
return result;
}
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 getNodeResult.
private boolean getNodeResult(List<CounterResult> counters, 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 counterResultDS = counterRetriever.getNodeCountersDirect(node);
if (counterResultDS == null) {
return false;
}
createCounterResults(counters, counterResultDS);
return !counters.isEmpty();
}
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 getNodeAggregatedCounters.
@Override
@SuppressWarnings("checkstyle:illegalCatch")
public ListenableFuture<RpcResult<GetNodeAggregatedCountersOutput>> getNodeAggregatedCounters(GetNodeAggregatedCountersInput input) {
BigInteger dpId = input.getNodeId();
LOG.trace("getting aggregated node counters for node {}", dpId);
GetNodeAggregatedCountersOutputBuilder gnacob = new GetNodeAggregatedCountersOutputBuilder();
List<CounterResult> aggregatedCounterResults = new ArrayList<>();
try {
if (!getNodeAggregatedResult(aggregatedCounterResults, dpId)) {
statisticsCounters.failedGettingAggregatedNodeCounters();
return RpcResultBuilder.<GetNodeAggregatedCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get node aggregated counters for node " + dpId).buildFuture();
}
} catch (Exception e) {
LOG.warn("failed to get counter result for node {}", dpId, e);
return RpcResultBuilder.<GetNodeAggregatedCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get node aggregated counters for node " + dpId).buildFuture();
}
gnacob.setCounterResult(aggregatedCounterResults);
return RpcResultBuilder.success(gnacob.build()).buildFuture();
}
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 createCounterResults.
private void createCounterResults(List<CounterResult> counters, CounterResultDataStructure counterResultDS) {
for (String counterResultId : counterResultDS.getResults().keySet()) {
CounterResultBuilder crb = new CounterResultBuilder();
crb.setId(counterResultId);
createGroups(counters, counterResultDS, crb, counterResultId);
}
}
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 createCounterResults.
private void createCounterResults(List<CounterResult> counters, CounterResultDataStructure counterResultDS, String resultId) {
for (String counterResultId : counterResultDS.getResults().keySet()) {
CounterResultBuilder crb = new CounterResultBuilder();
crb.setId(resultId);
createGroups(counters, counterResultDS, crb, counterResultId);
}
}
Aggregations