Search in sources :

Example 21 with ISymmetricEngine

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

the class InternalTransportManager method getPullTransport.

public IIncomingTransport getPullTransport(Node remote, final Node local, String securityToken, Map<String, String> requestProperties, String registrationUrl) throws IOException {
    final PipedOutputStream respOs = new PipedOutputStream();
    final PipedInputStream respIs = new PipedInputStream(respOs);
    final ChannelMap suspendIgnoreChannels = symmetricEngine.getConfigurationService().getSuspendIgnoreChannelLists(remote.getNodeId());
    runAtClient(remote.getSyncUrl(), null, respOs, new IClientRunnable() {

        public void run(ISymmetricEngine engine, InputStream is, OutputStream os) throws Exception {
            IOutgoingTransport transport = new InternalOutgoingTransport(respOs, suspendIgnoreChannels, IoConstants.ENCODING);
            ProcessInfo processInfo = engine.getStatisticManager().newProcessInfo(new ProcessInfoKey(engine.getNodeService().findIdentityNodeId(), local.getNodeId(), ProcessType.PULL_HANDLER));
            try {
                engine.getDataExtractorService().extract(processInfo, local, transport);
                processInfo.setStatus(Status.OK);
            } catch (RuntimeException ex) {
                processInfo.setStatus(Status.ERROR);
                throw ex;
            }
            transport.close();
        }
    });
    return new InternalIncomingTransport(respIs);
}
Also used : ChannelMap(org.jumpmind.symmetric.model.ChannelMap) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) PipedOutputStream(java.io.PipedOutputStream) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) ProcessInfoKey(org.jumpmind.symmetric.model.ProcessInfoKey) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo) NotImplementedException(org.apache.commons.lang.NotImplementedException) IOException(java.io.IOException) IOutgoingTransport(org.jumpmind.symmetric.transport.IOutgoingTransport)

Example 22 with ISymmetricEngine

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

the class InternalTransportManager method getPushTransport.

public IOutgoingWithResponseTransport getPushTransport(final Node targetNode, final Node sourceNode, String securityToken, String channelId, String registrationUrl) throws IOException {
    final PipedOutputStream pushOs = new PipedOutputStream();
    final PipedInputStream pushIs = new PipedInputStream(pushOs);
    final PipedOutputStream respOs = new PipedOutputStream();
    final PipedInputStream respIs = new PipedInputStream(respOs);
    runAtClient(targetNode.getSyncUrl(), pushIs, respOs, new IClientRunnable() {

        public void run(ISymmetricEngine engine, InputStream is, OutputStream os) throws Exception {
            // This should be basically what the push servlet does ...
            engine.getDataLoaderService().loadDataFromPush(sourceNode, pushIs, respOs);
        }
    });
    return new InternalOutgoingWithResponseTransport(pushOs, respIs);
}
Also used : PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) PipedOutputStream(java.io.PipedOutputStream) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) NotImplementedException(org.apache.commons.lang.NotImplementedException) IOException(java.io.IOException)

Example 23 with ISymmetricEngine

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

the class InternalTransportManager method sendAcknowledgement.

public int sendAcknowledgement(Node remote, List<IncomingBatch> list, Node local, String securityToken, String registrationUrl) throws IOException {
    try {
        if (list != null && list.size() > 0) {
            ISymmetricEngine remoteEngine = getTargetEngine(remote.getSyncUrl());
            String ackData = getAcknowledgementData(remote.requires13Compatiblity(), local.getNodeId(), list);
            List<BatchAck> batches = readAcknowledgement(ackData);
            for (BatchAck batchInfo : batches) {
                remoteEngine.getAcknowledgeService().ack(batchInfo);
            }
        }
        return HttpURLConnection.HTTP_OK;
    } catch (Exception ex) {
        log.error("", ex);
        return -1;
    }
}
Also used : BatchAck(org.jumpmind.symmetric.model.BatchAck) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) NotImplementedException(org.apache.commons.lang.NotImplementedException) IOException(java.io.IOException)

Example 24 with ISymmetricEngine

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

the class InternalTransportManager method getRegisterTransport.

public IIncomingTransport getRegisterTransport(final Node client, String registrationUrl) throws IOException {
    final PipedOutputStream respOs = new PipedOutputStream();
    final PipedInputStream respIs = new PipedInputStream(respOs);
    runAtClient(registrationUrl, null, respOs, new IClientRunnable() {

        public void run(ISymmetricEngine engine, InputStream is, OutputStream os) throws Exception {
            // This should be basically what the registration servlet does
            // ...
            engine.getRegistrationService().registerNode(client, os, false);
        }
    });
    return new InternalIncomingTransport(respIs);
}
Also used : PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) PipedOutputStream(java.io.PipedOutputStream) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) NotImplementedException(org.apache.commons.lang.NotImplementedException) IOException(java.io.IOException)

Example 25 with ISymmetricEngine

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

the class InternalTransportManager method getFilePullTransport.

public IIncomingTransport getFilePullTransport(Node remote, final Node local, String securityToken, Map<String, String> requestProperties, String registrationUrl) throws IOException {
    final PipedOutputStream respOs = new PipedOutputStream();
    final PipedInputStream respIs = new PipedInputStream(respOs);
    runAtClient(remote.getSyncUrl(), null, respOs, new IClientRunnable() {

        public void run(ISymmetricEngine engine, InputStream is, OutputStream os) throws Exception {
            IOutgoingTransport transport = new InternalOutgoingTransport(respOs, null);
            ProcessInfo processInfo = engine.getStatisticManager().newProcessInfo(new ProcessInfoKey(engine.getNodeService().findIdentityNodeId(), local.getNodeId(), ProcessType.FILE_SYNC_PULL_HANDLER));
            try {
                engine.getFileSyncService().sendFiles(processInfo, local, transport);
                processInfo.setStatus(Status.OK);
            } catch (RuntimeException ex) {
                processInfo.setStatus(Status.ERROR);
                throw ex;
            }
            transport.close();
        }
    });
    return new InternalIncomingTransport(respIs);
}
Also used : PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) PipedOutputStream(java.io.PipedOutputStream) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) ProcessInfoKey(org.jumpmind.symmetric.model.ProcessInfoKey) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) ProcessInfo(org.jumpmind.symmetric.model.ProcessInfo) NotImplementedException(org.apache.commons.lang.NotImplementedException) IOException(java.io.IOException) IOutgoingTransport(org.jumpmind.symmetric.transport.IOutgoingTransport)

Aggregations

ISymmetricEngine (org.jumpmind.symmetric.ISymmetricEngine)35 IOException (java.io.IOException)12 INodeService (org.jumpmind.symmetric.service.INodeService)8 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)7 InputStream (java.io.InputStream)7 IDatabasePlatform (org.jumpmind.db.platform.IDatabasePlatform)7 Node (org.jumpmind.symmetric.model.Node)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)7 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)7 OutputStream (java.io.OutputStream)6 PipedInputStream (java.io.PipedInputStream)6 PipedOutputStream (java.io.PipedOutputStream)6 NotImplementedException (org.apache.commons.lang.NotImplementedException)6 DatabaseInfo (org.jumpmind.db.platform.DatabaseInfo)6 IExtensionService (org.jumpmind.symmetric.service.IExtensionService)6 File (java.io.File)5 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)5 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)5 IParameterService (org.jumpmind.symmetric.service.IParameterService)5