use of org.onosproject.cluster.ClusterAdminService in project onos by opennetworkinglab.
the class StorageNodesListCommand method doExecute.
@Override
protected void doExecute() {
ClusterAdminService service = get(ClusterAdminService.class);
List<Node> nodes = newArrayList(service.getConsensusNodes());
Collections.sort(nodes, Comparator.comparing(Node::id));
if (outputJson()) {
print("%s", json(nodes));
} else {
for (Node node : nodes) {
print(FMT, node.id(), node.host(), node.tcpPort());
}
}
}
use of org.onosproject.cluster.ClusterAdminService in project onos by opennetworkinglab.
the class MembershipsListCommand method doExecute.
@Override
protected void doExecute() {
MembershipService service = get(MembershipService.class);
ClusterAdminService clusterService = get(ClusterAdminService.class);
if (outputJson()) {
print("%s", json(service));
} else {
service.getGroups().forEach(group -> {
List<Member> members = newArrayList(group.members());
print("-------------------------------------------------------------------");
print("Version: %s, Members: %d", group.version(), members.size());
members.sort(MEMBERSHIP_COMPARATOR);
members.forEach(member -> {
Optional<ControllerNode> controllerNode = Optional.ofNullable(clusterService.getNode(member.nodeId()));
if (!controllerNode.isPresent()) {
print(" id=%s, version=%s, self=%s", member.nodeId(), member.version(), member.equals(service.getLocalMember()) ? "*" : "");
} else {
ControllerNode node = controllerNode.get();
print(" id=%s, ip=%s, tcpPort=%s, state=%s, self=%s", member.nodeId(), node.ip(), node.tcpPort(), clusterService.getState(node.id()), member.equals(service.getLocalMember()) ? "*" : "");
}
});
print("-------------------------------------------------------------------");
});
}
}
use of org.onosproject.cluster.ClusterAdminService in project onos by opennetworkinglab.
the class NodesListCommand method doExecute.
@Override
protected void doExecute() {
ClusterAdminService service = get(ClusterAdminService.class);
List<ControllerNode> nodes = newArrayList(service.getNodes());
Collections.sort(nodes, Comparators.NODE_COMPARATOR);
if (outputJson()) {
print("%s", json(service, nodes));
} else {
ControllerNode self = service.getLocalNode();
for (ControllerNode node : nodes) {
String timeAgo = service.localStatus(node.id());
Version version = service.getVersion(node.id());
print(FMT, node.id(), node.ip(), node.tcpPort(), service.getState(node.id()), version == null ? "unknown" : version, timeAgo, node.equals(self) ? "*" : "");
}
}
}
Aggregations