Search in sources :

Example 1 with GetNodeConnectorStatisticsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput 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 GetNodeConnectorStatisticsOutput

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

the class NodeConnectorDirectStatisticsServiceTest method testStoreStatistics.

@Override
public void testStoreStatistics() throws Exception {
    final NodeConnectorStatisticsAndPortNumberMap stat = mock(NodeConnectorStatisticsAndPortNumberMap.class);
    when(stat.getNodeConnectorId()).thenReturn(nodeConnectorId);
    final List<NodeConnectorStatisticsAndPortNumberMap> stats = Collections.singletonList(stat);
    final GetNodeConnectorStatisticsOutput output = mock(GetNodeConnectorStatisticsOutput.class);
    when(output.getNodeConnectorStatisticsAndPortNumberMap()).thenReturn(stats);
    multipartWriterProvider.lookup(MultipartType.OFPMPPORTSTATS).get().write(output, true);
    verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
Also used : GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)

Example 3 with GetNodeConnectorStatisticsOutput

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

the class NodeConnectorDirectStatisticsServiceTest method testBuildReply.

@Override
public void testBuildReply() throws Exception {
    final NodeConnectorStatisticsAndPortNumberMap portStat = new NodeConnectorStatisticsAndPortNumberMapBuilder().setNodeConnectorId(nodeConnectorId).build();
    final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyPortStatsBuilder().setNodeConnectorStatisticsAndPortNumberMap(Collections.singletonList(portStat)).build()).build();
    final List<MultipartReply> input = Collections.singletonList(reply);
    final GetNodeConnectorStatisticsOutput output = service.buildReply(input, true);
    assertTrue(output.getNodeConnectorStatisticsAndPortNumberMap().size() > 0);
    final NodeConnectorStatisticsAndPortNumberMap stats = output.getNodeConnectorStatisticsAndPortNumberMap().get(0);
    assertEquals(stats.getNodeConnectorId(), nodeConnectorId);
}
Also used : NodeConnectorStatisticsAndPortNumberMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder) MultipartReplyPortStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)

Example 4 with GetNodeConnectorStatisticsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput 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 5 with GetNodeConnectorStatisticsOutput

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

the class NodeConnectorDirectStatisticsServiceTest method testStoreStatistics.

@Override
public void testStoreStatistics() throws Exception {
    final NodeConnectorStatisticsAndPortNumberMap stat = mock(NodeConnectorStatisticsAndPortNumberMap.class);
    when(stat.getNodeConnectorId()).thenReturn(nodeConnectorId);
    final List<NodeConnectorStatisticsAndPortNumberMap> stats = Collections.singletonList(stat);
    final GetNodeConnectorStatisticsOutput output = mock(GetNodeConnectorStatisticsOutput.class);
    when(output.getNodeConnectorStatisticsAndPortNumberMap()).thenReturn(stats);
    multipartWriterProvider.lookup(MultipartType.OFPMPPORTSTATS).get().write(output, true);
    verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
Also used : GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)

Aggregations

GetNodeConnectorStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput)8 NodeConnectorStatisticsAndPortNumberMap (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)8 ExecutionException (java.util.concurrent.ExecutionException)3 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 GetNodeConnectorStatisticsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput)2 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)2 MultipartReplyPortStatsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase)2 MultipartReplyPortStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats)2 PortStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats)2 NodeConnectorStatisticsAndPortNumberMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder)2 BigInteger (java.math.BigInteger)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 TimeoutException (java.util.concurrent.TimeoutException)1 Counter (org.opendaylight.infrautils.metrics.Counter)1 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)1