Search in sources :

Example 91 with Node

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

the class GroupletService method isSourceEnabled.

public boolean isSourceEnabled(TriggerRouter triggerRouter) {
    boolean enabled = true;
    Node node = engine.getNodeService().findIdentity();
    if (node == null) {
        enabled = false;
    } else {
        List<Grouplet> grouplets = getGroupletsFor(triggerRouter, AppliesWhen.S, false);
        if (grouplets != null && grouplets.size() > 0) {
            enabled = false;
            for (Grouplet grouplet : grouplets) {
                GroupletLinkPolicy policy = grouplet.getGroupletLinkPolicy();
                List<GroupletLink> links = grouplet.getGroupletLinks();
                boolean foundMatch = false;
                for (GroupletLink groupletLink : links) {
                    if (groupletLink.getExternalId().equals(node.getExternalId())) {
                        foundMatch = true;
                    }
                }
                if ((foundMatch && policy == GroupletLinkPolicy.I) || (!foundMatch && policy == GroupletLinkPolicy.E)) {
                    enabled = true;
                }
            }
        }
    }
    return enabled;
}
Also used : TriggerRouterGrouplet(org.jumpmind.symmetric.model.TriggerRouterGrouplet) Grouplet(org.jumpmind.symmetric.model.Grouplet) GroupletLink(org.jumpmind.symmetric.model.GroupletLink) Node(org.jumpmind.symmetric.model.Node) GroupletLinkPolicy(org.jumpmind.symmetric.model.Grouplet.GroupletLinkPolicy)

Example 92 with Node

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

the class GroupletService method getTargetEnabled.

public Set<Node> getTargetEnabled(TriggerRouter triggerRouter, Set<Node> nodes) {
    List<Grouplet> grouplets = getGroupletsFor(triggerRouter, AppliesWhen.T, false);
    if (grouplets != null && grouplets.size() > 0) {
        Set<Node> matchedNodes = new HashSet<Node>();
        Set<Node> excludedNodes = new HashSet<Node>();
        for (Grouplet grouplet : grouplets) {
            GroupletLinkPolicy policy = grouplet.getGroupletLinkPolicy();
            List<GroupletLink> links = grouplet.getGroupletLinks();
            for (GroupletLink groupletLink : links) {
                for (Node node : nodes) {
                    if (groupletLink.getExternalId().equals(node.getExternalId())) {
                        if (policy == GroupletLinkPolicy.I) {
                            matchedNodes.add(node);
                        } else {
                            excludedNodes.add(node);
                        }
                    }
                }
            }
        }
        Set<Node> toReturn = new HashSet<Node>();
        excludedNodes.removeAll(matchedNodes);
        if (excludedNodes.size() > 0) {
            toReturn.addAll(nodes);
            toReturn.removeAll(excludedNodes);
        } else {
            toReturn.addAll(matchedNodes);
        }
        return toReturn;
    } else {
        return nodes;
    }
}
Also used : TriggerRouterGrouplet(org.jumpmind.symmetric.model.TriggerRouterGrouplet) Grouplet(org.jumpmind.symmetric.model.Grouplet) GroupletLink(org.jumpmind.symmetric.model.GroupletLink) Node(org.jumpmind.symmetric.model.Node) GroupletLinkPolicy(org.jumpmind.symmetric.model.Grouplet.GroupletLinkPolicy) HashSet(java.util.HashSet)

Example 93 with Node

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

the class FileSyncService method trackChanges.

public void trackChanges(boolean force) {
    if (force || engine.getClusterService().lock(ClusterConstants.FILE_SYNC_TRACKER)) {
        try {
            log.debug("Attempting to get exclusive lock for file sync track changes");
            if (engine.getClusterService().lock(ClusterConstants.FILE_SYNC_SHARED, ClusterConstants.TYPE_EXCLUSIVE, getParameterService().getLong(ParameterConstants.FILE_SYNC_LOCK_WAIT_MS))) {
                try {
                    log.debug("Tracking changes for file sync");
                    Node local = engine.getNodeService().findIdentity();
                    ProcessInfo processInfo = engine.getStatisticManager().newProcessInfo(new ProcessInfoKey(local.getNodeId(), null, ProcessInfoKey.ProcessType.FILE_SYNC_TRACKER));
                    boolean useCrc = engine.getParameterService().is(ParameterConstants.FILE_SYNC_USE_CRC);
                    if (engine.getParameterService().is(ParameterConstants.FILE_SYNC_FAST_SCAN)) {
                        trackChangesFastScan(processInfo, useCrc);
                    } else {
                        trackChanges(processInfo, useCrc);
                    }
                    if (engine.getParameterService().is(ParameterConstants.FILE_SYNC_PREVENT_PING_BACK)) {
                        deleteFromFileIncoming();
                    }
                    processInfo.setStatus(ProcessInfo.Status.OK);
                } finally {
                    log.debug("Done tracking changes for file sync");
                    engine.getClusterService().unlock(ClusterConstants.FILE_SYNC_SHARED, ClusterConstants.TYPE_EXCLUSIVE);
                }
            } else {
                log.warn("Did not run the track file sync changes process because it was shared locked");
            }
        } finally {
            if (!force) {
                engine.getClusterService().unlock(ClusterConstants.FILE_SYNC_TRACKER);
            }
        }
    } else {
        log.debug("Did not run the track file sync changes process because it was cluster locked");
    }
}
Also used : Node(org.jumpmind.symmetric.model.Node) ProcessInfoKey(org.jumpmind.symmetric.model.ProcessInfoKey) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo)

Example 94 with Node

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

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

the class NodeCommunicationService method filterForChannelThreading.

protected List<NodeCommunication> filterForChannelThreading(List<Node> nodesToCommunicateWith) {
    List<NodeCommunication> nodeCommunications = new ArrayList<NodeCommunication>();
    for (Node node : nodesToCommunicateWith) {
        if (node.isVersionGreaterThanOrEqualTo(3, 8, 0)) {
            Set<String> channelThreads = new HashSet<String>();
            for (Channel channel : configurationService.getChannels(false).values()) {
                if (!channelThreads.contains(channel.getQueue())) {
                    NodeCommunication nodeCommunication = new NodeCommunication();
                    nodeCommunication.setNodeId(node.getNodeId());
                    nodeCommunication.setQueue(channel.getQueue());
                    nodeCommunication.setNode(node);
                    nodeCommunications.add(nodeCommunication);
                    channelThreads.add(channel.getQueue());
                }
            }
        } else {
            NodeCommunication nodeCommunication = new NodeCommunication();
            nodeCommunication.setNodeId(node.getNodeId());
            nodeCommunication.setNode(node);
            nodeCommunications.add(nodeCommunication);
        }
    }
    return nodeCommunications;
}
Also used : NodeCommunication(org.jumpmind.symmetric.model.NodeCommunication) Node(org.jumpmind.symmetric.model.Node) Channel(org.jumpmind.symmetric.model.Channel) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Aggregations

Node (org.jumpmind.symmetric.model.Node)129 HashSet (java.util.HashSet)18 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)18 Test (org.junit.Test)18 TriggerHistory (org.jumpmind.symmetric.model.TriggerHistory)17 ArrayList (java.util.ArrayList)14 NetworkedNode (org.jumpmind.symmetric.model.NetworkedNode)14 NodeChannel (org.jumpmind.symmetric.model.NodeChannel)14 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)13 ProcessInfoKey (org.jumpmind.symmetric.model.ProcessInfoKey)13 Table (org.jumpmind.db.model.Table)12 Data (org.jumpmind.symmetric.model.Data)12 Router (org.jumpmind.symmetric.model.Router)12 Date (java.util.Date)11 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)11 IOException (java.io.IOException)10 DataMetaData (org.jumpmind.symmetric.model.DataMetaData)10 HashMap (java.util.HashMap)9 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)9 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)8