tom | ea961ff | 2014-10-01 12:45:15 -0700 | [diff] [blame] | 1 | package org.onlab.onos.store.trivial.impl; |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 2 | |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 3 | import com.google.common.base.Function; |
| 4 | import com.google.common.base.Predicate; |
| 5 | import com.google.common.collect.FluentIterable; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 6 | import com.google.common.collect.HashMultimap; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 7 | import com.google.common.collect.SetMultimap; |
Yuta HIGUCHI | 06dc6b9 | 2014-09-25 16:06:16 -0700 | [diff] [blame] | 8 | |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 9 | import org.apache.commons.lang3.concurrent.ConcurrentUtils; |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 10 | import org.apache.felix.scr.annotations.Activate; |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 11 | import org.apache.felix.scr.annotations.Component; |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 12 | import org.apache.felix.scr.annotations.Deactivate; |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 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; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 15 | import org.onlab.onos.net.ConnectPoint; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 16 | import org.onlab.onos.net.DefaultAnnotations; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 17 | import org.onlab.onos.net.DefaultLink; |
| 18 | import org.onlab.onos.net.DeviceId; |
| 19 | import org.onlab.onos.net.Link; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 20 | import org.onlab.onos.net.SparseAnnotations; |
| 21 | import org.onlab.onos.net.Link.Type; |
Yuta HIGUCHI | 06dc6b9 | 2014-09-25 16:06:16 -0700 | [diff] [blame] | 22 | import org.onlab.onos.net.LinkKey; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 23 | import org.onlab.onos.net.Provided; |
| 24 | import org.onlab.onos.net.link.DefaultLinkDescription; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 25 | import org.onlab.onos.net.link.LinkDescription; |
| 26 | import org.onlab.onos.net.link.LinkEvent; |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 27 | import org.onlab.onos.net.link.LinkStore; |
tom | f80c972 | 2014-09-24 14:49:18 -0700 | [diff] [blame] | 28 | import org.onlab.onos.net.link.LinkStoreDelegate; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 29 | import org.onlab.onos.net.provider.ProviderId; |
tom | f80c972 | 2014-09-24 14:49:18 -0700 | [diff] [blame] | 30 | import org.onlab.onos.store.AbstractStore; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 31 | import org.onlab.util.NewConcurrentHashMap; |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 32 | import org.slf4j.Logger; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 33 | |
| 34 | import java.util.Collections; |
| 35 | import java.util.HashSet; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 36 | import java.util.Set; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 37 | import java.util.Map.Entry; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 38 | import java.util.concurrent.ConcurrentHashMap; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 39 | import java.util.concurrent.ConcurrentMap; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 40 | |
Yuta HIGUCHI | 885be1d | 2014-10-04 21:47:26 -0700 | [diff] [blame] | 41 | import static org.onlab.onos.net.DefaultAnnotations.union; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 42 | import static org.onlab.onos.net.DefaultAnnotations.merge; |
tom | d176fc4 | 2014-09-08 00:12:30 -0700 | [diff] [blame] | 43 | import static org.onlab.onos.net.Link.Type.DIRECT; |
| 44 | import static org.onlab.onos.net.Link.Type.INDIRECT; |
Yuta HIGUCHI | 18ab8a9 | 2014-10-13 11:16:19 -0700 | [diff] [blame] | 45 | import static org.onlab.onos.net.LinkKey.linkKey; |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 46 | import static org.onlab.onos.net.link.LinkEvent.Type.*; |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 47 | import static org.slf4j.LoggerFactory.getLogger; |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 48 | import static com.google.common.collect.Multimaps.synchronizedSetMultimap; |
| 49 | import static com.google.common.base.Predicates.notNull; |
tom | d176fc4 | 2014-09-08 00:12:30 -0700 | [diff] [blame] | 50 | |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 51 | /** |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 52 | * Manages inventory of infrastructure links using trivial in-memory structures |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 53 | * implementation. |
| 54 | */ |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 55 | @Component(immediate = true) |
| 56 | @Service |
tom | f80c972 | 2014-09-24 14:49:18 -0700 | [diff] [blame] | 57 | public class SimpleLinkStore |
| 58 | extends AbstractStore<LinkEvent, LinkStoreDelegate> |
| 59 | implements LinkStore { |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 60 | |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 61 | private final Logger log = getLogger(getClass()); |
| 62 | |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 63 | // Link inventory |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 64 | private final ConcurrentMap<LinkKey, |
| 65 | ConcurrentMap<ProviderId, LinkDescription>> |
| 66 | linkDescs = new ConcurrentHashMap<>(); |
| 67 | |
| 68 | // Link instance cache |
| 69 | private final ConcurrentMap<LinkKey, Link> links = new ConcurrentHashMap<>(); |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 70 | |
| 71 | // Egress and ingress link sets |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 72 | private final SetMultimap<DeviceId, LinkKey> srcLinks = createSynchronizedHashMultiMap(); |
| 73 | private final SetMultimap<DeviceId, LinkKey> dstLinks = createSynchronizedHashMultiMap(); |
| 74 | |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 75 | |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 76 | @Activate |
| 77 | public void activate() { |
| 78 | log.info("Started"); |
| 79 | } |
| 80 | |
| 81 | @Deactivate |
| 82 | public void deactivate() { |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 83 | linkDescs.clear(); |
| 84 | links.clear(); |
| 85 | srcLinks.clear(); |
| 86 | dstLinks.clear(); |
tom | 5bcc946 | 2014-09-19 10:11:31 -0700 | [diff] [blame] | 87 | log.info("Stopped"); |
| 88 | } |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 89 | |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 90 | @Override |
| 91 | public int getLinkCount() { |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 92 | return links.size(); |
| 93 | } |
| 94 | |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 95 | @Override |
| 96 | public Iterable<Link> getLinks() { |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 97 | return Collections.unmodifiableCollection(links.values()); |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 98 | } |
| 99 | |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 100 | @Override |
| 101 | public Set<Link> getDeviceEgressLinks(DeviceId deviceId) { |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 102 | // lock for iteration |
| 103 | synchronized (srcLinks) { |
| 104 | return FluentIterable.from(srcLinks.get(deviceId)) |
| 105 | .transform(lookupLink()) |
| 106 | .filter(notNull()) |
| 107 | .toSet(); |
| 108 | } |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 109 | } |
| 110 | |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 111 | @Override |
| 112 | public Set<Link> getDeviceIngressLinks(DeviceId deviceId) { |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 113 | // lock for iteration |
| 114 | synchronized (dstLinks) { |
| 115 | return FluentIterable.from(dstLinks.get(deviceId)) |
| 116 | .transform(lookupLink()) |
| 117 | .filter(notNull()) |
| 118 | .toSet(); |
| 119 | } |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 120 | } |
| 121 | |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 122 | @Override |
| 123 | public Link getLink(ConnectPoint src, ConnectPoint dst) { |
Yuta HIGUCHI | 18ab8a9 | 2014-10-13 11:16:19 -0700 | [diff] [blame] | 124 | return links.get(linkKey(src, dst)); |
tom | d176fc4 | 2014-09-08 00:12:30 -0700 | [diff] [blame] | 125 | } |
| 126 | |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 127 | @Override |
| 128 | public Set<Link> getEgressLinks(ConnectPoint src) { |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 129 | Set<Link> egress = new HashSet<>(); |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 130 | for (LinkKey linkKey : srcLinks.get(src.deviceId())) { |
| 131 | if (linkKey.src().equals(src)) { |
| 132 | egress.add(links.get(linkKey)); |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 133 | } |
| 134 | } |
| 135 | return egress; |
| 136 | } |
| 137 | |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 138 | @Override |
| 139 | public Set<Link> getIngressLinks(ConnectPoint dst) { |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 140 | Set<Link> ingress = new HashSet<>(); |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 141 | for (LinkKey linkKey : dstLinks.get(dst.deviceId())) { |
| 142 | if (linkKey.dst().equals(dst)) { |
| 143 | ingress.add(links.get(linkKey)); |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 144 | } |
| 145 | } |
| 146 | return ingress; |
| 147 | } |
| 148 | |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 149 | @Override |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 150 | public LinkEvent createOrUpdateLink(ProviderId providerId, |
| 151 | LinkDescription linkDescription) { |
Yuta HIGUCHI | 990aecc | 2014-10-13 22:21:42 -0700 | [diff] [blame] | 152 | LinkKey key = linkKey(linkDescription.src(), linkDescription.dst()); |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 153 | |
| 154 | ConcurrentMap<ProviderId, LinkDescription> descs = getLinkDescriptions(key); |
| 155 | synchronized (descs) { |
| 156 | final Link oldLink = links.get(key); |
| 157 | // update description |
| 158 | createOrUpdateLinkDescription(descs, providerId, linkDescription); |
| 159 | final Link newLink = composeLink(descs); |
| 160 | if (oldLink == null) { |
| 161 | return createLink(key, newLink); |
| 162 | } |
| 163 | return updateLink(key, oldLink, newLink); |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 164 | } |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | // Guarded by linkDescs value (=locking each Link) |
| 168 | private LinkDescription createOrUpdateLinkDescription( |
| 169 | ConcurrentMap<ProviderId, LinkDescription> descs, |
| 170 | ProviderId providerId, |
| 171 | LinkDescription linkDescription) { |
| 172 | |
| 173 | // merge existing attributes and merge |
| 174 | LinkDescription oldDesc = descs.get(providerId); |
| 175 | LinkDescription newDesc = linkDescription; |
| 176 | if (oldDesc != null) { |
Yuta HIGUCHI | 885be1d | 2014-10-04 21:47:26 -0700 | [diff] [blame] | 177 | SparseAnnotations merged = union(oldDesc.annotations(), |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 178 | linkDescription.annotations()); |
| 179 | newDesc = new DefaultLinkDescription( |
| 180 | linkDescription.src(), |
| 181 | linkDescription.dst(), |
| 182 | linkDescription.type(), merged); |
| 183 | } |
| 184 | return descs.put(providerId, newDesc); |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | // Creates and stores the link and returns the appropriate event. |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 188 | // Guarded by linkDescs value (=locking each Link) |
| 189 | private LinkEvent createLink(LinkKey key, Link newLink) { |
| 190 | |
| 191 | if (newLink.providerId().isAncillary()) { |
| 192 | // TODO: revisit ancillary only Link handling |
| 193 | |
| 194 | // currently treating ancillary only as down (not visible outside) |
| 195 | return null; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 196 | } |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 197 | |
| 198 | links.put(key, newLink); |
| 199 | srcLinks.put(newLink.src().deviceId(), key); |
| 200 | dstLinks.put(newLink.dst().deviceId(), key); |
| 201 | return new LinkEvent(LINK_ADDED, newLink); |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | // Updates, if necessary the specified link and returns the appropriate event. |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 205 | // Guarded by linkDescs value (=locking each Link) |
| 206 | private LinkEvent updateLink(LinkKey key, Link oldLink, Link newLink) { |
tom | d176fc4 | 2014-09-08 00:12:30 -0700 | [diff] [blame] | 207 | |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 208 | if (newLink.providerId().isAncillary()) { |
| 209 | // TODO: revisit ancillary only Link handling |
| 210 | |
| 211 | // currently treating ancillary only as down (not visible outside) |
| 212 | return null; |
| 213 | } |
| 214 | |
| 215 | if ((oldLink.type() == INDIRECT && newLink.type() == DIRECT) || |
| 216 | !AnnotationsUtil.isEqual(oldLink.annotations(), newLink.annotations())) { |
| 217 | |
| 218 | links.put(key, newLink); |
| 219 | // strictly speaking following can be ommitted |
| 220 | srcLinks.put(oldLink.src().deviceId(), key); |
| 221 | dstLinks.put(oldLink.dst().deviceId(), key); |
| 222 | return new LinkEvent(LINK_UPDATED, newLink); |
tom | d176fc4 | 2014-09-08 00:12:30 -0700 | [diff] [blame] | 223 | } |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 224 | return null; |
| 225 | } |
| 226 | |
tom | 35c0dc3 | 2014-09-19 10:00:58 -0700 | [diff] [blame] | 227 | @Override |
| 228 | public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { |
Yuta HIGUCHI | 18ab8a9 | 2014-10-13 11:16:19 -0700 | [diff] [blame] | 229 | final LinkKey key = linkKey(src, dst); |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 230 | ConcurrentMap<ProviderId, LinkDescription> descs = getLinkDescriptions(key); |
| 231 | synchronized (descs) { |
| 232 | Link link = links.remove(key); |
Yuta HIGUCHI | 0d6a5e6 | 2014-10-03 15:54:09 -0700 | [diff] [blame] | 233 | descs.clear(); |
tom | d176fc4 | 2014-09-08 00:12:30 -0700 | [diff] [blame] | 234 | if (link != null) { |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 235 | srcLinks.remove(link.src().deviceId(), key); |
| 236 | dstLinks.remove(link.dst().deviceId(), key); |
tom | d176fc4 | 2014-09-08 00:12:30 -0700 | [diff] [blame] | 237 | return new LinkEvent(LINK_REMOVED, link); |
| 238 | } |
| 239 | return null; |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame] | 240 | } |
| 241 | } |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 242 | |
| 243 | private static <K, V> SetMultimap<K, V> createSynchronizedHashMultiMap() { |
| 244 | return synchronizedSetMultimap(HashMultimap.<K, V>create()); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * @return primary ProviderID, or randomly chosen one if none exists |
| 249 | */ |
| 250 | private ProviderId pickPrimaryPID( |
| 251 | ConcurrentMap<ProviderId, LinkDescription> providerDescs) { |
| 252 | |
| 253 | ProviderId fallBackPrimary = null; |
| 254 | for (Entry<ProviderId, LinkDescription> e : providerDescs.entrySet()) { |
| 255 | if (!e.getKey().isAncillary()) { |
| 256 | return e.getKey(); |
| 257 | } else if (fallBackPrimary == null) { |
| 258 | // pick randomly as a fallback in case there is no primary |
| 259 | fallBackPrimary = e.getKey(); |
| 260 | } |
| 261 | } |
| 262 | return fallBackPrimary; |
| 263 | } |
| 264 | |
| 265 | private Link composeLink(ConcurrentMap<ProviderId, LinkDescription> descs) { |
| 266 | ProviderId primary = pickPrimaryPID(descs); |
| 267 | LinkDescription base = descs.get(primary); |
| 268 | |
| 269 | ConnectPoint src = base.src(); |
| 270 | ConnectPoint dst = base.dst(); |
| 271 | Type type = base.type(); |
Yuta HIGUCHI | 885be1d | 2014-10-04 21:47:26 -0700 | [diff] [blame] | 272 | DefaultAnnotations annotations = DefaultAnnotations.builder().build(); |
Yuta HIGUCHI | 39ede6a | 2014-10-03 15:23:33 -0700 | [diff] [blame] | 273 | annotations = merge(annotations, base.annotations()); |
| 274 | |
| 275 | for (Entry<ProviderId, LinkDescription> e : descs.entrySet()) { |
| 276 | if (primary.equals(e.getKey())) { |
| 277 | continue; |
| 278 | } |
| 279 | |
| 280 | // TODO: should keep track of Description timestamp |
| 281 | // and only merge conflicting keys when timestamp is newer |
| 282 | // Currently assuming there will never be a key conflict between |
| 283 | // providers |
| 284 | |
| 285 | // annotation merging. not so efficient, should revisit later |
| 286 | annotations = merge(annotations, e.getValue().annotations()); |
| 287 | } |
| 288 | |
| 289 | return new DefaultLink(primary , src, dst, type, annotations); |
| 290 | } |
| 291 | |
| 292 | private ConcurrentMap<ProviderId, LinkDescription> getLinkDescriptions(LinkKey key) { |
| 293 | return ConcurrentUtils.createIfAbsentUnchecked(linkDescs, key, |
| 294 | NewConcurrentHashMap.<ProviderId, LinkDescription>ifNeeded()); |
| 295 | } |
| 296 | |
| 297 | private final Function<LinkKey, Link> lookupLink = new LookupLink(); |
| 298 | private Function<LinkKey, Link> lookupLink() { |
| 299 | return lookupLink; |
| 300 | } |
| 301 | |
| 302 | private final class LookupLink implements Function<LinkKey, Link> { |
| 303 | @Override |
| 304 | public Link apply(LinkKey input) { |
| 305 | return links.get(input); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | private static final Predicate<Provided> IS_PRIMARY = new IsPrimary(); |
| 310 | private static final Predicate<Provided> isPrimary() { |
| 311 | return IS_PRIMARY; |
| 312 | } |
| 313 | |
| 314 | private static final class IsPrimary implements Predicate<Provided> { |
| 315 | |
| 316 | @Override |
| 317 | public boolean apply(Provided input) { |
| 318 | return !input.providerId().isAncillary(); |
| 319 | } |
| 320 | } |
tom | 4c6606f | 2014-09-07 11:11:21 -0700 | [diff] [blame] | 321 | } |