use of org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.add.meters.batch.input.BatchAddMeters in project openflowplugin by opendaylight.
the class SalMetersBatchServiceImpl method addMetersBatch.
@Override
public Future<RpcResult<AddMetersBatchOutput>> addMetersBatch(final AddMetersBatchInput input) {
LOG.trace("Adding meters @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchAddMeters().size());
final ArrayList<ListenableFuture<RpcResult<AddMeterOutput>>> resultsLot = new ArrayList<>();
for (BatchAddMeters addMeter : input.getBatchAddMeters()) {
final AddMeterInput addMeterInput = new AddMeterInputBuilder(addMeter).setMeterRef(createMeterRef(input.getNode(), addMeter)).setNode(input.getNode()).build();
resultsLot.add(JdkFutureAdapters.listenInPoolThread(salMeterService.addMeter(addMeterInput)));
}
final ListenableFuture<RpcResult<List<BatchFailedMetersOutput>>> commonResult = Futures.transform(Futures.allAsList(resultsLot), MeterUtil.<AddMeterOutput>createCumulativeFunction(input.getBatchAddMeters()), MoreExecutors.directExecutor());
ListenableFuture<RpcResult<AddMetersBatchOutput>> addMetersBulkFuture = Futures.transform(commonResult, MeterUtil.METER_ADD_TRANSFORM, MoreExecutors.directExecutor());
if (input.isBarrierAfter()) {
addMetersBulkFuture = BarrierUtil.chainBarrier(addMetersBulkFuture, input.getNode(), transactionService, MeterUtil.METER_ADD_COMPOSING_TRANSFORM);
}
return addMetersBulkFuture;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.add.meters.batch.input.BatchAddMeters in project openflowplugin by opendaylight.
the class FlatBatchMeterAdapters method adaptFlatBatchAddMeter.
/**
* Adapt flat batch add meter.
* @param planStep batch step containing changes of the same type
* @param node pointer for RPC routing
* @return input suitable for {@link org.opendaylight.yang.gen.v1.urn
* .opendaylight.meters.service.rev160316.SalMetersBatchService#addMetersBatch(AddMetersBatchInput)}
*/
public static AddMetersBatchInput adaptFlatBatchAddMeter(final BatchPlanStep planStep, final NodeRef node) {
final List<BatchAddMeters> batchMeters = new ArrayList<>();
for (FlatBatchAddMeter batchAddMeter : planStep.<FlatBatchAddMeter>getTaskBag()) {
final BatchAddMeters addMeters = new BatchAddMetersBuilder(batchAddMeter).setMeterId(batchAddMeter.getMeterId()).build();
batchMeters.add(addMeters);
}
return new AddMetersBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchAddMeters(batchMeters).build();
}
Aggregations