Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -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 | |
| 18 | package org.onosproject.net.edgeservice.impl; |
| 19 | |
| 20 | import com.google.common.collect.ImmutableSet; |
| 21 | import com.google.common.collect.Maps; |
| 22 | import com.google.common.collect.Sets; |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 23 | import org.onosproject.event.AbstractListenerManager; |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 24 | import org.onosproject.net.ConnectPoint; |
| 25 | import org.onosproject.net.DeviceId; |
Yuta HIGUCHI | b440ef4 | 2016-07-15 09:09:09 -0700 | [diff] [blame] | 26 | import org.onosproject.net.Link.Type; |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 27 | import org.onosproject.net.device.DeviceEvent; |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 28 | import org.onosproject.net.device.DeviceListener; |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 29 | import org.onosproject.net.device.DeviceService; |
| 30 | import org.onosproject.net.edge.EdgePortEvent; |
| 31 | import org.onosproject.net.edge.EdgePortListener; |
| 32 | import org.onosproject.net.edge.EdgePortService; |
| 33 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
| 34 | import org.onosproject.net.flow.TrafficTreatment; |
| 35 | import org.onosproject.net.link.LinkEvent; |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 36 | import org.onosproject.net.link.LinkListener; |
| 37 | import org.onosproject.net.link.LinkService; |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 38 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 39 | import org.onosproject.net.packet.OutboundPacket; |
| 40 | import org.onosproject.net.packet.PacketService; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 41 | import org.osgi.service.component.annotations.Activate; |
| 42 | import org.osgi.service.component.annotations.Component; |
| 43 | import org.osgi.service.component.annotations.Deactivate; |
| 44 | import org.osgi.service.component.annotations.Reference; |
| 45 | import org.osgi.service.component.annotations.ReferenceCardinality; |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 46 | import org.slf4j.Logger; |
| 47 | |
| 48 | import java.nio.ByteBuffer; |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 49 | import java.util.Map; |
| 50 | import java.util.Optional; |
| 51 | import java.util.Set; |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 52 | |
| 53 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED; |
| 54 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED; |
| 55 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED; |
| 56 | import static org.onosproject.net.device.DeviceEvent.Type.PORT_STATS_UPDATED; |
| 57 | import static org.onosproject.net.device.DeviceEvent.Type.PORT_UPDATED; |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 58 | import static org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_ADDED; |
| 59 | import static org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_REMOVED; |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 60 | import static org.onosproject.security.AppGuard.checkPermission; |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 61 | import static org.onosproject.security.AppPermission.Type.PACKET_WRITE; |
| 62 | import static org.onosproject.security.AppPermission.Type.TOPOLOGY_READ; |
| 63 | import static org.slf4j.LoggerFactory.getLogger; |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * This is an implementation of the edge net service. |
| 67 | */ |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 68 | @Component(immediate = true, service = EdgePortService.class) |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 69 | public class EdgeManager |
| 70 | extends AbstractListenerManager<EdgePortEvent, EdgePortListener> |
| 71 | implements EdgePortService { |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 72 | |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 73 | private final Logger log = getLogger(getClass()); |
| 74 | |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 75 | // Set of edge ConnectPoints per Device. |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 76 | private final Map<DeviceId, Set<ConnectPoint>> connectionPoints = Maps.newConcurrentMap(); |
| 77 | |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 78 | private final DeviceListener deviceListener = new InnerDeviceListener(); |
| 79 | private final LinkListener linkListener = new InnerLinkListener(); |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 80 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 81 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 82 | protected PacketService packetService; |
| 83 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 84 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 85 | protected DeviceService deviceService; |
| 86 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 87 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 88 | protected LinkService linkService; |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 89 | |
| 90 | @Activate |
| 91 | public void activate() { |
| 92 | eventDispatcher.addSink(EdgePortEvent.class, listenerRegistry); |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 93 | deviceService.addListener(deviceListener); |
| 94 | linkService.addListener(linkListener); |
alshabib | 8a4a600 | 2015-11-25 14:31:16 -0800 | [diff] [blame] | 95 | loadAllEdgePorts(); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 96 | log.info("Started"); |
| 97 | } |
| 98 | |
| 99 | @Deactivate |
| 100 | public void deactivate() { |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 101 | deviceService.removeListener(deviceListener); |
| 102 | linkService.removeListener(linkListener); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 103 | eventDispatcher.removeSink(EdgePortEvent.class); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 104 | log.info("Stopped"); |
| 105 | } |
| 106 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 107 | @Override |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 108 | public boolean isEdgePoint(ConnectPoint point) { |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 109 | checkPermission(TOPOLOGY_READ); |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 110 | Set<ConnectPoint> connectPoints = connectionPoints.get(point.deviceId()); |
| 111 | return connectPoints != null && connectPoints.contains(point); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 114 | @Override |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 115 | public Iterable<ConnectPoint> getEdgePoints() { |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 116 | checkPermission(TOPOLOGY_READ); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 117 | ImmutableSet.Builder<ConnectPoint> builder = ImmutableSet.builder(); |
| 118 | connectionPoints.forEach((k, v) -> v.forEach(builder::add)); |
| 119 | return builder.build(); |
| 120 | } |
| 121 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 122 | @Override |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 123 | public Iterable<ConnectPoint> getEdgePoints(DeviceId deviceId) { |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 124 | checkPermission(TOPOLOGY_READ); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 125 | ImmutableSet.Builder<ConnectPoint> builder = ImmutableSet.builder(); |
| 126 | Set<ConnectPoint> set = connectionPoints.get(deviceId); |
| 127 | if (set != null) { |
| 128 | set.forEach(builder::add); |
| 129 | } |
| 130 | return builder.build(); |
| 131 | } |
| 132 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 133 | @Override |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 134 | public void emitPacket(ByteBuffer data, Optional<TrafficTreatment> treatment) { |
Heedo Kang | 4a47a30 | 2016-02-29 17:40:23 +0900 | [diff] [blame] | 135 | checkPermission(PACKET_WRITE); |
Sho SHIMIZU | ef7e290 | 2016-02-12 18:38:29 -0800 | [diff] [blame] | 136 | TrafficTreatment.Builder builder = treatment.map(DefaultTrafficTreatment::builder) |
| 137 | .orElse(DefaultTrafficTreatment.builder()); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 138 | getEdgePoints().forEach(p -> packetService.emit(packet(builder, p, data))); |
| 139 | } |
| 140 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 141 | @Override |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 142 | public void emitPacket(DeviceId deviceId, ByteBuffer data, |
| 143 | Optional<TrafficTreatment> treatment) { |
Sho SHIMIZU | ef7e290 | 2016-02-12 18:38:29 -0800 | [diff] [blame] | 144 | TrafficTreatment.Builder builder = treatment.map(DefaultTrafficTreatment::builder) |
| 145 | .orElse(DefaultTrafficTreatment.builder()); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 146 | getEdgePoints(deviceId).forEach(p -> packetService.emit(packet(builder, p, data))); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | private OutboundPacket packet(TrafficTreatment.Builder builder, ConnectPoint point, ByteBuffer data) { |
| 150 | builder.setOutput(point.port()); |
| 151 | return new DefaultOutboundPacket(point.deviceId(), builder.build(), data); |
| 152 | } |
| 153 | |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 154 | private class InnerLinkListener implements LinkListener { |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 155 | @Override |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 156 | public void event(LinkEvent event) { |
| 157 | processLinkEvent(event); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | private class InnerDeviceListener implements DeviceListener { |
| 162 | @Override |
| 163 | public void event(DeviceEvent event) { |
| 164 | if (event.type() == PORT_STATS_UPDATED) { |
| 165 | return; |
| 166 | } |
| 167 | processDeviceEvent(event); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 171 | // Initial loading of the edge port cache. |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 172 | private void loadAllEdgePorts() { |
Thomas Vachuska | f3ed655 | 2015-06-29 13:56:03 -0700 | [diff] [blame] | 173 | deviceService.getAvailableDevices().forEach(d -> deviceService.getPorts(d.id()) |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 174 | .forEach(p -> addEdgePort(new ConnectPoint(d.id(), p.number())))); |
| 175 | } |
| 176 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 177 | // Processes a link event by adding or removing its end-points in our cache. |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 178 | private void processLinkEvent(LinkEvent event) { |
Yuta HIGUCHI | b440ef4 | 2016-07-15 09:09:09 -0700 | [diff] [blame] | 179 | // negative Link event can result in increase of edge ports |
| 180 | boolean addEdgePort = event.type() == LinkEvent.Type.LINK_REMOVED; |
| 181 | |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 182 | // but if the Link is an Edge type, it will be the opposite |
Yuta HIGUCHI | b440ef4 | 2016-07-15 09:09:09 -0700 | [diff] [blame] | 183 | if (event.subject().type() == Type.EDGE) { |
| 184 | addEdgePort = !addEdgePort; |
| 185 | } |
| 186 | |
| 187 | if (addEdgePort) { |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 188 | addEdgePort(event.subject().src()); |
| 189 | addEdgePort(event.subject().dst()); |
Yuta HIGUCHI | b440ef4 | 2016-07-15 09:09:09 -0700 | [diff] [blame] | 190 | } else { |
| 191 | removeEdgePort(event.subject().src()); |
| 192 | removeEdgePort(event.subject().dst()); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 193 | } |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 194 | } |
| 195 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 196 | // Processes a device event by adding or removing its end-points in our cache. |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 197 | private void processDeviceEvent(DeviceEvent event) { |
Aaron Kruglikov | d812383 | 2015-07-06 14:20:25 -0700 | [diff] [blame] | 198 | //FIXME handle the case where a device is suspended, this may or may not come up |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 199 | DeviceEvent.Type type = event.type(); |
| 200 | DeviceId id = event.subject().id(); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 201 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 202 | if (type == DEVICE_ADDED || |
| 203 | type == DEVICE_AVAILABILITY_CHANGED && deviceService.isAvailable(id)) { |
| 204 | // When device is added or becomes available, add all its ports |
| 205 | deviceService.getPorts(event.subject().id()) |
| 206 | .forEach(p -> addEdgePort(new ConnectPoint(id, p.number()))); |
| 207 | } else if (type == DEVICE_REMOVED || |
| 208 | type == DEVICE_AVAILABILITY_CHANGED && !deviceService.isAvailable(id)) { |
Yuta HIGUCHI | b440ef4 | 2016-07-15 09:09:09 -0700 | [diff] [blame] | 209 | // When device is removed or becomes unavailable, remove all its ports. |
| 210 | // Note: cannot rely on Device subsystem, ports may be gone. |
| 211 | Optional.ofNullable(connectionPoints.remove(id)) |
| 212 | .orElse(ImmutableSet.of()) |
| 213 | .forEach(point -> post(new EdgePortEvent(EDGE_PORT_REMOVED, point))); |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 214 | |
| 215 | } else if (type == DeviceEvent.Type.PORT_ADDED || |
| 216 | type == PORT_UPDATED && event.port().isEnabled()) { |
| 217 | addEdgePort(new ConnectPoint(id, event.port().number())); |
| 218 | } else if (type == DeviceEvent.Type.PORT_REMOVED || |
| 219 | type == PORT_UPDATED && !event.port().isEnabled()) { |
| 220 | removeEdgePort(new ConnectPoint(id, event.port().number())); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 221 | } |
| 222 | } |
| 223 | |
Yuta HIGUCHI | b440ef4 | 2016-07-15 09:09:09 -0700 | [diff] [blame] | 224 | private boolean isEdgePort(ConnectPoint point) { |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 225 | // Logical ports are not counted as edge ports nor are infrastructure |
| 226 | // ports. Ports that have only edge links are considered edge ports. |
| 227 | return !point.port().isLogical() && |
Yuta HIGUCHI | 37dca33 | 2016-11-14 18:43:22 -0800 | [diff] [blame] | 228 | deviceService.getPort(point) != null && |
Jonathan Hart | 6ff6ffe | 2016-09-09 11:55:50 -0700 | [diff] [blame] | 229 | linkService.getLinks(point).stream() |
| 230 | .allMatch(link -> link.type() == Type.EDGE); |
Yuta HIGUCHI | b440ef4 | 2016-07-15 09:09:09 -0700 | [diff] [blame] | 231 | } |
| 232 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 233 | // Adds the specified connection point to the edge points if needed. |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 234 | private void addEdgePort(ConnectPoint point) { |
Yuta HIGUCHI | b440ef4 | 2016-07-15 09:09:09 -0700 | [diff] [blame] | 235 | if (isEdgePort(point)) { |
| 236 | Set<ConnectPoint> set = connectionPoints.computeIfAbsent(point.deviceId(), |
| 237 | (k) -> Sets.newConcurrentHashSet()); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 238 | if (set.add(point)) { |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 239 | post(new EdgePortEvent(EDGE_PORT_ADDED, point)); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 240 | } |
| 241 | } |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 242 | } |
| 243 | |
Thomas Vachuska | 8502192 | 2015-06-29 13:29:42 -0700 | [diff] [blame] | 244 | // Removes the specified connection point from the edge points. |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 245 | private void removeEdgePort(ConnectPoint point) { |
Yuta HIGUCHI | 0b5b82e | 2016-07-21 07:54:19 -0700 | [diff] [blame] | 246 | // trying to remove edge ports, so we shouldn't check if it's EdgePoint |
| 247 | if (!point.port().isLogical()) { |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 248 | Set<ConnectPoint> set = connectionPoints.get(point.deviceId()); |
| 249 | if (set == null) { |
| 250 | return; |
| 251 | } |
| 252 | if (set.remove(point)) { |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 253 | post(new EdgePortEvent(EDGE_PORT_REMOVED, point)); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 254 | } |
| 255 | if (set.isEmpty()) { |
Yuta HIGUCHI | b440ef4 | 2016-07-15 09:09:09 -0700 | [diff] [blame] | 256 | connectionPoints.computeIfPresent(point.deviceId(), (k, v) -> { |
| 257 | if (v.isEmpty()) { |
Yuta HIGUCHI | 0b5b82e | 2016-07-21 07:54:19 -0700 | [diff] [blame] | 258 | return null; |
Yuta HIGUCHI | b440ef4 | 2016-07-15 09:09:09 -0700 | [diff] [blame] | 259 | } else { |
| 260 | return v; |
| 261 | } |
| 262 | }); |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 263 | } |
| 264 | } |
Aaron Kruglikov | a2b5915 | 2015-06-24 14:01:41 -0700 | [diff] [blame] | 265 | } |
| 266 | } |