use of org.jumpmind.symmetric.model.NodeCommunication in project symmetric-ds by JumpMind.
the class PushService method pushData.
public synchronized RemoteNodeStatuses pushData(boolean force) {
RemoteNodeStatuses statuses = new RemoteNodeStatuses(configurationService.getChannels(false));
Node identity = nodeService.findIdentity();
if (identity != null && identity.isSyncEnabled()) {
long minimumPeriodMs = parameterService.getLong(ParameterConstants.PUSH_MINIMUM_PERIOD_MS, -1);
if (force || !clusterService.isInfiniteLocked(ClusterConstants.PUSH)) {
List<NodeCommunication> nodes = nodeCommunicationService.list(CommunicationType.PUSH);
if (nodes.size() > 0) {
NodeSecurity identitySecurity = nodeService.findNodeSecurity(identity.getNodeId(), true);
if (identitySecurity != null) {
int availableThreads = nodeCommunicationService.getAvailableThreads(CommunicationType.PUSH);
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.error("Could not find a node security row for '{}'. A node needs a matching security row in both the local and remote nodes if it is going to authenticate to push data", identity.getNodeId());
}
}
} else {
log.debug("Did not run the push process because it has been stopped");
}
}
return statuses;
}
use of org.jumpmind.symmetric.model.NodeCommunication 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;
}
use of org.jumpmind.symmetric.model.NodeCommunication 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;
}
use of org.jumpmind.symmetric.model.NodeCommunication in project symmetric-ds by JumpMind.
the class DataExtractorService method queue.
protected void queue(String nodeId, String queue, RemoteNodeStatuses statuses) {
final NodeCommunication.CommunicationType TYPE = NodeCommunication.CommunicationType.EXTRACT;
int availableThreads = nodeCommunicationService.getAvailableThreads(TYPE);
NodeCommunication lock = nodeCommunicationService.find(nodeId, queue, TYPE);
if (availableThreads > 0) {
nodeCommunicationService.execute(lock, statuses, this);
}
}
use of org.jumpmind.symmetric.model.NodeCommunication 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;
}
Aggregations