Search in sources :

Example 6 with RemoteNodeStatuses

use of org.jumpmind.symmetric.model.RemoteNodeStatuses 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 7 with RemoteNodeStatuses

use of org.jumpmind.symmetric.model.RemoteNodeStatuses 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 8 with RemoteNodeStatuses

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

the class DataExtractorService method queueWork.

public RemoteNodeStatuses queueWork(boolean force) {
    final RemoteNodeStatuses statuses = new RemoteNodeStatuses(configurationService.getChannels(false));
    Node identity = nodeService.findIdentity();
    if (identity != null) {
        if (force || clusterService.lock(ClusterConstants.INITIAL_LOAD_EXTRACT)) {
            try {
                Map<String, String> nodes = getExtractRequestNodes();
                for (Map.Entry<String, String> entry : nodes.entrySet()) {
                    queue(entry.getKey(), entry.getValue(), statuses);
                }
            } finally {
                if (!force) {
                    clusterService.unlock(ClusterConstants.INITIAL_LOAD_EXTRACT);
                }
            }
        }
    } else {
        log.debug("Not running initial load extract service because this node does not have an identity");
    }
    return statuses;
}
Also used : RemoteNodeStatuses(org.jumpmind.symmetric.model.RemoteNodeStatuses) Node(org.jumpmind.symmetric.model.Node) ChannelMap(org.jumpmind.symmetric.model.ChannelMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 9 with RemoteNodeStatuses

use of org.jumpmind.symmetric.model.RemoteNodeStatuses 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)

Example 10 with RemoteNodeStatuses

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

the class AbstractTest method pull.

protected boolean pull(String name) {
    int tries = 0;
    boolean pulled = false;
    boolean lastPull = false;
    boolean errorOccurred = false;
    while (!errorOccurred && (lastPull || (!pulled && tries < 10))) {
        RemoteNodeStatuses statuses = getWebServer(name).getEngine().pull();
        try {
            statuses.waitForComplete(60000);
        } catch (InterruptedException ex) {
            log.warn(ex.getMessage());
        }
        lastPull = statuses.wasDataProcessed();
        errorOccurred = statuses.errorOccurred();
        pulled |= lastPull;
        AppUtils.sleep(100);
        tries++;
    }
    return pulled;
}
Also used : RemoteNodeStatuses(org.jumpmind.symmetric.model.RemoteNodeStatuses) InterruptedException(org.jumpmind.exception.InterruptedException)

Aggregations

RemoteNodeStatuses (org.jumpmind.symmetric.model.RemoteNodeStatuses)12 Node (org.jumpmind.symmetric.model.Node)6 InterruptedException (org.jumpmind.exception.InterruptedException)5 NodeCommunication (org.jumpmind.symmetric.model.NodeCommunication)5 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ChannelMap (org.jumpmind.symmetric.model.ChannelMap)1 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)1 INodeCommunicationService (org.jumpmind.symmetric.service.INodeCommunicationService)1