@Override public boolean isEdgePoint(ConnectPoint point) { checkPermission(TOPOLOGY_READ); Set<ConnectPoint> connectPoints = connectionPoints.get(point.deviceId()); return connectPoints != null && connectPoints.contains(point); }
@Override public Set<Host> getConnectedHosts(DeviceId deviceId) { Set<Host> hostset = new HashSet<>(); for (ConnectPoint p : locations.keySet()) { if (p.deviceId().equals(deviceId)) { hostset.addAll(locations.get(p)); } } return hostset; }
@Override public Set<Link> getEgressLinks(ConnectPoint src) { Set<Link> egress = new HashSet<>(); synchronized (srcLinks) { for (LinkKey linkKey : srcLinks.get(src.deviceId())) { if (linkKey.src().equals(src)) { egress.add(links.get(linkKey)); } } } return egress; }
@Override public Set<Link> getIngressLinks(ConnectPoint dst) { Set<Link> ingress = new HashSet<>(); synchronized (dstLinks) { for (LinkKey linkKey : dstLinks.get(dst.deviceId())) { if (linkKey.dst().equals(dst)) { ingress.add(links.get(linkKey)); } } } return ingress; }
private void processIntfFilters(boolean install, Set<Interface> intfs) { log.info("Processing {} router interfaces", intfs.size()); for (Interface intf : intfs) { if (!intf.connectPoint().deviceId().equals(deviceId)) { // Ignore interfaces if they are not on the router switch continue; } createFilteringObjective(install, intf); createMcastFilteringObjective(install, intf); } }
private void addEdgePort(ConnectPoint point) { if (isEdgePort(point)) { Set<ConnectPoint> set = connectionPoints.computeIfAbsent(point.deviceId(), (k) -> Sets.newConcurrentHashSet()); if (set.add(point)) { post(new EdgePortEvent(EDGE_PORT_ADDED, point)); } } }
@Override public ObjectNode encode(ConnectPoint point, CodecContext context) { checkNotNull(point, "Connect point cannot be null"); ObjectNode root = context.mapper().createObjectNode() .put(PORT, point.port().toString()); if (point.elementId() instanceof DeviceId) { root.put(ELEMENT_DEVICE, point.deviceId().toString()); } else if (point.elementId() instanceof HostId) { root.put(ELEMENT_HOST, point.hostId().toString()); } return root; }
/** * Creates ResourceId for a port. * * @param cp ConnectPoint * @return ResourceId */ static DiscreteResourceId resourceId(ConnectPoint cp) { return Resources.discrete(cp.deviceId(), cp.port()).id(); }
private boolean isMultiplexingSupported(ConnectPoint cp) { Driver driver = driverService.getDriver(cp.deviceId()); return driver != null && driver.hasBehaviour(TributarySlotQuery.class) && staticPort(cp) == null; }
private boolean isBlacklisted(ConnectPoint cp) { // if parent device is blacklisted, so is the port if (isBlacklisted(cp.deviceId())) { return true; } LinkDiscoveryFromPort cfg = cfgRegistry.getConfig(cp, LinkDiscoveryFromPort.class); if (cfg == null) { return false; } return !cfg.enabled(); }
private LinkEvent updateLink(LinkKey key, Link oldLink, Link newLink) { if (oldLink.state() != newLink.state() || (oldLink.type() == INDIRECT && newLink.type() == DIRECT) || !AnnotationsUtil.isEqual(oldLink.annotations(), newLink.annotations())) { links.put(key, newLink); // strictly speaking following can be ommitted srcLinks.put(oldLink.src().deviceId(), key); dstLinks.put(oldLink.dst().deviceId(), key); return new LinkEvent(LINK_UPDATED, newLink); } return null; }
private List<Intent> createUnprotectedLinkCollectionIntent(PointToPointIntent intent) { Path path = getPathOrException(intent, intent.filteredIngressPoint().connectPoint().deviceId(), intent.filteredEgressPoint().connectPoint().deviceId()); // Allocate bandwidth if a bandwidth constraint is set allocateIntentBandwidth(intent, path); return asList(createLinkCollectionIntent(ImmutableSet.copyOf(path.links()), path.cost(), intent)); }
@Override public boolean isValid(Link link, ResourceContext context) { changedBwValue = requestBwValue; if (links.contains(link)) { changedBwValue = requestBwValue.isGreaterThan(sharedBwValue) ? requestBwValue.subtract(sharedBwValue) : Bandwidth.bps(0); } return Stream .of(link.src(), link.dst()) .map(cp -> Resources.continuous(cp.deviceId(), cp.port(), Bandwidth.class).resource( changedBwValue.bps())).allMatch(context::isAvailable); }
/** * Finds the TributarySlots available on the connect point. * * @param cp connect point * @return set of TributarySlots available on the connect point */ Set<TributarySlot> findTributarySlotsOnCp(ConnectPoint cp) { return resourceService.getAvailableResourceValues( Resources.discrete(cp.deviceId(), cp.port()).id(), TributarySlot.class); } }
/** * Finds the TributarySlots available on the connect point. * * @param cp connect point * @return set of TributarySlots available on the connect point */ Set<TributarySlot> findTributarySlotsOnCp(ConnectPoint cp) { return resourceService.getAvailableResourceValues( Resources.discrete(cp.deviceId(), cp.port()).id(), TributarySlot.class); } }
private void callForOptimization() { //Recompute the LSPs which it was delegated [LSPs stored in PCE store (failed paths)] for (PcePathInfo failedPathInfo : pceStore.getFailedPathInfos()) { checkForMasterAndSetupPath(failedPathInfo); } //Recompute the LSPs for which it was delegated [LSPs stored in tunnel store] tunnelService.queryTunnel(MPLS).forEach(t -> { checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t); }); }
private void callForOptimization() { //Recompute the LSPs which it was delegated [LSPs stored in PCE store (failed paths)] for (PcePathInfo failedPathInfo : pceStore.getFailedPathInfos()) { checkForMasterAndSetupPath(failedPathInfo); } //Recompute the LSPs for which it was delegated [LSPs stored in tunnel store] tunnelService.queryTunnel(MPLS).forEach(t -> { checkForMasterAndUpdateTunnel(t.path().src().deviceId(), t); }); }
@Override protected void doExecute() { DeviceService service = get(DeviceService.class); for (String portStr : ports) { ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(portStr); Port port = service.getPort(connectPoint.deviceId(), connectPoint.port()); printPort(port); printVlans(port); } }
private void updateFailoverGroup(PointToPointIntent intent, List<Link> links) { GroupKey groupKey = makeGroupKey(intent.id()); TrafficTreatment.Builder tBuilderIn = DefaultTrafficTreatment.builder(); ConnectPoint src = links.get(0).src(); tBuilderIn.setOutput(src.port()); GroupBucket bucket = DefaultGroupBucket.createFailoverGroupBucket(tBuilderIn.build(), src.port(), null); GroupBuckets addBuckets = new GroupBuckets(Collections.singletonList(bucket)); groupService.addBucketsToGroup(src.deviceId(), groupKey, addBuckets, groupKey, intent.appId()); }