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