Search in sources :

Example 1 with NodeStatus

use of org.jumpmind.symmetric.web.rest.model.NodeStatus in project symmetric-ds by JumpMind.

the class RestService method nodeStatusImpl.

private NodeStatus nodeStatusImpl(ISymmetricEngine engine) {
    NodeStatus status = new NodeStatus();
    if (isRegistered(engine)) {
        INodeService nodeService = engine.getNodeService();
        org.jumpmind.symmetric.model.Node modelNode = nodeService.findIdentity();
        NodeSecurity nodeSecurity = nodeService.findNodeSecurity(modelNode.getNodeId());
        List<NodeHost> nodeHost = nodeService.findNodeHosts(modelNode.getNodeId());
        status.setStarted(engine.isStarted());
        status.setRegistered(nodeSecurity.getRegistrationTime() != null);
        status.setInitialLoaded(nodeSecurity.getInitialLoadTime() != null);
        status.setReverseInitialLoaded(nodeSecurity.getRevInitialLoadTime() != null);
        status.setNodeId(modelNode.getNodeId());
        status.setNodeGroupId(modelNode.getNodeGroupId());
        status.setExternalId(modelNode.getExternalId());
        status.setSyncUrl(modelNode.getSyncUrl());
        status.setRegistrationUrl(engine.getParameterService().getRegistrationUrl());
        status.setDatabaseType(modelNode.getDatabaseType());
        status.setDatabaseVersion(modelNode.getDatabaseVersion());
        status.setSyncEnabled(modelNode.isSyncEnabled());
        status.setCreatedAtNodeId(modelNode.getCreatedAtNodeId());
        status.setBatchToSendCount(engine.getOutgoingBatchService().countOutgoingBatchesUnsent());
        status.setBatchInErrorCount(engine.getOutgoingBatchService().countOutgoingBatchesInError());
        status.setDeploymentType(modelNode.getDeploymentType());
        if (modelNode.getCreatedAtNodeId() == null) {
            status.setRegistrationServer(true);
        } else {
            status.setRegistrationServer(false);
        }
        if (nodeHost != null && nodeHost.size() > 0) {
            status.setLastHeartbeat(nodeHost.get(0).getHeartbeatTime());
        }
        status.setHeartbeatInterval(engine.getParameterService().getInt(ParameterConstants.HEARTBEAT_SYNC_ON_PUSH_PERIOD_SEC));
        if (status.getHeartbeatInterval() == 0) {
            status.setHeartbeatInterval(600);
        }
    } else {
        throw new NotFoundException();
    }
    return status;
}
Also used : NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) INodeService(org.jumpmind.symmetric.service.INodeService) NodeStatus(org.jumpmind.symmetric.web.rest.model.NodeStatus) NodeHost(org.jumpmind.symmetric.model.NodeHost)

Aggregations

NodeHost (org.jumpmind.symmetric.model.NodeHost)1 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)1 INodeService (org.jumpmind.symmetric.service.INodeService)1 NodeStatus (org.jumpmind.symmetric.web.rest.model.NodeStatus)1