Search in sources :

Example 6 with NetworkedNode

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;
    }
}
Also used : HashMap(java.util.HashMap) Node(org.jumpmind.symmetric.model.Node) NetworkedNode(org.jumpmind.symmetric.model.NetworkedNode) NetworkedNode(org.jumpmind.symmetric.model.NetworkedNode)

Example 7 with NetworkedNode

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;
}
Also used : NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) NodeList(org.jumpmind.symmetric.web.rest.model.NodeList) Node(org.jumpmind.symmetric.web.rest.model.Node) NetworkedNode(org.jumpmind.symmetric.model.NetworkedNode) INodeService(org.jumpmind.symmetric.service.INodeService) NetworkedNode(org.jumpmind.symmetric.model.NetworkedNode) NodeHost(org.jumpmind.symmetric.model.NodeHost)

Aggregations

NetworkedNode (org.jumpmind.symmetric.model.NetworkedNode)7 Node (org.jumpmind.symmetric.model.Node)4 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 IConfigurationService (org.jumpmind.symmetric.service.IConfigurationService)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 NodeHost (org.jumpmind.symmetric.model.NodeHost)1 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)1 TableReloadRequestKey (org.jumpmind.symmetric.model.TableReloadRequestKey)1 INodeService (org.jumpmind.symmetric.service.INodeService)1 Node (org.jumpmind.symmetric.web.rest.model.Node)1 NodeList (org.jumpmind.symmetric.web.rest.model.NodeList)1