Search in sources :

Example 1 with EgressElementCountersRequestConfig

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig in project netvirt by opendaylight.

the class StatisticsImpl method cleanAllElementCounterRequests.

@Override
public Future<RpcResult<CleanAllElementCounterRequestsOutput>> cleanAllElementCounterRequests(CleanAllElementCounterRequestsInput input) {
    ReadOnlyTransaction tx = db.newReadOnlyTransaction();
    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.<CleanAllElementCounterRequestsOutput>failed().withError(ErrorType.APPLICATION, "Couldn't read element counters config data from DB").buildFuture();
        }
        Set<String> idsToRelease = new HashSet<>();
        if (input.getPortId() != null && !input.getPortId().isEmpty()) {
            idsToRelease.addAll(getAllPortRequestsUniqueIds(input.getPortId(), iecrcOpt.get().getCounterRequests()));
            idsToRelease.addAll(getAllPortRequestsUniqueIds(input.getPortId(), eecrcOpt.get().getCounterRequests()));
            removeAllElementCounterRequestsOnPort(input.getPortId(), iecrcOpt.get().getCounterRequests());
            removeAllElementCounterRequestsOnPort(input.getPortId(), eecrcOpt.get().getCounterRequests());
        } else {
            idsToRelease.addAll(getAllRquestsUniqueIds(iecrcOpt.get().getCounterRequests()));
            idsToRelease.addAll(getAllRquestsUniqueIds(eecrcOpt.get().getCounterRequests()));
            removeAllElementCounterRequests(iecrcOpt.get().getCounterRequests());
            removeAllElementCounterRequests(eecrcOpt.get().getCounterRequests());
        }
        releaseIds(idsToRelease);
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("failed to get counter request data from DB");
        return RpcResultBuilder.<CleanAllElementCounterRequestsOutput>failed().withError(ErrorType.APPLICATION, "failed to get counter request data from DB").buildFuture();
    }
    return RpcResultBuilder.<CleanAllElementCounterRequestsOutput>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) CleanAllElementCounterRequestsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.CleanAllElementCounterRequestsOutput) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) ExecutionException(java.util.concurrent.ExecutionException) HashSet(java.util.HashSet)

Example 2 with EgressElementCountersRequestConfig

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig in project netvirt by opendaylight.

the class StatisticsImpl method putEgressElementCounterRequestInConfig.

private void putEgressElementCounterRequestInConfig(AcquireElementCountersRequestHandlerInput input, ElementCountersDirection direcion, ReadWriteTransaction transaction, String requestKey, InstanceIdentifier<EgressElementCountersRequestConfig> ecrcIdentifier, Optional<EgressElementCountersRequestConfig> eecrcOpt, String generatedUniqueId) {
    EgressElementCountersRequestConfig requestConfig = eecrcOpt.get();
    CounterRequestsBuilder crb = new CounterRequestsBuilder();
    crb.setRequestId(requestKey);
    crb.setKey(new CounterRequestsKey(requestKey));
    crb.setFilters(input.getIncomingTraffic().getFilters());
    crb.setPortId(input.getPortId());
    crb.setLportTag(getLportTag(input.getPortId()));
    crb.setDpn(getDpn(input.getPortId()));
    crb.setTrafficDirection(direcion.toString());
    crb.setGeneratedUniqueId(generatedUniqueId);
    List<CounterRequests> counterRequests = requestConfig.getCounterRequests();
    counterRequests.add(crb.build());
    EgressElementCountersRequestConfigBuilder ecrcb = new EgressElementCountersRequestConfigBuilder();
    ecrcb.setCounterRequests(counterRequests);
    requestConfig = ecrcb.build();
    transaction.put(LogicalDatastoreType.CONFIGURATION, ecrcIdentifier, requestConfig, WriteTransaction.CREATE_MISSING_PARENTS);
}
Also used : EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) EgressElementCountersRequestConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfigBuilder) CounterRequestsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequestsKey) CounterRequestsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequestsBuilder) CounterRequests(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequests)

Example 3 with EgressElementCountersRequestConfig

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig in project netvirt by opendaylight.

the class StatisticsImpl method creatEgressEelementCountersContainerInConfig.

private void creatEgressEelementCountersContainerInConfig(ReadWriteTransaction transaction, InstanceIdentifier<EgressElementCountersRequestConfig> ecrcIdentifier) {
    EgressElementCountersRequestConfigBuilder eecrcb = new EgressElementCountersRequestConfigBuilder();
    List<CounterRequests> counterRequests = new ArrayList<>();
    eecrcb.setCounterRequests(counterRequests);
    EgressElementCountersRequestConfig eecrc = eecrcb.build();
    transaction.put(LogicalDatastoreType.CONFIGURATION, ecrcIdentifier, eecrc, WriteTransaction.CREATE_MISSING_PARENTS);
}
Also used : EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) EgressElementCountersRequestConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfigBuilder) ArrayList(java.util.ArrayList) CounterRequests(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequests)

Example 4 with EgressElementCountersRequestConfig

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig in project netvirt by opendaylight.

the class StatisticsImpl method handleInterfaceRemoval.

@Override
public void handleInterfaceRemoval(String interfaceId) {
    CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc;
    CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc;
    try (ReadOnlyTransaction tx = db.newReadOnlyTransaction()) {
        iecrc = tx.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
        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;
        }
        removeAllElementCounterRequestsOnPort(interfaceId, iecrcOpt.get().getCounterRequests());
        removeAllElementCounterRequestsOnPort(interfaceId, eecrcOpt.get().getCounterRequests());
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("failed to get counter request data from DB");
        StatisticsPluginImplCounters.failed_getting_counter_results_port_removal.inc();
        return;
    }
}
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) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) ExecutionException(java.util.concurrent.ExecutionException)

Example 5 with EgressElementCountersRequestConfig

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig in project netvirt by opendaylight.

the class StatisticsImpl method initializeCountrsConfigDataSrore.

private void initializeCountrsConfigDataSrore() {
    ReadWriteTransaction transaction = db.newReadWriteTransaction();
    CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER);
    CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER);
    try {
        Optional<IngressElementCountersRequestConfig> iecrcOpt = iecrc.get();
        if (!iecrcOpt.isPresent()) {
            creatIngressEelementCountersContainerInConfig(transaction, CountersServiceUtils.IECRC_IDENTIFIER);
        }
        Optional<EgressElementCountersRequestConfig> eecrcOpt = eecrc.get();
        if (!eecrcOpt.isPresent()) {
            creatEgressEelementCountersContainerInConfig(transaction, CountersServiceUtils.EECRC_IDENTIFIER);
        }
        transaction.submit();
    } catch (InterruptedException | ExecutionException e) {
        StatisticsPluginImplCounters.failed_creating_counters_config.inc();
        LOG.warn("failed creating counters config data structure in DB");
    }
}
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) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

EgressElementCountersRequestConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig)7 Optional (com.google.common.base.Optional)5 ExecutionException (java.util.concurrent.ExecutionException)5 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 IngressElementCountersRequestConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.IngressElementCountersRequestConfig)5 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)3 CounterRequests (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequests)3 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)2 EgressElementCountersRequestConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfigBuilder)2 CounterRequestsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequestsKey)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 AcquireElementCountersRequestHandlerOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.AcquireElementCountersRequestHandlerOutput)1 AcquireElementCountersRequestHandlerOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.AcquireElementCountersRequestHandlerOutputBuilder)1 CleanAllElementCounterRequestsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.CleanAllElementCounterRequestsOutput)1 ReleaseElementCountersRequestHandlerOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.ReleaseElementCountersRequestHandlerOutput)1 CounterRequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.counterrequestsconfig.CounterRequestsBuilder)1