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;
}
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;
}
}
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");
}
}
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;
}
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;
}
Aggregations