tom | ea961ff | 2014-10-01 12:45:15 -0700 | [diff] [blame] | 1 | package org.onlab.onos.store.trivial.impl; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 2 | |
Yuta HIGUCHI | f547970 | 2014-09-25 00:09:24 -0700 | [diff] [blame] | 3 | import com.google.common.collect.FluentIterable; |
tom | 46a220d | 2014-09-05 08:25:56 -0700 | [diff] [blame] | 4 | import com.google.common.collect.ImmutableList; |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 5 | import com.google.common.collect.Maps; |
| 6 | import com.google.common.collect.Sets; |
Yuta HIGUCHI | f547970 | 2014-09-25 00:09:24 -0700 | [diff] [blame] | 7 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 8 | import org.apache.commons.lang3.concurrent.ConcurrentException; |
| 9 | import org.apache.commons.lang3.concurrent.ConcurrentInitializer; |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 10 | import org.apache.felix.scr.annotations.Activate; |
| 11 | import org.apache.felix.scr.annotations.Component; |
| 12 | import org.apache.felix.scr.annotations.Deactivate; |
| 13 | import org.apache.felix.scr.annotations.Service; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 14 | import org.onlab.onos.net.AnnotationsUtil; |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 15 | import org.onlab.onos.net.DefaultAnnotations; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 16 | import org.onlab.onos.net.DefaultDevice; |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 17 | import org.onlab.onos.net.DefaultPort; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 18 | import org.onlab.onos.net.Device; |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 19 | import org.onlab.onos.net.Device.Type; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 20 | import org.onlab.onos.net.DeviceId; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 21 | import org.onlab.onos.net.Port; |
| 22 | import org.onlab.onos.net.PortNumber; |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 23 | import org.onlab.onos.net.SparseAnnotations; |
| 24 | import org.onlab.onos.net.device.DefaultDeviceDescription; |
| 25 | import org.onlab.onos.net.device.DefaultPortDescription; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 26 | import org.onlab.onos.net.device.DeviceDescription; |
| 27 | import org.onlab.onos.net.device.DeviceEvent; |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 28 | import org.onlab.onos.net.device.DeviceStore; |
tom | f80c972 | 2014-09-24 14:49:18 -0700 | [diff] [blame] | 29 | import org.onlab.onos.net.device.DeviceStoreDelegate; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 30 | import org.onlab.onos.net.device.PortDescription; |
| 31 | import org.onlab.onos.net.provider.ProviderId; |
tom | f80c972 | 2014-09-24 14:49:18 -0700 | [diff] [blame] | 32 | import org.onlab.onos.store.AbstractStore; |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame^] | 33 | import org.onlab.packet.ChassisId; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 34 | import org.onlab.util.NewConcurrentHashMap; |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 35 | import org.slf4j.Logger; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 36 | |
| 37 | import java.util.ArrayList; |
| 38 | import java.util.Collections; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 39 | import java.util.HashSet; |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 40 | import java.util.Iterator; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 41 | import java.util.List; |
| 42 | import java.util.Map; |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 43 | import java.util.Map.Entry; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 44 | import java.util.Objects; |
| 45 | import java.util.Set; |
| 46 | import java.util.concurrent.ConcurrentHashMap; |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 47 | import java.util.concurrent.ConcurrentMap; |
| 48 | import java.util.concurrent.atomic.AtomicReference; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 49 | |
| 50 | import static com.google.common.base.Preconditions.checkArgument; |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 51 | import static com.google.common.base.Preconditions.checkNotNull; |
Yuta HIGUCHI | f547970 | 2014-09-25 00:09:24 -0700 | [diff] [blame] | 52 | import static com.google.common.base.Predicates.notNull; |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 53 | import static com.google.common.base.Verify.verify; |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 54 | import static org.onlab.onos.net.device.DeviceEvent.Type.*; |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 55 | import static org.slf4j.LoggerFactory.getLogger; |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 56 | import static org.apache.commons.lang3.concurrent.ConcurrentUtils.createIfAbsentUnchecked; |
Yuta HIGUCHI | 885be1d | 2014-10-04 21:47:26 -0700 | [diff] [blame] | 57 | import static org.onlab.onos.net.DefaultAnnotations.union; |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 58 | import static org.onlab.onos.net.DefaultAnnotations.merge; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 61 | * Manages inventory of infrastructure devices using trivial in-memory |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 62 | * structures implementation. |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 63 | */ |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 64 | @Component(immediate = true) |
| 65 | @Service |
tom | f80c972 | 2014-09-24 14:49:18 -0700 | [diff] [blame] | 66 | public class SimpleDeviceStore |
| 67 | extends AbstractStore<DeviceEvent, DeviceStoreDelegate> |
| 68 | implements DeviceStore { |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 69 | |
| 70 | private final Logger log = getLogger(getClass()); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 71 | |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 72 | public static final String DEVICE_NOT_FOUND = "Device with ID %s not found"; |
| 73 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 74 | // collection of Description given from various providers |
| 75 | private final ConcurrentMap<DeviceId, |
| 76 | ConcurrentMap<ProviderId, DeviceDescriptions>> |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 77 | deviceDescs = Maps.newConcurrentMap(); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 78 | |
| 79 | // cache of Device and Ports generated by compositing descriptions from providers |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 80 | private final ConcurrentMap<DeviceId, Device> devices = Maps.newConcurrentMap(); |
| 81 | private final ConcurrentMap<DeviceId, ConcurrentMap<PortNumber, Port>> devicePorts = Maps.newConcurrentMap(); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 82 | |
| 83 | // available(=UP) devices |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 84 | private final Set<DeviceId> availableDevices = Sets.newConcurrentHashSet(); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 85 | |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 86 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 87 | @Activate |
| 88 | public void activate() { |
| 89 | log.info("Started"); |
| 90 | } |
| 91 | |
| 92 | @Deactivate |
| 93 | public void deactivate() { |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 94 | deviceDescs.clear(); |
| 95 | devices.clear(); |
| 96 | devicePorts.clear(); |
| 97 | availableDevices.clear(); |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 98 | log.info("Stopped"); |
| 99 | } |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 100 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 101 | @Override |
| 102 | public int getDeviceCount() { |
tom | ad2d209 | 2014-09-06 23:24:20 -0700 | [diff] [blame] | 103 | return devices.size(); |
| 104 | } |
| 105 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 106 | @Override |
| 107 | public Iterable<Device> getDevices() { |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 108 | return Collections.unmodifiableCollection(devices.values()); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 109 | } |
| 110 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 111 | @Override |
| 112 | public Device getDevice(DeviceId deviceId) { |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 113 | return devices.get(deviceId); |
| 114 | } |
| 115 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 116 | @Override |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 117 | public DeviceEvent createOrUpdateDevice(ProviderId providerId, |
| 118 | DeviceId deviceId, |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 119 | DeviceDescription deviceDescription) { |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 120 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 121 | ConcurrentMap<ProviderId, DeviceDescriptions> providerDescs |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 122 | = getDeviceDescriptions(deviceId); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 123 | |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 124 | synchronized (providerDescs) { |
| 125 | // locking per device |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 126 | |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 127 | DeviceDescriptions descs |
| 128 | = createIfAbsentUnchecked(providerDescs, providerId, |
| 129 | new InitDeviceDescs(deviceDescription)); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 130 | |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 131 | Device oldDevice = devices.get(deviceId); |
| 132 | // update description |
| 133 | descs.putDeviceDesc(deviceDescription); |
| 134 | Device newDevice = composeDevice(deviceId, providerDescs); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 135 | |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 136 | if (oldDevice == null) { |
| 137 | // ADD |
| 138 | return createDevice(providerId, newDevice); |
| 139 | } else { |
| 140 | // UPDATE or ignore (no change or stale) |
| 141 | return updateDevice(providerId, oldDevice, newDevice); |
| 142 | } |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 143 | } |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | // Creates the device and returns the appropriate event if necessary. |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 147 | // Guarded by deviceDescs value (=Device lock) |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 148 | private DeviceEvent createDevice(ProviderId providerId, Device newDevice) { |
| 149 | |
| 150 | // update composed device cache |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 151 | Device oldDevice = devices.putIfAbsent(newDevice.id(), newDevice); |
| 152 | verify(oldDevice == null, |
| 153 | "Unexpected Device in cache. PID:%s [old=%s, new=%s]", |
| 154 | providerId, oldDevice, newDevice); |
| 155 | |
| 156 | if (!providerId.isAncillary()) { |
| 157 | availableDevices.add(newDevice.id()); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 158 | } |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 159 | |
| 160 | return new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, newDevice, null); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | // Updates the device and returns the appropriate event if necessary. |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 164 | // Guarded by deviceDescs value (=Device lock) |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 165 | private DeviceEvent updateDevice(ProviderId providerId, Device oldDevice, Device newDevice) { |
| 166 | |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 167 | // We allow only certain attributes to trigger update |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 168 | if (!Objects.equals(oldDevice.hwVersion(), newDevice.hwVersion()) || |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 169 | !Objects.equals(oldDevice.swVersion(), newDevice.swVersion()) || |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 170 | !AnnotationsUtil.isEqual(oldDevice.annotations(), newDevice.annotations())) { |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 171 | |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 172 | boolean replaced = devices.replace(newDevice.id(), oldDevice, newDevice); |
| 173 | if (!replaced) { |
| 174 | verify(replaced, |
| 175 | "Replacing devices cache failed. PID:%s [expected:%s, found:%s, new=%s]", |
| 176 | providerId, oldDevice, devices.get(newDevice.id()) |
| 177 | , newDevice); |
| 178 | } |
| 179 | if (!providerId.isAncillary()) { |
| 180 | availableDevices.add(newDevice.id()); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 181 | } |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 182 | return new DeviceEvent(DeviceEvent.Type.DEVICE_UPDATED, newDevice, null); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 185 | // Otherwise merely attempt to change availability if primary provider |
| 186 | if (!providerId.isAncillary()) { |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 187 | boolean added = availableDevices.add(newDevice.id()); |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 188 | return !added ? null : |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 189 | new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, newDevice, null); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 190 | } |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 191 | return null; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 192 | } |
| 193 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 194 | @Override |
| 195 | public DeviceEvent markOffline(DeviceId deviceId) { |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 196 | ConcurrentMap<ProviderId, DeviceDescriptions> providerDescs |
| 197 | = getDeviceDescriptions(deviceId); |
| 198 | |
| 199 | // locking device |
| 200 | synchronized (providerDescs) { |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 201 | Device device = devices.get(deviceId); |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 202 | if (device == null) { |
| 203 | return null; |
| 204 | } |
| 205 | boolean removed = availableDevices.remove(deviceId); |
| 206 | if (removed) { |
| 207 | // TODO: broadcast ... DOWN only? |
| 208 | return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device, null); |
| 209 | } |
| 210 | return null; |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 211 | } |
| 212 | } |
| 213 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 214 | @Override |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 215 | public List<DeviceEvent> updatePorts(ProviderId providerId, |
| 216 | DeviceId deviceId, |
| 217 | List<PortDescription> portDescriptions) { |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 218 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 219 | Device device = devices.get(deviceId); |
| 220 | checkArgument(device != null, DEVICE_NOT_FOUND, deviceId); |
| 221 | |
| 222 | ConcurrentMap<ProviderId, DeviceDescriptions> descsMap = deviceDescs.get(deviceId); |
| 223 | checkArgument(descsMap != null, DEVICE_NOT_FOUND, deviceId); |
| 224 | |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 225 | List<DeviceEvent> events = new ArrayList<>(); |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 226 | synchronized (descsMap) { |
| 227 | DeviceDescriptions descs = descsMap.get(providerId); |
| 228 | // every provider must provide DeviceDescription. |
| 229 | checkArgument(descs != null, |
| 230 | "Device description for Device ID %s from Provider %s was not found", |
| 231 | deviceId, providerId); |
| 232 | |
| 233 | Map<PortNumber, Port> ports = getPortMap(deviceId); |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 234 | |
| 235 | // Add new ports |
| 236 | Set<PortNumber> processed = new HashSet<>(); |
| 237 | for (PortDescription portDescription : portDescriptions) { |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 238 | final PortNumber number = portDescription.portNumber(); |
| 239 | processed.add(portDescription.portNumber()); |
| 240 | |
| 241 | final Port oldPort = ports.get(number); |
| 242 | final Port newPort; |
| 243 | |
| 244 | // event suppression hook? |
| 245 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 246 | // update description |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 247 | descs.putPortDesc(portDescription); |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 248 | newPort = composePort(device, number, descsMap); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 249 | |
| 250 | events.add(oldPort == null ? |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 251 | createPort(device, newPort, ports) : |
| 252 | updatePort(device, oldPort, newPort, ports)); |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | events.addAll(pruneOldPorts(device, ports, processed)); |
| 256 | } |
Yuta HIGUCHI | f547970 | 2014-09-25 00:09:24 -0700 | [diff] [blame] | 257 | return FluentIterable.from(events).filter(notNull()).toList(); |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | // Creates a new port based on the port description adds it to the map and |
| 261 | // Returns corresponding event. |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 262 | // Guarded by deviceDescs value (=Device lock) |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 263 | private DeviceEvent createPort(Device device, Port newPort, |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 264 | Map<PortNumber, Port> ports) { |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 265 | ports.put(newPort.number(), newPort); |
| 266 | return new DeviceEvent(PORT_ADDED, device, newPort); |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 269 | // Checks if the specified port requires update and if so, it replaces the |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 270 | // existing entry in the map and returns corresponding event. |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 271 | // Guarded by deviceDescs value (=Device lock) |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 272 | private DeviceEvent updatePort(Device device, Port oldPort, |
| 273 | Port newPort, |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 274 | Map<PortNumber, Port> ports) { |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 275 | if (oldPort.isEnabled() != newPort.isEnabled() || |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 276 | !AnnotationsUtil.isEqual(oldPort.annotations(), newPort.annotations())) { |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 277 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 278 | ports.put(oldPort.number(), newPort); |
| 279 | return new DeviceEvent(PORT_UPDATED, device, newPort); |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 280 | } |
| 281 | return null; |
| 282 | } |
| 283 | |
| 284 | // Prunes the specified list of ports based on which ports are in the |
| 285 | // processed list and returns list of corresponding events. |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 286 | // Guarded by deviceDescs value (=Device lock) |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 287 | private List<DeviceEvent> pruneOldPorts(Device device, |
| 288 | Map<PortNumber, Port> ports, |
| 289 | Set<PortNumber> processed) { |
| 290 | List<DeviceEvent> events = new ArrayList<>(); |
| 291 | Iterator<PortNumber> iterator = ports.keySet().iterator(); |
| 292 | while (iterator.hasNext()) { |
| 293 | PortNumber portNumber = iterator.next(); |
tom | 24c55cd | 2014-09-06 10:47:25 -0700 | [diff] [blame] | 294 | if (!processed.contains(portNumber)) { |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 295 | events.add(new DeviceEvent(PORT_REMOVED, device, |
| 296 | ports.get(portNumber))); |
| 297 | iterator.remove(); |
| 298 | } |
| 299 | } |
| 300 | return events; |
| 301 | } |
| 302 | |
| 303 | // Gets the map of ports for the specified device; if one does not already |
| 304 | // exist, it creates and registers a new one. |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 305 | private ConcurrentMap<PortNumber, Port> getPortMap(DeviceId deviceId) { |
| 306 | return createIfAbsentUnchecked(devicePorts, deviceId, |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 307 | NewConcurrentHashMap.<PortNumber, Port>ifNeeded()); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 310 | private ConcurrentMap<ProviderId, DeviceDescriptions> getDeviceDescriptions( |
| 311 | DeviceId deviceId) { |
| 312 | return createIfAbsentUnchecked(deviceDescs, deviceId, |
| 313 | NewConcurrentHashMap.<ProviderId, DeviceDescriptions>ifNeeded()); |
| 314 | } |
| 315 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 316 | @Override |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 317 | public DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId, |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 318 | PortDescription portDescription) { |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 319 | Device device = devices.get(deviceId); |
| 320 | checkArgument(device != null, DEVICE_NOT_FOUND, deviceId); |
| 321 | |
| 322 | ConcurrentMap<ProviderId, DeviceDescriptions> descsMap = deviceDescs.get(deviceId); |
| 323 | checkArgument(descsMap != null, DEVICE_NOT_FOUND, deviceId); |
| 324 | |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 325 | synchronized (descsMap) { |
| 326 | DeviceDescriptions descs = descsMap.get(providerId); |
| 327 | // assuming all providers must to give DeviceDescription |
| 328 | checkArgument(descs != null, |
| 329 | "Device description for Device ID %s from Provider %s was not found", |
| 330 | deviceId, providerId); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 331 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 332 | ConcurrentMap<PortNumber, Port> ports = getPortMap(deviceId); |
| 333 | final PortNumber number = portDescription.portNumber(); |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 334 | final Port oldPort = ports.get(number); |
| 335 | final Port newPort; |
| 336 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 337 | // update description |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 338 | descs.putPortDesc(portDescription); |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 339 | newPort = composePort(device, number, descsMap); |
| 340 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 341 | if (oldPort == null) { |
| 342 | return createPort(device, newPort, ports); |
| 343 | } else { |
| 344 | return updatePort(device, oldPort, newPort, ports); |
| 345 | } |
tom | 46a220d | 2014-09-05 08:25:56 -0700 | [diff] [blame] | 346 | } |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 347 | } |
| 348 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 349 | @Override |
| 350 | public List<Port> getPorts(DeviceId deviceId) { |
tom | 46a220d | 2014-09-05 08:25:56 -0700 | [diff] [blame] | 351 | Map<PortNumber, Port> ports = devicePorts.get(deviceId); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 352 | if (ports == null) { |
| 353 | return Collections.emptyList(); |
| 354 | } |
| 355 | return ImmutableList.copyOf(ports.values()); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 356 | } |
| 357 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 358 | @Override |
| 359 | public Port getPort(DeviceId deviceId, PortNumber portNumber) { |
tom | 46a220d | 2014-09-05 08:25:56 -0700 | [diff] [blame] | 360 | Map<PortNumber, Port> ports = devicePorts.get(deviceId); |
| 361 | return ports == null ? null : ports.get(portNumber); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 362 | } |
| 363 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 364 | @Override |
| 365 | public boolean isAvailable(DeviceId deviceId) { |
tom | ff7eb7c | 2014-09-08 12:49:03 -0700 | [diff] [blame] | 366 | return availableDevices.contains(deviceId); |
| 367 | } |
| 368 | |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 369 | @Override |
tom | 41a2c5f | 2014-09-19 09:20:35 -0700 | [diff] [blame] | 370 | public DeviceEvent removeDevice(DeviceId deviceId) { |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 371 | ConcurrentMap<ProviderId, DeviceDescriptions> descs = getDeviceDescriptions(deviceId); |
| 372 | synchronized (descs) { |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 373 | Device device = devices.remove(deviceId); |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 374 | // should DEVICE_REMOVED carry removed ports? |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 375 | Map<PortNumber, Port> ports = devicePorts.get(deviceId); |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 376 | if (ports != null) { |
| 377 | ports.clear(); |
| 378 | } |
| 379 | availableDevices.remove(deviceId); |
| 380 | descs.clear(); |
tom | 29df6f4 | 2014-09-05 08:14:14 -0700 | [diff] [blame] | 381 | return device == null ? null : |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 382 | new DeviceEvent(DEVICE_REMOVED, device, null); |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 383 | } |
| 384 | } |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 385 | |
| 386 | /** |
| 387 | * Returns a Device, merging description given from multiple Providers. |
| 388 | * |
| 389 | * @param deviceId device identifier |
| 390 | * @param providerDescs Collection of Descriptions from multiple providers |
| 391 | * @return Device instance |
| 392 | */ |
| 393 | private Device composeDevice(DeviceId deviceId, |
| 394 | ConcurrentMap<ProviderId, DeviceDescriptions> providerDescs) { |
| 395 | |
| 396 | checkArgument(!providerDescs.isEmpty(), "No Device descriptions supplied"); |
| 397 | |
| 398 | ProviderId primary = pickPrimaryPID(providerDescs); |
| 399 | |
| 400 | DeviceDescriptions desc = providerDescs.get(primary); |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 401 | |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 402 | final DeviceDescription base = desc.getDeviceDesc(); |
| 403 | Type type = base.type(); |
| 404 | String manufacturer = base.manufacturer(); |
| 405 | String hwVersion = base.hwVersion(); |
| 406 | String swVersion = base.swVersion(); |
| 407 | String serialNumber = base.serialNumber(); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame^] | 408 | ChassisId chassisId = base.chassisId(); |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 409 | DefaultAnnotations annotations = DefaultAnnotations.builder().build(); |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 410 | annotations = merge(annotations, base.annotations()); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 411 | |
| 412 | for (Entry<ProviderId, DeviceDescriptions> e : providerDescs.entrySet()) { |
| 413 | if (e.getKey().equals(primary)) { |
| 414 | continue; |
| 415 | } |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 416 | // TODO: should keep track of Description timestamp |
| 417 | // and only merge conflicting keys when timestamp is newer |
| 418 | // Currently assuming there will never be a key conflict between |
| 419 | // providers |
| 420 | |
| 421 | // annotation merging. not so efficient, should revisit later |
| 422 | annotations = merge(annotations, e.getValue().getDeviceDesc().annotations()); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 423 | } |
| 424 | |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 425 | return new DefaultDevice(primary, deviceId , type, manufacturer, |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame^] | 426 | hwVersion, swVersion, serialNumber, |
| 427 | chassisId, annotations); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 428 | } |
| 429 | |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 430 | /** |
| 431 | * Returns a Port, merging description given from multiple Providers. |
| 432 | * |
| 433 | * @param device device the port is on |
| 434 | * @param number port number |
| 435 | * @param providerDescs Collection of Descriptions from multiple providers |
| 436 | * @return Port instance |
| 437 | */ |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 438 | private Port composePort(Device device, PortNumber number, |
| 439 | ConcurrentMap<ProviderId, DeviceDescriptions> providerDescs) { |
| 440 | |
| 441 | ProviderId primary = pickPrimaryPID(providerDescs); |
| 442 | DeviceDescriptions primDescs = providerDescs.get(primary); |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 443 | // if no primary, assume not enabled |
| 444 | // TODO: revisit this default port enabled/disabled behavior |
| 445 | boolean isEnabled = false; |
| 446 | DefaultAnnotations annotations = DefaultAnnotations.builder().build(); |
| 447 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 448 | final PortDescription portDesc = primDescs.getPortDesc(number); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 449 | if (portDesc != null) { |
| 450 | isEnabled = portDesc.isEnabled(); |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 451 | annotations = merge(annotations, portDesc.annotations()); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | for (Entry<ProviderId, DeviceDescriptions> e : providerDescs.entrySet()) { |
| 455 | if (e.getKey().equals(primary)) { |
| 456 | continue; |
| 457 | } |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 458 | // TODO: should keep track of Description timestamp |
| 459 | // and only merge conflicting keys when timestamp is newer |
| 460 | // Currently assuming there will never be a key conflict between |
| 461 | // providers |
| 462 | |
| 463 | // annotation merging. not so efficient, should revisit later |
| 464 | final PortDescription otherPortDesc = e.getValue().getPortDesc(number); |
| 465 | if (otherPortDesc != null) { |
| 466 | annotations = merge(annotations, otherPortDesc.annotations()); |
| 467 | } |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 468 | } |
| 469 | |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 470 | return new DefaultPort(device, number, isEnabled, annotations); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | /** |
| 474 | * @return primary ProviderID, or randomly chosen one if none exists |
| 475 | */ |
| 476 | private ProviderId pickPrimaryPID( |
| 477 | ConcurrentMap<ProviderId, DeviceDescriptions> providerDescs) { |
| 478 | ProviderId fallBackPrimary = null; |
| 479 | for (Entry<ProviderId, DeviceDescriptions> e : providerDescs.entrySet()) { |
| 480 | if (!e.getKey().isAncillary()) { |
| 481 | return e.getKey(); |
| 482 | } else if (fallBackPrimary == null) { |
| 483 | // pick randomly as a fallback in case there is no primary |
| 484 | fallBackPrimary = e.getKey(); |
| 485 | } |
| 486 | } |
| 487 | return fallBackPrimary; |
| 488 | } |
| 489 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 490 | public static final class InitDeviceDescs |
| 491 | implements ConcurrentInitializer<DeviceDescriptions> { |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 492 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 493 | private final DeviceDescription deviceDesc; |
Yuta HIGUCHI | c35efac | 2014-10-06 14:43:53 -0700 | [diff] [blame] | 494 | |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 495 | public InitDeviceDescs(DeviceDescription deviceDesc) { |
| 496 | this.deviceDesc = checkNotNull(deviceDesc); |
| 497 | } |
| 498 | @Override |
| 499 | public DeviceDescriptions get() throws ConcurrentException { |
| 500 | return new DeviceDescriptions(deviceDesc); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | |
| 505 | /** |
| 506 | * Collection of Description of a Device and it's Ports given from a Provider. |
| 507 | */ |
| 508 | private static class DeviceDescriptions { |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 509 | |
| 510 | private final AtomicReference<DeviceDescription> deviceDesc; |
| 511 | private final ConcurrentMap<PortNumber, PortDescription> portDescs; |
| 512 | |
| 513 | public DeviceDescriptions(DeviceDescription desc) { |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 514 | this.deviceDesc = new AtomicReference<>(checkNotNull(desc)); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 515 | this.portDescs = new ConcurrentHashMap<>(); |
| 516 | } |
| 517 | |
| 518 | public DeviceDescription getDeviceDesc() { |
| 519 | return deviceDesc.get(); |
| 520 | } |
| 521 | |
| 522 | public PortDescription getPortDesc(PortNumber number) { |
| 523 | return portDescs.get(number); |
| 524 | } |
| 525 | |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 526 | /** |
| 527 | * Puts DeviceDescription, merging annotations as necessary. |
| 528 | * |
| 529 | * @param newDesc new DeviceDescription |
| 530 | * @return previous DeviceDescription |
| 531 | */ |
| 532 | public synchronized DeviceDescription putDeviceDesc(DeviceDescription newDesc) { |
| 533 | DeviceDescription oldOne = deviceDesc.get(); |
| 534 | DeviceDescription newOne = newDesc; |
| 535 | if (oldOne != null) { |
Yuta HIGUCHI | 885be1d | 2014-10-04 21:47:26 -0700 | [diff] [blame] | 536 | SparseAnnotations merged = union(oldOne.annotations(), |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 537 | newDesc.annotations()); |
| 538 | newOne = new DefaultDeviceDescription(newOne, merged); |
| 539 | } |
| 540 | return deviceDesc.getAndSet(newOne); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 541 | } |
| 542 | |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 543 | /** |
| 544 | * Puts PortDescription, merging annotations as necessary. |
| 545 | * |
| 546 | * @param newDesc new PortDescription |
| 547 | * @return previous PortDescription |
| 548 | */ |
| 549 | public synchronized PortDescription putPortDesc(PortDescription newDesc) { |
| 550 | PortDescription oldOne = portDescs.get(newDesc.portNumber()); |
| 551 | PortDescription newOne = newDesc; |
| 552 | if (oldOne != null) { |
Yuta HIGUCHI | 885be1d | 2014-10-04 21:47:26 -0700 | [diff] [blame] | 553 | SparseAnnotations merged = union(oldOne.annotations(), |
Yuta HIGUCHI | 55710e7 | 2014-10-02 14:58:32 -0700 | [diff] [blame] | 554 | newDesc.annotations()); |
| 555 | newOne = new DefaultPortDescription(newOne, merged); |
| 556 | } |
| 557 | return portDescs.put(newOne.portNumber(), newOne); |
Yuta HIGUCHI | 8e49379 | 2014-10-01 19:36:32 -0700 | [diff] [blame] | 558 | } |
| 559 | } |
tom | e5ec3fd | 2014-09-04 15:18:06 -0700 | [diff] [blame] | 560 | } |