use of org.jumpmind.symmetric.service.INodeCommunicationService 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;
}
Aggregations