use of org.jumpmind.symmetric.model.NetworkedNode in project symmetric-ds by JumpMind.
the class NodeService method getRootNetworkedNode.
public NetworkedNode getRootNetworkedNode() {
Map<String, Node> nodes = findAllNodesAsMap();
Map<String, NetworkedNode> leaves = new HashMap<String, NetworkedNode>(nodes.size());
NetworkedNode nodeLeaf = null;
for (Node node : nodes.values()) {
nodeLeaf = leaves.get(node.getNodeId());
if (nodeLeaf == null) {
nodeLeaf = new NetworkedNode(node);
nodeLeaf.addParents(nodes, leaves);
leaves.put(node.getNodeId(), nodeLeaf);
}
}
nodeLeaf = leaves.get(findIdentityNodeId());
if (nodeLeaf != null) {
NetworkedNode root = nodeLeaf.getRoot();
root.setAllNetworkedNodes(leaves);
return root;
} else {
return null;
}
}
use of org.jumpmind.symmetric.model.NetworkedNode in project symmetric-ds by JumpMind.
the class RestService method childrenImpl.
private NodeList childrenImpl(ISymmetricEngine engine) {
NodeList children = new NodeList();
Node xmlChildNode = null;
INodeService nodeService = engine.getNodeService();
org.jumpmind.symmetric.model.Node modelNode = nodeService.findIdentity();
if (isRegistered(engine)) {
if (isRootNode(engine, modelNode)) {
NetworkedNode networkedNode = nodeService.getRootNetworkedNode();
Set<NetworkedNode> childNetwork = networkedNode.getChildren();
if (childNetwork != null) {
for (NetworkedNode child : childNetwork) {
List<NodeHost> nodeHosts = nodeService.findNodeHosts(child.getNode().getNodeId());
NodeSecurity nodeSecurity = nodeService.findNodeSecurity(child.getNode().getNodeId());
xmlChildNode = new Node();
xmlChildNode.setNodeId(child.getNode().getNodeId());
xmlChildNode.setExternalId(child.getNode().getExternalId());
xmlChildNode.setRegistrationServer(false);
xmlChildNode.setSyncUrl(child.getNode().getSyncUrl());
xmlChildNode.setBatchInErrorCount(child.getNode().getBatchInErrorCount());
xmlChildNode.setBatchToSendCount(child.getNode().getBatchToSendCount());
if (nodeHosts.size() > 0) {
xmlChildNode.setLastHeartbeat(nodeHosts.get(0).getHeartbeatTime());
}
xmlChildNode.setRegistered(nodeSecurity.hasRegistered());
xmlChildNode.setInitialLoaded(nodeSecurity.hasInitialLoaded());
xmlChildNode.setReverseInitialLoaded(nodeSecurity.hasReverseInitialLoaded());
if (child.getNode().getCreatedAtNodeId() == null) {
xmlChildNode.setRegistrationServer(true);
}
children.addNode(xmlChildNode);
}
}
}
} else {
throw new NotFoundException();
}
return children;
}
Aggregations