@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (!(obj instanceof PendingFlowObjective)) { return false; } final PendingFlowObjective other = (PendingFlowObjective) obj; return this.deviceId.equals(other.deviceId) && this.flowObj.equals(other.flowObj); } }
@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 Collection<Alarm> getAlarms(DeviceId deviceId) { //FIXME: this is expensive, need refactoring when core maps provide different indexes. return ImmutableSet.copyOf(alarmsMap.values().stream() .filter(alarm -> alarm.deviceId().equals(deviceId)) .collect(Collectors.toSet())); }
private void pruneMap(Map<ConnectPoint, DataPoint> map, DeviceId deviceId) { map.keySet().stream().filter(cp -> deviceId.equals(cp.deviceId())) .collect(Collectors.toSet()).forEach(map::remove); }
/** * Returns all of the ACTIVE alarms for a specific device. Recently cleared alarms excluded. * * @param deviceId the device to use when searching alarms. * @return set of alarms; empty set if no alarms */ default Set<Alarm> getActiveAlarms(DeviceId deviceId) { return getActiveAlarms().stream() .filter(a -> deviceId.equals(a.deviceId())) .collect(Collectors.toSet()); }
@Override public Collection<VirtualPort> getPorts(DeviceId deviceId) { checkNotNull(deviceId, DEVICEID_NOT_NULL); return vPortStore.values().stream().filter(d -> d.deviceId().equals(deviceId)) .collect(Collectors.toList()); }
@Override public Collection<VirtualPort> getPorts(DeviceId deviceId) { checkNotNull(deviceId, DEVICEID_NOT_NULL); return vPortStore.values().stream().filter(d -> d.deviceId().equals(deviceId)) .collect(Collectors.toList()); }
private Set<Alarm> getActiveAlarms(DeviceId deviceId) { return ImmutableSet.copyOf(getActiveAlarms().stream().filter( a -> deviceId.equals(a.deviceId())). collect(Collectors.toSet())); }
/** * Get links originating from the source device ID. * * @param links list of available links * @param source the device ID of the source device * @return the list of links with the given source */ private List<Link> getEgressLinks(Set<Link> links, final DeviceId source) { return links.stream() .filter(link -> link.src().deviceId().equals(source)) .collect(Collectors.toList()); }
@Override public Collection<Meter> getMeters(DeviceId deviceId) { return store.getAllMeters().stream().filter(m -> m.deviceId().equals(deviceId)).collect(Collectors.toList()); }
private boolean pathValidation(List<Path> partialPath, Path path) { //List of devices in new path computed List<DeviceId> newPartialPathDevList; newPartialPathDevList = createListOfDeviceIds(path.links()); //List of devices in partial computed path List<DeviceId> partialComputedPathDevList; partialComputedPathDevList = createListOfDeviceIds(partialPath); for (DeviceId deviceId : newPartialPathDevList) { for (DeviceId devId : partialComputedPathDevList) { if (!newPartialPathDevList.get(0).equals(deviceId) && !partialComputedPathDevList.get(partialComputedPathDevList.size() - 1).equals(devId) && deviceId.equals(devId)) { return false; } } } return true; }
private Stream<Interface> getInterfacesForDevice(DeviceId deviceId) { return interfaceService.getInterfaces().stream() .filter(intf -> intf.connectPoint().deviceId().equals(deviceId)); }
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); } }
/** * Checks if there is any port remained with same vni at the device, on which the removed VM was run. * * @param removedPort removedport info * @param deviceId device id on which removed VM was run * @param vni vni which removed VM was belonged * @param openstackPortInfoMap openstackPortInfoMap * @return true if there is, false otherwise */ private boolean checkIfAnyPortRemainedInSameCnode(Port removedPort, DeviceId deviceId, long vni, Map<String, OpenstackPortInfo> openstackPortInfoMap) { for (Map.Entry<String, OpenstackPortInfo> entry : openstackPortInfoMap.entrySet()) { if (!removedPort.annotations().value(PORT_NAME).equals(entry.getKey())) { if (entry.getValue().vni() == vni && entry.getValue().deviceId().equals(deviceId)) { return true; } } } return false; }
private void updateDevice() { if (controlPlaneConnectPoint != null && deviceService.isAvailable(controlPlaneConnectPoint.deviceId())) { DeviceId deviceId = controlPlaneConnectPoint.deviceId(); interfaceService.getInterfaces().stream() .filter(intf -> intf.connectPoint().deviceId().equals(deviceId)) .filter(intf -> interfaces.isEmpty() || interfaces.contains(intf.name())) .forEach(this::provisionInterface); log.info("Set up interfaces on {}", controlPlaneConnectPoint.deviceId()); } }
private void updateDevice() { if (deviceId != null && deviceService.isAvailable(deviceId)) { Set<Interface> intfs; if (interfaces.isEmpty()) { intfs = interfaceService.getInterfaces(); } else { // TODO need to fix by making interface names globally unique intfs = interfaceService.getInterfaces().stream() .filter(intf -> intf.connectPoint().deviceId().equals(deviceId)) .filter(intf -> interfaces.contains(intf.name())) .collect(Collectors.toSet()); } processIntfFilters(true, intfs); } }
protected Set<Host> getVmsInDifferentCnode(Host host) { return Tools.stream(hostService.getHosts()) .filter(h -> !h.location().deviceId().equals(host.location().deviceId())) .filter(this::isValidHost) .filter(h -> Objects.equals(getVni(h), getVni(host))) .collect(Collectors.toSet()); }
/** * Get FilteredConnectPoint from LinkCollectionIntent. * * @param deviceId device Id for connect point * @param portNumber port number * @param intent source intent * @return filtered connetion point */ private Optional<FilteredConnectPoint> getFilteredConnectPointFromIntent(DeviceId deviceId, PortNumber portNumber, LinkCollectionIntent intent) { Set<FilteredConnectPoint> filteredConnectPoints = Sets.union(intent.filteredIngressPoints(), intent.filteredEgressPoints()); return filteredConnectPoints.stream() .filter(port -> port.connectPoint().deviceId().equals(deviceId)) .filter(port -> port.connectPoint().port().equals(portNumber)) .findFirst(); }
/** * Pushes all rules to the specified device. * * @param device device on which to install packet request flows */ private void pushRulesToDevice(Device device) { log.debug("Pushing packet requests to device {}", device.id()); for (PacketRequest request : store.existingRequests()) { if (!request.deviceId().isPresent()) { pushRule(device, request); } else if (request.deviceId().get().equals(device.id())) { pushRule(device, request); } } }
private void processIntfFilter(boolean install, Interface intf) { if (!intf.connectPoint().deviceId().equals(deviceId)) { // Ignore interfaces if they are not on the router switch return; } createFilteringObjective(install, intf); createMcastFilteringObjective(install, intf); }