blob: 9766f8f4dc941ecc62c7dd992ef4c19a12b6b337 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Brian O'Connorb876bf12014-10-02 14:59:37 -070019package org.onlab.onos.net.intent;
20
tom85258ee2014-10-07 00:10:02 -070021import com.google.common.base.MoreObjects;
22import com.google.common.collect.Sets;
Thomas Vachuskae0f804a2014-10-27 23:40:48 -070023import org.onlab.onos.core.ApplicationId;
Brian O'Connorb876bf12014-10-02 14:59:37 -070024import org.onlab.onos.net.ConnectPoint;
25import org.onlab.onos.net.flow.TrafficSelector;
26import org.onlab.onos.net.flow.TrafficTreatment;
27
tom85258ee2014-10-07 00:10:02 -070028import java.util.Set;
29
30import static com.google.common.base.Preconditions.checkArgument;
31import static com.google.common.base.Preconditions.checkNotNull;
Brian O'Connorb876bf12014-10-02 14:59:37 -070032
33/**
34 * Abstraction of multiple source to single destination connectivity intent.
35 */
Ray Milkeye6684082014-10-16 16:59:47 -070036public final class MultiPointToSinglePointIntent extends ConnectivityIntent {
Brian O'Connorb876bf12014-10-02 14:59:37 -070037
tom85258ee2014-10-07 00:10:02 -070038 private final Set<ConnectPoint> ingressPoints;
39 private final ConnectPoint egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070040
41 /**
42 * Creates a new multi-to-single point connectivity intent for the specified
Thomas Vachuskac96058a2014-10-20 23:00:16 -070043 * traffic selector and treatment.
Brian O'Connorb876bf12014-10-02 14:59:37 -070044 *
Thomas Vachuskac96058a2014-10-20 23:00:16 -070045 * @param appId application identifier
46 * @param selector traffic selector
47 * @param treatment treatment
tom85258ee2014-10-07 00:10:02 -070048 * @param ingressPoints set of ports from which ingress traffic originates
49 * @param egressPoint port to which traffic will egress
50 * @throws NullPointerException if {@code ingressPoints} or
51 * {@code egressPoint} is null.
52 * @throws IllegalArgumentException if the size of {@code ingressPoints} is
toma1d16b62014-10-02 23:45:11 -070053 * not more than 1
Brian O'Connorb876bf12014-10-02 14:59:37 -070054 */
Thomas Vachuskac96058a2014-10-20 23:00:16 -070055 public MultiPointToSinglePointIntent(ApplicationId appId,
56 TrafficSelector selector,
57 TrafficTreatment treatment,
tom85258ee2014-10-07 00:10:02 -070058 Set<ConnectPoint> ingressPoints,
59 ConnectPoint egressPoint) {
Thomas Vachuskac96058a2014-10-20 23:00:16 -070060 super(id(MultiPointToSinglePointIntent.class, selector, treatment,
61 ingressPoints, egressPoint), appId, null, selector, treatment);
Brian O'Connorb876bf12014-10-02 14:59:37 -070062
tom85258ee2014-10-07 00:10:02 -070063 checkNotNull(ingressPoints);
Thomas Vachuskac96058a2014-10-20 23:00:16 -070064 checkArgument(!ingressPoints.isEmpty(), "Ingress point set cannot be empty");
Brian O'Connorb876bf12014-10-02 14:59:37 -070065
tom85258ee2014-10-07 00:10:02 -070066 this.ingressPoints = Sets.newHashSet(ingressPoints);
67 this.egressPoint = checkNotNull(egressPoint);
Brian O'Connorb876bf12014-10-02 14:59:37 -070068 }
69
70 /**
71 * Constructor for serializer.
72 */
73 protected MultiPointToSinglePointIntent() {
74 super();
tom85258ee2014-10-07 00:10:02 -070075 this.ingressPoints = null;
76 this.egressPoint = null;
Brian O'Connorb876bf12014-10-02 14:59:37 -070077 }
78
79 /**
80 * Returns the set of ports on which ingress traffic should be connected to
81 * the egress port.
82 *
83 * @return set of ingress ports
84 */
tom85258ee2014-10-07 00:10:02 -070085 public Set<ConnectPoint> ingressPoints() {
86 return ingressPoints;
Brian O'Connorb876bf12014-10-02 14:59:37 -070087 }
88
89 /**
90 * Returns the port on which the traffic should egress.
91 *
92 * @return egress port
93 */
tom85258ee2014-10-07 00:10:02 -070094 public ConnectPoint egressPoint() {
95 return egressPoint;
Brian O'Connorb876bf12014-10-02 14:59:37 -070096 }
97
98 @Override
Brian O'Connorb876bf12014-10-02 14:59:37 -070099 public String toString() {
100 return MoreObjects.toStringHelper(getClass())
tom85258ee2014-10-07 00:10:02 -0700101 .add("id", id())
Thomas Vachuskae291c842014-10-21 02:52:38 -0700102 .add("appId", appId())
103 .add("selector", selector())
104 .add("treatment", treatment())
105 .add("ingress", ingressPoints())
106 .add("egress", egressPoint())
Brian O'Connorb876bf12014-10-02 14:59:37 -0700107 .toString();
108 }
109}