-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import java.util.ArrayList;
+import com.google.common.collect.ImmutableSet;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.services.ServiceException;
+import org.opendaylight.openflowplugin.impl.services.util.RequestInputUtils;
import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
final class MeterFeaturesService
extends AbstractCompatibleStatService<GetMeterFeaturesInput, GetMeterFeaturesOutput, MeterFeaturesUpdated> {
- private static final MultipartRequestMeterFeaturesCase METER_FEATURES_CASE = new MultipartRequestMeterFeaturesCaseBuilder().build();
+ private static final MultipartRequestMeterFeaturesCase METER_FEATURES_CASE =
+ new MultipartRequestMeterFeaturesCaseBuilder().build();
- public MeterFeaturesService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ MeterFeaturesService(final RequestContextStack requestContextStack,
+ final DeviceContext deviceContext,
+ final AtomicLong compatibilityXidSeed) {
super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
- protected OfHeader buildRequest(final Xid xid, final GetMeterFeaturesInput input) throws ServiceException {
+ protected OfHeader buildRequest(final Xid xid, final GetMeterFeaturesInput input) {
MultipartRequestInputBuilder mprInput =
RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETERFEATURES, xid.getValue(), getVersion());
mprInput.setMultipartRequestBody(METER_FEATURES_CASE);
}
@Override
- public GetMeterFeaturesOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ public GetMeterFeaturesOutput buildTxCapableResult(final TransactionId emulatedTxId) {
return new GetMeterFeaturesOutputBuilder().setTransactionId(emulatedTxId).build();
}
@Override
- public MeterFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ public MeterFeaturesUpdated transformToNotification(final List<MultipartReply> result,
+ final TransactionId emulatedTxId) {
final int mpSize = result.size();
- Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
+ Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: %s", mpSize);
MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
notification.setId(getDeviceInfo().getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
- MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
+ MultipartReplyMeterFeaturesCase caseBody =
+ (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
notification.setMaxBands(replyBody.getMaxBands());
notification.setMaxColor(replyBody.getMaxColor());
}
@VisibleForTesting
- protected List<Class<? extends MeterBand>> extractSupportedMeterBand(MultipartReplyMeterFeatures replyBody, MeterBandTypeBitmap bandTypes) {
- List<Class<? extends MeterBand>> supportedMeterBand = new ArrayList<>();
- if (bandTypes.isOFPMBTDROP()) {
- supportedMeterBand.add(MeterBandDrop.class);
+ protected static Set<MeterBand> extractSupportedMeterBand(
+ final MultipartReplyMeterFeatures replyBody, final MeterBandTypeBitmap bandTypes) {
+ final var supportedMeterBand = ImmutableSet.<MeterBand>builder();
+ if (bandTypes.getOFPMBTDROP()) {
+ supportedMeterBand.add(MeterBandDrop.VALUE);
}
- if (replyBody.getBandTypes().isOFPMBTDSCPREMARK()) {
- supportedMeterBand.add(MeterBandDscpRemark.class);
+ if (replyBody.getBandTypes().getOFPMBTDSCPREMARK()) {
+ supportedMeterBand.add(MeterBandDscpRemark.VALUE);
}
- return supportedMeterBand;
+ return supportedMeterBand.build();
}
@VisibleForTesting
- protected static List<Class<? extends MeterCapability>> extractMeterCapabilities(MeterFlags capabilities) {
- List<Class<? extends MeterCapability>> supportedCapabilities = new ArrayList<>();
-
- if (capabilities.isOFPMFBURST()) {
- supportedCapabilities.add(MeterBurst.class);
+ protected static Set<MeterCapability> extractMeterCapabilities(final MeterFlags capabilities) {
+ final var supportedCapabilities = ImmutableSet.<MeterCapability>builder();
+ if (capabilities.getOFPMFBURST()) {
+ supportedCapabilities.add(MeterBurst.VALUE);
}
- if (capabilities.isOFPMFKBPS()) {
- supportedCapabilities.add(MeterKbps.class);
+ if (capabilities.getOFPMFKBPS()) {
+ supportedCapabilities.add(MeterKbps.VALUE);
}
- if (capabilities.isOFPMFPKTPS()) {
- supportedCapabilities.add(MeterPktps.class);
+ if (capabilities.getOFPMFPKTPS()) {
+ supportedCapabilities.add(MeterPktps.VALUE);
}
- if (capabilities.isOFPMFSTATS()) {
- supportedCapabilities.add(MeterStats.class);
+ if (capabilities.getOFPMFSTATS()) {
+ supportedCapabilities.add(MeterStats.VALUE);
}
- return supportedCapabilities;
+ return supportedCapabilities.build();
}
}