use of org.jumpmind.symmetric.service.IOutgoingBatchService in project symmetric-ds by JumpMind.
the class RestService method getOutgoingBatchSummary.
@ApiOperation(value = "Outgoing summary of batches and data counts waiting for a node")
@RequestMapping(value = "/engine/{engine}/outgoingBatchSummary", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final BatchSummaries getOutgoingBatchSummary(@PathVariable("engine") String engineName, @RequestParam(value = WebConstants.NODE_ID) String nodeId, @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) {
ISymmetricEngine engine = getSymmetricEngine(engineName);
if (securityVerified(nodeId, engine, securityToken)) {
BatchSummaries summaries = new BatchSummaries();
summaries.setNodeId(nodeId);
IOutgoingBatchService outgoingBatchService = engine.getOutgoingBatchService();
List<OutgoingBatchSummary> list = outgoingBatchService.findOutgoingBatchSummary(OutgoingBatch.Status.RQ, OutgoingBatch.Status.QY, OutgoingBatch.Status.NE, OutgoingBatch.Status.SE, OutgoingBatch.Status.LD, OutgoingBatch.Status.ER);
for (OutgoingBatchSummary sum : list) {
if (sum.getNodeId().equals(nodeId)) {
BatchSummary summary = new BatchSummary();
summary.setBatchCount(sum.getBatchCount());
summary.setDataCount(sum.getDataCount());
summary.setOldestBatchCreateTime(sum.getOldestBatchCreateTime());
summary.setStatus(sum.getStatus().name());
summaries.getBatchSummaries().add(summary);
}
}
return summaries;
} else {
throw new NotAllowedException();
}
}
use of org.jumpmind.symmetric.service.IOutgoingBatchService in project symmetric-ds by JumpMind.
the class CopyNodeUriHandler method handle.
public void handle(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
IRegistrationService registrationService = engine.getRegistrationService();
IOutgoingBatchService outgoingBatchService = engine.getOutgoingBatchService();
INodeService nodeService = engine.getNodeService();
IConfigurationService configurationService = engine.getConfigurationService();
String identityNodeId = nodeService.findIdentityNodeId();
String copyFromNodeId = req.getParameter(WebConstants.NODE_ID);
String newExternalId = req.getParameter(WebConstants.EXTERNAL_ID);
String newGroupId = req.getParameter(WebConstants.NODE_GROUP_ID);
String newNodeId = registrationService.openRegistration(newGroupId, newExternalId);
log.info("Received a copy request. New external_id={}, new node_group_id={}, old node_id={}, new node_id={}", new Object[] { newExternalId, newGroupId, copyFromNodeId, newNodeId });
Set<String> channelIds = configurationService.getChannels(false).keySet();
for (String channelId : channelIds) {
String batchId = req.getParameter(channelId + "-" + identityNodeId);
if (isNotBlank(batchId)) {
outgoingBatchService.copyOutgoingBatches(channelId, NumberUtils.toLong(batchId.trim()), copyFromNodeId, newNodeId);
}
}
}
use of org.jumpmind.symmetric.service.IOutgoingBatchService in project symmetric-ds by JumpMind.
the class SimpleIntegrationTest method test29SyncShellCommand.
@Test(timeout = 120000)
public void test29SyncShellCommand() throws Exception {
logTestRunning();
IDataService rootDataService = getServer().getDataService();
IOutgoingBatchService rootOutgoingBatchService = getServer().getOutgoingBatchService();
testFlag = false;
String scriptData = "org.jumpmind.symmetric.test.SimpleIntegrationTest.testFlag=true;";
rootDataService.sendScript(TestConstants.TEST_CLIENT_EXTERNAL_ID, scriptData, false);
clientPull();
OutgoingBatches batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
assertEquals(0, batches.countBatches(true));
assertTrue("Expected the testFlag static variable to have been set to true", testFlag);
}
use of org.jumpmind.symmetric.service.IOutgoingBatchService in project symmetric-ds by JumpMind.
the class SimpleIntegrationTest method test14SuspendIgnorePullRemoteLocalComboBatches.
@Test(timeout = 120000)
public void test14SuspendIgnorePullRemoteLocalComboBatches() throws Exception {
// test suspend / ignore with remote database specifying the suspends
// and ignores
logTestRunning();
Date date = DateUtils.parseDate("2009-09-30", new String[] { "yyyy-MM-dd" });
Order order = new Order("442", 100, "C", date);
serverTestService.insertOrder(order);
clientPull();
IOutgoingBatchService rootOutgoingBatchService = getServer().getOutgoingBatchService();
OutgoingBatches batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
assertNotNull(clientTestService.getOrder(order.getOrderId()));
assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
IConfigurationService rootConfigurationService = getServer().getConfigurationService();
IConfigurationService clientConfigurationService = getClient().getConfigurationService();
// suspend on remote
NodeChannel c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setSuspendEnabled(true);
rootConfigurationService.saveNodeChannel(c, true);
// ignore on local
c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setIgnoreEnabled(true);
clientConfigurationService.saveNodeChannel(c, true);
order = new Order("443", 100, "C", date);
serverTestService.insertOrder(order);
clientPull();
batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
assertNull(clientTestService.getOrder(order.getOrderId()));
// ignore on remote
c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setIgnoreEnabled(true);
c.setSuspendEnabled(false);
rootConfigurationService.saveNodeChannel(c, true);
// suspend on local
c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setIgnoreEnabled(false);
c.setSuspendEnabled(true);
clientConfigurationService.saveNodeChannel(c, true);
order = new Order("444", 100, "C", date);
clientPull();
batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
assertNull(clientTestService.getOrder(order.getOrderId()));
// Cleanup!
c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setSuspendEnabled(false);
c.setIgnoreEnabled(false);
rootConfigurationService.saveNodeChannel(c, true);
c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setSuspendEnabled(false);
c.setIgnoreEnabled(false);
clientConfigurationService.saveNodeChannel(c, true);
clientPull();
}
use of org.jumpmind.symmetric.service.IOutgoingBatchService in project symmetric-ds by JumpMind.
the class SimpleIntegrationTest method test13SuspendIgnorePullRemoteBatches.
@Test(timeout = 120000)
public void test13SuspendIgnorePullRemoteBatches() throws Exception {
// test suspend / ignore with remote database specifying the suspends
// and ignores
logTestRunning();
clientPull();
Date date = DateUtils.parseDate("2009-09-30", new String[] { "yyyy-MM-dd" });
Order order = new Order("42", 100, "C", date);
serverTestService.insertOrder(order);
clientPull();
IOutgoingBatchService rootOutgoingBatchService = getServer().getOutgoingBatchService();
OutgoingBatches batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
assertNotNull(clientTestService.getOrder(order.getOrderId()));
assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
// Suspend the channel...
IConfigurationService rootConfigurationService = getServer().getConfigurationService();
NodeChannel c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setSuspendEnabled(true);
rootConfigurationService.saveNodeChannel(c, true);
date = DateUtils.parseDate("2009-09-30", new String[] { "yyyy-MM-dd" });
order = new Order("43", 100, "C", date);
serverTestService.insertOrder(order);
clientPull();
batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
assertEquals("There should be 1 outgoing batch", 1, batches.getBatches().size());
assertNull(clientTestService.getOrder(order.getOrderId()));
c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setIgnoreEnabled(true);
rootConfigurationService.saveNodeChannel(c, true);
// ignore
clientPull();
batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
assertNull(clientTestService.getOrder(order.getOrderId()));
assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
// Cleanup!
c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setSuspendEnabled(false);
c.setIgnoreEnabled(false);
rootConfigurationService.saveNodeChannel(c, true);
clientPull();
batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
assertNull(clientTestService.getOrder(order.getOrderId()));
}
Aggregations