blob: 48fdf34b41cf14476838ea36a9c0ec2c8d2aec6a [file] [log] [blame]
Lee Yongjae7c27bb42017-11-17 12:00:45 +09001/*
Jian Li8df54a92018-08-23 17:01:31 +09002 * Copyright 2018-present Open Networking Foundation
Lee Yongjae7c27bb42017-11-17 12:00:45 +09003 *
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
Jian Li8df54a92018-08-23 17:01:31 +090017package org.onosproject.simplefabric.impl;
Lee Yongjae7c27bb42017-11-17 12:00:45 +090018
19import com.google.common.collect.ImmutableList;
20import com.google.common.collect.ImmutableSet;
21import com.google.common.collect.Maps;
22import com.google.common.collect.Sets;
Ray Milkeyd84f89b2018-08-17 14:54:17 -070023import org.osgi.service.component.annotations.Activate;
24import org.osgi.service.component.annotations.Component;
25import org.osgi.service.component.annotations.Deactivate;
26import org.osgi.service.component.annotations.Reference;
27import org.osgi.service.component.annotations.ReferenceCardinality;
Lee Yongjae7c27bb42017-11-17 12:00:45 +090028import org.onlab.packet.MacAddress;
29import org.onlab.packet.VlanId;
30import org.onosproject.core.ApplicationId;
31import org.onosproject.core.CoreService;
Lee Yongjae7c27bb42017-11-17 12:00:45 +090032import org.onosproject.net.ConnectPoint;
33import org.onosproject.net.EncapsulationType;
34import org.onosproject.net.FilteredConnectPoint;
35import org.onosproject.net.Host;
36import org.onosproject.net.ResourceGroup;
37import org.onosproject.net.flow.DefaultTrafficSelector;
38import org.onosproject.net.flow.TrafficSelector;
39import org.onosproject.net.host.HostService;
40import org.onosproject.net.intent.Constraint;
41import org.onosproject.net.intent.Intent;
42import org.onosproject.net.intent.IntentService;
43import org.onosproject.net.intent.Key;
44import org.onosproject.net.intent.MultiPointToSinglePointIntent;
45import org.onosproject.net.intent.SinglePointToMultiPointIntent;
46import org.onosproject.net.intent.constraint.EncapsulationConstraint;
47import org.onosproject.net.intent.constraint.PartialFailureConstraint;
Jian Lie2d87512018-08-23 17:33:05 +090048import org.onosproject.net.intf.Interface;
49import org.onosproject.simplefabric.api.FabricNetwork;
Jian Lic7efc1d2018-08-23 16:37:34 +090050import org.onosproject.simplefabric.api.SimpleFabricEvent;
51import org.onosproject.simplefabric.api.SimpleFabricListener;
52import org.onosproject.simplefabric.api.SimpleFabricService;
Lee Yongjae7c27bb42017-11-17 12:00:45 +090053import org.slf4j.Logger;
54import org.slf4j.LoggerFactory;
55
56import java.io.PrintStream;
57import java.util.ArrayList;
58import java.util.Collection;
Lee Yongjae7c27bb42017-11-17 12:00:45 +090059import java.util.HashSet;
60import java.util.List;
Lee Yongjae7c27bb42017-11-17 12:00:45 +090061import java.util.Map;
Jian Lie2d87512018-08-23 17:33:05 +090062import java.util.Objects;
63import java.util.Set;
Lee Yongjae7c27bb42017-11-17 12:00:45 +090064import java.util.stream.Collectors;
65
Jian Lie2d87512018-08-23 17:33:05 +090066import static org.onosproject.simplefabric.api.Constants.FORWARDING_APP_ID;
Jian Li8df54a92018-08-23 17:01:31 +090067import static org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_BROADCAST;
68import static org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_UNICAST;
69
Lee Yongjae7c27bb42017-11-17 12:00:45 +090070
71/**
72 * An implementation of L2NetworkOperationService.
73 * Handles the execution order of the L2 Network operations generated by the
74 * application.
75 */
76@Component(immediate = true, enabled = false)
Jian Lie2d87512018-08-23 17:33:05 +090077public class SimpleFabricForwarding {
Lee Yongjae7c27bb42017-11-17 12:00:45 +090078
79 public static final String BROADCAST = "BCAST";
80 public static final String UNICAST = "UNI";
81
82 private final Logger log = LoggerFactory.getLogger(getClass());
Jian Lie2d87512018-08-23 17:33:05 +090083 protected ApplicationId appId;
Lee Yongjae7c27bb42017-11-17 12:00:45 +090084
Ray Milkeyd84f89b2018-08-17 14:54:17 -070085 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Lee Yongjae7c27bb42017-11-17 12:00:45 +090086 protected CoreService coreService;
87
Ray Milkeyd84f89b2018-08-17 14:54:17 -070088 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Lee Yongjae7c27bb42017-11-17 12:00:45 +090089 protected IntentService intentService;
90
Ray Milkeyd84f89b2018-08-17 14:54:17 -070091 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Lee Yongjae7c27bb42017-11-17 12:00:45 +090092 protected HostService hostService;
93
Ray Milkeyd84f89b2018-08-17 14:54:17 -070094 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Lee Yongjae7c27bb42017-11-17 12:00:45 +090095 protected SimpleFabricService simpleFabric;
96
97 public static final ImmutableList<Constraint> L2NETWORK_CONSTRAINTS =
98 ImmutableList.of(new PartialFailureConstraint());
99
100 private Map<Key, SinglePointToMultiPointIntent> bctIntentsMap = Maps.newConcurrentMap();
101 private Map<Key, MultiPointToSinglePointIntent> uniIntentsMap = Maps.newConcurrentMap();
102 private Set<Key> toBePurgedIntentKeys = new HashSet<>();
103
104 private final InternalSimpleFabricListener simpleFabricListener = new InternalSimpleFabricListener();
105
106 @Activate
107 public void activate() {
Jian Lie2d87512018-08-23 17:33:05 +0900108 appId = coreService.registerApplication(FORWARDING_APP_ID);
109 log.info("simple fabric forwarding starting with l2net app id {}", appId.toString());
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900110
111 simpleFabric.addListener(simpleFabricListener);
112
113 refresh();
114 checkIntentsPurge();
115
Jian Lie2d87512018-08-23 17:33:05 +0900116 log.info("simple fabric forwarding started");
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900117 }
118
119 @Deactivate
120 public void deactivate() {
Jian Lie2d87512018-08-23 17:33:05 +0900121 log.info("simple fabric forwarding stopping");
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900122
123 simpleFabric.removeListener(simpleFabricListener);
124
125 for (Intent intent : bctIntentsMap.values()) {
126 intentService.withdraw(intent);
127 toBePurgedIntentKeys.add(intent.key());
128 }
129 for (Intent intent : uniIntentsMap.values()) {
130 intentService.withdraw(intent);
131 toBePurgedIntentKeys.add(intent.key());
132 }
133 for (Key key : toBePurgedIntentKeys) {
134 Intent intentToPurge = intentService.getIntent(key);
135 if (intentToPurge != null) {
136 intentService.purge(intentToPurge);
137 }
138 }
139
140 // do not set clear for switch compatibility
141 //bctIntentsMap.clear();
142 //uniIntentsMap.clear();
143
Jian Lie2d87512018-08-23 17:33:05 +0900144 log.info("simple fabric forwarding stopped");
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900145 }
146
147 private void refresh() {
Jian Lie2d87512018-08-23 17:33:05 +0900148 log.debug("simple fabric forwarding refresh");
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900149
150 Map<Key, SinglePointToMultiPointIntent> newBctIntentsMap = Maps.newConcurrentMap();
151 Map<Key, MultiPointToSinglePointIntent> newUniIntentsMap = Maps.newConcurrentMap();
152
Jian Lie2d87512018-08-23 17:33:05 +0900153 for (FabricNetwork fabricNetwork : simpleFabric.fabricNetworks()) {
154 // scans all l2network regardless of isDirty flag
155 // if fabricNetwork.isForward == false or number of interfaces() < 2, no Intents generated
156 for (SinglePointToMultiPointIntent intent : buildBrcIntents(fabricNetwork)) {
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900157 newBctIntentsMap.put(intent.key(), intent);
158 }
Jian Lie2d87512018-08-23 17:33:05 +0900159 for (MultiPointToSinglePointIntent intent :
160 buildUniIntents(fabricNetwork, hostsFromL2Network(fabricNetwork))) {
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900161 newUniIntentsMap.put(intent.key(), intent);
162 }
Jian Lie2d87512018-08-23 17:33:05 +0900163 if (fabricNetwork.isDirty()) {
164 fabricNetwork.setDirty(false);
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900165 }
166 }
167
168 boolean bctUpdated = false;
169 for (SinglePointToMultiPointIntent intent : bctIntentsMap.values()) {
170 SinglePointToMultiPointIntent newIntent = newBctIntentsMap.get(intent.key());
171 if (newIntent == null) {
Jian Lie2d87512018-08-23 17:33:05 +0900172 log.info("simple fabric forwarding withdraw broadcast intent: {}",
173 intent.key().toString());
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900174 toBePurgedIntentKeys.add(intent.key());
175 intentService.withdraw(intent);
176 bctUpdated = true;
177 }
178 }
179 for (SinglePointToMultiPointIntent intent : newBctIntentsMap.values()) {
180 SinglePointToMultiPointIntent oldIntent = bctIntentsMap.get(intent.key());
181 if (oldIntent == null ||
182 !oldIntent.filteredEgressPoints().equals(intent.filteredEgressPoints()) ||
183 !oldIntent.filteredIngressPoint().equals(intent.filteredIngressPoint()) ||
184 !oldIntent.selector().equals(intent.selector()) ||
185 !oldIntent.treatment().equals(intent.treatment()) ||
186 !oldIntent.constraints().equals(intent.constraints())) {
Jian Lie2d87512018-08-23 17:33:05 +0900187 log.info("simple fabric forwarding submit broadcast intent: {}",
188 intent.key().toString());
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900189 toBePurgedIntentKeys.remove(intent.key());
190 intentService.submit(intent);
191 bctUpdated = true;
192 }
193 }
194
195 boolean uniUpdated = false;
196 for (MultiPointToSinglePointIntent intent : uniIntentsMap.values()) {
197 MultiPointToSinglePointIntent newIntent = newUniIntentsMap.get(intent.key());
198 if (newIntent == null) {
Jian Lie2d87512018-08-23 17:33:05 +0900199 log.info("simple fabric forwarding withdraw unicast intent: {}",
200 intent.key().toString());
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900201 toBePurgedIntentKeys.add(intent.key());
202 intentService.withdraw(intent);
203 uniUpdated = true;
204 }
205 }
206 for (MultiPointToSinglePointIntent intent : newUniIntentsMap.values()) {
207 MultiPointToSinglePointIntent oldIntent = uniIntentsMap.get(intent.key());
208 if (oldIntent == null ||
209 !oldIntent.filteredEgressPoint().equals(intent.filteredEgressPoint()) ||
210 !oldIntent.filteredIngressPoints().equals(intent.filteredIngressPoints()) ||
211 !oldIntent.selector().equals(intent.selector()) ||
212 !oldIntent.treatment().equals(intent.treatment()) ||
213 !oldIntent.constraints().equals(intent.constraints())) {
Jian Lie2d87512018-08-23 17:33:05 +0900214 log.info("simple fabric forwarding submit unicast intent: {}",
215 intent.key().toString());
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900216 toBePurgedIntentKeys.remove(intent.key());
217 intentService.submit(intent);
218 uniUpdated = true;
219 }
220 }
221
222 if (bctUpdated) {
223 bctIntentsMap = newBctIntentsMap;
224 }
225 if (uniUpdated) {
226 uniIntentsMap = newUniIntentsMap;
227 }
228 }
229
230 private void checkIntentsPurge() {
231 // check intents to be purge
232 if (!toBePurgedIntentKeys.isEmpty()) {
233 Set<Key> purgedKeys = new HashSet<>();
234 for (Key key : toBePurgedIntentKeys) {
235 Intent intentToPurge = intentService.getIntent(key);
236 if (intentToPurge == null) {
Jian Lie2d87512018-08-23 17:33:05 +0900237 log.info("simple fabric forwarding purged intent: key={}", key.toString());
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900238 purgedKeys.add(key);
239 } else {
240 switch (intentService.getIntentState(key)) {
241 case FAILED:
242 case WITHDRAWN:
Jian Lie2d87512018-08-23 17:33:05 +0900243 log.info("simple fabric forwarding try to purge intent: key={}",
244 key.toString());
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900245 intentService.purge(intentToPurge);
246 break;
247 case INSTALL_REQ:
248 case INSTALLED:
249 case INSTALLING:
250 case RECOMPILING:
251 case COMPILING:
Jian Lie2d87512018-08-23 17:33:05 +0900252 log.warn("simple fabric forwarding withdraw intent to purge: key={}", key);
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900253 intentService.withdraw(intentToPurge);
254 break;
255 case WITHDRAW_REQ:
256 case WITHDRAWING:
257 case PURGE_REQ:
258 case CORRUPT:
259 default:
260 // no action
261 break;
262 }
263 }
264 }
265 toBePurgedIntentKeys.removeAll(purgedKeys);
266 }
267 }
268
269 // Generates Unicast Intents and broadcast Intents for the L2 Network.
270
Jian Lie2d87512018-08-23 17:33:05 +0900271 private Set<Intent> generateL2NetworkIntents(FabricNetwork fabricNetwork) {
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900272 return new ImmutableSet.Builder<Intent>()
Jian Lie2d87512018-08-23 17:33:05 +0900273 .addAll(buildBrcIntents(fabricNetwork))
274 .addAll(buildUniIntents(fabricNetwork, hostsFromL2Network(fabricNetwork)))
Lee Yongjae6dc7e4f2017-12-06 16:17:51 +0900275 .build();
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900276 }
277
278 // Build Boadcast Intents for a L2 Network.
Jian Lie2d87512018-08-23 17:33:05 +0900279 private Set<SinglePointToMultiPointIntent> buildBrcIntents(FabricNetwork fabricNetwork) {
280 Set<Interface> interfaces = fabricNetwork.interfaces();
281 if (interfaces.size() < 2 || !fabricNetwork.isForward() || !fabricNetwork.isBroadcast()) {
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900282 return ImmutableSet.of();
283 }
284 Set<SinglePointToMultiPointIntent> brcIntents = Sets.newHashSet();
Jian Lie2d87512018-08-23 17:33:05 +0900285 ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900286
287 // Generates broadcast Intents from any network interface to other
288 // network interface from the L2 Network.
289 interfaces
290 .forEach(src -> {
291 FilteredConnectPoint srcFcp = buildFilteredConnectedPoint(src);
292 Set<FilteredConnectPoint> dstFcps = interfaces.stream()
293 .filter(iface -> !iface.equals(src))
294 .map(this::buildFilteredConnectedPoint)
295 .collect(Collectors.toSet());
Jian Lie2d87512018-08-23 17:33:05 +0900296 Key key = buildKey(fabricNetwork.name(), "BCAST",
297 srcFcp.connectPoint(), MacAddress.BROADCAST);
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900298 TrafficSelector selector = DefaultTrafficSelector.builder()
299 .matchEthDst(MacAddress.BROADCAST)
300 .build();
Jian Lie2d87512018-08-23 17:33:05 +0900301 SinglePointToMultiPointIntent.Builder
302 intentBuilder = SinglePointToMultiPointIntent.builder()
303 .appId(appId)
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900304 .key(key)
305 .selector(selector)
306 .filteredIngressPoint(srcFcp)
307 .filteredEgressPoints(dstFcps)
Jian Lie2d87512018-08-23 17:33:05 +0900308 .constraints(buildConstraints(L2NETWORK_CONSTRAINTS,
309 fabricNetwork.encapsulation()))
Jian Li8df54a92018-08-23 17:01:31 +0900310 .priority(PRI_L2NETWORK_BROADCAST)
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900311 .resourceGroup(resourceGroup);
312 brcIntents.add(intentBuilder.build());
313 });
314 return brcIntents;
315 }
316
317 // Builds unicast Intents for a L2 Network.
Jian Lie2d87512018-08-23 17:33:05 +0900318 private Set<MultiPointToSinglePointIntent> buildUniIntents(FabricNetwork fabricNetwork,
319 Set<Host> hosts) {
320 Set<Interface> interfaces = fabricNetwork.interfaces();
321 if (!fabricNetwork.isForward() || interfaces.size() < 2) {
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900322 return ImmutableSet.of();
323 }
324 Set<MultiPointToSinglePointIntent> uniIntents = Sets.newHashSet();
Jian Lie2d87512018-08-23 17:33:05 +0900325 ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900326 hosts.forEach(host -> {
327 FilteredConnectPoint hostFcp = buildFilteredConnectedPoint(host);
328 Set<FilteredConnectPoint> srcFcps = interfaces.stream()
329 .map(this::buildFilteredConnectedPoint)
330 .filter(fcp -> !fcp.equals(hostFcp))
331 .collect(Collectors.toSet());
Jian Lie2d87512018-08-23 17:33:05 +0900332 Key key = buildKey(fabricNetwork.name(), "UNI", hostFcp.connectPoint(), host.mac());
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900333 TrafficSelector selector = DefaultTrafficSelector.builder()
334 .matchEthDst(host.mac()).build();
Jian Lie2d87512018-08-23 17:33:05 +0900335 MultiPointToSinglePointIntent.Builder
336 intentBuilder = MultiPointToSinglePointIntent.builder()
337 .appId(appId)
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900338 .key(key)
339 .selector(selector)
340 .filteredIngressPoints(srcFcps)
341 .filteredEgressPoint(hostFcp)
Jian Lie2d87512018-08-23 17:33:05 +0900342 .constraints(buildConstraints(L2NETWORK_CONSTRAINTS,
343 fabricNetwork.encapsulation()))
Jian Li8df54a92018-08-23 17:01:31 +0900344 .priority(PRI_L2NETWORK_UNICAST)
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900345 .resourceGroup(resourceGroup);
346 uniIntents.add(intentBuilder.build());
347 });
348
349 return uniIntents;
350 }
351
352 // Intent generate utilities
353
Jian Lie2d87512018-08-23 17:33:05 +0900354 private Set<Host> hostsFromL2Network(FabricNetwork fabricNetwork) {
355 Set<Interface> interfaces = fabricNetwork.interfaces();
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900356 return interfaces.stream()
357 .map(this::hostsFromInterface)
358 .flatMap(Collection::stream)
359 .collect(Collectors.toSet());
360 }
361
362 private Set<Host> hostsFromInterface(Interface iface) {
363 return hostService.getConnectedHosts(iface.connectPoint())
364 .stream()
365 .filter(host -> host.vlan().equals(iface.vlan()))
366 .collect(Collectors.toSet());
367 }
368
Jian Lie2d87512018-08-23 17:33:05 +0900369 private Key buildKey(String l2NetworkName, String type,
370 ConnectPoint cPoint, MacAddress dstMac) {
371 return Key.of(l2NetworkName + "-" + type + "-" +
372 cPoint.toString() + "-" + dstMac, appId);
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900373 }
374
Jian Lie2d87512018-08-23 17:33:05 +0900375 private List<Constraint> buildConstraints(List<Constraint> constraints,
376 EncapsulationType encapsulation) {
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900377 if (!encapsulation.equals(EncapsulationType.NONE)) {
378 List<Constraint> newConstraints = new ArrayList<>(constraints);
379 constraints.stream()
380 .filter(c -> c instanceof EncapsulationConstraint)
381 .forEach(newConstraints::remove);
382 newConstraints.add(new EncapsulationConstraint(encapsulation));
383 return ImmutableList.copyOf(newConstraints);
384 }
385 return constraints;
386 }
387
388 private FilteredConnectPoint buildFilteredConnectedPoint(Interface iface) {
389 Objects.requireNonNull(iface);
390 TrafficSelector.Builder trafficSelector = DefaultTrafficSelector.builder();
391
392 if (iface.vlan() != null && !iface.vlan().equals(VlanId.NONE)) {
393 trafficSelector.matchVlanId(iface.vlan());
394 }
395 return new FilteredConnectPoint(iface.connectPoint(), trafficSelector.build());
396 }
397
398 protected FilteredConnectPoint buildFilteredConnectedPoint(Host host) {
399 Objects.requireNonNull(host);
400 TrafficSelector.Builder trafficSelector = DefaultTrafficSelector.builder();
401
402 if (host.vlan() != null && !host.vlan().equals(VlanId.NONE)) {
403 trafficSelector.matchVlanId(host.vlan());
404 }
405 return new FilteredConnectPoint(host.location(), trafficSelector.build());
406 }
407
408 // Dump command handler
409 private void dump(String subject, PrintStream out) {
Ray Milkey2ff67162018-01-22 10:14:19 -0800410 if ("intents".equals(subject)) {
Jian Lie2d87512018-08-23 17:33:05 +0900411 out.println("Forwarding Broadcast Intents:\n");
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900412 for (SinglePointToMultiPointIntent intent: bctIntentsMap.values()) {
413 out.println(" " + intent.key().toString()
414 + ": " + intent.selector().criteria()
415 + ", [" + intent.filteredIngressPoint().connectPoint()
416 + "] -> " + intent.filteredEgressPoints().stream()
Jian Lie2d87512018-08-23 17:33:05 +0900417 .map(FilteredConnectPoint::connectPoint)
418 .collect(Collectors.toSet()));
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900419 }
420 out.println("");
Jian Lie2d87512018-08-23 17:33:05 +0900421 out.println("Forwarding Unicast Intents:\n");
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900422 for (MultiPointToSinglePointIntent intent: uniIntentsMap.values()) {
423 out.println(" " + intent.key().toString()
424 + ": " + intent.selector().criteria()
425 + ", [" + intent.filteredIngressPoints().stream()
Jian Lie2d87512018-08-23 17:33:05 +0900426 .map(FilteredConnectPoint::connectPoint)
427 .collect(Collectors.toSet())
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900428 + "] -> " + intent.filteredEgressPoint().connectPoint());
429 }
430 out.println("");
Jian Lie2d87512018-08-23 17:33:05 +0900431 out.println("Forwarding Intents to Be Purged:\n");
Lee Yongjae7c27bb42017-11-17 12:00:45 +0900432 for (Key key: toBePurgedIntentKeys) {
433 out.println(" " + key.toString());
434 }
435 out.println("");
436 }
437 }
438
439 // Listener
440 private class InternalSimpleFabricListener implements SimpleFabricListener {
441 @Override
442 public void event(SimpleFabricEvent event) {
443 switch (event.type()) {
444 case SIMPLE_FABRIC_UPDATED:
445 refresh();
446 checkIntentsPurge();
447 break;
448 case SIMPLE_FABRIC_IDLE:
449 refresh();
450 checkIntentsPurge();
451 break;
452 case SIMPLE_FABRIC_DUMP:
453 dump(event.subject(), event.out());
454 break;
455 default:
456 // NOTE: nothing to do on SIMPLE_FABRIC_FLUSH
457 break;
458 }
459 }
460 }
461
462}