use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.AcquireElementCountersRequestHandlerInput 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.withKey(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.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, ecrcIdentifier, requestConfig);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.AcquireElementCountersRequestHandlerInput in project netvirt by opendaylight.
the class StatisticsImpl method acquireElementCountersRequestHandler.
@Override
public ListenableFuture<RpcResult<AcquireElementCountersRequestHandlerOutput>> acquireElementCountersRequestHandler(AcquireElementCountersRequestHandlerInput input) {
AcquireElementCountersRequestHandlerOutputBuilder aecrhob = new AcquireElementCountersRequestHandlerOutputBuilder();
UUID randomNumber = UUID.randomUUID();
Integer intRequestKey = allocateId(randomNumber.toString());
if (intRequestKey == null) {
LOG.warn("failed generating unique request identifier");
statisticsCounters.failedGeneratingUniqueRequestId();
return RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed generating unique request identifier").buildFuture();
}
String requestKey = String.valueOf(intRequestKey);
SettableFuture<RpcResult<AcquireElementCountersRequestHandlerOutput>> result = SettableFuture.create();
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(transaction -> {
if (input.getIncomingTraffic() != null) {
Optional<EgressElementCountersRequestConfig> eecrcOpt = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.EECRC_IDENTIFIER).get();
if (!eecrcOpt.isPresent()) {
LOG.warn("failed creating incoming traffic counter request data container in DB");
statisticsCounters.failedCreatingEgressCounterDataConfig();
result.setFuture(RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed creating egress counter request data container in DB").buildFuture());
return;
}
if (!isIdenticalCounterRequestExist(input.getPortId(), ElementCountersDirection.EGRESS.toString(), input.getIncomingTraffic().getFilters(), eecrcOpt.get().getCounterRequests())) {
installCounterSpecificRules(input.getPortId(), getLportTag(input.getPortId()), getDpn(input.getPortId()), ElementCountersDirection.EGRESS, input.getIncomingTraffic().getFilters());
}
putEgressElementCounterRequestInConfig(input, ElementCountersDirection.EGRESS, transaction, requestKey, CountersServiceUtils.EECRC_IDENTIFIER, eecrcOpt, randomNumber.toString());
aecrhob.setIncomingTrafficHandler(requestKey);
bindCountersServiceIfUnbound(input.getPortId(), ElementCountersDirection.EGRESS);
}
if (input.getOutgoingTraffic() != null) {
Optional<IngressElementCountersRequestConfig> iecrcOpt = transaction.read(LogicalDatastoreType.CONFIGURATION, CountersServiceUtils.IECRC_IDENTIFIER).get();
if (!iecrcOpt.isPresent()) {
LOG.warn("failed creating outgoing traffc counter request data container in DB");
statisticsCounters.failedCreatingIngressCounterDataConfig();
result.setFuture(RpcResultBuilder.<AcquireElementCountersRequestHandlerOutput>failed().withError(ErrorType.APPLICATION, "failed creating ingress counter request data container in DB").buildFuture());
return;
}
if (!isIdenticalCounterRequestExist(input.getPortId(), ElementCountersDirection.INGRESS.toString(), input.getOutgoingTraffic().getFilters(), iecrcOpt.get().getCounterRequests())) {
installCounterSpecificRules(input.getPortId(), getLportTag(input.getPortId()), getDpn(input.getPortId()), ElementCountersDirection.INGRESS, input.getOutgoingTraffic().getFilters());
}
putIngressElementCounterRequestInConfig(input, ElementCountersDirection.INGRESS, transaction, requestKey, CountersServiceUtils.IECRC_IDENTIFIER, iecrcOpt, randomNumber.toString());
aecrhob.setIncomingTrafficHandler(requestKey);
bindCountersServiceIfUnbound(input.getPortId(), ElementCountersDirection.INGRESS);
result.setFuture(RpcResultBuilder.success(aecrhob.build()).buildFuture());
}
}), LOG, "Error acquiring element counters");
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.AcquireElementCountersRequestHandlerInput in project netvirt by opendaylight.
the class StatisticsImpl method putIngressElementCounterRequestInConfig.
private void putIngressElementCounterRequestInConfig(AcquireElementCountersRequestHandlerInput input, ElementCountersDirection direcion, ReadWriteTransaction transaction, String requestKey, InstanceIdentifier<IngressElementCountersRequestConfig> ecrcIdentifier, Optional<IngressElementCountersRequestConfig> iecrcOpt, String generatedUniqueId) {
IngressElementCountersRequestConfig requestConfig = iecrcOpt.get();
CounterRequestsBuilder crb = new CounterRequestsBuilder();
crb.setRequestId(requestKey);
crb.withKey(new CounterRequestsKey(requestKey));
crb.setFilters(input.getOutgoingTraffic().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());
IngressElementCountersRequestConfigBuilder ecrcb = new IngressElementCountersRequestConfigBuilder();
ecrcb.setCounterRequests(counterRequests);
requestConfig = ecrcb.build();
transaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, ecrcIdentifier, requestConfig);
}
Aggregations