use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput in project openflowplugin by opendaylight.
the class SalMetersBatchServiceImpl method updateMetersBatch.
@Override
public Future<RpcResult<UpdateMetersBatchOutput>> updateMetersBatch(final UpdateMetersBatchInput input) {
final List<BatchUpdateMeters> batchUpdateMeters = input.getBatchUpdateMeters();
LOG.trace("Updating meters @ {} : {}", PathUtil.extractNodeId(input.getNode()), batchUpdateMeters.size());
final ArrayList<ListenableFuture<RpcResult<UpdateMeterOutput>>> resultsLot = new ArrayList<>();
for (BatchUpdateMeters batchMeter : batchUpdateMeters) {
final UpdateMeterInput updateMeterInput = new UpdateMeterInputBuilder(input).setOriginalMeter(new OriginalMeterBuilder(batchMeter.getOriginalBatchedMeter()).build()).setUpdatedMeter(new UpdatedMeterBuilder(batchMeter.getUpdatedBatchedMeter()).build()).setMeterRef(createMeterRef(input.getNode(), batchMeter)).setNode(input.getNode()).build();
resultsLot.add(JdkFutureAdapters.listenInPoolThread(salMeterService.updateMeter(updateMeterInput)));
}
final Iterable<Meter> meters = batchUpdateMeters.stream().map(BatchMeterInputUpdateGrouping::getUpdatedBatchedMeter).collect(Collectors.toList());
final ListenableFuture<RpcResult<List<BatchFailedMetersOutput>>> commonResult = Futures.transform(Futures.allAsList(resultsLot), MeterUtil.<UpdateMeterOutput>createCumulativeFunction(meters, batchUpdateMeters.size()), MoreExecutors.directExecutor());
ListenableFuture<RpcResult<UpdateMetersBatchOutput>> updateMetersBulkFuture = Futures.transform(commonResult, MeterUtil.METER_UPDATE_TRANSFORM, MoreExecutors.directExecutor());
if (input.isBarrierAfter()) {
updateMetersBulkFuture = BarrierUtil.chainBarrier(updateMetersBulkFuture, input.getNode(), transactionService, MeterUtil.METER_UPDATE_COMPOSING_TRANSFORM);
}
return updateMetersBulkFuture;
}
Aggregations