Committed by
Gerrit Code Review
added treatment support and conversion to an instruction
moved to meter api to onos-api Change-Id: I0504f06fdc503953fa7696224d97edda43596d6e
Showing
35 changed files
with
177 additions
and
65 deletions
... | @@ -28,6 +28,7 @@ import org.onosproject.net.IndexedLambda; | ... | @@ -28,6 +28,7 @@ import org.onosproject.net.IndexedLambda; |
28 | import org.onosproject.net.PortNumber; | 28 | import org.onosproject.net.PortNumber; |
29 | import org.onosproject.net.flow.instructions.Instruction; | 29 | import org.onosproject.net.flow.instructions.Instruction; |
30 | import org.onosproject.net.flow.instructions.Instructions; | 30 | import org.onosproject.net.flow.instructions.Instructions; |
31 | +import org.onosproject.net.meter.MeterId; | ||
31 | 32 | ||
32 | import java.util.Collections; | 33 | import java.util.Collections; |
33 | import java.util.List; | 34 | import java.util.List; |
... | @@ -50,6 +51,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -50,6 +51,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
50 | 51 | ||
51 | private static final DefaultTrafficTreatment EMPTY | 52 | private static final DefaultTrafficTreatment EMPTY |
52 | = new DefaultTrafficTreatment(Collections.emptyList()); | 53 | = new DefaultTrafficTreatment(Collections.emptyList()); |
54 | + private final Instructions.MeterInstruction meter; | ||
53 | 55 | ||
54 | /** | 56 | /** |
55 | * Creates a new traffic treatment from the specified list of instructions. | 57 | * Creates a new traffic treatment from the specified list of instructions. |
... | @@ -63,6 +65,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -63,6 +65,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
63 | this.hasClear = false; | 65 | this.hasClear = false; |
64 | this.table = null; | 66 | this.table = null; |
65 | this.meta = null; | 67 | this.meta = null; |
68 | + this.meter = null; | ||
66 | } | 69 | } |
67 | 70 | ||
68 | /** | 71 | /** |
... | @@ -77,7 +80,8 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -77,7 +80,8 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
77 | List<Instruction> immediate, | 80 | List<Instruction> immediate, |
78 | Instructions.TableTypeTransition table, | 81 | Instructions.TableTypeTransition table, |
79 | boolean clear, | 82 | boolean clear, |
80 | - Instructions.MetadataInstruction meta) { | 83 | + Instructions.MetadataInstruction meta, |
84 | + Instructions.MeterInstruction meter) { | ||
81 | this.immediate = ImmutableList.copyOf(checkNotNull(immediate)); | 85 | this.immediate = ImmutableList.copyOf(checkNotNull(immediate)); |
82 | this.deferred = ImmutableList.copyOf(checkNotNull(deferred)); | 86 | this.deferred = ImmutableList.copyOf(checkNotNull(deferred)); |
83 | this.all = new ImmutableList.Builder<Instruction>() | 87 | this.all = new ImmutableList.Builder<Instruction>() |
... | @@ -87,6 +91,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -87,6 +91,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
87 | this.table = table; | 91 | this.table = table; |
88 | this.meta = meta; | 92 | this.meta = meta; |
89 | this.hasClear = clear; | 93 | this.hasClear = clear; |
94 | + this.meter = meter; | ||
90 | } | 95 | } |
91 | 96 | ||
92 | @Override | 97 | @Override |
... | @@ -119,6 +124,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -119,6 +124,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
119 | return meta; | 124 | return meta; |
120 | } | 125 | } |
121 | 126 | ||
127 | + @Override | ||
128 | + public Instructions.MeterInstruction metered() { | ||
129 | + return meter; | ||
130 | + } | ||
131 | + | ||
122 | /** | 132 | /** |
123 | * Returns a new traffic treatment builder. | 133 | * Returns a new traffic treatment builder. |
124 | * | 134 | * |
... | @@ -193,12 +203,16 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -193,12 +203,16 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
193 | 203 | ||
194 | Instructions.MetadataInstruction meta; | 204 | Instructions.MetadataInstruction meta; |
195 | 205 | ||
206 | + Instructions.MeterInstruction meter; | ||
207 | + | ||
196 | List<Instruction> deferred = Lists.newLinkedList(); | 208 | List<Instruction> deferred = Lists.newLinkedList(); |
197 | 209 | ||
198 | List<Instruction> immediate = Lists.newLinkedList(); | 210 | List<Instruction> immediate = Lists.newLinkedList(); |
199 | 211 | ||
200 | List<Instruction> current = immediate; | 212 | List<Instruction> current = immediate; |
201 | 213 | ||
214 | + | ||
215 | + | ||
202 | // Creates a new builder | 216 | // Creates a new builder |
203 | private Builder() { | 217 | private Builder() { |
204 | } | 218 | } |
... | @@ -233,6 +247,8 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -233,6 +247,8 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
233 | case METADATA: | 247 | case METADATA: |
234 | meta = (Instructions.MetadataInstruction) instruction; | 248 | meta = (Instructions.MetadataInstruction) instruction; |
235 | break; | 249 | break; |
250 | + case METER: | ||
251 | + meter = (Instructions.MeterInstruction) instruction; | ||
236 | default: | 252 | default: |
237 | throw new IllegalArgumentException("Unknown instruction type: " + | 253 | throw new IllegalArgumentException("Unknown instruction type: " + |
238 | instruction.type()); | 254 | instruction.type()); |
... | @@ -343,6 +359,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -343,6 +359,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
343 | } | 359 | } |
344 | 360 | ||
345 | @Override | 361 | @Override |
362 | + public TrafficTreatment.Builder meter(MeterId meterId) { | ||
363 | + return add(Instructions.meterTraffic(meterId)); | ||
364 | + } | ||
365 | + | ||
366 | + @Override | ||
346 | public Builder popVlan() { | 367 | public Builder popVlan() { |
347 | return add(Instructions.popVlan()); | 368 | return add(Instructions.popVlan()); |
348 | } | 369 | } |
... | @@ -420,7 +441,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { | ... | @@ -420,7 +441,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { |
420 | // && table == null && !clear) { | 441 | // && table == null && !clear) { |
421 | // drop(); | 442 | // drop(); |
422 | //} | 443 | //} |
423 | - return new DefaultTrafficTreatment(deferred, immediate, table, clear, meta); | 444 | + return new DefaultTrafficTreatment(deferred, immediate, table, clear, meta, meter); |
424 | } | 445 | } |
425 | 446 | ||
426 | } | 447 | } | ... | ... |
... | @@ -24,6 +24,7 @@ import org.onosproject.core.GroupId; | ... | @@ -24,6 +24,7 @@ import org.onosproject.core.GroupId; |
24 | import org.onosproject.net.PortNumber; | 24 | import org.onosproject.net.PortNumber; |
25 | import org.onosproject.net.flow.instructions.Instruction; | 25 | import org.onosproject.net.flow.instructions.Instruction; |
26 | import org.onosproject.net.flow.instructions.Instructions; | 26 | import org.onosproject.net.flow.instructions.Instructions; |
27 | +import org.onosproject.net.meter.MeterId; | ||
27 | 28 | ||
28 | import java.util.List; | 29 | import java.util.List; |
29 | 30 | ||
... | @@ -75,6 +76,13 @@ public interface TrafficTreatment { | ... | @@ -75,6 +76,13 @@ public interface TrafficTreatment { |
75 | Instructions.MetadataInstruction writeMetadata(); | 76 | Instructions.MetadataInstruction writeMetadata(); |
76 | 77 | ||
77 | /** | 78 | /** |
79 | + * Returns the meter instruction if there is one. | ||
80 | + * | ||
81 | + * @return a meter instruction that may be null | ||
82 | + */ | ||
83 | + Instructions.MeterInstruction metered(); | ||
84 | + | ||
85 | + /** | ||
78 | * Builder of traffic treatment entities. | 86 | * Builder of traffic treatment entities. |
79 | */ | 87 | */ |
80 | interface Builder { | 88 | interface Builder { |
... | @@ -243,6 +251,13 @@ public interface TrafficTreatment { | ... | @@ -243,6 +251,13 @@ public interface TrafficTreatment { |
243 | */ | 251 | */ |
244 | Builder group(GroupId groupId); | 252 | Builder group(GroupId groupId); |
245 | 253 | ||
254 | + /** | ||
255 | + * Sets a meter to be used by this flow. | ||
256 | + * | ||
257 | + * @param meterId a meter id | ||
258 | + * @return a treatment builder | ||
259 | + */ | ||
260 | + Builder meter(MeterId meterId); | ||
246 | 261 | ||
247 | /** | 262 | /** |
248 | * Sets the next table type to transition to. | 263 | * Sets the next table type to transition to. | ... | ... |
... | @@ -40,6 +40,11 @@ public interface Instruction { | ... | @@ -40,6 +40,11 @@ public interface Instruction { |
40 | GROUP, | 40 | GROUP, |
41 | 41 | ||
42 | /** | 42 | /** |
43 | + * Signifies that traffic should be metered according to a meter. | ||
44 | + */ | ||
45 | + METER, | ||
46 | + | ||
47 | + /** | ||
43 | * Signifies that the traffic should be modified in L0 way. | 48 | * Signifies that the traffic should be modified in L0 way. |
44 | */ | 49 | */ |
45 | L0MODIFICATION, | 50 | L0MODIFICATION, | ... | ... |
... | @@ -34,6 +34,7 @@ import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6Fl | ... | @@ -34,6 +34,7 @@ import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6Fl |
34 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModTtlInstruction; | 34 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModTtlInstruction; |
35 | import org.onosproject.net.flow.instructions.L4ModificationInstruction.L4SubType; | 35 | import org.onosproject.net.flow.instructions.L4ModificationInstruction.L4SubType; |
36 | import org.onosproject.net.flow.instructions.L4ModificationInstruction.ModTransportPortInstruction; | 36 | import org.onosproject.net.flow.instructions.L4ModificationInstruction.ModTransportPortInstruction; |
37 | +import org.onosproject.net.meter.MeterId; | ||
37 | 38 | ||
38 | import java.util.Objects; | 39 | import java.util.Objects; |
39 | 40 | ||
... | @@ -81,6 +82,11 @@ public final class Instructions { | ... | @@ -81,6 +82,11 @@ public final class Instructions { |
81 | return new GroupInstruction(groupId); | 82 | return new GroupInstruction(groupId); |
82 | } | 83 | } |
83 | 84 | ||
85 | + public static MeterInstruction meterTraffic(final MeterId meterId) { | ||
86 | + checkNotNull(meterId, "meter id cannot be null"); | ||
87 | + return new MeterInstruction(meterId); | ||
88 | + } | ||
89 | + | ||
84 | /** | 90 | /** |
85 | * Creates a l0 modification. | 91 | * Creates a l0 modification. |
86 | * | 92 | * |
... | @@ -528,6 +534,50 @@ public final class Instructions { | ... | @@ -528,6 +534,50 @@ public final class Instructions { |
528 | } | 534 | } |
529 | 535 | ||
530 | /** | 536 | /** |
537 | + * A meter instruction. | ||
538 | + */ | ||
539 | + public static final class MeterInstruction implements Instruction { | ||
540 | + private final MeterId meterId; | ||
541 | + | ||
542 | + private MeterInstruction(MeterId meterId) { | ||
543 | + this.meterId = meterId; | ||
544 | + } | ||
545 | + | ||
546 | + public MeterId meterId() { | ||
547 | + return meterId; | ||
548 | + } | ||
549 | + | ||
550 | + @Override | ||
551 | + public Type type() { | ||
552 | + return Type.METER; | ||
553 | + } | ||
554 | + | ||
555 | + @Override | ||
556 | + public String toString() { | ||
557 | + return toStringHelper(type().toString()) | ||
558 | + .add("meter ID", meterId.id()).toString(); | ||
559 | + } | ||
560 | + | ||
561 | + @Override | ||
562 | + public int hashCode() { | ||
563 | + return Objects.hash(type().ordinal(), meterId); | ||
564 | + } | ||
565 | + | ||
566 | + @Override | ||
567 | + public boolean equals(Object obj) { | ||
568 | + if (this == obj) { | ||
569 | + return true; | ||
570 | + } | ||
571 | + if (obj instanceof MeterInstruction) { | ||
572 | + MeterInstruction that = (MeterInstruction) obj; | ||
573 | + return Objects.equals(meterId, that.meterId); | ||
574 | + | ||
575 | + } | ||
576 | + return false; | ||
577 | + } | ||
578 | + } | ||
579 | + | ||
580 | + /** | ||
531 | * Transition instruction. | 581 | * Transition instruction. |
532 | */ | 582 | */ |
533 | public static class TableTypeTransition implements Instruction { | 583 | public static class TableTypeTransition implements Instruction { | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Represents a band used within a meter. | 19 | * Represents a band used within a meter. | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Represents a stored band. | 19 | * Represents a stored band. | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import static com.google.common.base.Preconditions.checkArgument; | 18 | import static com.google.common.base.Preconditions.checkArgument; |
19 | 19 | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import org.onosproject.core.ApplicationId; | 18 | import org.onosproject.core.ApplicationId; |
19 | import org.onosproject.net.DeviceId; | 19 | import org.onosproject.net.DeviceId; | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import org.onosproject.core.ApplicationId; | 18 | import org.onosproject.core.ApplicationId; |
19 | import org.onosproject.net.DeviceId; | 19 | import org.onosproject.net.DeviceId; | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * A context permitting the application to be notified when the | 19 | * A context permitting the application to be notified when the | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Represents a stored meter. | 19 | * Represents a stored meter. | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import org.onosproject.event.AbstractEvent; | 18 | import org.onosproject.event.AbstractEvent; |
19 | 19 | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Enum used to represent a meter failure condition. | 19 | * Enum used to represent a meter failure condition. | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import static com.google.common.base.Preconditions.checkArgument; | 18 | import static com.google.common.base.Preconditions.checkArgument; |
19 | 19 | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import org.onosproject.event.EventListener; | 18 | import org.onosproject.event.EventListener; |
19 | 19 | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
19 | 19 | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import com.google.common.collect.ImmutableList; | 18 | import com.google.common.collect.ImmutableList; |
19 | 19 | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import org.onosproject.net.DeviceId; | 18 | import org.onosproject.net.DeviceId; |
19 | import org.onosproject.net.provider.Provider; | 19 | import org.onosproject.net.provider.Provider; | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | 18 | ||
19 | import org.onosproject.net.provider.ProviderRegistry; | 19 | import org.onosproject.net.provider.ProviderRegistry; | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import org.onosproject.net.DeviceId; | 18 | import org.onosproject.net.DeviceId; |
19 | import org.onosproject.net.provider.ProviderService; | 19 | import org.onosproject.net.provider.ProviderService; | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import org.onosproject.event.ListenerService; | 18 | import org.onosproject.event.ListenerService; |
19 | 19 | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Represents the state of the meter as seen by the store. | 19 | * Represents the state of the meter as seen by the store. | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import org.onosproject.store.Store; | 18 | import org.onosproject.store.Store; |
19 | 19 | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import org.onosproject.store.StoreDelegate; | 18 | import org.onosproject.store.StoreDelegate; |
19 | 19 | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.incubator.net.meter; | 16 | +package org.onosproject.net.meter; |
17 | 17 | ||
18 | import java.util.Optional; | 18 | import java.util.Optional; |
19 | 19 | ... | ... |
... | @@ -17,4 +17,4 @@ | ... | @@ -17,4 +17,4 @@ |
17 | /** | 17 | /** |
18 | * Flow meter model and related services. | 18 | * Flow meter model and related services. |
19 | */ | 19 | */ |
20 | -package org.onosproject.incubator.net.meter; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
20 | +package org.onosproject.net.meter; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -124,6 +124,11 @@ public class IntentTestsMocks { | ... | @@ -124,6 +124,11 @@ public class IntentTestsMocks { |
124 | public MetadataInstruction writeMetadata() { | 124 | public MetadataInstruction writeMetadata() { |
125 | return null; | 125 | return null; |
126 | } | 126 | } |
127 | + | ||
128 | + @Override | ||
129 | + public Instructions.MeterInstruction metered() { | ||
130 | + return null; | ||
131 | + } | ||
127 | } | 132 | } |
128 | 133 | ||
129 | /** | 134 | /** | ... | ... |
... | @@ -610,6 +610,11 @@ public class FlowRuleManagerTest { | ... | @@ -610,6 +610,11 @@ public class FlowRuleManagerTest { |
610 | return null; | 610 | return null; |
611 | } | 611 | } |
612 | 612 | ||
613 | + @Override | ||
614 | + public Instructions.MeterInstruction metered() { | ||
615 | + return null; | ||
616 | + } | ||
617 | + | ||
613 | } | 618 | } |
614 | 619 | ||
615 | public class TestApplicationId extends DefaultApplicationId { | 620 | public class TestApplicationId extends DefaultApplicationId { | ... | ... |
... | @@ -160,6 +160,7 @@ import org.onosproject.net.intent.constraint.ObstacleConstraint; | ... | @@ -160,6 +160,7 @@ import org.onosproject.net.intent.constraint.ObstacleConstraint; |
160 | import org.onosproject.net.intent.constraint.PartialFailureConstraint; | 160 | import org.onosproject.net.intent.constraint.PartialFailureConstraint; |
161 | import org.onosproject.net.intent.constraint.WaypointConstraint; | 161 | import org.onosproject.net.intent.constraint.WaypointConstraint; |
162 | import org.onosproject.net.link.DefaultLinkDescription; | 162 | import org.onosproject.net.link.DefaultLinkDescription; |
163 | +import org.onosproject.net.meter.MeterId; | ||
163 | import org.onosproject.net.newresource.ResourceAllocation; | 164 | import org.onosproject.net.newresource.ResourceAllocation; |
164 | import org.onosproject.net.newresource.ResourcePath; | 165 | import org.onosproject.net.newresource.ResourcePath; |
165 | import org.onosproject.net.packet.DefaultOutboundPacket; | 166 | import org.onosproject.net.packet.DefaultOutboundPacket; |
... | @@ -271,6 +272,8 @@ public final class KryoNamespaces { | ... | @@ -271,6 +272,8 @@ public final class KryoNamespaces { |
271 | .register(MISC) | 272 | .register(MISC) |
272 | .nextId(KryoNamespace.INITIAL_ID + 30 + 10) | 273 | .nextId(KryoNamespace.INITIAL_ID + 30 + 10) |
273 | .register( | 274 | .register( |
275 | + Instructions.MeterInstruction.class, | ||
276 | + MeterId.class, | ||
274 | Version.class, | 277 | Version.class, |
275 | ControllerNode.State.class, | 278 | ControllerNode.State.class, |
276 | ApplicationState.class, | 279 | ApplicationState.class, | ... | ... |
... | @@ -22,21 +22,21 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -22,21 +22,21 @@ import org.apache.felix.scr.annotations.Reference; |
22 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
23 | import org.apache.felix.scr.annotations.Service; | 23 | import org.apache.felix.scr.annotations.Service; |
24 | import org.onlab.util.TriConsumer; | 24 | import org.onlab.util.TriConsumer; |
25 | -import org.onosproject.incubator.net.meter.DefaultMeter; | 25 | +import org.onosproject.net.meter.DefaultMeter; |
26 | -import org.onosproject.incubator.net.meter.Meter; | 26 | +import org.onosproject.net.meter.Meter; |
27 | -import org.onosproject.incubator.net.meter.MeterEvent; | 27 | +import org.onosproject.net.meter.MeterEvent; |
28 | -import org.onosproject.incubator.net.meter.MeterFailReason; | 28 | +import org.onosproject.net.meter.MeterFailReason; |
29 | -import org.onosproject.incubator.net.meter.MeterId; | 29 | +import org.onosproject.net.meter.MeterId; |
30 | -import org.onosproject.incubator.net.meter.MeterListener; | 30 | +import org.onosproject.net.meter.MeterListener; |
31 | -import org.onosproject.incubator.net.meter.MeterOperation; | 31 | +import org.onosproject.net.meter.MeterOperation; |
32 | -import org.onosproject.incubator.net.meter.MeterProvider; | 32 | +import org.onosproject.net.meter.MeterProvider; |
33 | -import org.onosproject.incubator.net.meter.MeterProviderRegistry; | 33 | +import org.onosproject.net.meter.MeterProviderRegistry; |
34 | -import org.onosproject.incubator.net.meter.MeterProviderService; | 34 | +import org.onosproject.net.meter.MeterProviderService; |
35 | -import org.onosproject.incubator.net.meter.MeterService; | 35 | +import org.onosproject.net.meter.MeterService; |
36 | -import org.onosproject.incubator.net.meter.MeterState; | 36 | +import org.onosproject.net.meter.MeterState; |
37 | -import org.onosproject.incubator.net.meter.MeterStore; | 37 | +import org.onosproject.net.meter.MeterStore; |
38 | -import org.onosproject.incubator.net.meter.MeterStoreDelegate; | 38 | +import org.onosproject.net.meter.MeterStoreDelegate; |
39 | -import org.onosproject.incubator.net.meter.MeterStoreResult; | 39 | +import org.onosproject.net.meter.MeterStoreResult; |
40 | import org.onosproject.net.DeviceId; | 40 | import org.onosproject.net.DeviceId; |
41 | import org.onosproject.net.provider.AbstractListenerProviderRegistry; | 41 | import org.onosproject.net.provider.AbstractListenerProviderRegistry; |
42 | import org.onosproject.net.provider.AbstractProviderService; | 42 | import org.onosproject.net.provider.AbstractProviderService; | ... | ... |
... | @@ -23,16 +23,16 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -23,16 +23,16 @@ import org.apache.felix.scr.annotations.Reference; |
23 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 23 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
24 | import org.onosproject.cluster.ClusterService; | 24 | import org.onosproject.cluster.ClusterService; |
25 | import org.onosproject.cluster.NodeId; | 25 | import org.onosproject.cluster.NodeId; |
26 | -import org.onosproject.incubator.net.meter.DefaultMeter; | 26 | +import org.onosproject.net.meter.DefaultMeter; |
27 | -import org.onosproject.incubator.net.meter.Meter; | 27 | +import org.onosproject.net.meter.Meter; |
28 | -import org.onosproject.incubator.net.meter.MeterEvent; | 28 | +import org.onosproject.net.meter.MeterEvent; |
29 | -import org.onosproject.incubator.net.meter.MeterFailReason; | 29 | +import org.onosproject.net.meter.MeterFailReason; |
30 | -import org.onosproject.incubator.net.meter.MeterId; | 30 | +import org.onosproject.net.meter.MeterId; |
31 | -import org.onosproject.incubator.net.meter.MeterOperation; | 31 | +import org.onosproject.net.meter.MeterOperation; |
32 | -import org.onosproject.incubator.net.meter.MeterState; | 32 | +import org.onosproject.net.meter.MeterState; |
33 | -import org.onosproject.incubator.net.meter.MeterStore; | 33 | +import org.onosproject.net.meter.MeterStore; |
34 | -import org.onosproject.incubator.net.meter.MeterStoreDelegate; | 34 | +import org.onosproject.net.meter.MeterStoreDelegate; |
35 | -import org.onosproject.incubator.net.meter.MeterStoreResult; | 35 | +import org.onosproject.net.meter.MeterStoreResult; |
36 | import org.onosproject.mastership.MastershipService; | 36 | import org.onosproject.mastership.MastershipService; |
37 | import org.onosproject.store.AbstractStore; | 37 | import org.onosproject.store.AbstractStore; |
38 | import org.onosproject.store.serializers.KryoNamespaces; | 38 | import org.onosproject.store.serializers.KryoNamespaces; | ... | ... |
... | @@ -16,8 +16,8 @@ | ... | @@ -16,8 +16,8 @@ |
16 | package org.onosproject.incubator.store.meter.impl; | 16 | package org.onosproject.incubator.store.meter.impl; |
17 | 17 | ||
18 | import org.onosproject.cluster.NodeId; | 18 | import org.onosproject.cluster.NodeId; |
19 | -import org.onosproject.incubator.net.meter.Meter; | 19 | +import org.onosproject.net.meter.Meter; |
20 | -import org.onosproject.incubator.net.meter.MeterFailReason; | 20 | +import org.onosproject.net.meter.MeterFailReason; |
21 | 21 | ||
22 | import java.util.Optional; | 22 | import java.util.Optional; |
23 | 23 | ... | ... |
providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
... | @@ -161,6 +161,9 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -161,6 +161,9 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
161 | if (treatment.writeMetadata() != null) { | 161 | if (treatment.writeMetadata() != null) { |
162 | instructions.add(buildMetadata(treatment.writeMetadata())); | 162 | instructions.add(buildMetadata(treatment.writeMetadata())); |
163 | } | 163 | } |
164 | + if (treatment.metered() != null) { | ||
165 | + instructions.add(buildMeter(treatment.metered())); | ||
166 | + } | ||
164 | 167 | ||
165 | long cookie = flowRule().id().value(); | 168 | long cookie = flowRule().id().value(); |
166 | 169 | ||
... | @@ -263,6 +266,11 @@ public class FlowModBuilderVer13 extends FlowModBuilder { | ... | @@ -263,6 +266,11 @@ public class FlowModBuilderVer13 extends FlowModBuilder { |
263 | return instruction; | 266 | return instruction; |
264 | } | 267 | } |
265 | 268 | ||
269 | + private OFInstruction buildMeter(Instructions.MeterInstruction metered) { | ||
270 | + return factory().instructions().meter(metered.meterId().id()); | ||
271 | + } | ||
272 | + | ||
273 | + | ||
266 | private OFAction buildL0Modification(Instruction i) { | 274 | private OFAction buildL0Modification(Instruction i) { |
267 | L0ModificationInstruction l0m = (L0ModificationInstruction) i; | 275 | L0ModificationInstruction l0m = (L0ModificationInstruction) i; |
268 | switch (l0m.subtype()) { | 276 | switch (l0m.subtype()) { | ... | ... |
... | @@ -15,9 +15,9 @@ | ... | @@ -15,9 +15,9 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.provider.of.meter.impl; | 16 | package org.onosproject.provider.of.meter.impl; |
17 | 17 | ||
18 | -import org.onosproject.incubator.net.meter.Band; | 18 | +import org.onosproject.net.meter.Band; |
19 | -import org.onosproject.incubator.net.meter.Meter; | 19 | +import org.onosproject.net.meter.Meter; |
20 | -import org.onosproject.incubator.net.meter.MeterId; | 20 | +import org.onosproject.net.meter.MeterId; |
21 | import org.projectfloodlight.openflow.protocol.OFFactory; | 21 | import org.projectfloodlight.openflow.protocol.OFFactory; |
22 | import org.projectfloodlight.openflow.protocol.OFMeterFlags; | 22 | import org.projectfloodlight.openflow.protocol.OFMeterFlags; |
23 | import org.projectfloodlight.openflow.protocol.OFMeterMod; | 23 | import org.projectfloodlight.openflow.protocol.OFMeterMod; | ... | ... |
... | @@ -28,17 +28,17 @@ import org.apache.felix.scr.annotations.Deactivate; | ... | @@ -28,17 +28,17 @@ import org.apache.felix.scr.annotations.Deactivate; |
28 | import org.apache.felix.scr.annotations.Reference; | 28 | import org.apache.felix.scr.annotations.Reference; |
29 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 29 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
30 | import org.onosproject.core.CoreService; | 30 | import org.onosproject.core.CoreService; |
31 | -import org.onosproject.incubator.net.meter.Band; | 31 | +import org.onosproject.net.meter.Band; |
32 | -import org.onosproject.incubator.net.meter.DefaultBand; | 32 | +import org.onosproject.net.meter.DefaultBand; |
33 | -import org.onosproject.incubator.net.meter.DefaultMeter; | 33 | +import org.onosproject.net.meter.DefaultMeter; |
34 | -import org.onosproject.incubator.net.meter.Meter; | 34 | +import org.onosproject.net.meter.Meter; |
35 | -import org.onosproject.incubator.net.meter.MeterFailReason; | 35 | +import org.onosproject.net.meter.MeterFailReason; |
36 | -import org.onosproject.incubator.net.meter.MeterOperation; | 36 | +import org.onosproject.net.meter.MeterOperation; |
37 | -import org.onosproject.incubator.net.meter.MeterOperations; | 37 | +import org.onosproject.net.meter.MeterOperations; |
38 | -import org.onosproject.incubator.net.meter.MeterProvider; | 38 | +import org.onosproject.net.meter.MeterProvider; |
39 | -import org.onosproject.incubator.net.meter.MeterProviderRegistry; | 39 | +import org.onosproject.net.meter.MeterProviderRegistry; |
40 | -import org.onosproject.incubator.net.meter.MeterProviderService; | 40 | +import org.onosproject.net.meter.MeterProviderService; |
41 | -import org.onosproject.incubator.net.meter.MeterState; | 41 | +import org.onosproject.net.meter.MeterState; |
42 | import org.onosproject.net.DeviceId; | 42 | import org.onosproject.net.DeviceId; |
43 | import org.onosproject.net.provider.AbstractProvider; | 43 | import org.onosproject.net.provider.AbstractProvider; |
44 | import org.onosproject.net.provider.ProviderId; | 44 | import org.onosproject.net.provider.ProviderId; | ... | ... |
-
Please register or login to post a comment