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);
}
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());
}
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);
}
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());
}
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());
}
Aggregations