Sho SHIMIZU | 228140c | 2014-08-11 19:15:43 -0700 | [diff] [blame] | 1 | package net.onrc.onos.api.newintent; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 2 | |
Sho SHIMIZU | 5473991 | 2014-07-21 18:55:39 -0700 | [diff] [blame] | 3 | import net.onrc.onos.core.matchaction.match.PacketMatch; |
| 4 | import net.onrc.onos.core.util.SwitchPort; |
| 5 | |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 6 | import java.util.Collection; |
| 7 | import java.util.Collections; |
| 8 | import java.util.HashSet; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 9 | import java.util.Set; |
| 10 | |
Sho SHIMIZU | 228140c | 2014-08-11 19:15:43 -0700 | [diff] [blame] | 11 | // TODO: consider if this intent should be sub-class of Connectivity intent |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 12 | /** |
| 13 | * A packet layer Intent for a connectivity from a set of ports to a set of |
| 14 | * ports. |
| 15 | * <p> |
| 16 | * TODO: Design methods to support the ReactiveForwarding and the SDN-IP. <br> |
| 17 | * NOTE: Should this class support modifier methods? Should this object a |
| 18 | * read-only object? |
| 19 | */ |
Sho SHIMIZU | 228140c | 2014-08-11 19:15:43 -0700 | [diff] [blame] | 20 | public class PacketConnectivityIntent extends AbstractIntent { |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 21 | protected Set<SwitchPort> srcSwitchPorts; |
| 22 | protected PacketMatch match; |
| 23 | protected Set<SwitchPort> dstSwitchPorts; |
| 24 | protected boolean canSetupOpticalFlow; |
| 25 | protected int idleTimeoutValue; |
| 26 | protected int hardTimeoutValue; |
| 27 | |
| 28 | /** |
| 29 | * Creates a connectivity intent for the packet layer. |
| 30 | * <p> |
| 31 | * When the "canSetupOpticalFlow" option is true, this intent will compute |
| 32 | * the packet/optical converged path, decompose it to the OpticalPathFlow |
| 33 | * and the PacketPathFlow objects, and execute the operations to add them |
| 34 | * considering the dependency between the packet and optical layers. |
| 35 | * |
| 36 | * @param id ID for this new Intent object. |
| 37 | * @param srcSwitchPorts The set of source switch ports. |
| 38 | * @param match Traffic specifier for this object. |
| 39 | * @param dstSwitchPorts The set of destination switch ports. |
| 40 | * @param canSetupOpticalFlow The flag whether this intent can create |
| 41 | * optical flows if needed. |
| 42 | */ |
Sho SHIMIZU | ec4f5a7 | 2014-07-21 18:21:23 -0700 | [diff] [blame] | 43 | public PacketConnectivityIntent(IntentId id, |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 44 | Collection<SwitchPort> srcSwitchPorts, PacketMatch match, |
| 45 | Collection<SwitchPort> dstSwitchPorts, boolean canSetupOpticalFlow) { |
| 46 | super(id); |
| 47 | this.srcSwitchPorts = new HashSet<SwitchPort>(srcSwitchPorts); |
| 48 | this.match = match; |
| 49 | this.dstSwitchPorts = new HashSet<SwitchPort>(dstSwitchPorts); |
| 50 | this.canSetupOpticalFlow = canSetupOpticalFlow; |
| 51 | this.idleTimeoutValue = 0; |
| 52 | this.hardTimeoutValue = 0; |
| 53 | |
| 54 | // TODO: check consistency between these parameters. |
| 55 | } |
| 56 | |
| 57 | /** |
Sho SHIMIZU | 1674fb3 | 2014-08-20 14:44:31 -0700 | [diff] [blame] | 58 | * Constructor for serializer. |
| 59 | */ |
| 60 | protected PacketConnectivityIntent() { |
| 61 | super(); |
| 62 | this.srcSwitchPorts = null; |
| 63 | this.match = null; |
| 64 | this.dstSwitchPorts = null; |
| 65 | this.canSetupOpticalFlow = false; |
| 66 | this.idleTimeoutValue = 0; |
| 67 | this.hardTimeoutValue = 0; |
| 68 | } |
| 69 | |
| 70 | /** |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 71 | * Gets the set of source switch ports. |
| 72 | * |
| 73 | * @return the set of source switch ports. |
| 74 | */ |
| 75 | public Collection<SwitchPort> getSrcSwitchPorts() { |
| 76 | return Collections.unmodifiableCollection(srcSwitchPorts); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Gets the traffic specifier. |
| 81 | * |
| 82 | * @return The traffic specifier. |
| 83 | */ |
| 84 | public PacketMatch getMatch() { |
| 85 | return match; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Gets the set of destination switch ports. |
| 90 | * |
| 91 | * @return the set of destination switch ports. |
| 92 | */ |
| 93 | public Collection<SwitchPort> getDstSwitchPorts() { |
| 94 | return Collections.unmodifiableCollection(dstSwitchPorts); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Adds the specified port to the set of source ports. |
| 99 | * |
| 100 | * @param port SwitchPort object to be added |
| 101 | */ |
| 102 | public void addSrcSwitchPort(SwitchPort port) { |
| 103 | // TODO implement it. |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Adds the specified port to the set of destination ports. |
| 108 | * |
| 109 | * @param port SwitchPort object to be added |
| 110 | */ |
| 111 | public void addDstSwitchPort(SwitchPort port) { |
| 112 | // TODO implement it. |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Removes the specified port from the set of source ports. |
| 117 | * |
| 118 | * @param port SwitchPort object to be removed |
| 119 | */ |
| 120 | public void removeSrcSwitchPort(SwitchPort port) { |
| 121 | // TODO implement it. |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Removes the specified port from the set of destination ports. |
| 126 | * |
| 127 | * @param port SwitchPort object to be removed |
| 128 | */ |
| 129 | public void removeDstSwitchPort(SwitchPort port) { |
| 130 | // TODO implement it. |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Sets idle-timeout value. |
| 135 | * |
| 136 | * @param timeout Idle-timeout value (seconds) |
| 137 | */ |
| 138 | public void setIdleTimeout(int timeout) { |
| 139 | idleTimeoutValue = timeout; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Sets hard-timeout value. |
| 144 | * |
| 145 | * @param timeout Hard-timeout value (seconds) |
| 146 | */ |
| 147 | public void setHardTimeout(int timeout) { |
| 148 | hardTimeoutValue = timeout; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Gets idle-timeout value. |
| 153 | * |
| 154 | * @return Idle-timeout value (seconds) |
| 155 | */ |
| 156 | public int getIdleTimeout() { |
| 157 | return idleTimeoutValue; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Gets hard-timeout value. |
| 162 | * |
| 163 | * @return Hard-timeout value (seconds) |
| 164 | */ |
| 165 | public int getHardTimeout() { |
| 166 | return hardTimeoutValue; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Returns whether this intent can create optical flows if needed. |
| 171 | * |
| 172 | * @return whether this intent can create optical flows. |
| 173 | */ |
| 174 | public boolean canSetupOpticalFlow() { |
| 175 | return canSetupOpticalFlow; |
| 176 | } |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 177 | } |