use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project netvirt by opendaylight.
the class NaptManager method removeIpMappingForRouterID.
private void removeIpMappingForRouterID(Uint32 segmentId) {
InstanceIdentifierBuilder<IpMapping> idBuilder = InstanceIdentifier.builder(IntextIpMap.class).child(IpMapping.class, new IpMappingKey(segmentId));
InstanceIdentifier<IpMapping> id = idBuilder.build();
// Get all externalIps and decrement their counters before deleting the ipmap
Optional<IpMapping> ipMapping = Optional.empty();
try {
ipMapping = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
} catch (ExecutionException | InterruptedException e) {
LOG.error("removeIpMappingForRouterID: Exception while reading IpMapping DS for the segmentId {} ", segmentId, e);
}
if (ipMapping.isPresent()) {
for (IpMap ipMap : ipMapping.get().nonnullIpMap().values()) {
String externalIp = ipMap.getExternalIp();
LOG.debug("removeIpMappingForRouterID : externalIP is {}", externalIp);
if (externalIp != null) {
updateCounter(segmentId, externalIp, false);
}
}
// remove from ipmap DS
LOG.debug("removeIpMappingForRouterID : Removing Ipmap for router {} from datastore", segmentId);
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters 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(() -> {
Future<RpcResult<GetNodeConnectorStatisticsOutput>> rpcResultFuture = odlDirectStatsService.getNodeConnectorStatistics(gncsi);
try {
return new NodeConnectorStatisticsSupplierOutput(rpcResultFuture.get(), nodeConnector.getId());
} catch (InterruptedException | ExecutionException e) {
statisticsCounters.failedGettingNodeConnectorCounters();
return null;
}
}));
}
try {
CompletableFuture<Void> allOf = CompletableFuture.allOf(futureList.toArray(new CompletableFuture[0]));
allOf.get(nodeResultTimeout, TimeUnit.SECONDS);
for (CompletableFuture<NodeConnectorStatisticsSupplierOutput> completableCurrentResult : futureList) {
if (completableCurrentResult == null) {
LOG.warn("Unable to retrieve node counters");
statisticsCounters.failedGettingNodeCounters();
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 {
statisticsCounters.failedGettingNodeCounters();
LOG.warn("Unable to retrieve node counters");
return null;
}
}
} catch (InterruptedException | ExecutionException | TimeoutException e) {
statisticsCounters.failedGettingNodeCounters();
LOG.warn("Unable to retrieve node counters");
return null;
}
return mergeCountersResults(countersResults);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project controller by opendaylight.
the class CarProvider method stopStressTest.
@Override
public Future<RpcResult<StopStressTestOutput>> stopStressTest() {
stopThread();
StopStressTestOutputBuilder stopStressTestOutput;
stopStressTestOutput = new StopStressTestOutputBuilder().setSuccessCount(succcessCounter.longValue()).setFailureCount(failureCounter.longValue());
final StopStressTestOutput result = stopStressTestOutput.build();
LOG_PURCHASE_CAR.info("Executed Stop Stress test; No. of cars created {}; " + "No. of cars failed {}; ", succcessCounter, failureCounter);
// clear counters
succcessCounter.set(0);
failureCounter.set(0);
return Futures.immediateFuture(RpcResultBuilder.<StopStressTestOutput>success(result).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project netvirt by opendaylight.
the class StatisticsImpl method releaseElementCountersRequestHandler.
@Override
public Future<RpcResult<ReleaseElementCountersRequestHandlerOutput>> releaseElementCountersRequestHandler(ReleaseElementCountersRequestHandlerInput input) {
InstanceIdentifier<CounterRequests> ingressPath = InstanceIdentifier.builder(IngressElementCountersRequestConfig.class).child(CounterRequests.class, new CounterRequestsKey(input.getHandler())).build();
InstanceIdentifier<CounterRequests> egressPath = InstanceIdentifier.builder(EgressElementCountersRequestConfig.class).child(CounterRequests.class, new CounterRequestsKey(input.getHandler())).build();
ReadWriteTransaction tx = db.newReadWriteTransaction();
CheckedFuture<Optional<CounterRequests>, ReadFailedException> ingressRequestData = tx.read(LogicalDatastoreType.CONFIGURATION, ingressPath);
CheckedFuture<Optional<CounterRequests>, ReadFailedException> egressRequestData = tx.read(LogicalDatastoreType.CONFIGURATION, egressPath);
CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc = tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc = tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
try {
Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
if (!iecrcOpt.isPresent() || !eecrcOpt.isPresent()) {
LOG.warn("Couldn't read element counters config data from DB");
StatisticsPluginImplCounters.failed_reading_counter_data_from_config.inc();
return RpcResultBuilder.<ReleaseElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "Couldn't read element counters config data from DB").buildFuture();
}
if (!ingressRequestData.get().isPresent() && !egressRequestData.get().isPresent()) {
LOG.warn("Handler does not exists");
StatisticsPluginImplCounters.unknown_request_handler.inc();
return RpcResultBuilder.<ReleaseElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "Handler does not exists").buildFuture();
}
String generatedKey = null;
if (ingressRequestData.get().isPresent()) {
handleReleaseTransaction(input, ingressPath, ingressRequestData, iecrcOpt.get().getCounterRequests());
generatedKey = ingressRequestData.get().get().getGeneratedUniqueId();
}
if (egressRequestData.get().isPresent()) {
handleReleaseTransaction(input, egressPath, egressRequestData, eecrcOpt.get().getCounterRequests());
generatedKey = egressRequestData.get().get().getGeneratedUniqueId();
}
releaseId(generatedKey);
} catch (InterruptedException | ExecutionException e) {
LOG.warn("failed to get counter request data from DB");
return RpcResultBuilder.<ReleaseElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed to get counter request data from DB").buildFuture();
}
return RpcResultBuilder.<ReleaseElementCountersRequestHandlerOutput>success().buildFuture();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters in project netvirt by opendaylight.
the class NaptManager method removeIpMappingForRouterID.
private void removeIpMappingForRouterID(long segmentId) {
InstanceIdentifierBuilder<IpMapping> idBuilder = InstanceIdentifier.builder(IntextIpMap.class).child(IpMapping.class, new IpMappingKey(segmentId));
InstanceIdentifier<IpMapping> id = idBuilder.build();
// Get all externalIps and decrement their counters before deleting the ipmap
String externalIp = null;
Optional<IpMapping> ipMapping = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
if (ipMapping.isPresent()) {
List<IpMap> ipMaps = ipMapping.get().getIpMap();
for (IpMap ipMap : ipMaps) {
externalIp = ipMap.getExternalIp();
LOG.debug("removeIpMappingForRouterID : externalIP is {}", externalIp);
if (externalIp != null) {
updateCounter(segmentId, externalIp, false);
}
}
// remove from ipmap DS
LOG.debug("removeIpMappingForRouterID : Removing Ipmap for router {} from datastore", segmentId);
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
}
}
Aggregations