blob: 0c47aaddb2d0ebe5b02dadc0f3d0a9f353d5ebc6 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070016package org.onlab.onos.net.intent;
17
tom85258ee2014-10-07 00:10:02 -070018import com.google.common.base.MoreObjects;
19import com.google.common.collect.Sets;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070020import org.onlab.onos.core.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -070021import org.onlab.onos.net.ConnectPoint;
22import org.onlab.onos.net.flow.TrafficSelector;
23import org.onlab.onos.net.flow.TrafficTreatment;
24
tom85258ee2014-10-07 00:10:02 -070025import java.util.Set;
26
27import static com.google.common.base.Preconditions.checkArgument;
28import static com.google.common.base.Preconditions.checkNotNull;
Brian O'Connorb876bf12014-10-02 14:59:37 -070029
30/**
31 * Abstraction of multiple source to single destination connectivity intent.
32 */
Ray Milkeye6684082014-10-16 16:59:47 -070033public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
Brian O'Connorb876bf12014-10-02 14:59:37 -070034
tom85258ee2014-10-07 00:10:02 -070035 private final Set<ConnectPoint> ingressPoints;
36 private final ConnectPoint egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070037
38 /**
39 * Creates a new multi-to-single point connectivity intent for the specified
Thomas Vachuskac96058a2014-10-20 23:00:16 -070040 * traffic selector and treatment.
Brian O'Connorb876bf12014-10-02 14:59:37 -070041 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070042 * @param appId application identifier
43 * @param selector traffic selector
44 * @param treatment treatment
tom85258ee2014-10-07 00:10:02 -070045 * @param ingressPoints set of ports from which ingress traffic originates
46 * @param egressPoint port to which traffic will egress
47 * @throws NullPointerException if {@code ingressPoints} or
48 * {@code egressPoint} is null.
49 * @throws IllegalArgumentException if the size of {@code ingressPoints} is
toma1d16b62014-10-02 23:45:11 -070050 * not more than 1
Brian O'Connorb876bf12014-10-02 14:59:37 -070051 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070052 public MultiPointToSinglePointIntent(ApplicationId appId,
53 TrafficSelector selector,
54 TrafficTreatment treatment,
tom85258ee2014-10-07 00:10:02 -070055 Set<ConnectPoint> ingressPoints,
56 ConnectPoint egressPoint) {
Thomas Vachuskac96058a2014-10-20 23:00:16 -070057 super(id(MultiPointToSinglePointIntent.class, selector, treatment,
58 ingressPoints, egressPoint), appId, null, selector, treatment);
Brian O'Connorb876bf12014-10-02 14:59:37 -070059
tom85258ee2014-10-07 00:10:02 -070060 checkNotNull(ingressPoints);
Thomas Vachuskac96058a2014-10-20 23:00:16 -070061 checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty");
Brian O'Connorb876bf12014-10-02 14:59:37 -070062
tom85258ee2014-10-07 00:10:02 -070063 this.ingressPoints = Sets.newHashSet(ingressPoints);
64 this.egressPoint = checkNotNull(egressPoint);
Brian O'Connorb876bf12014-10-02 14:59:37 -070065 }
66
67 /**
68 * Constructor for serializer.
69 */
70 protected MultiPointToSinglePointIntent() {
71 super();
tom85258ee2014-10-07 00:10:02 -070072 this.ingressPoints = null;
73 this.egressPoint = null;
Brian O'Connorb876bf12014-10-02 14:59:37 -070074 }
75
76 /**
77 * Returns the set of ports on which ingress traffic should be connected to
78 * the egress port.
79 *
80 * @return set of ingress ports
81 */
tom85258ee2014-10-07 00:10:02 -070082 public Set<ConnectPoint> ingressPoints() {
83 return ingressPoints;
Brian O'Connorb876bf12014-10-02 14:59:37 -070084 }
85
86 /**
87 * Returns the port on which the traffic should egress.
88 *
89 * @return egress port
90 */
tom85258ee2014-10-07 00:10:02 -070091 public ConnectPoint egressPoint() {
92 return egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070093 }
94
95 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070096 public String toString() {
97 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -070098 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -070099 .add("appId", appId())
100 .add("selector", selector())
101 .add("treatment", treatment())
102 .add("ingress", ingressPoints())
103 .add("egress", egressPoint())
Brian O'Connorb876bf12014-10-02 14:59:37 -0700104 .toString();
105 }
106}