Search in sources :

Example 1 with GetNodeConnectorStatisticsInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder in project netvirt by opendaylight.

the class CounterRetriever method getNodeCountersDirect.

public CounterResultDataStructure getNodeCountersDirect(Node node) {
    List<CounterResultDataStructure> countersResults = new ArrayList<>();
    List<CompletableFuture<NodeConnectorStatisticsSupplierOutput>> futureList = new ArrayList<>();
    for (NodeConnector nodeConnector : node.getNodeConnector()) {
        GetNodeConnectorStatisticsInput gncsi = getNodeConnectorStatisticsInputBuilder(node.getId(), nodeConnector.getId());
        futureList.add(CompletableFuture.supplyAsync(new NodeConnectorStatisticsSupplier(odlDirectStatsService, gncsi, nodeConnector.getId())));
    }
    try {
        CompletableFuture<Void> allOf = CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0]));
        allOf.get(nodeResultTimeout, TimeUnit.SECONDS);
        for (int i = 0; i < futureList.size(); i++) {
            CompletableFuture<NodeConnectorStatisticsSupplierOutput> completableCurrentResult = futureList.get(i);
            if (completableCurrentResult == null) {
                LOG.warn("Unable to retrieve node counters");
                counters.failedGettingNodeCounters.inc();
                return null;
            }
            RpcResult<GetNodeConnectorStatisticsOutput> currentResult = completableCurrentResult.get().getNodeConnectorStatisticsOutput();
            if (currentResult != null && currentResult.isSuccessful() && currentResult.getResult() != null) {
                GetNodeConnectorStatisticsOutput nodeConnectorStatsOutput = currentResult.getResult();
                countersResults.add(createNodeConnectorResultMapDirect(nodeConnectorStatsOutput, completableCurrentResult.get().getNodeConnectrId()));
            } else {
                counters.failedGettingNodeCounters.inc();
                LOG.warn("Unable to retrieve node counters");
                return null;
            }
        }
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        counters.failedGettingNodeCounters.inc();
        LOG.warn("Unable to retrieve node counters");
        return null;
    }
    return mergeCountersResults(countersResults);
}
Also used : NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) ArrayList(java.util.ArrayList) CompletableFuture(java.util.concurrent.CompletableFuture) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) GetNodeConnectorStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with GetNodeConnectorStatisticsInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder in project openflowplugin by opendaylight.

the class OpendaylightPortStatisticsServiceImplTest method testGetNodeConnectorStatistics.

@Test
public void testGetNodeConnectorStatistics() throws Exception {
    GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder().setNode(createNodeRef("unitProt:123")).setNodeConnectorId(new NodeConnectorId("unitProt:123:321"));
    rpcResult = buildPortStatisticsReply();
    final Future<RpcResult<GetNodeConnectorStatisticsOutput>> resultFuture = portStatisticsService.getNodeConnectorStatistics(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetNodeConnectorStatisticsOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPPORTSTATS, requestInput.getValue().getType());
}
Also used : GetNodeConnectorStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput) Test(org.junit.Test)

Example 3 with GetNodeConnectorStatisticsInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder in project openflowplugin by opendaylight.

the class PortStatsServiceTest method testBuildRequest.

@Test
public void testBuildRequest() throws Exception {
    Xid xid = new Xid(42L);
    GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder().setNodeConnectorId(new NodeConnectorId("junitProto:11:12")).setNode(createNodeRef("junitProto:11"));
    final OfHeader request = portStatsService.buildRequest(xid, input.build());
    Assert.assertTrue(request instanceof MultipartRequestInput);
    final MultipartRequestInput mpRequest = (MultipartRequestInput) request;
    Assert.assertTrue(mpRequest.getMultipartRequestBody() instanceof MultipartRequestPortStatsCase);
    final MultipartRequestPortStatsCase mpRequestBody = (MultipartRequestPortStatsCase) mpRequest.getMultipartRequestBody();
    Assert.assertEquals(12L, mpRequestBody.getMultipartRequestPortStats().getPortNo().longValue());
}
Also used : GetNodeConnectorStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartRequestPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 4 with GetNodeConnectorStatisticsInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder in project netvirt by opendaylight.

the class CounterRetriever method getNodeConnectorStatisticsInputBuilder.

private GetNodeConnectorStatisticsInput getNodeConnectorStatisticsInputBuilder(NodeId nodeId, NodeConnectorId nodeConnectorId) {
    NodeRef nodeRef = new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(nodeId)).toInstance());
    GetNodeConnectorStatisticsInputBuilder nodeConnectorBuilder = new GetNodeConnectorStatisticsInputBuilder().setNode(nodeRef).setNodeConnectorId(nodeConnectorId);
    GetNodeConnectorStatisticsInput gncsi = nodeConnectorBuilder.build();
    return gncsi;
}
Also used : GetNodeConnectorStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInputBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) GetNodeConnectorStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)

Example 5 with GetNodeConnectorStatisticsInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder 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) {
        counters.failedGettingNodeConnectorCounters.inc();
        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 {
        counters.failedGettingRpcResultForNodeConnectorCounters.inc();
        LOG.warn("Unable to retrieve node connector counters for port {}", nodeConnectorId);
        return null;
    }
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) GetNodeConnectorStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)3 GetNodeConnectorStatisticsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput)3 GetNodeConnectorStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 Test (org.junit.Test)2 GetNodeConnectorStatisticsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInputBuilder)2 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)2 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)2 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)2 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)2 GetNodeConnectorStatisticsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 TimeoutException (java.util.concurrent.TimeoutException)1 Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)1 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)1 NodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)1 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)1