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