Multiple meter support added and meter action added for OF1.5
MeterFeaturesFlag added for OF1.5
Change-Id: I84d2785f37ea51b08244de9c54effe5224af9531
diff --git a/core/api/src/main/java/org/onosproject/net/meter/DefaultMeterFeatures.java b/core/api/src/main/java/org/onosproject/net/meter/DefaultMeterFeatures.java
index 1835872..bd5d998 100644
--- a/core/api/src/main/java/org/onosproject/net/meter/DefaultMeterFeatures.java
+++ b/core/api/src/main/java/org/onosproject/net/meter/DefaultMeterFeatures.java
@@ -16,6 +16,7 @@
package org.onosproject.net.meter;
import com.google.common.base.MoreObjects;
+import com.google.common.collect.Sets;
import org.onosproject.net.DeviceId;
import java.util.HashSet;
@@ -35,11 +36,12 @@
private boolean stats;
private short maxBands;
private short maxColor;
+ private Set<MeterFeaturesFlag> features;
private DefaultMeterFeatures(DeviceId did, long maxMeter,
Set<Band.Type> bandTypes, Set<Meter.Unit> units,
boolean burst, boolean stats,
- short maxBands, short maxColor) {
+ short maxBands, short maxColor, Set<MeterFeaturesFlag> flag) {
this.deviceId = did;
this.maxMeter = maxMeter;
this.bandTypes = bandTypes;
@@ -48,6 +50,7 @@
this.units = units;
this.maxBands = maxBands;
this.maxColor = maxColor;
+ this.features = flag;
}
@Override
@@ -90,6 +93,11 @@
return maxColor;
}
+ @Override
+ public Set<MeterFeaturesFlag> features() {
+ return features;
+ }
+
public static Builder builder() {
return new Builder();
}
@@ -125,6 +133,7 @@
private Set<Meter.Unit> units1 = new HashSet<>();
private boolean burst = false;
private boolean stats = false;
+ private Set<MeterFeaturesFlag> features = Sets.newHashSet();
@Override
public MeterFeatures.Builder forDevice(DeviceId deviceId) {
@@ -175,9 +184,15 @@
}
@Override
+ public MeterFeatures.Builder withFeatures(Set<MeterFeaturesFlag> featureFlags) {
+ features = featureFlags;
+ return this;
+ }
+
+ @Override
public MeterFeatures build() {
checkNotNull(did, "Must specify a device");
- return new DefaultMeterFeatures(did, mmeter, bandTypes, units1, burst, stats, mbands, mcolors);
+ return new DefaultMeterFeatures(did, mmeter, bandTypes, units1, burst, stats, mbands, mcolors, features);
}
}
}
diff --git a/core/api/src/main/java/org/onosproject/net/meter/MeterFeatures.java b/core/api/src/main/java/org/onosproject/net/meter/MeterFeatures.java
index 143e927..2749687 100644
--- a/core/api/src/main/java/org/onosproject/net/meter/MeterFeatures.java
+++ b/core/api/src/main/java/org/onosproject/net/meter/MeterFeatures.java
@@ -81,6 +81,14 @@
short maxColor();
/**
+ * Returns features flags that supported for meter actions by device.
+ *
+ * @return meter features flags
+ * otherwise empty set.
+ */
+ Set<MeterFeaturesFlag> features();
+
+ /**
* A meter features builder.
*/
interface Builder {
@@ -149,6 +157,14 @@
Builder hasStats(boolean hasStats);
/**
+ * Assigns the features for this meter features for OF1.5.
+ *
+ * @param featureFlags if meter features flags are supported
+ * @return this builder
+ */
+ Builder withFeatures(Set<MeterFeaturesFlag> featureFlags);
+
+ /**
* Builds the Meter Features based on the specified parameters.
*
* @return the meter features
diff --git a/core/api/src/main/java/org/onosproject/net/meter/MeterFeaturesFlag.java b/core/api/src/main/java/org/onosproject/net/meter/MeterFeaturesFlag.java
new file mode 100644
index 0000000..36356ef
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/meter/MeterFeaturesFlag.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.meter;
+
+public enum MeterFeaturesFlag {
+ /**
+ * Support meter action in action set.
+ */
+ ACTION_SET,
+ /**
+ * Support any position in action list.
+ */
+ ANY_POSITION,
+ /**
+ * Support multiple actions in action list.
+ */
+ MULTI_LIST
+}