blob: d5c4d572fe24b5364bb251bd243f6715615cccf0 [file] [log] [blame]
Ray Milkeycaa450b2014-10-29 15:54:24 -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 */
19package org.onlab.onos.net.intent;
20
21import org.onlab.onos.core.ApplicationId;
22import org.onlab.onos.net.ConnectPoint;
23import org.onlab.onos.net.flow.TrafficSelector;
24import org.onlab.onos.net.flow.TrafficTreatment;
25import org.onlab.onos.net.resource.BandwidthResourceRequest;
26
27import com.google.common.base.MoreObjects;
28
29import static com.google.common.base.Preconditions.checkNotNull;
30
31/**
32 * Abstraction of point-to-point connectivity.
33 */
34public class PointToPointIntentWithBandwidthConstraint extends ConnectivityIntent {
35
36 private final ConnectPoint ingressPoint;
37 private final ConnectPoint egressPoint;
38 private final BandwidthResourceRequest bandwidthResourceRequest;
39
40 /**
41 * Creates a new point-to-point intent with the supplied ingress/egress
42 * ports.
43 *
44 * @param appId application identifier
45 * @param selector traffic selector
46 * @param treatment treatment
47 * @param ingressPoint ingress port
48 * @param egressPoint egress port
49 * @throws NullPointerException if {@code ingressPoint} or {@code egressPoints} is null.
50 */
51 public PointToPointIntentWithBandwidthConstraint(ApplicationId appId, TrafficSelector selector,
52 TrafficTreatment treatment,
53 ConnectPoint ingressPoint,
54 ConnectPoint egressPoint,
55 BandwidthResourceRequest bandwidthResourceRequest) {
56 super(id(PointToPointIntentWithBandwidthConstraint.class, selector,
57 treatment, ingressPoint, egressPoint, bandwidthResourceRequest.bandwidth()),
58 appId, null, selector, treatment);
59 this.ingressPoint = checkNotNull(ingressPoint);
60 this.egressPoint = checkNotNull(egressPoint);
61 this.bandwidthResourceRequest = bandwidthResourceRequest;
62 }
63
64 /**
65 * Constructor for serializer.
66 */
67 protected PointToPointIntentWithBandwidthConstraint() {
68 super();
69 this.ingressPoint = null;
70 this.egressPoint = null;
71 bandwidthResourceRequest = new BandwidthResourceRequest(0.0);
72 }
73
74 /**
75 * Returns the port on which the ingress traffic should be connected to
76 * the egress.
77 *
78 * @return ingress port
79 */
80 public ConnectPoint ingressPoint() {
81 return ingressPoint;
82 }
83
84 /**
85 * Returns the port on which the traffic should egress.
86 *
87 * @return egress port
88 */
89 public ConnectPoint egressPoint() {
90 return egressPoint;
91 }
92
93 public BandwidthResourceRequest bandwidthRequest() {
94 return this.bandwidthResourceRequest;
95 }
96
97 @Override
98 public String toString() {
99 return MoreObjects.toStringHelper(getClass())
100 .add("id", id())
101 .add("appId", appId())
102 .add("selector", selector())
103 .add("treatment", treatment())
104 .add("ingress", ingressPoint)
105 .add("egress", egressPoint)
106 .add("bandwidth", bandwidthResourceRequest.bandwidth().toString())
107 .toString();
108 }
109
110}