Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.incubator.net.virtual.impl.provider; |
| 18 | |
| 19 | import com.google.common.collect.ImmutableList; |
| 20 | import com.google.common.collect.ImmutableSet; |
| 21 | import org.junit.After; |
| 22 | import org.junit.Before; |
| 23 | import org.junit.Test; |
Ray Milkey | a7cf8c8 | 2018-02-08 15:07:06 -0800 | [diff] [blame] | 24 | import org.onlab.graph.ScalarWeight; |
| 25 | import org.onlab.graph.Weight; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 26 | import org.onosproject.core.ApplicationId; |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 27 | import org.onosproject.core.CoreServiceAdapter; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 28 | import org.onosproject.core.DefaultApplicationId; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 29 | import org.onosproject.incubator.net.virtual.DefaultVirtualDevice; |
| 30 | import org.onosproject.incubator.net.virtual.DefaultVirtualNetwork; |
| 31 | import org.onosproject.incubator.net.virtual.DefaultVirtualPort; |
| 32 | import org.onosproject.incubator.net.virtual.NetworkId; |
Thomas Vachuska | 52f2cd1 | 2018-11-08 21:20:04 -0800 | [diff] [blame^] | 33 | import org.onosproject.net.TenantId; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 34 | import org.onosproject.incubator.net.virtual.VirtualDevice; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 35 | import org.onosproject.incubator.net.virtual.VirtualLink; |
| 36 | import org.onosproject.incubator.net.virtual.VirtualNetwork; |
Yoonseon Han | ffcc32f | 2017-05-03 14:42:17 -0700 | [diff] [blame] | 37 | import org.onosproject.incubator.net.virtual.VirtualNetworkAdminServiceAdapter; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 38 | import org.onosproject.incubator.net.virtual.VirtualPort; |
| 39 | import org.onosproject.net.ConnectPoint; |
| 40 | import org.onosproject.net.DefaultAnnotations; |
| 41 | import org.onosproject.net.DefaultDevice; |
| 42 | import org.onosproject.net.DefaultLink; |
| 43 | import org.onosproject.net.DefaultPath; |
| 44 | import org.onosproject.net.DefaultPort; |
| 45 | import org.onosproject.net.Device; |
| 46 | import org.onosproject.net.DeviceId; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 47 | import org.onosproject.net.Link; |
| 48 | import org.onosproject.net.Path; |
| 49 | import org.onosproject.net.Port; |
| 50 | import org.onosproject.net.PortNumber; |
| 51 | import org.onosproject.net.device.DeviceServiceAdapter; |
| 52 | import org.onosproject.net.flow.DefaultFlowEntry; |
| 53 | import org.onosproject.net.flow.DefaultFlowRule; |
| 54 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 55 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 56 | import org.onosproject.net.flow.FlowEntry; |
| 57 | import org.onosproject.net.flow.FlowRule; |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 58 | import org.onosproject.net.flow.FlowRuleServiceAdapter; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 59 | import org.onosproject.net.flow.TrafficSelector; |
| 60 | import org.onosproject.net.flow.TrafficTreatment; |
| 61 | import org.onosproject.net.flow.instructions.Instruction; |
| 62 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; |
| 63 | import org.onosproject.net.provider.ProviderId; |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 64 | import org.onosproject.net.topology.LinkWeigher; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 65 | import org.onosproject.net.topology.Topology; |
Yuta HIGUCHI | 03c234e | 2017-01-23 17:21:34 -0800 | [diff] [blame] | 66 | import org.onosproject.net.topology.TopologyServiceAdapter; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 67 | |
Yoonseon Han | c8089db | 2017-03-22 20:22:12 +0900 | [diff] [blame] | 68 | import java.util.Arrays; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 69 | import java.util.HashSet; |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 70 | import java.util.Set; |
| 71 | import java.util.stream.Collectors; |
| 72 | |
| 73 | import static org.junit.Assert.assertEquals; |
| 74 | |
| 75 | public class DefaultVirtualFlowRuleProviderTest { |
| 76 | private static final ProviderId PID = new ProviderId("of", "foo"); |
| 77 | |
| 78 | private static final DeviceId DID1 = DeviceId.deviceId("of:001"); |
| 79 | private static final DeviceId DID2 = DeviceId.deviceId("of:002"); |
| 80 | private static final PortNumber PORT_NUM1 = PortNumber.portNumber(1); |
| 81 | private static final PortNumber PORT_NUM2 = PortNumber.portNumber(2); |
| 82 | |
| 83 | private static final DefaultAnnotations ANNOTATIONS = |
| 84 | DefaultAnnotations.builder().set("foo", "bar").build(); |
| 85 | |
| 86 | private static final Device DEV1 = |
| 87 | new DefaultDevice(PID, DID1, Device.Type.SWITCH, "", "", "", "", null); |
| 88 | private static final Device DEV2 = |
| 89 | new DefaultDevice(PID, DID2, Device.Type.SWITCH, "", "", "", "", null); |
| 90 | private static final Port PORT11 = |
| 91 | new DefaultPort(DEV1, PORT_NUM1, true, ANNOTATIONS); |
| 92 | private static final Port PORT12 = |
| 93 | new DefaultPort(DEV1, PORT_NUM2, true, ANNOTATIONS); |
| 94 | private static final Port PORT21 = |
| 95 | new DefaultPort(DEV2, PORT_NUM1, true, ANNOTATIONS); |
| 96 | private static final Port PORT22 = |
| 97 | new DefaultPort(DEV2, PORT_NUM2, true, ANNOTATIONS); |
| 98 | |
| 99 | private static final ConnectPoint CP11 = new ConnectPoint(DID1, PORT_NUM1); |
| 100 | private static final ConnectPoint CP12 = new ConnectPoint(DID1, PORT_NUM2); |
| 101 | private static final ConnectPoint CP21 = new ConnectPoint(DID2, PORT_NUM1); |
| 102 | private static final ConnectPoint CP22 = new ConnectPoint(DID2, PORT_NUM2); |
| 103 | private static final Link LINK1 = DefaultLink.builder() |
| 104 | .src(CP12).dst(CP21).providerId(PID).type(Link.Type.DIRECT).build(); |
| 105 | |
| 106 | private static final NetworkId VNET_ID = NetworkId.networkId(1); |
| 107 | private static final DeviceId VDID = DeviceId.deviceId("of:100"); |
| 108 | |
| 109 | private static final VirtualNetwork VNET = new DefaultVirtualNetwork( |
| 110 | VNET_ID, TenantId.tenantId("t1")); |
| 111 | private static final VirtualDevice VDEV = |
| 112 | new DefaultVirtualDevice(VNET_ID, VDID); |
| 113 | private static final VirtualPort VPORT1 = |
| 114 | new DefaultVirtualPort(VNET_ID, VDEV, PORT_NUM1, CP11); |
| 115 | private static final VirtualPort VPORT2 = |
| 116 | new DefaultVirtualPort(VNET_ID, VDEV, PORT_NUM2, CP22); |
| 117 | |
| 118 | private static final int TIMEOUT = 10; |
| 119 | |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 120 | protected DefaultVirtualFlowRuleProvider virtualProvider; |
| 121 | |
| 122 | private ApplicationId vAppId; |
| 123 | |
| 124 | @Before |
| 125 | public void setUp() { |
| 126 | virtualProvider = new DefaultVirtualFlowRuleProvider(); |
| 127 | |
| 128 | virtualProvider.deviceService = new TestDeviceService(); |
| 129 | virtualProvider.coreService = new TestCoreService(); |
Yoonseon Han | c8089db | 2017-03-22 20:22:12 +0900 | [diff] [blame] | 130 | virtualProvider.vnService = |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 131 | new TestVirtualNetworkAdminService(); |
| 132 | virtualProvider.topologyService = new TestTopologyService(); |
| 133 | virtualProvider.flowRuleService = new TestFlowRuleService(); |
| 134 | virtualProvider.providerRegistryService = new VirtualProviderManager(); |
| 135 | |
| 136 | virtualProvider.activate(); |
| 137 | vAppId = new TestApplicationId(0, "Virtual App"); |
| 138 | } |
| 139 | |
| 140 | @After |
| 141 | public void tearDown() { |
| 142 | virtualProvider.deactivate(); |
| 143 | virtualProvider.deviceService = null; |
| 144 | virtualProvider.coreService = null; |
| 145 | } |
| 146 | |
| 147 | @Test |
Yoonseon Han | c8089db | 2017-03-22 20:22:12 +0900 | [diff] [blame] | 148 | public void devirtualizeFlowRuleWithInPort() { |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 149 | TrafficSelector ts = DefaultTrafficSelector.builder() |
| 150 | .matchInPort(PORT_NUM1).build(); |
| 151 | TrafficTreatment tr = DefaultTrafficTreatment.builder() |
| 152 | .setOutput(PORT_NUM2).build(); |
| 153 | |
| 154 | FlowRule r1 = DefaultFlowRule.builder() |
| 155 | .forDevice(VDID) |
| 156 | .withSelector(ts) |
| 157 | .withTreatment(tr) |
| 158 | .withPriority(10) |
| 159 | .fromApp(vAppId) |
| 160 | .makeTemporary(TIMEOUT) |
| 161 | .build(); |
| 162 | |
| 163 | virtualProvider.applyFlowRule(VNET_ID, r1); |
| 164 | |
| 165 | assertEquals("2 rules should exist", 2, |
| 166 | virtualProvider.flowRuleService.getFlowRuleCount()); |
| 167 | |
| 168 | Set<FlowEntry> phyRules = new HashSet<>(); |
| 169 | for (FlowEntry i : virtualProvider.flowRuleService.getFlowEntries(DID1)) { |
| 170 | phyRules.add(i); |
| 171 | } |
| 172 | for (FlowEntry i : virtualProvider.flowRuleService.getFlowEntries(DID2)) { |
| 173 | phyRules.add(i); |
| 174 | } |
| 175 | |
| 176 | FlowRule in = null; |
| 177 | FlowRule out = null; |
| 178 | |
| 179 | for (FlowRule rule : phyRules) { |
| 180 | |
| 181 | L2ModificationInstruction i = (L2ModificationInstruction) |
| 182 | rule.treatment().allInstructions().get(0); |
| 183 | |
| 184 | if (i.subtype() == L2ModificationInstruction.L2SubType.VLAN_PUSH) { |
| 185 | in = rule; |
| 186 | } else { |
| 187 | out = rule; |
| 188 | } |
| 189 | |
| 190 | } |
| 191 | |
| 192 | assertEquals(DID1, in.deviceId()); |
| 193 | assertEquals(DID2, out.deviceId()); |
| 194 | } |
| 195 | |
| 196 | @Test |
Yoonseon Han | c8089db | 2017-03-22 20:22:12 +0900 | [diff] [blame] | 197 | public void devirtualizeFlowRuleWithoutInPort() { |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 198 | TrafficSelector ts = DefaultTrafficSelector.builder().build(); |
| 199 | TrafficTreatment tr = DefaultTrafficTreatment.builder() |
| 200 | .setOutput(PORT_NUM2).build(); |
| 201 | |
| 202 | FlowRule r1 = DefaultFlowRule.builder() |
| 203 | .forDevice(VDID) |
| 204 | .withSelector(ts) |
| 205 | .withTreatment(tr) |
| 206 | .withPriority(10) |
| 207 | .fromApp(vAppId) |
| 208 | .makeTemporary(TIMEOUT) |
| 209 | .build(); |
| 210 | |
| 211 | virtualProvider.applyFlowRule(VNET_ID, r1); |
| 212 | |
| 213 | assertEquals("3 rules should exist", 3, |
| 214 | virtualProvider.flowRuleService.getFlowRuleCount()); |
| 215 | |
| 216 | FlowRule inFromDID1 = null; |
| 217 | FlowRule inFromDID2 = null; |
| 218 | FlowRule out = null; |
| 219 | |
| 220 | Set<FlowEntry> phyRules = new HashSet<>(); |
| 221 | for (FlowEntry i : virtualProvider.flowRuleService.getFlowEntries(DID1)) { |
| 222 | phyRules.add(i); |
| 223 | } |
| 224 | for (FlowEntry i : virtualProvider.flowRuleService.getFlowEntries(DID2)) { |
| 225 | phyRules.add(i); |
| 226 | } |
| 227 | |
| 228 | for (FlowRule rule : phyRules) { |
| 229 | for (Instruction inst : rule.treatment().allInstructions()) { |
| 230 | if (inst.type() == Instruction.Type.L2MODIFICATION) { |
| 231 | L2ModificationInstruction i = (L2ModificationInstruction) inst; |
| 232 | if (i.subtype() == L2ModificationInstruction.L2SubType.VLAN_PUSH) { |
| 233 | inFromDID1 = rule; |
| 234 | break; |
| 235 | } else { |
| 236 | out = rule; |
| 237 | break; |
| 238 | } |
| 239 | } else { |
| 240 | inFromDID2 = rule; |
| 241 | break; |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | assertEquals(DID1, inFromDID1.deviceId()); |
| 247 | assertEquals(DID2, inFromDID2.deviceId()); |
| 248 | assertEquals(DID2, out.deviceId()); |
| 249 | } |
| 250 | |
| 251 | @Test |
| 252 | public void removeVirtualizeFlowRule() { |
| 253 | TrafficSelector ts = DefaultTrafficSelector.builder().build(); |
| 254 | TrafficTreatment tr = DefaultTrafficTreatment.builder() |
| 255 | .setOutput(PORT_NUM2).build(); |
| 256 | |
| 257 | FlowRule r1 = DefaultFlowRule.builder() |
| 258 | .forDevice(VDID) |
| 259 | .withSelector(ts) |
| 260 | .withTreatment(tr) |
| 261 | .withPriority(10) |
| 262 | .fromApp(vAppId) |
| 263 | .makeTemporary(TIMEOUT) |
| 264 | .build(); |
| 265 | |
| 266 | virtualProvider.removeFlowRule(VNET_ID, r1); |
| 267 | |
| 268 | assertEquals("0 rules should exist", 0, |
| 269 | virtualProvider.flowRuleService.getFlowRuleCount()); |
| 270 | } |
| 271 | |
| 272 | |
| 273 | private static class TestDeviceService extends DeviceServiceAdapter { |
| 274 | @Override |
| 275 | public int getDeviceCount() { |
| 276 | return 2; |
| 277 | } |
| 278 | |
| 279 | @Override |
| 280 | public Iterable<Device> getDevices() { |
| 281 | return ImmutableList.of(DEV1, DEV2); |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public Iterable<Device> getAvailableDevices() { |
| 286 | return getDevices(); |
| 287 | } |
| 288 | |
| 289 | @Override |
| 290 | public Device getDevice(DeviceId deviceId) { |
| 291 | return deviceId.equals(DID2) ? DEV2 : DEV1; |
| 292 | } |
| 293 | } |
| 294 | |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 295 | private static class TestCoreService extends CoreServiceAdapter { |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 296 | |
| 297 | @Override |
| 298 | public ApplicationId registerApplication(String name) { |
| 299 | return new TestApplicationId(1, name); |
| 300 | } |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | private static class TestApplicationId extends DefaultApplicationId { |
| 304 | public TestApplicationId(int id, String name) { |
| 305 | super(id, name); |
| 306 | } |
| 307 | } |
| 308 | |
Yoonseon Han | c8089db | 2017-03-22 20:22:12 +0900 | [diff] [blame] | 309 | private class TestVirtualNetworkAdminService |
Yoonseon Han | ffcc32f | 2017-05-03 14:42:17 -0700 | [diff] [blame] | 310 | extends VirtualNetworkAdminServiceAdapter { |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 311 | |
| 312 | @Override |
| 313 | public Set<VirtualDevice> getVirtualDevices(NetworkId networkId) { |
| 314 | return ImmutableSet.of(VDEV); |
| 315 | } |
| 316 | |
| 317 | @Override |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 318 | public Set<VirtualLink> getVirtualLinks(NetworkId networkId) { |
Harold Huang | 7362e67 | 2017-04-19 10:00:11 +0800 | [diff] [blame] | 319 | return new HashSet<>(); |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | @Override |
| 323 | public Set<VirtualPort> getVirtualPorts(NetworkId networkId, |
| 324 | DeviceId deviceId) { |
| 325 | return ImmutableSet.of(VPORT1, VPORT2); |
| 326 | } |
| 327 | |
| 328 | @Override |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 329 | public ApplicationId getVirtualNetworkApplicationId(NetworkId networkId) { |
Yoonseon Han | c8089db | 2017-03-22 20:22:12 +0900 | [diff] [blame] | 330 | return vAppId; |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 331 | } |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Yuta HIGUCHI | 03c234e | 2017-01-23 17:21:34 -0800 | [diff] [blame] | 334 | private static class TestTopologyService extends TopologyServiceAdapter { |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 335 | |
Ray Milkey | a7cf8c8 | 2018-02-08 15:07:06 -0800 | [diff] [blame] | 336 | Weight oneHundred = ScalarWeight.toWeight(100); |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 337 | @Override |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 338 | public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst) { |
| 339 | DefaultPath path = new DefaultPath(PID, ImmutableList.of(LINK1), |
Ray Milkey | a7cf8c8 | 2018-02-08 15:07:06 -0800 | [diff] [blame] | 340 | oneHundred, ANNOTATIONS); |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 341 | return ImmutableSet.of(path); |
| 342 | } |
| 343 | |
| 344 | @Override |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 345 | public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, |
| 346 | LinkWeigher weigher) { |
| 347 | DefaultPath path = new DefaultPath(PID, ImmutableList.of(LINK1), |
Ray Milkey | a7cf8c8 | 2018-02-08 15:07:06 -0800 | [diff] [blame] | 348 | oneHundred, ANNOTATIONS); |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 349 | return ImmutableSet.of(path); |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 352 | } |
| 353 | |
yoonseon | 322c9c3 | 2016-12-07 16:47:02 -0800 | [diff] [blame] | 354 | private static class TestFlowRuleService extends FlowRuleServiceAdapter { |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 355 | static Set<FlowRule> ruleCollection = new HashSet<>(); |
| 356 | |
| 357 | @Override |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 358 | public int getFlowRuleCount() { |
| 359 | return ruleCollection.size(); |
| 360 | } |
| 361 | |
| 362 | @Override |
| 363 | public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { |
| 364 | return ruleCollection.stream() |
| 365 | .filter(r -> r.deviceId().equals(deviceId)) |
Yoonseon Han | c8089db | 2017-03-22 20:22:12 +0900 | [diff] [blame] | 366 | .map(DefaultFlowEntry::new) |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 367 | .collect(Collectors.toSet()); |
| 368 | } |
| 369 | |
| 370 | @Override |
| 371 | public void applyFlowRules(FlowRule... flowRules) { |
Yoonseon Han | c8089db | 2017-03-22 20:22:12 +0900 | [diff] [blame] | 372 | ruleCollection.addAll(Arrays.asList(flowRules)); |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | @Override |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 376 | public void removeFlowRules(FlowRule... flowRules) { |
| 377 | Set<FlowRule> candidates = new HashSet<>(); |
| 378 | for (FlowRule rule : flowRules) { |
| 379 | ruleCollection.stream() |
| 380 | .filter(r -> r.exactMatch(rule)) |
| 381 | .forEach(candidates::add); |
| 382 | } |
| 383 | ruleCollection.removeAll(candidates); |
| 384 | } |
Yoonseon Han | c70b4e0 | 2016-10-20 15:24:33 -0700 | [diff] [blame] | 385 | } |
| 386 | } |