blob: 7caef9f7eb7a7727701a2395f8da31b09868ab24 [file] [log] [blame]
Toshio Koidead17d5e2014-02-11 11:36:02 -08001package net.onrc.onos.intent;
2
3import net.onrc.onos.ofcontroller.networkgraph.Path;
4
5/**
6 * @author Toshio Koide (t-koide@onlab.us)
7 */
8public class PathIntent extends Intent {
Toshio Koided9fa2a82014-02-19 17:35:18 -08009 protected Path path;
Toshio Koide0e4d8d22014-02-14 10:56:10 -080010 protected double bandwidth;
Toshio Koidead17d5e2014-02-11 11:36:02 -080011 protected Intent parentIntent;
Toshio Koidec406e792014-02-14 16:52:42 -080012
Toshio Koidea10c0372014-02-20 17:28:10 -080013 public static String createFirstId(String parentId) {
Toshio Koide52a6bca2014-02-21 21:28:22 -080014 return String.format("%s___0", parentId);
Toshio Koidea10c0372014-02-20 17:28:10 -080015 }
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 Koidec406e792014-02-14 16:52:42 -080022 /**
23 * Default constructor for Kryo deserialization
24 */
25 protected PathIntent() {
26 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080027
28 /**
Toshio Koided9fa2a82014-02-19 17:35:18 -080029 *
Toshio Koidead17d5e2014-02-11 11:36:02 -080030 * @param graph
31 * @param path
32 * @param bandwidth bandwidth which should be allocated for the path.
Toshio Koide0e4d8d22014-02-14 10:56:10 -080033 * If 0, no intent for bandwidth allocation (best effort).
34 * @param parentIntent parent intent. If null, this is root intent.
Toshio Koide13986d12014-02-11 20:25:32 -080035 * @param id
Toshio Koidead17d5e2014-02-11 11:36:02 -080036 */
Toshio Koide0e4d8d22014-02-14 10:56:10 -080037 public PathIntent(String id, Path path, double bandwidth, Intent parentIntent) {
Toshio Koide13986d12014-02-11 20:25:32 -080038 super(id);
Toshio Koided9fa2a82014-02-19 17:35:18 -080039 this.path = path;
Toshio Koidead17d5e2014-02-11 11:36:02 -080040 this.bandwidth = bandwidth;
41 this.parentIntent = parentIntent;
42 }
43
Toshio Koidec406e792014-02-14 16:52:42 -080044 public double getBandwidth() {
Toshio Koidead17d5e2014-02-11 11:36:02 -080045 return bandwidth;
46 }
47
Toshio Koided9fa2a82014-02-19 17:35:18 -080048 public Path getPath() {
Toshio Koide0c9106d2014-02-19 15:26:38 -080049 return path;
Toshio Koidec406e792014-02-14 16:52:42 -080050 }
51
Toshio Koidead17d5e2014-02-11 11:36:02 -080052 public Intent getParentIntent() {
53 return parentIntent;
54 }
Toshio Koide93be5d62014-02-23 19:30:57 -080055
56 @Override
57 public String toString() {
58 return String.format("%s, %s, %s", getId(), getState(), getPath());
59 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080060}