blob: 633fe8bc47468ca95887fe3b2773785e323123ab [file] [log] [blame]
Jonathan Hartaa380972014-04-03 10:24:46 -07001package net.onrc.onos.core.intent;
Toshio Koidead17d5e2014-02-11 11:36:02 -08002
Jonathan Hart472062d2014-04-03 10:56:48 -07003import net.onrc.onos.core.topology.Path;
Toshio Koidead17d5e2014-02-11 11:36:02 -08004
5/**
6 * @author Toshio Koide (t-koide@onlab.us)
7 */
8public class PathIntent extends Intent {
Ray Milkey269ffb92014-04-03 14:43:30 -07009 protected Path path;
10 protected double bandwidth;
11 protected Intent parentIntent;
Toshio Koidec406e792014-02-14 16:52:42 -080012
Ray Milkey269ffb92014-04-03 14:43:30 -070013 public static String createFirstId(String parentId) {
14 return String.format("%s___0", parentId);
15 }
Toshio Koidea10c0372014-02-20 17:28:10 -080016
Ray Milkey269ffb92014-04-03 14:43:30 -070017 public static String createNextId(String currentId) {
Ray Milkey45614c52014-04-07 16:30:54 -070018 String[] parts = currentId.split("___");
Ray Milkey269ffb92014-04-03 14:43:30 -070019 return String.format("%s___%d", parts[0], Long.valueOf(parts[1]) + 1);
20 }
Toshio Koidea10c0372014-02-20 17:28:10 -080021
Ray Milkey269ffb92014-04-03 14:43:30 -070022 /**
23 * Default constructor for Kryo deserialization
24 */
25 protected PathIntent() {
26 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080027
Ray Milkey269ffb92014-04-03 14:43:30 -070028 /**
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 Koidead17d5e2014-02-11 11:36:02 -080042
Ray Milkey269ffb92014-04-03 14:43:30 -070043 public double getBandwidth() {
44 return bandwidth;
45 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080046
Ray Milkey269ffb92014-04-03 14:43:30 -070047 public Path getPath() {
48 return path;
49 }
Toshio Koidec406e792014-02-14 16:52:42 -080050
Ray Milkey269ffb92014-04-03 14:43:30 -070051 public Intent getParentIntent() {
52 return parentIntent;
53 }
Toshio Koide93be5d62014-02-23 19:30:57 -080054
Ray Milkey269ffb92014-04-03 14:43:30 -070055 @Override
56 public String toString() {
57 return String.format("%s, %s, %s", getId(), getState(), getPath());
58 }
Toshio Koidead17d5e2014-02-11 11:36:02 -080059}