Search in sources :

Example 1 with BatchRemoveMeters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMeters in project openflowplugin by opendaylight.

the class SalMetersBatchServiceImpl method removeMetersBatch.

@Override
public Future<RpcResult<RemoveMetersBatchOutput>> removeMetersBatch(final RemoveMetersBatchInput input) {
    LOG.trace("Removing meters @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchRemoveMeters().size());
    final ArrayList<ListenableFuture<RpcResult<RemoveMeterOutput>>> resultsLot = new ArrayList<>();
    for (BatchRemoveMeters addMeter : input.getBatchRemoveMeters()) {
        final RemoveMeterInput removeMeterInput = new RemoveMeterInputBuilder(addMeter).setMeterRef(createMeterRef(input.getNode(), addMeter)).setNode(input.getNode()).build();
        resultsLot.add(JdkFutureAdapters.listenInPoolThread(salMeterService.removeMeter(removeMeterInput)));
    }
    final ListenableFuture<RpcResult<List<BatchFailedMetersOutput>>> commonResult = Futures.transform(Futures.allAsList(resultsLot), MeterUtil.<RemoveMeterOutput>createCumulativeFunction(input.getBatchRemoveMeters()), MoreExecutors.directExecutor());
    ListenableFuture<RpcResult<RemoveMetersBatchOutput>> removeMetersBulkFuture = Futures.transform(commonResult, MeterUtil.METER_REMOVE_TRANSFORM, MoreExecutors.directExecutor());
    if (input.isBarrierAfter()) {
        removeMetersBulkFuture = BarrierUtil.chainBarrier(removeMetersBulkFuture, input.getNode(), transactionService, MeterUtil.METER_REMOVE_COMPOSING_TRANSFORM);
    }
    return removeMetersBulkFuture;
}
Also used : BatchRemoveMeters(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMeters) RemoveMeterOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RemoveMeterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder) BatchFailedMetersOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput) RemoveMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput)

Example 2 with BatchRemoveMeters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMeters in project openflowplugin by opendaylight.

the class FlatBatchMeterAdapters method adaptFlatBatchRemoveMeter.

/**
 * Adapt flat batch remove 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#removeMetersBatch(RemoveMetersBatchInput)}
 */
public static RemoveMetersBatchInput adaptFlatBatchRemoveMeter(final BatchPlanStep planStep, final NodeRef node) {
    final List<BatchRemoveMeters> batchMeters = new ArrayList<>();
    for (FlatBatchRemoveMeter batchRemoveMeter : planStep.<FlatBatchRemoveMeter>getTaskBag()) {
        final BatchRemoveMeters removeMeters = new BatchRemoveMetersBuilder(batchRemoveMeter).setMeterId(batchRemoveMeter.getMeterId()).build();
        batchMeters.add(removeMeters);
    }
    return new RemoveMetersBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchRemoveMeters(batchMeters).build();
}
Also used : BatchRemoveMeters(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMeters) ArrayList(java.util.ArrayList) BatchRemoveMetersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMetersBuilder) RemoveMetersBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInputBuilder) FlatBatchRemoveMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeter)

Aggregations

ArrayList (java.util.ArrayList)2 BatchRemoveMeters (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMeters)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 FlatBatchRemoveMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeter)1 RemoveMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput)1 RemoveMeterInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder)1 RemoveMeterOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput)1 RemoveMetersBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInputBuilder)1 BatchFailedMetersOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput)1 BatchRemoveMetersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMetersBuilder)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1