use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput 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.direct.statistics.rev160511.GetNodeConnectorStatisticsInput in project openflowplugin by opendaylight.
the class NodeConnectorDirectStatisticsServiceTest method testBuildRequestBody.
@Override
public void testBuildRequestBody() throws Exception {
final GetNodeConnectorStatisticsInput input = mock(GetNodeConnectorStatisticsInput.class);
when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
when(input.getNodeConnectorId()).thenReturn(nodeConnectorId);
final MultipartRequestPortStats body = (MultipartRequestPortStats) ((MultipartRequest) service.buildRequest(new Xid(42L), input)).getMultipartRequestBody();
assertEquals(nodeConnectorId, body.getNodeConnectorId());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput in project openflowplugin by opendaylight.
the class NodeConnectorDirectStatisticsServiceTest method testBuildRequestBody.
@Override
public void testBuildRequestBody() throws Exception {
final GetNodeConnectorStatisticsInput input = mock(GetNodeConnectorStatisticsInput.class);
when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
when(input.getNodeConnectorId()).thenReturn(nodeConnectorId);
final MultipartRequestPortStatsCase body = (MultipartRequestPortStatsCase) ((MultipartRequestInput) service.buildRequest(new Xid(42L), input)).getMultipartRequestBody();
final MultipartRequestPortStats nodeConnector = body.getMultipartRequestPortStats();
assertEquals(PORT_NO, nodeConnector.getPortNo());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput 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.direct.statistics.rev160511.GetNodeConnectorStatisticsInput 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