use of org.jumpmind.symmetric.model.RemoteNodeStatuses 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.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;
}
use of org.jumpmind.symmetric.model.RemoteNodeStatuses in project symmetric-ds by JumpMind.
the class DataExtractorService method queueWork.
public RemoteNodeStatuses queueWork(boolean force) {
final RemoteNodeStatuses statuses = new RemoteNodeStatuses(configurationService.getChannels(false));
Node identity = nodeService.findIdentity();
if (identity != null) {
if (force || clusterService.lock(ClusterConstants.INITIAL_LOAD_EXTRACT)) {
try {
Map<String, String> nodes = getExtractRequestNodes();
for (Map.Entry<String, String> entry : nodes.entrySet()) {
queue(entry.getKey(), entry.getValue(), statuses);
}
} finally {
if (!force) {
clusterService.unlock(ClusterConstants.INITIAL_LOAD_EXTRACT);
}
}
}
} else {
log.debug("Not running initial load extract service because this node does not have an identity");
}
return statuses;
}
use of org.jumpmind.symmetric.model.RemoteNodeStatuses 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.RemoteNodeStatuses in project symmetric-ds by JumpMind.
the class AbstractTest method pull.
protected boolean pull(String name) {
int tries = 0;
boolean pulled = false;
boolean lastPull = false;
boolean errorOccurred = false;
while (!errorOccurred && (lastPull || (!pulled && tries < 10))) {
RemoteNodeStatuses statuses = getWebServer(name).getEngine().pull();
try {
statuses.waitForComplete(60000);
} catch (InterruptedException ex) {
log.warn(ex.getMessage());
}
lastPull = statuses.wasDataProcessed();
errorOccurred = statuses.errorOccurred();
pulled |= lastPull;
AppUtils.sleep(100);
tries++;
}
return pulled;
}
Aggregations