Search in sources :

Example 6 with NodeCommunication

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

the class PushService method pushData.

public synchronized RemoteNodeStatuses pushData(boolean force) {
    RemoteNodeStatuses statuses = new RemoteNodeStatuses(configurationService.getChannels(false));
    Node identity = nodeService.findIdentity();
    if (identity != null && identity.isSyncEnabled()) {
        long minimumPeriodMs = parameterService.getLong(ParameterConstants.PUSH_MINIMUM_PERIOD_MS, -1);
        if (force || !clusterService.isInfiniteLocked(ClusterConstants.PUSH)) {
            List<NodeCommunication> nodes = nodeCommunicationService.list(CommunicationType.PUSH);
            if (nodes.size() > 0) {
                NodeSecurity identitySecurity = nodeService.findNodeSecurity(identity.getNodeId(), true);
                if (identitySecurity != null) {
                    int availableThreads = nodeCommunicationService.getAvailableThreads(CommunicationType.PUSH);
                    for (NodeCommunication nodeCommunication : nodes) {
                        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.error("Could not find a node security row for '{}'.  A node needs a matching security row in both the local and remote nodes if it is going to authenticate to push data", identity.getNodeId());
                }
            }
        } else {
            log.debug("Did not run the push process because it has been stopped");
        }
    }
    return statuses;
}
Also used : RemoteNodeStatuses(org.jumpmind.symmetric.model.RemoteNodeStatuses) NodeCommunication(org.jumpmind.symmetric.model.NodeCommunication) NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) Node(org.jumpmind.symmetric.model.Node)

Example 7 with NodeCommunication

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

the class PullService method pullData.

public synchronized RemoteNodeStatuses pullData(boolean force) {
    final RemoteNodeStatuses statuses = new RemoteNodeStatuses(configurationService.getChannels(false));
    Node identity = nodeService.findIdentity();
    if (identity == null || identity.isSyncEnabled()) {
        long minimumPeriodMs = parameterService.getLong(ParameterConstants.PULL_MINIMUM_PERIOD_MS, -1);
        if (force || !clusterService.isInfiniteLocked(ClusterConstants.PULL)) {
            // register if we haven't already been registered
            registrationService.registerWithServer();
            identity = nodeService.findIdentity();
            if (identity != null) {
                List<NodeCommunication> nodes = nodeCommunicationService.list(CommunicationType.PULL);
                int availableThreads = nodeCommunicationService.getAvailableThreads(CommunicationType.PULL);
                for (NodeCommunication nodeCommunication : nodes) {
                    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.debug("Did not run the pull process because it has been stopped");
        }
    }
    return statuses;
}
Also used : RemoteNodeStatuses(org.jumpmind.symmetric.model.RemoteNodeStatuses) NodeCommunication(org.jumpmind.symmetric.model.NodeCommunication) Node(org.jumpmind.symmetric.model.Node)

Example 8 with NodeCommunication

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

the class OfflinePullService method pullData.

public synchronized RemoteNodeStatuses pullData(boolean force) {
    RemoteNodeStatuses statuses = new RemoteNodeStatuses(configurationService.getChannels(false));
    Node identity = nodeService.findIdentity();
    if (identity != null && identity.isSyncEnabled()) {
        if (force || !clusterService.isInfiniteLocked(ClusterConstants.OFFLINE_PULL)) {
            List<NodeCommunication> nodes = nodeCommunicationService.list(CommunicationType.OFFLN_PULL);
            int availableThreads = nodeCommunicationService.getAvailableThreads(CommunicationType.OFFLN_PULL);
            for (NodeCommunication nodeCommunication : nodes) {
                if (availableThreads > 0) {
                    if (nodeCommunicationService.execute(nodeCommunication, statuses, this)) {
                        availableThreads--;
                    }
                }
            }
        } else {
            log.debug("Did not run the offline pull process because it has been stopped");
        }
    }
    return statuses;
}
Also used : RemoteNodeStatuses(org.jumpmind.symmetric.model.RemoteNodeStatuses) NodeCommunication(org.jumpmind.symmetric.model.NodeCommunication) Node(org.jumpmind.symmetric.model.Node)

Example 9 with NodeCommunication

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

the class DataExtractorService method queue.

protected void queue(String nodeId, String queue, RemoteNodeStatuses statuses) {
    final NodeCommunication.CommunicationType TYPE = NodeCommunication.CommunicationType.EXTRACT;
    int availableThreads = nodeCommunicationService.getAvailableThreads(TYPE);
    NodeCommunication lock = nodeCommunicationService.find(nodeId, queue, TYPE);
    if (availableThreads > 0) {
        nodeCommunicationService.execute(lock, statuses, this);
    }
}
Also used : NodeCommunication(org.jumpmind.symmetric.model.NodeCommunication) CommunicationType(org.jumpmind.symmetric.model.NodeCommunication.CommunicationType) TransformPoint(org.jumpmind.symmetric.io.data.transform.TransformPoint)

Example 10 with NodeCommunication

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

the class OfflinePushService method pushData.

public synchronized RemoteNodeStatuses pushData(boolean force) {
    RemoteNodeStatuses statuses = new RemoteNodeStatuses(configurationService.getChannels(false));
    Node identity = nodeService.findIdentity();
    if (identity != null && identity.isSyncEnabled()) {
        if (force || !clusterService.isInfiniteLocked(ClusterConstants.OFFLINE_PUSH)) {
            List<NodeCommunication> nodes = nodeCommunicationService.list(CommunicationType.OFFLN_PUSH);
            int availableThreads = nodeCommunicationService.getAvailableThreads(CommunicationType.OFFLN_PUSH);
            for (NodeCommunication nodeCommunication : nodes) {
                if (availableThreads > 0) {
                    if (nodeCommunicationService.execute(nodeCommunication, statuses, this)) {
                        availableThreads--;
                    }
                }
            }
        } else {
            log.debug("Did not run the offline push process because it has been stopped");
        }
    }
    return statuses;
}
Also used : RemoteNodeStatuses(org.jumpmind.symmetric.model.RemoteNodeStatuses) NodeCommunication(org.jumpmind.symmetric.model.NodeCommunication) Node(org.jumpmind.symmetric.model.Node)

Aggregations

NodeCommunication (org.jumpmind.symmetric.model.NodeCommunication)13 Node (org.jumpmind.symmetric.model.Node)7 RemoteNodeStatuses (org.jumpmind.symmetric.model.RemoteNodeStatuses)5 ArrayList (java.util.ArrayList)2 CommunicationType (org.jumpmind.symmetric.model.NodeCommunication.CommunicationType)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 TransformPoint (org.jumpmind.symmetric.io.data.transform.TransformPoint)1 Channel (org.jumpmind.symmetric.model.Channel)1 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)1 INodeCommunicationService (org.jumpmind.symmetric.service.INodeCommunicationService)1