Search in sources :

Example 6 with UpdateMeterInput

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;
}
Also used : BatchUpdateMeters(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.update.meters.batch.input.BatchUpdateMeters) UpdateMeterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder) UpdateMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BatchFailedMetersOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput) OriginalMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeterBuilder) UpdatedMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder)

Aggregations

UpdateMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput)6 Test (org.junit.Test)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 InOrder (org.mockito.InOrder)2 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)2 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder)2 UpdateMeterInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder)2 UpdateMeterOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput)2 UpdateMeterOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder)2 OriginalMeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeterBuilder)2 UpdatedMeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder)2 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)2 UpdateMetersBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchInput)2 UpdateMetersBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchInputBuilder)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)1 MeterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey)1 StaleMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter)1