use of org.jumpmind.symmetric.transport.file.FileIncomingTransport in project symmetric-ds by JumpMind.
the class OfflinePullService method execute.
public void execute(NodeCommunication nodeCommunication, RemoteNodeStatus status) {
Node node = nodeCommunication.getNode();
Node local = nodeService.findIdentity();
try {
long batchesProcessedCount = 0;
do {
batchesProcessedCount = status.getBatchesProcessed();
log.debug("Offline pull requested for {}", node.toString());
FileIncomingTransport transport = (FileIncomingTransport) transportManager.getPullTransport(node, local, null, null, null);
dataLoaderService.loadDataFromOfflineTransport(node, status, transport);
if (!status.failed() && status.getBatchesProcessed() > batchesProcessedCount) {
log.info("Offline pull data read for {}. {} rows and {} batches were processed", new Object[] { node.toString(), status.getDataProcessed(), status.getBatchesProcessed() });
} else if (status.failed()) {
log.info("There was a failure while reading pull data for {}. {} rows and {} batches were processed", new Object[] { node.toString(), status.getDataProcessed(), status.getBatchesProcessed() });
}
transport.complete(!status.failed());
} while (!status.failed() && status.getBatchesProcessed() > batchesProcessedCount);
} catch (IOException e) {
log.error("An IO exception happened while attempting to read offline pull data", e);
}
}
use of org.jumpmind.symmetric.transport.file.FileIncomingTransport in project symmetric-ds by JumpMind.
the class FileSyncService method pullFilesFromNode.
protected void pullFilesFromNode(NodeCommunication nodeCommunication, RemoteNodeStatus status, Node identity, NodeSecurity security) {
IIncomingTransport transport = null;
ProcessInfo processInfo = engine.getStatisticManager().newProcessInfo(new ProcessInfoKey(nodeCommunication.getNodeId(), identity.getNodeId(), ProcessType.FILE_SYNC_PULL_JOB));
try {
processInfo.setStatus(ProcessInfo.Status.TRANSFERRING);
ITransportManager transportManager;
if (!engine.getParameterService().is(ParameterConstants.NODE_OFFLINE)) {
transportManager = engine.getTransportManager();
transport = transportManager.getFilePullTransport(nodeCommunication.getNode(), identity, security.getNodePassword(), null, parameterService.getRegistrationUrl());
} else {
transportManager = ((AbstractSymmetricEngine) engine).getOfflineTransportManager();
transport = transportManager.getFilePullTransport(nodeCommunication.getNode(), identity, security.getNodePassword(), null, parameterService.getRegistrationUrl());
}
List<IncomingBatch> batchesProcessed = processZip(transport.openStream(), nodeCommunication.getNodeId(), processInfo);
if (batchesProcessed.size() > 0) {
processInfo.setStatus(ProcessInfo.Status.ACKING);
status.updateIncomingStatus(batchesProcessed);
sendAck(nodeCommunication.getNode(), identity, security, batchesProcessed, transportManager);
}
if (!status.failed() && batchesProcessed.size() > 0) {
log.info("Pull files received from {}. {} files and {} batches were processed", new Object[] { nodeCommunication.getNodeId(), status.getDataProcessed(), status.getBatchesProcessed() });
} else if (status.failed()) {
log.info("There was a failure while pulling files from {}. {} files and {} batches were processed", new Object[] { nodeCommunication.getNodeId(), status.getDataProcessed(), status.getBatchesProcessed() });
}
} catch (NoContentException noContentEx) {
log.debug("Server reported no batches. " + noContentEx);
} catch (Exception e) {
fireOffline(e, nodeCommunication.getNode(), status);
} finally {
if (transport != null) {
transport.close();
if (processInfo.getStatus() != ProcessInfo.Status.ERROR) {
processInfo.setStatus(ProcessInfo.Status.OK);
}
if (transport instanceof FileIncomingTransport) {
((FileIncomingTransport) transport).complete(!status.failed());
}
}
}
}
Aggregations