Search in sources :

Example 16 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 getNodeConnectorResult.

private boolean getNodeConnectorResult(List<CounterResult> counters, BigInteger dpId, String portNumber) {
    CounterResultDataStructure counterResultDS = counterRetriever.getNodeConnectorCountersDirect(new NodeId(CountersUtils.getNodeId(dpId)), new NodeConnectorId(CountersUtils.getNodeConnectorId(dpId, portNumber)));
    if (counterResultDS == null) {
        return false;
    }
    CounterResultBuilder crb = new CounterResultBuilder();
    String resultId = CountersUtils.getNodeConnectorId(dpId, portNumber);
    crb.setId(resultId);
    createGroups(counters, counterResultDS, crb, resultId);
    return !counters.isEmpty();
}
Also used : CounterResultBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.CounterResultBuilder) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)

Example 17 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 createGroupsResult.

private Groups createGroupsResult(String groupName, Map<String, BigInteger> countersMap) {
    GroupsBuilder gb = new GroupsBuilder();
    gb.setName(groupName);
    Map<String, Counters> counters = new HashMap<>();
    List<Counters> countersList = new ArrayList<>();
    for (String counterName : countersMap.keySet()) {
        addCountersToMap(countersMap, counters, counterName);
    }
    for (Counters counter : counters.values()) {
        countersList.add(counter);
    }
    gb.setCounters(countersList);
    return gb.build();
}
Also used : HashMap(java.util.HashMap) GroupsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.GroupsBuilder) ArrayList(java.util.ArrayList) Counters(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.result.counterresult.groups.Counters)

Example 18 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 cleanAllElementCounterRequests.

@Override
public ListenableFuture<RpcResult<CleanAllElementCounterRequestsOutput>> cleanAllElementCounterRequests(CleanAllElementCounterRequestsInput input) {
    ReadTransaction 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");
            statisticsCounters.failedReadingCounterDataFromConfig();
            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();
    } finally {
        tx.close();
    }
    return RpcResultBuilder.<CleanAllElementCounterRequestsOutput>success().buildFuture();
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) Optional(java.util.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) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) ExecutionException(java.util.concurrent.ExecutionException) HashSet(java.util.HashSet)

Example 19 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 handleInterfaceRemoval.

@Override
public void handleInterfaceRemoval(String interfaceId) {
    CheckedFuture<Optional<IngressElementCountersRequestConfig>, ReadFailedException> iecrc;
    CheckedFuture<Optional<EgressElementCountersRequestConfig>, ReadFailedException> eecrc;
    try (ReadTransaction 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");
            statisticsCounters.failedReadingCounterDataFromConfig();
            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");
        statisticsCounters.failedGettingCounterResultsPortRemoval();
        return;
    }
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) EgressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.EgressElementCountersRequestConfig) Optional(java.util.Optional) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) IngressElementCountersRequestConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.IngressElementCountersRequestConfig) ExecutionException(java.util.concurrent.ExecutionException)

Example 20 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 EgressCountersServiceImpl method bind.

@Override
public void bind(String interfaceId) {
    int instructionKey = 0;
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.EGRESS_COUNTERS_TABLE, ++instructionKey));
    BoundServices serviceInfo = CountersServiceUtils.getBoundServices(String.format("%s.%s", "counters-egress", interfaceId), CountersServiceUtils.EGRESS_COUNTERS_SERVICE_INDEX, CountersServiceUtils.EGRESS_COUNTERS_DEFAULT_FLOW_PRIORITY, CountersServiceUtils.COOKIE_COUNTERS_BASE, instructions);
    InstanceIdentifier<BoundServices> serviceId = CountersServiceUtils.buildServiceId(interfaceId, CountersServiceUtils.EGRESS_COUNTERS_SERVICE_INDEX, ServiceModeEgress.class);
    MDSALUtil.syncWrite(db, LogicalDatastoreType.CONFIGURATION, serviceId, serviceInfo);
}
Also used : BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) ArrayList(java.util.ArrayList) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

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