use of org.jumpmind.symmetric.transport.internal.InternalIncomingTransport in project symmetric-ds by JumpMind.
the class DataLoaderService method loadDataFromPush.
/**
* Load database from input stream and write acknowledgment to output
* stream. This is used for a "push" request with a response of an
* acknowledgment.
*/
public void loadDataFromPush(Node sourceNode, String channelId, InputStream in, OutputStream out) throws IOException {
Node local = nodeService.findIdentity();
if (local != null) {
ProcessInfo processInfo = statisticManager.newProcessInfo(new ProcessInfoKey(sourceNode.getNodeId(), channelId, local.getNodeId(), ProcessInfoKey.ProcessType.PUSH_HANDLER));
try {
List<IncomingBatch> batchList = loadDataFromTransport(processInfo, sourceNode, new InternalIncomingTransport(in), out);
logDataReceivedFromPush(sourceNode, batchList);
NodeSecurity security = nodeService.findNodeSecurity(local.getNodeId());
processInfo.setStatus(ProcessInfo.Status.ACKING);
transportManager.writeAcknowledgement(out, sourceNode, batchList, local, security != null ? security.getNodePassword() : null);
if (containsError(batchList)) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
} else {
processInfo.setStatus(ProcessInfo.Status.OK);
}
} catch (Exception e) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else if (e instanceof IOException) {
throw (IOException) e;
}
throw new RuntimeException(e);
}
} else {
throw new SymmetricException("Could not load data because the node is not registered");
}
}
use of org.jumpmind.symmetric.transport.internal.InternalIncomingTransport in project symmetric-ds by JumpMind.
the class DataLoaderService method loadDataFromPush.
/**
* Load database from input stream and write acknowledgment to output
* stream. This is used for a "push" request with a response of an
* acknowledgment.
*/
public void loadDataFromPush(Node sourceNode, InputStream in, OutputStream out) throws IOException {
Node local = nodeService.findIdentity();
if (local != null) {
ProcessInfo processInfo = statisticManager.newProcessInfo(new ProcessInfoKey(sourceNode.getNodeId(), local.getNodeId(), ProcessType.LOAD_FROM_PUSH));
try {
List<IncomingBatch> batchList = loadDataFromTransport(processInfo, sourceNode, new InternalIncomingTransport(in));
logDataReceivedFromPush(sourceNode, batchList);
NodeSecurity security = nodeService.findNodeSecurity(local.getNodeId());
processInfo.setStatus(ProcessInfo.Status.ACKING);
transportManager.writeAcknowledgement(out, sourceNode, batchList, local, security != null ? security.getNodePassword() : null);
if (containsError(batchList)) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
} else {
processInfo.setStatus(ProcessInfo.Status.OK);
}
} catch (RuntimeException e) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
throw e;
}
} else {
throw new SymmetricException("Could not load data because the node is not registered");
}
}
use of org.jumpmind.symmetric.transport.internal.InternalIncomingTransport in project symmetric-ds by JumpMind.
the class DataLoaderService method loadDataBatch.
public List<IncomingBatch> loadDataBatch(String batchData) {
String nodeId = nodeService.findIdentityNodeId();
if (StringUtils.isNotBlank(nodeId)) {
ProcessInfo processInfo = statisticManager.newProcessInfo(new ProcessInfoKey(nodeId, nodeId, ProcessType.MANUAL_LOAD));
try {
InternalIncomingTransport transport = new InternalIncomingTransport(new BufferedReader(new StringReader(batchData)));
List<IncomingBatch> list = loadDataFromTransport(processInfo, nodeService.findIdentity(), transport);
processInfo.setStatus(ProcessInfo.Status.OK);
return list;
} catch (IOException ex) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
throw new IoException();
} catch (RuntimeException ex) {
processInfo.setStatus(ProcessInfo.Status.ERROR);
throw ex;
}
} else {
return new ArrayList<IncomingBatch>(0);
}
}
use of org.jumpmind.symmetric.transport.internal.InternalIncomingTransport in project symmetric-ds by JumpMind.
the class AbstractDataLoaderServiceTest method load.
protected void load(ByteArrayOutputStream out) throws Exception {
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
getTransportManager().setIncomingTransport(new InternalIncomingTransport(in));
getDataLoaderService().loadDataFromPull(client);
}
Aggregations