Esempio n. 1
0
 /**
  * Creates a new point-to-point intent with the supplied ingress/egress ports and using the
  * specified explicit path.
  *
  * @param appId application identifier
  * @param selector traffic selector
  * @param treatment treatment
  * @param path traversed links
  * @param constraints optional list of constraints
  * @param priority priority to use for the generated flows
  * @throws NullPointerException {@code path} is null
  */
 protected PathIntent(
     ApplicationId appId,
     TrafficSelector selector,
     TrafficTreatment treatment,
     Path path,
     List<Constraint> constraints,
     int priority) {
   super(appId, null, resources(path.links()), selector, treatment, constraints, priority);
   PathIntent.validate(path.links());
   this.path = path;
 }
  @Override
  public boolean validate(Path path, LinkResourceService resourceService) {
    LinkedList<DeviceId> waypoints = new LinkedList<>(this.waypoints);
    DeviceId current = waypoints.poll();
    // This is safe because Path class ensures the number of links are more than 0
    Link firstLink = path.links().get(0);
    if (firstLink.src().elementId().equals(current)) {
      current = waypoints.poll();
    }

    for (Link link : path.links()) {
      if (link.dst().elementId().equals(current)) {
        current = waypoints.poll();
        // Empty waypoints means passing through all waypoints in the specified order
        if (current == null) {
          return true;
        }
      }
    }

    return false;
  }
Esempio n. 3
0
 // Produces a direct edge-to-edge path.
 private Path edgeToEdgePath(EdgeLink srcLink, EdgeLink dstLink, Path path) {
   List<Link> links = Lists.newArrayListWithCapacity(2);
   // Add source and destination edge links only if they are real and
   // add the infrastructure path only if it is not null.
   if (srcLink != NOT_HOST) {
     links.add(srcLink);
   }
   if (path != null) {
     links.addAll(path.links());
   }
   if (dstLink != NOT_HOST) {
     links.add(dstLink);
   }
   return new DefaultPath(PID, links, 2);
 }