Thomas Vachuska

Fixing visuals for the SDN-IP demo.

Change-Id: I1d3020ab3787c1b560438e32fe4254edf6a640bd
1 { 1 {
2 + "devices": [
3 + { "alias": "s1", "uri": "of:0000000000000001", "mac": "000000000001", "annotations": { "name": "DEN", "latitude": 39.739317, "longitude": -104.983791 }, "type": "SWITCH" },
4 + { "alias": "s2", "uri": "of:0000000000000002", "mac": "000000000002", "annotations": { "name": "ORD", "latitude": 41.880143, "longitude": -87.624257 }, "type": "SWITCH" },
5 + { "alias": "s3", "uri": "of:0000000000000003", "mac": "000000000003", "annotations": { "name": "ABQ", "latitude": 35.116541, "longitude": -106.604146 }, "type": "SWITCH" },
6 + { "alias": "s4", "uri": "of:0000000000000004", "mac": "000000000004", "annotations": { "name": "DFW", "latitude": 32.779501, "longitude": -96.801104 }, "type": "SWITCH" },
7 + { "alias": "s5", "uri": "of:0000000000000005", "mac": "000000000005", "annotations": { "name": "SEA", "latitude": 47.606126, "longitude": -122.332903 }, "type": "SWITCH" },
8 + { "alias": "s6", "uri": "of:0000000000000006", "mac": "000000000006", "annotations": { "name": "SFO", "latitude": 37.785286, "longitude": -122.406509 }, "type": "SWITCH" },
9 + { "alias": "s7", "uri": "of:0000000000000007", "mac": "000000000007", "annotations": { "name": "LAX", "latitude": 34.055604, "longitude": -118.248567 }, "type": "SWITCH" },
10 + { "alias": "s8", "uri": "of:0000000000000008", "mac": "000000000008", "annotations": { "name": "JFK", "latitude": 40.769487, "longitude": -73.972520 }, "type": "SWITCH" },
11 + { "alias": "s9", "uri": "of:0000000000000009", "mac": "000000000009", "annotations": { "name": "IAD", "latitude": 38.897676, "longitude": -77.036525 }, "type": "SWITCH" },
12 + { "alias": "s10", "uri": "of:0000000000000010", "mac": "000000000010", "annotations": { "name": "ATL", "latitude": 33.756298, "longitude": -84.388507 }, "type": "SWITCH" }
13 + ],
14 +
2 "hosts" : [ 15 "hosts" : [
3 { "mac": "00:00:00:00:00:01", "vlan": -1, "location": "of:0000000000000001/10", "ip": "0.0.0.0", "annotations": { "type": "bgpSpeaker" } }, 16 { "mac": "00:00:00:00:00:01", "vlan": -1, "location": "of:0000000000000001/10", "ip": "0.0.0.0", "annotations": { "type": "bgpSpeaker" } },
4 { "mac": "00:00:00:00:00:02", "vlan": -1, "location": "of:0000000000000002/10", "ip": "0.0.0.0", "annotations": { "type": "bgpSpeaker" } }, 17 { "mac": "00:00:00:00:00:02", "vlan": -1, "location": "of:0000000000000002/10", "ip": "0.0.0.0", "annotations": { "type": "bgpSpeaker" } },
......
...@@ -56,6 +56,7 @@ import org.onlab.packet.IpAddress; ...@@ -56,6 +56,7 @@ import org.onlab.packet.IpAddress;
56 import org.slf4j.Logger; 56 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory; 57 import org.slf4j.LoggerFactory;
58 58
59 +import java.text.DecimalFormat;
59 import java.util.Iterator; 60 import java.util.Iterator;
60 import java.util.List; 61 import java.util.List;
61 import java.util.Map; 62 import java.util.Map;
...@@ -85,6 +86,15 @@ public abstract class TopologyViewMessages { ...@@ -85,6 +86,15 @@ public abstract class TopologyViewMessages {
85 private static final ProviderId PID = new ProviderId("core", "org.onlab.onos.core", true); 86 private static final ProviderId PID = new ProviderId("core", "org.onlab.onos.core", true);
86 private static final String COMPACT = "%s/%s-%s/%s"; 87 private static final String COMPACT = "%s/%s-%s/%s";
87 88
89 + private static final double KB = 1024;
90 + private static final double MB = 1024 * KB;
91 + private static final double GB = 1024 * MB;
92 +
93 + private static final String GB_UNIT = "GB";
94 + private static final String MB_UNIT = "MB";
95 + private static final String KB_UNIT = "KB";
96 + private static final String B_UNIT = "B";
97 +
88 protected final ServiceDirectory directory; 98 protected final ServiceDirectory directory;
89 protected final ClusterService clusterService; 99 protected final ClusterService clusterService;
90 protected final DeviceService deviceService; 100 protected final DeviceService deviceService;
...@@ -424,14 +434,16 @@ public abstract class TopologyViewMessages { ...@@ -424,14 +434,16 @@ public abstract class TopologyViewMessages {
424 ArrayNode labels = mapper.createArrayNode(); 434 ArrayNode labels = mapper.createArrayNode();
425 boolean hasTraffic = false; 435 boolean hasTraffic = false;
426 for (Link link : links) { 436 for (Link link : links) {
427 - linksNode.add(compactLinkString(link)); 437 + if (isInfrastructureEgress(link)) {
428 - Load load = statService.load(link); 438 + linksNode.add(compactLinkString(link));
429 - String label = ""; 439 + Load load = statService.load(link);
430 - if (load.rate() > 0) { 440 + String label = "";
431 - hasTraffic = true; 441 + if (load.rate() > 0) {
432 - label = load.latest() + " bytes"; 442 + hasTraffic = true;
443 + label = format(load);
444 + }
445 + labels.add(label);
433 } 446 }
434 - labels.add(label);
435 } 447 }
436 pathNode.put("class", hasTraffic ? type + " animated" : type); 448 pathNode.put("class", hasTraffic ? type + " animated" : type);
437 pathNode.put("traffic", hasTraffic); 449 pathNode.put("traffic", hasTraffic);
...@@ -441,6 +453,32 @@ public abstract class TopologyViewMessages { ...@@ -441,6 +453,32 @@ public abstract class TopologyViewMessages {
441 } 453 }
442 } 454 }
443 455
456 + // Poor-mans formatting to get the labels with byte counts looking nice.
457 + private String format(Load load) {
458 + long bytes = load.latest();
459 + String unit;
460 + double value;
461 + if (bytes > GB) {
462 + value = bytes / GB;
463 + unit = GB_UNIT;
464 + } else if (bytes > MB) {
465 + value = bytes / MB;
466 + unit = MB_UNIT;
467 + } else if (bytes > KB) {
468 + value = bytes / KB;
469 + unit = KB_UNIT;
470 + } else {
471 + value = bytes;
472 + unit = B_UNIT;
473 + }
474 + DecimalFormat format = new DecimalFormat("#,###.##");
475 + return format.format(value) + " " + unit;
476 + }
477 +
478 + private boolean isInfrastructureEgress(Link link) {
479 + return link.src().elementId() instanceof DeviceId;
480 + }
481 +
444 // Produces compact string representation of a link. 482 // Produces compact string representation of a link.
445 private static String compactLinkString(Link link) { 483 private static String compactLinkString(Link link) {
446 return String.format(COMPACT, link.src().elementId(), link.src().port(), 484 return String.format(COMPACT, link.src().elementId(), link.src().port(),
......
...@@ -143,7 +143,7 @@ svg .node.host circle { ...@@ -143,7 +143,7 @@ svg .node.host circle {
143 } 143 }
144 #topo svg .link.animated { 144 #topo svg .link.animated {
145 stroke: #f11; 145 stroke: #f11;
146 - stroke-width: 8px; 146 + stroke-width: 6px;
147 stroke-dasharray: 8 8 147 stroke-dasharray: 8 8
148 } 148 }
149 149
...@@ -162,15 +162,16 @@ svg .node.host circle { ...@@ -162,15 +162,16 @@ svg .node.host circle {
162 } 162 }
163 163
164 #topo svg .linkLabel rect { 164 #topo svg .linkLabel rect {
165 - fill: #eef; 165 + stroke: #999;
166 - stroke: blue; 166 + stroke-width: 1.2px;
167 - stroke-width: 0.3; 167 + fill: #eee;
168 + stroke: none;
168 } 169 }
169 #topo svg .linkLabel text { 170 #topo svg .linkLabel text {
170 text-anchor: middle; 171 text-anchor: middle;
171 - fill: #a13d11; 172 + stroke: #777;
172 - stroke: none; 173 + stroke-width: 0.1px;
173 - font-size: 8pt; 174 + font-size: 9pt;
174 } 175 }
175 176
176 /* Fly-in details pane */ 177 /* Fly-in details pane */
......