Andrea Campanella

Add GeoLink Path support

Change-Id: If2a849ce7e687fed7e11079697eaeb0010bc64a0
......@@ -26,6 +26,9 @@ import org.onosproject.net.ElementId;
import org.onosproject.net.HostId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.topology.GeoDistanceLinkWeight;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.PathService;
import org.onosproject.ui.RequestHandler;
import org.onosproject.ui.UiConnection;
......@@ -62,11 +65,12 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler {
private static final String ENDSTATION = "endstation";
public static final String DST = "Dst";
public static final String SRC = "Src";
private static LinkWeight linkData;
private Set<Link> allPathLinks;
private enum Mode {
SHORTEST, DISJOINT, SRLG
SHORTEST, DISJOINT, GEODATA, SRLG, INVALID
}
private final Logger log = LoggerFactory.getLogger(getClass());
......@@ -87,6 +91,7 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler {
public void init(UiConnection connection, ServiceDirectory directory) {
super.init(connection, directory);
pathService = directory.get(PathService.class);
linkData = new GeoDistanceLinkWeight(directory.get(DeviceService.class));
}
@Override
......@@ -165,6 +170,8 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler {
}
}
private final class NextPathHandler extends RequestHandler {
public NextPathHandler() {
super(PAINTER_NEXT_PATH);
......@@ -197,9 +204,23 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler {
@Override
public void process(long sid, ObjectNode payload) {
String mode = string(payload, MODE);
currentMode = (mode.equals("shortest") ?
Mode.SHORTEST : (mode.equals("disjoint") ?
Mode.DISJOINT : Mode.SRLG));
switch (mode) {
case "shortest":
currentMode = Mode.SHORTEST;
break;
case "disjoint":
currentMode = Mode.DISJOINT;
break;
case "geodata":
currentMode = Mode.GEODATA;
break;
case "srlg":
currentMode = Mode.SRLG;
break;
default:
currentMode = Mode.INVALID;
break;
}
//TODO: add support for SRLG
findAndSendPaths(currentMode);
}
......@@ -226,6 +247,9 @@ public class PathPainterTopovMessageHandler extends UiMessageHandler {
} else if (mode.equals(Mode.DISJOINT)) {
paths = ImmutableList.copyOf(pathService.getDisjointPaths(src, dst));
allPathLinks = buildDisjointPaths(builder).build();
} else if (mode.equals(Mode.GEODATA)) {
paths = ImmutableList.copyOf(pathService.getPaths(src, dst, linkData));
allPathLinks = buildPaths(builder).build();
} else {
log.info("Unsupported MODE");
}
......
......@@ -53,8 +53,74 @@
d: 'M25.8,84l-9.2-57 M27.3,83.8l-9.2-57l-3,0.5l9.2,57L27.3,83.8z M83.2,37.7L26.8,15.5 M83.7,36.1L26.6,14' +
'l-1,3.2l57,22.1L83.7,36.1z M34.1,95l61.4-40.6 M96.4,55.7l-1.9-2.5L33.2,93.8l1.9,2.5L96.4,55.7z M26.6,27.6H6.7V7.7h19.9V27.6z' +
'M102.1,36H82.2v19.9h19.9V36z M35.3,83.5H15.3v19.9h19.9V83.5z'
}
},
geo: {
vb: '0 0 110 110',
d: 'M55.7,94.6c-0.1-0.3,0-1-0.1-1.4'+
'c-0.7-0.5-1.3-2.2-2.1-2.6c-0.5-0.3-1.4-0.2-2-0.5c-0.3-0.1-0.6-0.3-0.9-0.4c-0.4-0.1-0.8-0.1-1.1-0.3c-1.3-0.7-1.9-3-3.5-2.9'+
'c-0.7,0-1.3,0.7-1.9,0.7c-0.6,0-1.6-0.5-2.4-0.9c-0.8-0.4-1.6-0.6-2.3-1c-0.5-0.3-0.9-0.9-1.3-1.1C37.8,84,37.2,84,37,83.9'+
'c-0.4-0.2-0.8-0.7-1.3-1.1c-0.5-0.4-1-0.9-1-1.4c0-0.6,0.5-1,0.5-1.6c0.2-1.7-1-2.9-1.7-3.9c-0.5-0.7-1.1-1.4-1.7-2.1'+
'c0-0.5,0-0.5,0-1c-0.4-0.4-0.7-1.1-1.1-1.7c-0.4-0.6-1.1-1.2-1.2-1.9c-0.1-0.8,0.3-1.5,0-2.3c-0.5-1.3-2-0.7-1.8,1'+
'c0.1,0.5,0.6,1.1,0.8,1.6c0.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.9,1-2.8,1.5c-0.8,0.5-2,1.1-2.2,2.1c-0.1,0.5,0,1.3-0.2,1.8c-0.1,0.3-0.4,0.6-0.5,0.9c-0.7,1.5-1.3,3.4-0.8,5.5'+
'c0.1,0.3,0.8,2.1,1.1,2.4c0.3,0.4,1.3,1,1.8,1c0.5,0,1-0.3,1.5-0.4c0.5-0.1,1.2-0.1,1.7-0.3c1.4-0.5,1.1-2.6,2.5-3.3'+
'c0.6-0.3,1.3-0.4,2.4-0.4c0.3,0.3,0.5,0.9,0.4,1.4c0,0.4-0.3,0.7-0.5,1.2c-0.1,0.5-0.2,1-0.3,1.4c-0.2,0.5-0.6,0.8-0.8,1.3'+
'c-0.1,0.3,0,0.7-0.1,0.9c-0.1,0.5-0.7,0.8-0.4,1.3c1.4,0.6,3-0.2,4.2,0.1c0.5,0.1,1.5,0.8,1.5,1.7c0,0.7-0.4,1.1-0.5,1.8'+
'c-0.1,0.9-0.4,2-0.4,2.7c-0.1,1.2,1.5,3.2,2.7,3.2L55.7,94.6z M39.1,54.2L31.7,54v11.2h10.3v-8.7L39.1,54.2z M52.2,35.7l7.5,0.1'+
'V24.6H49.5l0,8.9 M39.1,54.2l2.9,2.3l10.3-20.8l-2.7-2.1L39.1,54.2z M47.2,46.4'
}
},
activate: function () {
......@@ -124,6 +190,13 @@
tt: 'Set disjoint paths mode',
gid: '*djp'
},
6: {
cb: function () {
pps.setMode("geodata");
},
tt: 'Set geodata path weight mode',
gid: '*geo'
},
leftArrow: {
cb: function () {
pps.prevPath();
......@@ -140,7 +213,7 @@
},
_keyOrder: [
'1', '2', '3', '4', '5', 'leftArrow', 'rightArrow'
'1', '2', '3', '4', '5', '6', 'leftArrow', 'rightArrow'
]
},
......