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);
}
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);
}
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;
}
}
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);
}
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);
}
Aggregations