use of org.jumpmind.symmetric.service.IAcknowledgeService in project symmetric-ds by JumpMind.
the class PushService method updateBatchStatus.
protected Status updateBatchStatus(OutgoingBatch batch, Node targetNode, Node identityNode, NodeSecurity identitySecurity) {
OutgoingBatch.Status returnStatus = batch.getStatus();
ITransportManager transportManager = engine.getTransportManager();
IAcknowledgeService acknowledgeService = engine.getAcknowledgeService();
IIncomingTransport transport = null;
try {
transport = transportManager.getAckStatusTransport(batch, targetNode, identityNode, identitySecurity.getNodePassword(), parameterService.getRegistrationUrl());
BufferedReader reader = transport.openReader();
String line = null;
do {
line = reader.readLine();
if (line != null) {
log.info("Updating batch status: {}", line);
List<BatchAck> batchAcks = transportManager.readAcknowledgement(line, "");
for (BatchAck batchInfo : batchAcks) {
if (batchInfo.getBatchId() == batch.getBatchId()) {
acknowledgeService.ack(batchInfo);
returnStatus = batchInfo.getStatus();
}
}
}
} while (line != null);
} catch (FileNotFoundException ex) {
log.info("Failed to read batch status for {}. It is probably because the server is not online yet", batch.getNodeBatchId());
} catch (Exception ex) {
log.warn(String.format("Failed to read the batch status for %s", batch.getNodeBatchId()), ex);
} finally {
transport.close();
}
return returnStatus;
}
use of org.jumpmind.symmetric.service.IAcknowledgeService in project symmetric-ds by JumpMind.
the class RestService method putAcknowledgeBatch.
@ApiOperation(value = "Acknowledge a set of batches for the specified engine")
@RequestMapping(value = "/engine/{engine}/acknowledgebatch", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final BatchAckResults putAcknowledgeBatch(@PathVariable("engine") String engineName, @ApiParam(value = "This the password for the nodeId being passed in. The password is stored in the node_security table.") @RequestParam(value = WebConstants.SECURITY_TOKEN) String securityToken, @RequestBody BatchResults batchResults) {
BatchAckResults finalResult = new BatchAckResults();
ISymmetricEngine engine = getSymmetricEngine(engineName);
List<BatchAckResult> results = null;
if (batchResults.getBatchResults().size() > 0) {
if (securityVerified(batchResults.getNodeId(), engine, securityToken)) {
IAcknowledgeService ackService = engine.getAcknowledgeService();
List<BatchAck> batchAcks = convertBatchResultsToAck(batchResults);
results = ackService.ack(batchAcks);
} else {
throw new NotAllowedException();
}
}
finalResult.setBatchAckResults(results);
return finalResult;
}
Aggregations