Thomas Vachuska
Committed by Gerrit Code Review

ONOS-4137 Adding a "ready" check-mark glyph to the node instances.

Introduced a new INSTANCE_READY type of ClusterEvent.

Change-Id: I7f77ebae56cb18c196cd3ec7f2735faa4ca363db
......@@ -42,6 +42,11 @@ public class ClusterEvent extends AbstractEvent<ClusterEvent.Type, ControllerNod
INSTANCE_ACTIVATED,
/**
* Signifies that a cluster instance became ready.
*/
INSTANCE_READY,
/**
* Signifies that a cluster instance became inactive.
*/
INSTANCE_DEACTIVATED
......
......@@ -43,6 +43,7 @@ import org.onosproject.store.serializers.KryoSerializer;
import org.slf4j.Logger;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -53,6 +54,9 @@ import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_ACTIVATED;
import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_DEACTIVATED;
import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_READY;
import static org.slf4j.LoggerFactory.getLogger;
@Component(immediate = true)
......@@ -196,8 +200,12 @@ public class DistributedClusterStore
}
private void updateState(NodeId nodeId, State newState) {
State currentState = nodeStates.get(nodeId);
if (!Objects.equals(currentState, newState)) {
nodeStates.put(nodeId, newState);
nodeStateLastUpdatedTimes.put(nodeId, DateTime.now());
notifyStateChange(nodeId, currentState, newState);
}
}
private void heartbeat() {
......@@ -215,12 +223,10 @@ public class DistributedClusterStore
if (phi >= PHI_FAILURE_THRESHOLD) {
if (currentState.isActive()) {
updateState(node.id(), State.INACTIVE);
notifyStateChange(node.id(), State.ACTIVE, State.INACTIVE);
}
} else {
if (currentState == State.INACTIVE) {
updateState(node.id(), State.ACTIVE);
notifyStateChange(node.id(), State.INACTIVE, State.ACTIVE);
}
}
});
......@@ -230,11 +236,12 @@ public class DistributedClusterStore
}
private void notifyStateChange(NodeId nodeId, State oldState, State newState) {
if (oldState != newState) {
ControllerNode node = allNodes.get(nodeId);
if (newState.isActive()) {
notifyDelegate(new ClusterEvent(ClusterEvent.Type.INSTANCE_ACTIVATED, node));
} else {
notifyDelegate(new ClusterEvent(ClusterEvent.Type.INSTANCE_DEACTIVATED, node));
ClusterEvent.Type type = newState == State.READY ? INSTANCE_READY :
newState == State.ACTIVE ? INSTANCE_ACTIVATED :
INSTANCE_DEACTIVATED;
notifyDelegate(new ClusterEvent(type, node));
}
}
......
......@@ -230,6 +230,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
.put("id", node.id().toString())
.put("ip", node.ip().toString())
.put("online", clusterService.getState(node.id()).isActive())
.put("ready", clusterService.getState(node.id()).isReady())
.put("uiAttached", node.equals(clusterService.getLocalNode()))
.put("switches", switchCount);
......
......@@ -767,3 +767,7 @@ html[data-platform='iPad'] #topo-p-detail {
fill: #447;
}
.notReady .readyBadge {
visibility: hidden;
}
......
......@@ -155,10 +155,15 @@
}
function attachUiBadge(svg) {
gs.addGlyph(svg, 'uiAttached', 30, true, [12, instCfg.uiDy])
gs.addGlyph(svg, 'uiAttached', 24, true, [28, instCfg.uiDy])
.classed('badgeIcon uiBadge', true);
}
function attachReadyBadge(svg) {
gs.addGlyph(svg, 'checkMark', 16, true, [12, instCfg.uiDy + 4])
.classed('badgeIcon readyBadge', true);
}
function instColor(id, online) {
return sus.cat7().getColor(id, !online, ts.theme());
}
......@@ -183,6 +188,7 @@
// update online state
el.classed('online', d.online);
el.classed('notReady', !d.ready);
// update ui-attached state
svg.select('use.uiBadge').remove();
......@@ -190,6 +196,8 @@
attachUiBadge(svg);
}
attachReadyBadge(svg, d.ready);
function updAttr(id, value) {
svg.select('text.instLabel.'+id).text(value);
}
......@@ -204,6 +212,7 @@
.append('div')
.attr('class', 'onosInst')
.classed('online', function (d) { return d.online; })
.classed('notReady', function (d) { return !d.ready; })
.on('click', clickInst);
entering.each(function (d) {
......@@ -228,6 +237,8 @@
attachUiBadge(svg);
}
attachReadyBadge(svg);
var left = c.nodeOx + c.nodeDim,
len = rectAttr.width - left,
hlen = len / 2,
......