use of org.jumpmind.symmetric.transport.file.FileOutgoingTransport in project symmetric-ds by JumpMind.
the class OfflinePushService method pushToNode.
private void pushToNode(Node remote, RemoteNodeStatus status) {
Node identity = nodeService.findIdentity();
FileOutgoingTransport transport = null;
ProcessInfo processInfo = statisticManager.newProcessInfo(new ProcessInfoKey(identity.getNodeId(), status.getChannelId(), remote.getNodeId(), ProcessType.OFFLINE_PUSH));
List<OutgoingBatch> extractedBatches = null;
try {
transport = (FileOutgoingTransport) transportManager.getPushTransport(remote, identity, null, null);
extractedBatches = dataExtractorService.extract(processInfo, remote, status.getChannelId(), transport);
if (extractedBatches.size() > 0) {
log.info("Offline push data written for {} at {}", remote, transport.getOutgoingDir());
List<BatchAck> batchAcks = readAcks(extractedBatches, transport, transportManager, acknowledgeService);
status.updateOutgoingStatus(extractedBatches, batchAcks);
}
if (processInfo.getStatus() != Status.ERROR) {
processInfo.setStatus(Status.OK);
}
} catch (Exception ex) {
processInfo.setStatus(Status.ERROR);
log.error("Failed to write offline file", ex);
} finally {
transport.close();
transport.complete(processInfo.getStatus() == Status.OK);
}
}
use of org.jumpmind.symmetric.transport.file.FileOutgoingTransport in project symmetric-ds by JumpMind.
the class FileSyncService method pushFilesToNode.
protected void pushFilesToNode(NodeCommunication nodeCommunication, RemoteNodeStatus status, Node identity, NodeSecurity security) {
ProcessInfo processInfo = engine.getStatisticManager().newProcessInfo(new ProcessInfoKey(nodeCommunication.getNodeId(), identity.getNodeId(), ProcessType.FILE_SYNC_PUSH_JOB));
IOutgoingWithResponseTransport transport = null;
ITransportManager transportManager = null;
try {
if (!engine.getParameterService().is(ParameterConstants.NODE_OFFLINE)) {
transportManager = engine.getTransportManager();
transport = transportManager.getFilePushTransport(nodeCommunication.getNode(), identity, security.getNodePassword(), parameterService.getRegistrationUrl());
} else {
transportManager = ((AbstractSymmetricEngine) engine).getOfflineTransportManager();
transport = transportManager.getFilePushTransport(nodeCommunication.getNode(), identity, security.getNodePassword(), parameterService.getRegistrationUrl());
}
List<OutgoingBatch> batches = sendFiles(processInfo, nodeCommunication.getNode(), transport);
if (batches.size() > 0) {
if (transport instanceof FileOutgoingTransport) {
((FileOutgoingTransport) transport).setProcessedBatches(batches);
}
List<BatchAck> batchAcks = readAcks(batches, transport, transportManager, engine.getAcknowledgeService());
status.updateOutgoingStatus(batches, batchAcks);
}
if (!status.failed() && batches.size() > 0) {
log.info("Pushed files to {}. {} files and {} batches were processed", new Object[] { nodeCommunication.getNodeId(), status.getDataProcessed(), status.getBatchesProcessed() });
} else if (status.failed()) {
log.info("There was a failure while pushing files to {}. {} files and {} batches were processed", new Object[] { nodeCommunication.getNodeId(), status.getDataProcessed(), status.getBatchesProcessed() });
}
} catch (Exception e) {
fireOffline(e, nodeCommunication.getNode(), status);
} finally {
if (processInfo.getStatus() != ProcessInfo.Status.ERROR) {
processInfo.setStatus(ProcessInfo.Status.OK);
}
if (transport != null) {
transport.close();
if (transport instanceof FileOutgoingTransport) {
((FileOutgoingTransport) transport).complete(processInfo.getStatus() == ProcessInfo.Status.OK);
}
}
}
}
Aggregations