Added endPortA/B to UiLink class.
Removed 'online' property from UiDevice, choosing to look up availability on the fly from device service. Change-Id: Ib14ab371a11c442a30cf407f11d366271d087c68
Showing
8 changed files
with
61 additions
and
33 deletions
| ... | @@ -32,7 +32,6 @@ public class UiDevice extends UiNode { | ... | @@ -32,7 +32,6 @@ public class UiDevice extends UiNode { |
| 32 | 32 | ||
| 33 | private RegionId regionId; | 33 | private RegionId regionId; |
| 34 | private NodeId masterId; | 34 | private NodeId masterId; |
| 35 | - private boolean online; | ||
| 36 | 35 | ||
| 37 | /** | 36 | /** |
| 38 | * Creates a new UI device. | 37 | * Creates a new UI device. |
| ... | @@ -63,15 +62,6 @@ public class UiDevice extends UiNode { | ... | @@ -63,15 +62,6 @@ public class UiDevice extends UiNode { |
| 63 | this.masterId = masterId; | 62 | this.masterId = masterId; |
| 64 | } | 63 | } |
| 65 | 64 | ||
| 66 | - /** | ||
| 67 | - * Sets a flag indicating whether the backing device is online. | ||
| 68 | - * | ||
| 69 | - * @param online boolen flag | ||
| 70 | - */ | ||
| 71 | - public void setOnline(boolean online) { | ||
| 72 | - this.online = online; | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | @Override | 65 | @Override |
| 76 | public String toString() { | 66 | public String toString() { |
| 77 | return MoreObjects.toStringHelper(this) | 67 | return MoreObjects.toStringHelper(this) |
| ... | @@ -136,15 +126,6 @@ public class UiDevice extends UiNode { | ... | @@ -136,15 +126,6 @@ public class UiDevice extends UiNode { |
| 136 | } | 126 | } |
| 137 | 127 | ||
| 138 | /** | 128 | /** |
| 139 | - * Returns a boolean indicating whether the backing device is online. | ||
| 140 | - * | ||
| 141 | - * @return true if device is online, false otherwise | ||
| 142 | - */ | ||
| 143 | - public boolean isOnline() { | ||
| 144 | - return online; | ||
| 145 | - } | ||
| 146 | - | ||
| 147 | - /** | ||
| 148 | * Returns the identifier for the cluster member that has | 129 | * Returns the identifier for the cluster member that has |
| 149 | * mastership over this device. | 130 | * mastership over this device. |
| 150 | * | 131 | * | ... | ... |
| ... | @@ -59,6 +59,16 @@ public class UiDeviceLink extends UiLink { | ... | @@ -59,6 +59,16 @@ public class UiDeviceLink extends UiLink { |
| 59 | return deviceB + UiLinkId.ID_PORT_DELIMITER + portB; | 59 | return deviceB + UiLinkId.ID_PORT_DELIMITER + portB; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | + @Override | ||
| 63 | + public String endPortA() { | ||
| 64 | + return portA.toString(); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Override | ||
| 68 | + public String endPortB() { | ||
| 69 | + return portB.toString(); | ||
| 70 | + } | ||
| 71 | + | ||
| 62 | 72 | ||
| 63 | @Override | 73 | @Override |
| 64 | protected void destroy() { | 74 | protected void destroy() { | ... | ... |
| ... | @@ -53,6 +53,13 @@ public class UiEdgeLink extends UiLink { | ... | @@ -53,6 +53,13 @@ public class UiEdgeLink extends UiLink { |
| 53 | return edgeDevice + UiLinkId.ID_PORT_DELIMITER + edgePort; | 53 | return edgeDevice + UiLinkId.ID_PORT_DELIMITER + edgePort; |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | + // no port for end-point A | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public String endPortB() { | ||
| 60 | + return edgePort.toString(); | ||
| 61 | + } | ||
| 62 | + | ||
| 56 | @Override | 63 | @Override |
| 57 | protected void destroy() { | 64 | protected void destroy() { |
| 58 | edgeDevice = null; | 65 | edgeDevice = null; | ... | ... |
| ... | @@ -96,4 +96,28 @@ public abstract class UiLink extends UiElement { | ... | @@ -96,4 +96,28 @@ public abstract class UiLink extends UiElement { |
| 96 | * @return end point B identifier | 96 | * @return end point B identifier |
| 97 | */ | 97 | */ |
| 98 | public abstract String endPointB(); | 98 | public abstract String endPointB(); |
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * Returns the port number (as a string) for end-point A, if applicable. | ||
| 102 | + * This default implementation returns null, indicating not-applicable. | ||
| 103 | + * Subclasses only need to override this method if end-point A has an | ||
| 104 | + * associated port. | ||
| 105 | + * | ||
| 106 | + * @return port number for end-point A | ||
| 107 | + */ | ||
| 108 | + public String endPortA() { | ||
| 109 | + return null; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * Returns the port number (as a string) for end-point B, if applicable. | ||
| 114 | + * This default implementation returns null, indicating not-applicable. | ||
| 115 | + * Subclasses only need to override this method if end-point B has an | ||
| 116 | + * associated port. | ||
| 117 | + * | ||
| 118 | + * @return port number for end-point B | ||
| 119 | + */ | ||
| 120 | + public String endPortB() { | ||
| 121 | + return null; | ||
| 122 | + } | ||
| 99 | } | 123 | } | ... | ... |
| ... | @@ -63,6 +63,13 @@ public class UiRegionDeviceLink extends UiLink { | ... | @@ -63,6 +63,13 @@ public class UiRegionDeviceLink extends UiLink { |
| 63 | return device + UiLinkId.ID_PORT_DELIMITER + port; | 63 | return device + UiLinkId.ID_PORT_DELIMITER + port; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | + // no port for end-point A | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public String endPortB() { | ||
| 70 | + return port.toString(); | ||
| 71 | + } | ||
| 72 | + | ||
| 66 | /** | 73 | /** |
| 67 | * Returns the identity of the region. | 74 | * Returns the identity of the region. |
| 68 | * | 75 | * | ... | ... |
| ... | @@ -58,6 +58,8 @@ public class UiRegionLink extends UiLink { | ... | @@ -58,6 +58,8 @@ public class UiRegionLink extends UiLink { |
| 58 | return regionB.id(); | 58 | return regionB.id(); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | + // no ports for end-points A and B | ||
| 62 | + | ||
| 61 | /** | 63 | /** |
| 62 | * Returns the identity of the first region. | 64 | * Returns the identity of the first region. |
| 63 | * | 65 | * | ... | ... |
| ... | @@ -281,7 +281,7 @@ class Topo2Jsonifier { | ... | @@ -281,7 +281,7 @@ class Topo2Jsonifier { |
| 281 | .put("id", device.idAsString()) | 281 | .put("id", device.idAsString()) |
| 282 | .put("nodeType", DEVICE) | 282 | .put("nodeType", DEVICE) |
| 283 | .put("type", device.type()) | 283 | .put("type", device.type()) |
| 284 | - .put("online", device.isOnline()) | 284 | + .put("online", deviceService.isAvailable(device.id())) |
| 285 | .put("master", nullIsEmpty(device.master())) | 285 | .put("master", nullIsEmpty(device.master())) |
| 286 | .put("layer", device.layer()); | 286 | .put("layer", device.layer()); |
| 287 | 287 | ||
| ... | @@ -364,11 +364,20 @@ class Topo2Jsonifier { | ... | @@ -364,11 +364,20 @@ class Topo2Jsonifier { |
| 364 | 364 | ||
| 365 | private ObjectNode json(UiSynthLink sLink) { | 365 | private ObjectNode json(UiSynthLink sLink) { |
| 366 | UiLink uLink = sLink.link(); | 366 | UiLink uLink = sLink.link(); |
| 367 | - return objectNode() | 367 | + ObjectNode data = objectNode() |
| 368 | .put("id", uLink.idAsString()) | 368 | .put("id", uLink.idAsString()) |
| 369 | .put("epA", uLink.endPointA()) | 369 | .put("epA", uLink.endPointA()) |
| 370 | .put("epB", uLink.endPointB()) | 370 | .put("epB", uLink.endPointB()) |
| 371 | .put("type", uLink.type()); | 371 | .put("type", uLink.type()); |
| 372 | + String pA = uLink.endPortA(); | ||
| 373 | + String pB = uLink.endPortB(); | ||
| 374 | + if (pA != null) { | ||
| 375 | + data.put("portA", pA); | ||
| 376 | + } | ||
| 377 | + if (pB != null) { | ||
| 378 | + data.put("portB", pB); | ||
| 379 | + } | ||
| 380 | + return data; | ||
| 372 | } | 381 | } |
| 373 | 382 | ||
| 374 | 383 | ... | ... |
| ... | @@ -136,22 +136,10 @@ public class Topo2ViewMessageHandler extends UiMessageHandler { | ... | @@ -136,22 +136,10 @@ public class Topo2ViewMessageHandler extends UiMessageHandler { |
| 136 | peersPayload.set("peers", t2json.closedNodes(peers)); | 136 | peersPayload.set("peers", t2json.closedNodes(peers)); |
| 137 | sendMessage(PEER_REGIONS, peersPayload); | 137 | sendMessage(PEER_REGIONS, peersPayload); |
| 138 | 138 | ||
| 139 | - // TODO: send breadcrumb message | ||
| 140 | - | ||
| 141 | // finally, tell the UI that we are done : TODO review / delete?? | 139 | // finally, tell the UI that we are done : TODO review / delete?? |
| 142 | sendMessage(TOPO_START_DONE, null); | 140 | sendMessage(TOPO_START_DONE, null); |
| 143 | - | ||
| 144 | - | ||
| 145 | - // OLD CODE DID THE FOLLOWING... | ||
| 146 | -// addListeners(); | ||
| 147 | -// sendAllInstances(null); | ||
| 148 | -// sendAllDevices(); | ||
| 149 | -// sendAllLinks(); | ||
| 150 | -// sendAllHosts(); | ||
| 151 | -// sendTopoStartDone(); | ||
| 152 | } | 141 | } |
| 153 | 142 | ||
| 154 | - | ||
| 155 | } | 143 | } |
| 156 | 144 | ||
| 157 | private final class Topo2NavRegion extends RequestHandler { | 145 | private final class Topo2NavRegion extends RequestHandler { | ... | ... |
-
Please register or login to post a comment