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