Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 1 | package net.onrc.onos.intent; |
| 2 | |
| 3 | import net.onrc.onos.ofcontroller.networkgraph.Path; |
| 4 | |
| 5 | /** |
| 6 | * @author Toshio Koide (t-koide@onlab.us) |
| 7 | */ |
| 8 | public class PathIntent extends Intent { |
Toshio Koide | d9fa2a8 | 2014-02-19 17:35:18 -0800 | [diff] [blame] | 9 | protected Path path; |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 10 | protected double bandwidth; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 11 | protected Intent parentIntent; |
Toshio Koide | c406e79 | 2014-02-14 16:52:42 -0800 | [diff] [blame] | 12 | |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 13 | public static String createFirstId(String parentId) { |
Toshio Koide | 52a6bca | 2014-02-21 21:28:22 -0800 | [diff] [blame] | 14 | return String.format("%s___0", parentId); |
Toshio Koide | a10c037 | 2014-02-20 17:28:10 -0800 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | public static String createNextId(String currentId) { |
| 18 | String parts[] = currentId.split("___"); |
| 19 | return String.format("%s___%d", parts[0], Long.valueOf(parts[1])+1); |
| 20 | } |
| 21 | |
Toshio Koide | c406e79 | 2014-02-14 16:52:42 -0800 | [diff] [blame] | 22 | /** |
| 23 | * Default constructor for Kryo deserialization |
| 24 | */ |
| 25 | protected PathIntent() { |
| 26 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 27 | |
| 28 | /** |
Toshio Koide | d9fa2a8 | 2014-02-19 17:35:18 -0800 | [diff] [blame] | 29 | * |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 30 | * @param graph |
| 31 | * @param path |
| 32 | * @param bandwidth bandwidth which should be allocated for the path. |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 33 | * If 0, no intent for bandwidth allocation (best effort). |
| 34 | * @param parentIntent parent intent. If null, this is root intent. |
Toshio Koide | 13986d1 | 2014-02-11 20:25:32 -0800 | [diff] [blame] | 35 | * @param id |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 36 | */ |
Toshio Koide | 0e4d8d2 | 2014-02-14 10:56:10 -0800 | [diff] [blame] | 37 | public PathIntent(String id, Path path, double bandwidth, Intent parentIntent) { |
Toshio Koide | 13986d1 | 2014-02-11 20:25:32 -0800 | [diff] [blame] | 38 | super(id); |
Toshio Koide | d9fa2a8 | 2014-02-19 17:35:18 -0800 | [diff] [blame] | 39 | this.path = path; |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 40 | this.bandwidth = bandwidth; |
| 41 | this.parentIntent = parentIntent; |
| 42 | } |
| 43 | |
Toshio Koide | c406e79 | 2014-02-14 16:52:42 -0800 | [diff] [blame] | 44 | public double getBandwidth() { |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 45 | return bandwidth; |
| 46 | } |
| 47 | |
Toshio Koide | d9fa2a8 | 2014-02-19 17:35:18 -0800 | [diff] [blame] | 48 | public Path getPath() { |
Toshio Koide | 0c9106d | 2014-02-19 15:26:38 -0800 | [diff] [blame] | 49 | return path; |
Toshio Koide | c406e79 | 2014-02-14 16:52:42 -0800 | [diff] [blame] | 50 | } |
| 51 | |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 52 | public Intent getParentIntent() { |
| 53 | return parentIntent; |
| 54 | } |
Toshio Koide | 93be5d6 | 2014-02-23 19:30:57 -0800 | [diff] [blame] | 55 | |
| 56 | @Override |
| 57 | public String toString() { |
| 58 | return String.format("%s, %s, %s", getId(), getState(), getPath()); |
| 59 | } |
Toshio Koide | ad17d5e | 2014-02-11 11:36:02 -0800 | [diff] [blame] | 60 | } |