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 | |
Jonathan Hart | 472062d | 2014-04-03 10:56:48 -0700 | [diff] [blame] | 3 | import net.onrc.onos.core.topology.Path; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 4 | |
| 5 | /** |
| 6 | * @author Toshio Koide (t-koide@onlab.us) |
| 7 | */ |
| 8 | public class PathIntent extends Intent { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 9 | protected Path path; |
| 10 | protected double bandwidth; |
| 11 | protected Intent parentIntent; |
Toshio Koide | c406e79 | 2014-02-14 16:52:42 -0800 | [diff] [blame] | 12 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 13 | public static String createFirstId(String parentId) { |
| 14 | return String.format("%s___0", parentId); |
| 15 | } |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 16 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 17 | public static String createNextId(String currentId) { |
Ray Milkey | 45614c5 | 2014-04-07 16:30:54 -0700 | [diff] [blame] | 18 | String[] parts = currentId.split("___"); |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 19 | return String.format("%s___%d", parts[0], Long.valueOf(parts[1]) + 1); |
| 20 | } |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 21 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 22 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 23 | * Default constructor for Kryo deserialization. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 24 | */ |
| 25 | protected PathIntent() { |
| 26 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 27 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 28 | /** |
| 29 | * @param graph |
| 30 | * @param path |
| 31 | * @param bandwidth bandwidth which should be allocated for the path. |
| 32 | * If 0, no intent for bandwidth allocation (best effort). |
| 33 | * @param parentIntent parent intent. If null, this is root intent. |
| 34 | * @param id |
| 35 | */ |
| 36 | public PathIntent(String id, Path path, double bandwidth, Intent parentIntent) { |
| 37 | super(id); |
| 38 | this.path = path; |
| 39 | this.bandwidth = bandwidth; |
| 40 | this.parentIntent = parentIntent; |
| 41 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 42 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 43 | public double getBandwidth() { |
| 44 | return bandwidth; |
| 45 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 46 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 47 | public Path getPath() { |
| 48 | return path; |
| 49 | } |
Toshio Koide | c406e79 | 2014-02-14 16:52:42 -0800 | [diff] [blame] | 50 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 51 | public Intent getParentIntent() { |
| 52 | return parentIntent; |
| 53 | } |
Toshio Koide | 93be5d6 | 2014-02-23 19:30:57 -0800 | [diff] [blame] | 54 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 55 | @Override |
Pavlin Radoslavov | 7fb1641 | 2014-04-11 18:45:19 -0700 | [diff] [blame] | 56 | public int hashCode() { |
| 57 | // TODO: Is this the intended behavior? |
| 58 | return (super.hashCode()); |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public boolean equals(Object obj) { |
| 63 | // TODO: Is this the intended behavior? |
| 64 | return (super.equals(obj)); |
| 65 | } |
| 66 | |
| 67 | @Override |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 68 | public String toString() { |
| 69 | return String.format("%s, %s, %s", getId(), getState(), getPath()); |
| 70 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 71 | } |