use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class FlatBatchMeterAdapters method convertBatchMeterResult.
/**
* Convert meter batch result.
* @param stepOffset offset of current batch plan step
* @return converted {@link ProcessFlatBatchOutput} RPC result
*/
@VisibleForTesting
static <T extends BatchMeterOutputListGrouping> Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>> convertBatchMeterResult(final int stepOffset) {
return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {
@Nullable
@Override
public RpcResult<ProcessFlatBatchOutput> apply(@Nonnull final RpcResult<T> input) {
List<BatchFailure> batchFailures = wrapBatchMeterFailuresForFlat(input, stepOffset);
ProcessFlatBatchOutputBuilder outputBuilder = new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
return RpcResultBuilder.<ProcessFlatBatchOutput>status(input.isSuccessful()).withRpcErrors(input.getErrors()).withResult(outputBuilder.build()).build();
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class SingleLayerMeterService method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final Meter input) throws ServiceException {
final MeterMessageBuilder meterMessageBuilder = new MeterMessageBuilder(input);
final Class<? extends DataContainer> clazz = input.getImplementedInterface();
if (clazz.equals(AddMeterInput.class) || clazz.equals(UpdatedMeter.class)) {
meterMessageBuilder.setCommand(MeterModCommand.OFPMCADD);
} else if (clazz.equals(RemoveMeterInput.class) || clazz.equals(OriginalMeter.class)) {
meterMessageBuilder.setCommand(MeterModCommand.OFPMCDELETE);
}
return meterMessageBuilder.setVersion(getVersion()).setXid(xid.getValue()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class MeterConvertor method getBandsFromSAL.
private static void getBandsFromSAL(MeterBandHeaders meterBandHeaders, List<Bands> bands) {
for (MeterBandHeader meterBandHeader : meterBandHeaders.getMeterBandHeader()) {
// The band types :drop,DSCP_Remark or experimenter.
if (null != meterBandHeader.getMeterBandTypes() && null != meterBandHeader.getMeterBandTypes().getFlags()) {
if (meterBandHeader.getMeterBandTypes().getFlags().isOfpmbtDrop()) {
if (meterBandHeader.getBandType() != null) {
MeterBandDropBuilder meterBandDropBuilder = new MeterBandDropBuilder();
meterBandDropBuilder.setType(MeterBandType.OFPMBTDROP);
Drop drop = (Drop) meterBandHeader.getBandType();
meterBandDropBuilder.setBurstSize(drop.getDropBurstSize());
meterBandDropBuilder.setRate(drop.getDropRate());
MeterBandDropCaseBuilder dropCaseBuilder = new MeterBandDropCaseBuilder();
dropCaseBuilder.setMeterBandDrop(meterBandDropBuilder.build());
MeterBand meterBandItem = dropCaseBuilder.build();
BandsBuilder bandsB = new BandsBuilder();
bandsB.setMeterBand(meterBandItem);
// Bands list
bands.add(bandsB.build());
} else {
logBandTypeMissing(MeterBandType.OFPMBTDROP);
}
} else if (meterBandHeader.getMeterBandTypes().getFlags().isOfpmbtDscpRemark()) {
if (meterBandHeader.getBandType() != null) {
MeterBandDscpRemarkBuilder meterBandDscpRemarkBuilder = new MeterBandDscpRemarkBuilder();
meterBandDscpRemarkBuilder.setType(MeterBandType.OFPMBTDSCPREMARK);
DscpRemark dscpRemark = (DscpRemark) meterBandHeader.getBandType();
meterBandDscpRemarkBuilder.setBurstSize(dscpRemark.getDscpRemarkBurstSize());
meterBandDscpRemarkBuilder.setRate(dscpRemark.getDscpRemarkRate());
meterBandDscpRemarkBuilder.setPrecLevel(dscpRemark.getPrecLevel());
MeterBandDscpRemarkCaseBuilder dscpCaseBuilder = new MeterBandDscpRemarkCaseBuilder();
dscpCaseBuilder.setMeterBandDscpRemark(meterBandDscpRemarkBuilder.build());
MeterBand meterBandItem = dscpCaseBuilder.build();
BandsBuilder bandsB = new BandsBuilder();
bandsB.setMeterBand(meterBandItem);
// Bands list
bands.add(bandsB.build());
} else {
logBandTypeMissing(MeterBandType.OFPMBTDSCPREMARK);
}
} else if (meterBandHeader.getMeterBandTypes().getFlags().isOfpmbtExperimenter()) {
if (meterBandHeader.getBandType() != null) {
MeterBandExperimenterBuilder meterBandExperimenterBuilder = new MeterBandExperimenterBuilder();
meterBandExperimenterBuilder.setType(MeterBandType.OFPMBTEXPERIMENTER);
Experimenter experimenter = (Experimenter) meterBandHeader.getBandType();
meterBandExperimenterBuilder.setBurstSize(experimenter.getExperimenterBurstSize());
meterBandExperimenterBuilder.setRate(experimenter.getExperimenterRate());
ExperimenterIdMeterBandBuilder expBuilder = new ExperimenterIdMeterBandBuilder();
expBuilder.setExperimenter(new ExperimenterId(experimenter.getExperimenter()));
meterBandExperimenterBuilder.addAugmentation(ExperimenterIdMeterBand.class, expBuilder.build());
// TODO - implement / finish experimenter meter band translation
MeterBandExperimenterCaseBuilder experimenterCaseBuilder = new MeterBandExperimenterCaseBuilder();
experimenterCaseBuilder.setMeterBandExperimenter(meterBandExperimenterBuilder.build());
MeterBand meterBandItem = experimenterCaseBuilder.build();
BandsBuilder bandsB = new BandsBuilder();
bandsB.setMeterBand(meterBandItem);
// Bands list
bands.add(bandsB.build());
} else {
logBandTypeMissing(MeterBandType.OFPMBTEXPERIMENTER);
}
}
} else {
LOG.error("Invalid meter band data found.");
}
}
}
Aggregations