Search in sources :

Example 21 with Counters

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);
    }
}
Also used : IntextIpMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.IntextIpMap) IpMappingKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.IpMappingKey) IpMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.IpMapping) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) IpMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.ip.mapping.IpMap) IntextIpMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.IntextIpMap)

Example 22 with Counters

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);
}
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) CompletableFuture(java.util.concurrent.CompletableFuture) Future(java.util.concurrent.Future) GetNodeConnectorStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsInput) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 23 with Counters

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());
}
Also used : StopStressTestOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.StopStressTestOutput) StopStressTestOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.StopStressTestOutputBuilder)

Example 24 with Counters

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();
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) Optional(com.google.common.base.Optional) IngressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.IngressElementCountersRequestConfig) CounterRequestsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequestsKey) CounterRequests(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequests) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) ExecutionException(java.util.concurrent.ExecutionException) ReleaseElementCountersRequestHandlerOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.ReleaseElementCountersRequestHandlerOutput)

Example 25 with Counters

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);
    }
}
Also used : IntextIpMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.IntextIpMap) IpMappingKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.IpMappingKey) IpMapping(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.IpMapping) IpMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.ip.mapping.IpMap) IntextIpMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.IntextIpMap)

Aggregations

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)23 ArrayList (java.util.ArrayList)17 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)17 ExecutionException (java.util.concurrent.ExecutionException)13 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 Test (org.junit.Test)11 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)11 Map (java.util.Map)10 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)10 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)10 InOrder (org.mockito.InOrder)9 BigInteger (java.math.BigInteger)8 List (java.util.List)8 CrudCounts (org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts)8 SyncCrudCounters (org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters)8 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)8 Futures (com.google.common.util.concurrent.Futures)7 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)7 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)6