Search in sources :

Example 1 with INodeCommunicationService

use of org.jumpmind.symmetric.service.INodeCommunicationService in project symmetric-ds by JumpMind.

the class FileSyncService method queueJob.

protected RemoteNodeStatuses queueJob(boolean force, long minimumPeriodMs, String clusterLock, CommunicationType type) {
    final RemoteNodeStatuses statuses = new RemoteNodeStatuses(engine.getConfigurationService().getChannels(false));
    Node identity = engine.getNodeService().findIdentity();
    if (identity != null && identity.isSyncEnabled()) {
        if (force || !engine.getClusterService().isInfiniteLocked(clusterLock)) {
            INodeCommunicationService nodeCommunicationService = engine.getNodeCommunicationService();
            List<NodeCommunication> nodes = nodeCommunicationService.list(type);
            int availableThreads = nodeCommunicationService.getAvailableThreads(type);
            for (NodeCommunication nodeCommunication : nodes) {
                if (StringUtils.isNotBlank(nodeCommunication.getNode().getSyncUrl()) || !parameterService.isRegistrationServer()) {
                    boolean meetsMinimumTime = true;
                    if (minimumPeriodMs > 0 && nodeCommunication.getLastLockTime() != null && (System.currentTimeMillis() - nodeCommunication.getLastLockTime().getTime()) < minimumPeriodMs) {
                        meetsMinimumTime = false;
                    }
                    if (availableThreads > 0 && meetsMinimumTime) {
                        if (nodeCommunicationService.execute(nodeCommunication, statuses, this)) {
                            availableThreads--;
                        }
                    }
                } else {
                    log.warn("File sync cannot communicate with node '{}' in the group '{}'.  The sync url is blank", nodeCommunication.getNode().getNodeId(), nodeCommunication.getNode().getNodeGroupId());
                }
            }
        } else {
            log.debug("Did not run the {} process because it has been stopped", type.name().toLowerCase());
        }
    }
    return statuses;
}
Also used : RemoteNodeStatuses(org.jumpmind.symmetric.model.RemoteNodeStatuses) NodeCommunication(org.jumpmind.symmetric.model.NodeCommunication) Node(org.jumpmind.symmetric.model.Node) INodeCommunicationService(org.jumpmind.symmetric.service.INodeCommunicationService)

Aggregations

Node (org.jumpmind.symmetric.model.Node)1 NodeCommunication (org.jumpmind.symmetric.model.NodeCommunication)1 RemoteNodeStatuses (org.jumpmind.symmetric.model.RemoteNodeStatuses)1 INodeCommunicationService (org.jumpmind.symmetric.service.INodeCommunicationService)1