Search in sources :

Example 1 with IOutgoingWithResponseTransport

use of org.jumpmind.symmetric.transport.IOutgoingWithResponseTransport 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;
    try {
        transport = engine.getTransportManager().getFilePushTransport(nodeCommunication.getNode(), identity, security.getNodePassword(), parameterService.getRegistrationUrl());
        List<OutgoingBatch> batches = sendFiles(processInfo, nodeCommunication.getNode(), transport);
        if (batches.size() > 0) {
            List<BatchAck> batchAcks = readAcks(batches, transport, engine.getTransportManager(), engine.getAcknowledgeService());
            status.updateOutgoingStatus(batches, batchAcks);
        }
    } 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);
        }
    }
}
Also used : BatchAck(org.jumpmind.symmetric.model.BatchAck) IOutgoingWithResponseTransport(org.jumpmind.symmetric.transport.IOutgoingWithResponseTransport) ProcessInfoKey(org.jumpmind.symmetric.model.ProcessInfoKey) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo) OutgoingBatch(org.jumpmind.symmetric.model.OutgoingBatch) FileConflictException(org.jumpmind.symmetric.file.FileConflictException) SymmetricException(org.jumpmind.symmetric.SymmetricException) IoException(org.jumpmind.exception.IoException) IOException(java.io.IOException)

Example 2 with IOutgoingWithResponseTransport

use of org.jumpmind.symmetric.transport.IOutgoingWithResponseTransport in project symmetric-ds by JumpMind.

the class PushService method pushToNode.

private void pushToNode(Node remote, RemoteNodeStatus status) {
    Node identity = nodeService.findIdentity();
    NodeSecurity identitySecurity = nodeService.findNodeSecurity(identity.getNodeId(), true);
    IOutgoingWithResponseTransport transport = null;
    ProcessInfo processInfo = statisticManager.newProcessInfo(new ProcessInfoKey(identity.getNodeId(), status.getChannelId(), remote.getNodeId(), ProcessType.PUSH_JOB));
    Map<String, String> requestProperties = new HashMap<String, String>();
    requestProperties.put(WebConstants.THREAD_CHANNEL, status.getChannelId());
    try {
        transport = transportManager.getPushTransport(remote, identity, identitySecurity.getNodePassword(), requestProperties, parameterService.getRegistrationUrl());
        List<OutgoingBatch> extractedBatches = dataExtractorService.extract(processInfo, remote, status.getChannelId(), transport);
        if (extractedBatches.size() > 0) {
            log.info("Push data sent to {}", remote);
            List<BatchAck> batchAcks = readAcks(extractedBatches, transport, transportManager, acknowledgeService);
            status.updateOutgoingStatus(extractedBatches, batchAcks);
        }
        if (processInfo.getStatus() != Status.ERROR) {
            processInfo.setStatus(Status.OK);
        }
        fireOnline(remote, status);
    } catch (Exception ex) {
        processInfo.setStatus(Status.ERROR);
        fireOffline(ex, remote, status);
    } finally {
        try {
            transport.close();
        } catch (Exception e) {
        }
    }
}
Also used : NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) HashMap(java.util.HashMap) Node(org.jumpmind.symmetric.model.Node) ProcessInfoKey(org.jumpmind.symmetric.model.ProcessInfoKey) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo) BatchAck(org.jumpmind.symmetric.model.BatchAck) IOutgoingWithResponseTransport(org.jumpmind.symmetric.transport.IOutgoingWithResponseTransport) OutgoingBatch(org.jumpmind.symmetric.model.OutgoingBatch)

Aggregations

BatchAck (org.jumpmind.symmetric.model.BatchAck)2 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)2 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)2 ProcessInfoKey (org.jumpmind.symmetric.model.ProcessInfoKey)2 IOutgoingWithResponseTransport (org.jumpmind.symmetric.transport.IOutgoingWithResponseTransport)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 IoException (org.jumpmind.exception.IoException)1 SymmetricException (org.jumpmind.symmetric.SymmetricException)1 FileConflictException (org.jumpmind.symmetric.file.FileConflictException)1 Node (org.jumpmind.symmetric.model.Node)1 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)1