Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.intent; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 2 | |
| 3 | import net.floodlightcontroller.util.MACAddress; |
Ray Milkey | 2fa6ca4 | 2014-06-13 15:38:20 -0700 | [diff] [blame^] | 4 | import net.onrc.onos.core.topology.web.serializers.ShortestPathIntentSerializer; |
Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 5 | import net.onrc.onos.core.util.Dpid; |
Ray Milkey | 2fa6ca4 | 2014-06-13 15:38:20 -0700 | [diff] [blame^] | 6 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 7 | |
| 8 | /** |
| 9 | * @author Toshio Koide (t-koide@onlab.us) |
| 10 | */ |
Ray Milkey | 2fa6ca4 | 2014-06-13 15:38:20 -0700 | [diff] [blame^] | 11 | @JsonSerialize(using = ShortestPathIntentSerializer.class) |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 12 | public class ShortestPathIntent extends Intent { |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 13 | public static final long EMPTYMACADDRESS = 0; |
| 14 | public static final int EMPTYIPADDRESS = 0; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 15 | protected long srcSwitchDpid; |
| 16 | protected long srcPortNumber; |
| 17 | protected long srcMacAddress; |
| 18 | protected long dstSwitchDpid; |
| 19 | protected long dstPortNumber; |
| 20 | protected long dstMacAddress; |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 21 | protected int srcIpAddress; |
| 22 | protected int dstIpAddress; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 23 | protected String pathIntentId = null; |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 24 | protected int idleTimeout; |
| 25 | protected int hardTimeout; |
| 26 | protected int firstSwitchIdleTimeout; |
Jonathan Hart | 4dc8d87 | 2014-05-30 14:23:25 -0700 | [diff] [blame] | 27 | protected int firstSwitchHardTimeout; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 28 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 29 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 30 | * Default constructor for Kryo deserialization. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 31 | */ |
| 32 | protected ShortestPathIntent() { |
| 33 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 34 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Constructor for ShortestPathIntent. |
| 37 | * |
| 38 | * @param id Intent ID |
| 39 | * @param srcSwitch Source Switch DPID |
| 40 | * @param srcPort Source Port |
| 41 | * @param srcMac Source Host MAC Address |
| 42 | * @param dstSwitch Destination Switch DPID |
| 43 | * @param dstPort Destination Port |
| 44 | * @param dstMac Destination Host MAC Address |
| 45 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 46 | public ShortestPathIntent(String id, |
| 47 | long srcSwitch, long srcPort, long srcMac, |
| 48 | long dstSwitch, long dstPort, long dstMac) { |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 49 | //super(id); |
| 50 | this(id, srcSwitch, srcPort, srcMac, EMPTYIPADDRESS, dstSwitch, dstPort, dstMac, EMPTYIPADDRESS); |
| 51 | } |
| 52 | |
| 53 | // CHECKSTYLE:OFF suppress the warning about too many parameters |
| 54 | public ShortestPathIntent(String id, |
| 55 | long srcSwitch, long srcPort, long srcMac, int srcIp, |
| 56 | long dstSwitch, long dstPort, long dstMac, int dstIp ) { |
| 57 | // CHECKSTYLE:ON |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 58 | super(id); |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 59 | this.srcSwitchDpid = srcSwitch; |
| 60 | this.srcPortNumber = srcPort; |
| 61 | this.srcMacAddress = srcMac; |
| 62 | this.dstSwitchDpid = dstSwitch; |
| 63 | this.dstPortNumber = dstPort; |
| 64 | this.dstMacAddress = dstMac; |
| 65 | this.srcIpAddress = srcIp; |
| 66 | this.dstIpAddress = dstIp; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 67 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 68 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 69 | /** |
| 70 | * Gets the source Switch DPID. |
| 71 | * |
| 72 | * @return Source Switch DPID |
| 73 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 74 | public long getSrcSwitchDpid() { |
| 75 | return srcSwitchDpid; |
| 76 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 77 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 78 | /** |
| 79 | * Gets the source Port. |
| 80 | * |
| 81 | * @return Source Port |
| 82 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 83 | public long getSrcPortNumber() { |
| 84 | return srcPortNumber; |
| 85 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 86 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 87 | /** |
| 88 | * Gets the source Host MAC Address. |
| 89 | * |
| 90 | * @return Source Host MAC Address |
| 91 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 92 | public long getSrcMac() { |
| 93 | return srcMacAddress; |
| 94 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 95 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 96 | /** |
| 97 | * Gets the destination Switch DPID. |
| 98 | * |
| 99 | * @return Destination Switch DPID |
| 100 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 101 | public long getDstSwitchDpid() { |
| 102 | return dstSwitchDpid; |
| 103 | } |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 104 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 105 | /** |
| 106 | * Gets the destination Port. |
| 107 | * |
| 108 | * @return Destination Port |
| 109 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 110 | public long getDstPortNumber() { |
| 111 | return dstPortNumber; |
| 112 | } |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 113 | |
Yuta HIGUCHI | ce4a06b | 2014-04-25 19:37:57 -0700 | [diff] [blame] | 114 | /** |
| 115 | * Gets the destination Host MAC Address. |
| 116 | * |
| 117 | * @return Destination Host MAC Address |
| 118 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 119 | public long getDstMac() { |
| 120 | return dstMacAddress; |
| 121 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 122 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 123 | public void setPathIntent(PathIntent pathIntent) { |
| 124 | pathIntentId = pathIntent.getId(); |
| 125 | } |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 126 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 127 | public String getPathIntentId() { |
| 128 | return pathIntentId; |
| 129 | } |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 130 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 131 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 132 | public int getIdleTimeout() { |
| 133 | return idleTimeout; |
| 134 | } |
| 135 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 136 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 137 | public int getHardTimeout() { |
| 138 | return hardTimeout; |
| 139 | } |
| 140 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 141 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 142 | public void setIdleTimeout(int idleTimeout) { |
| 143 | this.idleTimeout = idleTimeout; |
| 144 | } |
| 145 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 146 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 147 | public void setHardTimeout(int hardTimeout) { |
| 148 | this.hardTimeout = hardTimeout; |
| 149 | } |
| 150 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 151 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 152 | public int getFirstSwitchIdleTimeout() { |
| 153 | return firstSwitchIdleTimeout; |
| 154 | } |
| 155 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 156 | // TODO - this is intended to be refactored and removed |
Jonathan Hart | 33e1f30 | 2014-05-30 14:37:09 -0700 | [diff] [blame] | 157 | public int getFirstSwitchHardTimeout() { |
Jonathan Hart | 4dc8d87 | 2014-05-30 14:23:25 -0700 | [diff] [blame] | 158 | return firstSwitchHardTimeout; |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 161 | // TODO - this is intended to be refactored and removed |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 162 | public void setFirstSwitchIdleTimeout(int firstSwitchIdleTimeout) { |
| 163 | this.firstSwitchIdleTimeout = firstSwitchIdleTimeout; |
| 164 | } |
| 165 | |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 166 | // TODO - this is intended to be refactored and removed |
Jonathan Hart | 33e1f30 | 2014-05-30 14:37:09 -0700 | [diff] [blame] | 167 | public void setFirstSwitchHardTimeout(int firstSwitchHardTimeout) { |
| 168 | this.firstSwitchHardTimeout = firstSwitchHardTimeout; |
TeruU | 30c0c93 | 2014-05-15 16:47:41 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 171 | @Override |
Pavlin Radoslavov | 7fb1641 | 2014-04-11 18:45:19 -0700 | [diff] [blame] | 172 | public int hashCode() { |
| 173 | // TODO: Is this the intended behavior? |
| 174 | return (super.hashCode()); |
| 175 | } |
| 176 | |
| 177 | @Override |
| 178 | public boolean equals(Object obj) { |
| 179 | // TODO: Is this the intended behavior? |
| 180 | return (super.equals(obj)); |
| 181 | } |
| 182 | |
| 183 | @Override |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 184 | public String toString() { |
Jonathan Hart | c00f5c2 | 2014-06-10 15:14:40 -0700 | [diff] [blame] | 185 | return String.format("id:%s, state:%s, srcDpid:%s, srcPort:%d, " + |
| 186 | "srcMac:%s, srcIP:%s, dstDpid:%s, dstPort:%d, dstMac:%s, dstIP:%s", |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 187 | getId(), getState(), |
Jonathan Hart | c00f5c2 | 2014-06-10 15:14:40 -0700 | [diff] [blame] | 188 | new Dpid(srcSwitchDpid), srcPortNumber, |
| 189 | MACAddress.valueOf(srcMacAddress), Integer.toString(srcIpAddress), |
| 190 | new Dpid(dstSwitchDpid), dstPortNumber, |
| 191 | MACAddress.valueOf(dstMacAddress), Integer.toString(dstIpAddress)); |
Komal Shah | 399a292 | 2014-05-28 01:57:40 -0700 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | public int getSrcIp() { |
| 195 | return srcIpAddress; |
| 196 | } |
| 197 | |
| 198 | public int getDstIp() { |
| 199 | return dstIpAddress; |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 200 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 201 | } |