Search in sources :

Example 1 with RemoteNodeStatuses

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

the class AbstractIntegrationTest method clientPull.

protected boolean clientPull() {
    int tries = 0;
    boolean pulled = false;
    while (!pulled && tries < 10) {
        RemoteNodeStatuses statuses = getClient().pull();
        try {
            statuses.waitForComplete(20000);
        } catch (InterruptedException ex) {
        }
        pulled = statuses.wasDataProcessed();
        AppUtils.sleep(100);
        tries++;
    }
    return pulled;
}
Also used : RemoteNodeStatuses(org.jumpmind.symmetric.model.RemoteNodeStatuses) InterruptedException(org.jumpmind.exception.InterruptedException)

Example 2 with RemoteNodeStatuses

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

the class AbstractIntegrationTest method clientPush.

protected boolean clientPush() {
    int tries = 0;
    boolean pushed = false;
    while (!pushed && tries < 10) {
        RemoteNodeStatuses statuses = getClient().push();
        statuses.waitForComplete(15000);
        pushed = statuses.wasDataProcessed();
        AppUtils.sleep(100);
        tries++;
    }
    return pushed;
}
Also used : RemoteNodeStatuses(org.jumpmind.symmetric.model.RemoteNodeStatuses)

Example 3 with RemoteNodeStatuses

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

the class AbstractTest method push.

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

Example 4 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 5 with RemoteNodeStatuses

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

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