use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult in project netvirt by opendaylight.
the class StatisticsImpl method getNodeConnectorResult.
private boolean getNodeConnectorResult(List<CounterResult> counters, BigInteger dpId, String portNumber) {
CounterResultDataStructure counterResultDS = counterRetriever.getNodeConnectorCountersDirect(new NodeId(CountersUtils.getNodeId(dpId)), new NodeConnectorId(CountersUtils.getNodeConnectorId(dpId, portNumber)));
if (counterResultDS == null) {
return false;
}
CounterResultBuilder crb = new CounterResultBuilder();
String resultId = CountersUtils.getNodeConnectorId(dpId, portNumber);
crb.setId(resultId);
createGroups(counters, counterResultDS, crb, resultId);
return !counters.isEmpty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult in project netvirt by opendaylight.
the class StatisticsImpl method getNodeCounters.
@Override
@SuppressWarnings("checkstyle:illegalCatch")
public Future<RpcResult<GetNodeCountersOutput>> getNodeCounters(GetNodeCountersInput input) {
BigInteger dpId = input.getNodeId();
LOG.trace("getting node counters for node {}", dpId);
GetNodeCountersOutputBuilder gncob = new GetNodeCountersOutputBuilder();
List<CounterResult> counterResults = new ArrayList<>();
try {
if (!getNodeResult(counterResults, dpId)) {
StatisticsPluginImplCounters.failed_getting_node_counters.inc();
return RpcResultBuilder.<GetNodeCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get node counters for node: " + dpId).buildFuture();
}
} catch (RuntimeException e) {
LOG.warn("failed to get counter result for node {}", dpId, e);
return RpcResultBuilder.<GetNodeCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get node counters for node: " + dpId).buildFuture();
}
gncob.setCounterResult(counterResults);
return RpcResultBuilder.success(gncob.build()).buildFuture();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult in project netvirt by opendaylight.
the class StatisticsImpl method getNodeConnectorCounters.
@Override
@SuppressWarnings("checkstyle:illegalCatch")
public Future<RpcResult<GetNodeConnectorCountersOutput>> getNodeConnectorCounters(GetNodeConnectorCountersInput input) {
String portId = input.getPortId();
LOG.trace("getting port counters of port {}", portId);
Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(db, portId);
if (interfaceState == null) {
LOG.warn("trying to get counters for non exist port {}", portId);
return RpcResultBuilder.<GetNodeConnectorCountersOutput>failed().buildFuture();
}
BigInteger dpId = InterfaceUtils.getDpIdFromInterface(interfaceState);
if (interfaceState.getLowerLayerIf() == null || interfaceState.getLowerLayerIf().isEmpty()) {
LOG.warn("Lower layer if wasn't found for port {}", portId);
return RpcResultBuilder.<GetNodeConnectorCountersOutput>failed().buildFuture();
}
String portNumber = interfaceState.getLowerLayerIf().get(0);
portNumber = portNumber.split(":")[2];
List<CounterResult> counterResults = new ArrayList<>();
try {
if (!getNodeConnectorResult(counterResults, dpId, portNumber)) {
StatisticsPluginImplCounters.failed_getting_node_connector_counters.inc();
return RpcResultBuilder.<GetNodeConnectorCountersOutput>failed().withError(ErrorType.APPLICATION, "failed to get port counters").buildFuture();
}
} catch (RuntimeException e) {
LOG.warn("failed to get counter result for port {}", portId, e);
}
GetNodeConnectorCountersOutputBuilder gpcob = new GetNodeConnectorCountersOutputBuilder();
gpcob.setCounterResult(counterResults);
return RpcResultBuilder.success(gpcob.build()).buildFuture();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult in project netvirt by opendaylight.
the class StatisticsImpl method getElementCountersByHandler.
@Override
public Future<RpcResult<GetElementCountersByHandlerOutput>> getElementCountersByHandler(GetElementCountersByHandlerInput input) {
InstanceIdentifier<CounterRequests> ingressPath = InstanceIdentifier.builder(IngressElementCountersRequestConfig.class).child(CounterRequests.class, new CounterRequestsKey(input.getHandler())).build();
InstanceIdentifier<CounterRequests> egressPath = InstanceIdentifier.builder(EgressElementCountersRequestConfig.class).child(CounterRequests.class, new CounterRequestsKey(input.getHandler())).build();
ReadOnlyTransaction tx = db.newReadOnlyTransaction();
CheckedFuture<Optional<CounterRequests>, ReadFailedException> ingressRequestData = tx.read(LogicalDatastoreType.CONFIGURATION, ingressPath);
CheckedFuture<Optional<CounterRequests>, ReadFailedException> egressRequestData = tx.read(LogicalDatastoreType.CONFIGURATION, egressPath);
List<CounterResult> counters = new ArrayList<>();
try {
if (!ingressRequestData.get().isPresent() && !egressRequestData.get().isPresent()) {
LOG.warn("Handler does not exists");
return RpcResultBuilder.<GetElementCountersByHandlerOutput>failed().withError(ErrorType.APPLICATION, "Handler does not exists").buildFuture();
}
if (ingressRequestData.get().isPresent()) {
CounterRequests ingressCounterRequest = ingressRequestData.get().get();
CounterResultDataStructure ingressCounterResultDS = createElementCountersResult(ingressCounterRequest);
if (ingressCounterResultDS == null) {
LOG.warn("Unable to get counter results");
StatisticsPluginImplCounters.failed_getting_counter_results.inc();
return RpcResultBuilder.<GetElementCountersByHandlerOutput>failed().withError(ErrorType.APPLICATION, "Unable to get counter results").buildFuture();
}
createCounterResults(counters, ingressCounterResultDS, CountersServiceUtils.INGRESS_COUNTER_RESULT_ID);
}
if (egressRequestData.get().isPresent()) {
CounterRequests egressCounterRequest = egressRequestData.get().get();
CounterResultDataStructure egressCounterResultDS = createElementCountersResult(egressCounterRequest);
if (egressCounterResultDS == null) {
LOG.warn("Unable to get counter results");
StatisticsPluginImplCounters.failed_getting_counter_results.inc();
return RpcResultBuilder.<GetElementCountersByHandlerOutput>failed().withError(ErrorType.APPLICATION, "Unable to get counter results").buildFuture();
}
createCounterResults(counters, egressCounterResultDS, CountersServiceUtils.EGRESS_COUNTER_RESULT_ID);
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("failed to get counter request data from DB");
return RpcResultBuilder.<GetElementCountersByHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed to get counter request data from DB").buildFuture();
}
GetElementCountersByHandlerOutputBuilder gecbhob = new GetElementCountersByHandlerOutputBuilder();
gecbhob.setCounterResult(counters);
return RpcResultBuilder.success(gecbhob.build()).buildFuture();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult 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