blob: cc00979882f7688fdffb5847033106346c6ea248 [file] [log] [blame]
Jonathan Hartaa380972014-04-03 10:24:46 -07001package net.onrc.onos.core.intent;
Toshio Koidead17d5e2014-02-11 11:36:02 -08002
Toshio Koidead17d5e2014-02-11 11:36:02 -08003
4/**
5 * @author Toshio Koide (t-koide@onlab.us)
6 */
7public class PathIntent extends Intent {
Ray Milkey269ffb92014-04-03 14:43:30 -07008 protected Path path;
9 protected double bandwidth;
10 protected Intent parentIntent;
Toshio Koidec406e792014-02-14 16:52:42 -080011
Ray Milkey269ffb92014-04-03 14:43:30 -070012 public static String createFirstId(String parentId) {
13 return String.format("%s___0", parentId);
14 }
Toshio Koidea10c0372014-02-20 17:28:10 -080015
Ray Milkey269ffb92014-04-03 14:43:30 -070016 public static String createNextId(String currentId) {
Ray Milkey45614c52014-04-07 16:30:54 -070017 String[] parts = currentId.split("___");
Ray Milkey269ffb92014-04-03 14:43:30 -070018 return String.format("%s___%d", parts[0], Long.valueOf(parts[1]) + 1);
19 }
Toshio Koidea10c0372014-02-20 17:28:10 -080020
Ray Milkey269ffb92014-04-03 14:43:30 -070021 /**
Ray Milkeyb41100a2014-04-10 10:42:15 -070022 * Default constructor for Kryo deserialization.
Ray Milkey269ffb92014-04-03 14:43:30 -070023 */
24 protected PathIntent() {
25 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080026
Ray Milkey269ffb92014-04-03 14:43:30 -070027 /**
Ray Milkey269ffb92014-04-03 14:43:30 -070028 * @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 Koidead17d5e2014-02-11 11:36:02 -080040
Ray Milkey269ffb92014-04-03 14:43:30 -070041 public double getBandwidth() {
42 return bandwidth;
43 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080044
Ray Milkey269ffb92014-04-03 14:43:30 -070045 public Path getPath() {
46 return path;
47 }
Toshio Koidec406e792014-02-14 16:52:42 -080048
Ray Milkey269ffb92014-04-03 14:43:30 -070049 public Intent getParentIntent() {
50 return parentIntent;
51 }
Toshio Koide93be5d62014-02-23 19:30:57 -080052
Ray Milkey269ffb92014-04-03 14:43:30 -070053 @Override
Pavlin Radoslavov7fb16412014-04-11 18:45:19 -070054 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 Milkey269ffb92014-04-03 14:43:30 -070066 public String toString() {
67 return String.format("%s, %s, %s", getId(), getState(), getPath());
68 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080069}