Search in sources :

Example 1 with FileIncomingTransport

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);
    }
}
Also used : FileIncomingTransport(org.jumpmind.symmetric.transport.file.FileIncomingTransport) Node(org.jumpmind.symmetric.model.Node) IOException(java.io.IOException)

Example 2 with FileIncomingTransport

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());
            }
        }
    }
}
Also used : IIncomingTransport(org.jumpmind.symmetric.transport.IIncomingTransport) ITransportManager(org.jumpmind.symmetric.transport.ITransportManager) FileIncomingTransport(org.jumpmind.symmetric.transport.file.FileIncomingTransport) ProcessInfoKey(org.jumpmind.symmetric.model.ProcessInfoKey) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo) NoContentException(org.jumpmind.symmetric.transport.NoContentException) IncomingBatch(org.jumpmind.symmetric.model.IncomingBatch) FileConflictException(org.jumpmind.symmetric.file.FileConflictException) NoContentException(org.jumpmind.symmetric.transport.NoContentException) SymmetricException(org.jumpmind.symmetric.SymmetricException) IoException(org.jumpmind.exception.IoException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 FileIncomingTransport (org.jumpmind.symmetric.transport.file.FileIncomingTransport)2 IoException (org.jumpmind.exception.IoException)1 SymmetricException (org.jumpmind.symmetric.SymmetricException)1 FileConflictException (org.jumpmind.symmetric.file.FileConflictException)1 IncomingBatch (org.jumpmind.symmetric.model.IncomingBatch)1 Node (org.jumpmind.symmetric.model.Node)1 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)1 ProcessInfoKey (org.jumpmind.symmetric.model.ProcessInfoKey)1 IIncomingTransport (org.jumpmind.symmetric.transport.IIncomingTransport)1 ITransportManager (org.jumpmind.symmetric.transport.ITransportManager)1 NoContentException (org.jumpmind.symmetric.transport.NoContentException)1