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();
}
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();
}
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();
}
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;
}
}
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);
}
Aggregations