Simon Hunt

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
......@@ -32,7 +32,6 @@ public class UiDevice extends UiNode {
private RegionId regionId;
private NodeId masterId;
private boolean online;
/**
* Creates a new UI device.
......@@ -63,15 +62,6 @@ public class UiDevice extends UiNode {
this.masterId = masterId;
}
/**
* Sets a flag indicating whether the backing device is online.
*
* @param online boolen flag
*/
public void setOnline(boolean online) {
this.online = online;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
......@@ -136,15 +126,6 @@ public class UiDevice extends UiNode {
}
/**
* Returns a boolean indicating whether the backing device is online.
*
* @return true if device is online, false otherwise
*/
public boolean isOnline() {
return online;
}
/**
* Returns the identifier for the cluster member that has
* mastership over this device.
*
......
......@@ -59,6 +59,16 @@ public class UiDeviceLink extends UiLink {
return deviceB + UiLinkId.ID_PORT_DELIMITER + portB;
}
@Override
public String endPortA() {
return portA.toString();
}
@Override
public String endPortB() {
return portB.toString();
}
@Override
protected void destroy() {
......
......@@ -53,6 +53,13 @@ public class UiEdgeLink extends UiLink {
return edgeDevice + UiLinkId.ID_PORT_DELIMITER + edgePort;
}
// no port for end-point A
@Override
public String endPortB() {
return edgePort.toString();
}
@Override
protected void destroy() {
edgeDevice = null;
......
......@@ -96,4 +96,28 @@ public abstract class UiLink extends UiElement {
* @return end point B identifier
*/
public abstract String endPointB();
/**
* Returns the port number (as a string) for end-point A, if applicable.
* This default implementation returns null, indicating not-applicable.
* Subclasses only need to override this method if end-point A has an
* associated port.
*
* @return port number for end-point A
*/
public String endPortA() {
return null;
}
/**
* Returns the port number (as a string) for end-point B, if applicable.
* This default implementation returns null, indicating not-applicable.
* Subclasses only need to override this method if end-point B has an
* associated port.
*
* @return port number for end-point B
*/
public String endPortB() {
return null;
}
}
......
......@@ -63,6 +63,13 @@ public class UiRegionDeviceLink extends UiLink {
return device + UiLinkId.ID_PORT_DELIMITER + port;
}
// no port for end-point A
@Override
public String endPortB() {
return port.toString();
}
/**
* Returns the identity of the region.
*
......
......@@ -58,6 +58,8 @@ public class UiRegionLink extends UiLink {
return regionB.id();
}
// no ports for end-points A and B
/**
* Returns the identity of the first region.
*
......
......@@ -281,7 +281,7 @@ class Topo2Jsonifier {
.put("id", device.idAsString())
.put("nodeType", DEVICE)
.put("type", device.type())
.put("online", device.isOnline())
.put("online", deviceService.isAvailable(device.id()))
.put("master", nullIsEmpty(device.master()))
.put("layer", device.layer());
......@@ -364,11 +364,20 @@ class Topo2Jsonifier {
private ObjectNode json(UiSynthLink sLink) {
UiLink uLink = sLink.link();
return objectNode()
ObjectNode data = objectNode()
.put("id", uLink.idAsString())
.put("epA", uLink.endPointA())
.put("epB", uLink.endPointB())
.put("type", uLink.type());
String pA = uLink.endPortA();
String pB = uLink.endPortB();
if (pA != null) {
data.put("portA", pA);
}
if (pB != null) {
data.put("portB", pB);
}
return data;
}
......
......@@ -136,22 +136,10 @@ public class Topo2ViewMessageHandler extends UiMessageHandler {
peersPayload.set("peers", t2json.closedNodes(peers));
sendMessage(PEER_REGIONS, peersPayload);
// TODO: send breadcrumb message
// finally, tell the UI that we are done : TODO review / delete??
sendMessage(TOPO_START_DONE, null);
// OLD CODE DID THE FOLLOWING...
// addListeners();
// sendAllInstances(null);
// sendAllDevices();
// sendAllLinks();
// sendAllHosts();
// sendTopoStartDone();
}
}
private final class Topo2NavRegion extends RequestHandler {
......