Search in sources :

Example 1 with GetNodeConnectorCountersOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeConnectorCountersOutputBuilder 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();
}
Also used : ArrayList(java.util.ArrayList) GetNodeConnectorCountersOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeConnectorCountersOutput) BigInteger(java.math.BigInteger) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) CounterResult(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult) GetNodeConnectorCountersOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.GetNodeConnectorCountersOutputBuilder)

Aggregations

BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)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 CounterResult (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResult)1