Search in sources :

Example 1 with NodeHost

use of org.jumpmind.symmetric.model.NodeHost in project symmetric-ds by JumpMind.

the class RestService method heartbeatImpl.

private void heartbeatImpl(ISymmetricEngine engine, Heartbeat heartbeat) {
    INodeService nodeService = engine.getNodeService();
    NodeHost nodeHost = new NodeHost();
    if (heartbeat.getAvailableProcessors() != null) {
        nodeHost.setAvailableProcessors(heartbeat.getAvailableProcessors());
    }
    if (heartbeat.getCreateTime() != null) {
        nodeHost.setCreateTime(heartbeat.getCreateTime());
    }
    if (heartbeat.getFreeMemoryBytes() != null) {
        nodeHost.setFreeMemoryBytes(heartbeat.getFreeMemoryBytes());
    }
    if (heartbeat.getHeartbeatTime() != null) {
        nodeHost.setHeartbeatTime(heartbeat.getHeartbeatTime());
    }
    if (heartbeat.getHostName() != null) {
        nodeHost.setHostName(heartbeat.getHostName());
    }
    if (heartbeat.getIpAddress() != null) {
        nodeHost.setIpAddress(heartbeat.getIpAddress());
    }
    if (heartbeat.getJavaVendor() != null) {
        nodeHost.setJavaVendor(heartbeat.getJavaVendor());
    }
    if (heartbeat.getJdbcVersion() != null) {
        nodeHost.setJdbcVersion(heartbeat.getJdbcVersion());
    }
    if (heartbeat.getJavaVersion() != null) {
        nodeHost.setJavaVersion(heartbeat.getJavaVersion());
    }
    if (heartbeat.getLastRestartTime() != null) {
        nodeHost.setLastRestartTime(heartbeat.getLastRestartTime());
    }
    if (heartbeat.getMaxMemoryBytes() != null) {
        nodeHost.setMaxMemoryBytes(heartbeat.getMaxMemoryBytes());
    }
    if (heartbeat.getNodeId() != null) {
        nodeHost.setNodeId(heartbeat.getNodeId());
    }
    if (heartbeat.getOsArchitecture() != null) {
        nodeHost.setOsArch(heartbeat.getOsArchitecture());
    }
    if (heartbeat.getOsName() != null) {
        nodeHost.setOsName(heartbeat.getOsName());
    }
    if (heartbeat.getOsUser() != null) {
        nodeHost.setOsUser(heartbeat.getOsUser());
    }
    if (heartbeat.getOsVersion() != null) {
        nodeHost.setOsVersion(heartbeat.getOsVersion());
    }
    if (heartbeat.getSymmetricVersion() != null) {
        nodeHost.setSymmetricVersion(heartbeat.getSymmetricVersion());
    }
    if (heartbeat.getTimezoneOffset() != null) {
        nodeHost.setTimezoneOffset(heartbeat.getTimezoneOffset());
    }
    if (heartbeat.getTotalMemoryBytes() != null) {
        nodeHost.setTotalMemoryBytes(heartbeat.getTotalMemoryBytes());
    }
    nodeService.updateNodeHost(nodeHost);
}
Also used : INodeService(org.jumpmind.symmetric.service.INodeService) NodeHost(org.jumpmind.symmetric.model.NodeHost)

Example 2 with NodeHost

use of org.jumpmind.symmetric.model.NodeHost in project symmetric-ds by JumpMind.

the class NodeService method updateNodeHostForCurrentNode.

public void updateNodeHostForCurrentNode() {
    if (nodeHostForCurrentNode == null) {
        nodeHostForCurrentNode = new NodeHost(findIdentityNodeId());
    }
    nodeHostForCurrentNode.refresh(platform);
    updateNodeHost(nodeHostForCurrentNode);
}
Also used : NodeHost(org.jumpmind.symmetric.model.NodeHost)

Example 3 with NodeHost

use of org.jumpmind.symmetric.model.NodeHost in project symmetric-ds by JumpMind.

the class OutgoingBatchService method inTimeWindow.

/**
     * If {@link NodeGroupChannelWindow}s are defined for this channel, then
     * check to see if the time (according to the offset passed in) is within on
     * of the configured windows.
     */
public boolean inTimeWindow(List<NodeGroupChannelWindow> windows, String targetNodeId) {
    if (windows != null && windows.size() > 0) {
        for (NodeGroupChannelWindow window : windows) {
            String timezoneOffset = null;
            List<NodeHost> hosts = nodeService.findNodeHosts(targetNodeId);
            if (hosts.size() > 0) {
                timezoneOffset = hosts.get(0).getTimezoneOffset();
            } else {
                timezoneOffset = AppUtils.getTimezoneOffset();
            }
            if (window.inTimeWindow(timezoneOffset)) {
                return true;
            }
        }
        return false;
    } else {
        return true;
    }
}
Also used : NodeGroupChannelWindow(org.jumpmind.symmetric.model.NodeGroupChannelWindow) NodeHost(org.jumpmind.symmetric.model.NodeHost)

Example 4 with NodeHost

use of org.jumpmind.symmetric.model.NodeHost in project symmetric-ds by JumpMind.

the class RegistrationService method openRegistration.

protected String openRegistration(Node node, String remoteHost, String remoteAddress) {
    Node me = nodeService.findIdentity();
    if (me != null) {
        String nodeId = extensionService.getExtensionPoint(INodeIdCreator.class).generateNodeId(node, remoteHost, remoteAddress);
        Node existingNode = nodeService.findNode(nodeId);
        if (existingNode == null) {
            node.setNodeId(nodeId);
            node.setSyncEnabled(false);
            boolean masterToMasterOnly = configurationService.containsMasterToMaster();
            node.setCreatedAtNodeId(masterToMasterOnly ? null : me.getNodeId());
            nodeService.save(node);
            // make sure there isn't a node security row lying around w/out
            // a node row
            nodeService.deleteNodeSecurity(nodeId);
            String password = extensionService.getExtensionPoint(INodeIdCreator.class).generatePassword(node);
            password = filterPasswordOnSaveIfNeeded(password);
            sqlTemplate.update(getSql("openRegistrationNodeSecuritySql"), new Object[] { nodeId, password, masterToMasterOnly ? null : me.getNodeId() });
            if (isNotBlank(remoteHost)) {
                NodeHost nodeHost = new NodeHost(node.getNodeId());
                nodeHost.setHeartbeatTime(new Date());
                nodeHost.setIpAddress(remoteAddress);
                nodeHost.setHostName(remoteHost);
                nodeService.updateNodeHost(nodeHost);
            }
            nodeService.flushNodeAuthorizedCache();
            nodeService.flushNodeCache();
            nodeService.insertNodeGroup(node.getNodeGroupId(), null);
            nodeService.flushNodeGroupCache();
            log.info("Just opened registration for external id of {} and a node group of {} and a node id of {}", new Object[] { node.getExternalId(), node.getNodeGroupId(), nodeId });
        } else {
            reOpenRegistration(nodeId, remoteHost, remoteAddress);
        }
        return nodeId;
    } else {
        throw new IllegalStateException("This node has not been configured.  Could not find a row in the identity table");
    }
}
Also used : INodeIdCreator(org.jumpmind.symmetric.config.INodeIdCreator) Node(org.jumpmind.symmetric.model.Node) Date(java.util.Date) NodeHost(org.jumpmind.symmetric.model.NodeHost)

Example 5 with NodeHost

use of org.jumpmind.symmetric.model.NodeHost in project symmetric-ds by JumpMind.

the class RegistrationService method reOpenRegistration.

protected synchronized void reOpenRegistration(String nodeId, String remoteHost, String remoteAddress) {
    Node node = nodeService.findNode(nodeId);
    NodeSecurity security = nodeService.findNodeSecurity(nodeId);
    String password = null;
    if (security != null && parameterService.is(ParameterConstants.REGISTRATION_REOPEN_USE_SAME_PASSWORD, true)) {
        password = security.getNodePassword();
    } else {
        password = extensionService.getExtensionPoint(INodeIdCreator.class).generatePassword(node);
        password = filterPasswordOnSaveIfNeeded(password);
    }
    if (node != null) {
        int updateCount = sqlTemplate.update(getSql("reopenRegistrationSql"), new Object[] { password, nodeId });
        if (updateCount == 0 && nodeService.findNodeSecurity(nodeId) == null) {
            // if the update count was 0, then we probably have a row in the
            // node table, but not in node security.
            // lets go ahead and try to insert into node security.
            sqlTemplate.update(getSql("openRegistrationNodeSecuritySql"), new Object[] { nodeId, password, nodeService.findNode(nodeId).getNodeId() });
            log.info("Registration was opened for {}", nodeId);
        } else if (updateCount == 0) {
            log.warn("Registration was already enabled for {}.  No need to reenable it", nodeId);
        } else {
            log.info("Registration was reopened for {}", nodeId);
        }
        if (isNotBlank(remoteHost)) {
            NodeHost nodeHost = new NodeHost(node.getNodeId());
            nodeHost.setHeartbeatTime(new Date());
            nodeHost.setIpAddress(remoteAddress);
            nodeHost.setHostName(remoteHost);
            nodeService.updateNodeHost(nodeHost);
        }
        nodeService.flushNodeAuthorizedCache();
    } else {
        log.warn("There was no row with a node id of {} to 'reopen' registration for", nodeId);
    }
}
Also used : NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) Node(org.jumpmind.symmetric.model.Node) Date(java.util.Date) NodeHost(org.jumpmind.symmetric.model.NodeHost)

Aggregations

NodeHost (org.jumpmind.symmetric.model.NodeHost)8 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)4 INodeService (org.jumpmind.symmetric.service.INodeService)4 Date (java.util.Date)2 NetworkedNode (org.jumpmind.symmetric.model.NetworkedNode)2 Node (org.jumpmind.symmetric.model.Node)2 Node (org.jumpmind.symmetric.web.rest.model.Node)2 INodeIdCreator (org.jumpmind.symmetric.config.INodeIdCreator)1 NodeGroupChannelWindow (org.jumpmind.symmetric.model.NodeGroupChannelWindow)1 NodeList (org.jumpmind.symmetric.web.rest.model.NodeList)1 NodeStatus (org.jumpmind.symmetric.web.rest.model.NodeStatus)1