Search in sources :

Example 6 with CounterResult

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult 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);
    }
}
Also used : CounterResultBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResultBuilder)

Example 7 with CounterResult

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

the class StatisticsImpl method getNodeAggregatedCounters.

@Override
@SuppressWarnings("checkstyle:illegalCatch")
public Future<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)) {
            StatisticsPluginImplCounters.failed_getting_aggregated_node_counters.inc();
            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();
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) GetNodeAggregatedCountersOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeAggregatedCountersOutputBuilder) CounterResult(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) GetNodeAggregatedCountersOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeAggregatedCountersOutput)

Example 8 with CounterResult

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult 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();
}
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)

Example 9 with CounterResult

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult 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);
    }
}
Also used : CounterResultBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResultBuilder)

Aggregations

ArrayList (java.util.ArrayList)4 CounterResult (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult)4 BigInteger (java.math.BigInteger)3 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)3 CounterResultBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResultBuilder)3 ExecutionException (java.util.concurrent.ExecutionException)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)2 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)2 Optional (com.google.common.base.Optional)1 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)1 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)1 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)1 GetElementCountersByHandlerOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetElementCountersByHandlerOutput)1 GetElementCountersByHandlerOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetElementCountersByHandlerOutputBuilder)1 GetNodeAggregatedCountersOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeAggregatedCountersOutput)1 GetNodeAggregatedCountersOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeAggregatedCountersOutputBuilder)1 GetNodeConnectorCountersOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeConnectorCountersOutput)1 GetNodeConnectorCountersOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeConnectorCountersOutputBuilder)1 GetNodeCountersOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeCountersOutput)1