Search in sources :

Example 6 with IOutgoingBatchService

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();
    }
}
Also used : BatchSummary(org.jumpmind.symmetric.web.rest.model.BatchSummary) OutgoingBatchSummary(org.jumpmind.symmetric.model.OutgoingBatchSummary) OutgoingBatchSummary(org.jumpmind.symmetric.model.OutgoingBatchSummary) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService) BatchSummaries(org.jumpmind.symmetric.web.rest.model.BatchSummaries) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with IOutgoingBatchService

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);
        }
    }
}
Also used : IRegistrationService(org.jumpmind.symmetric.service.IRegistrationService) INodeService(org.jumpmind.symmetric.service.INodeService) IConfigurationService(org.jumpmind.symmetric.service.IConfigurationService) IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService)

Example 8 with IOutgoingBatchService

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);
}
Also used : IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) IDataService(org.jumpmind.symmetric.service.IDataService) Test(org.junit.Test)

Example 9 with IOutgoingBatchService

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();
}
Also used : FixMethodOrder(org.junit.FixMethodOrder) IConfigurationService(org.jumpmind.symmetric.service.IConfigurationService) IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) Date(java.util.Date) Test(org.junit.Test)

Example 10 with IOutgoingBatchService

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()));
}
Also used : FixMethodOrder(org.junit.FixMethodOrder) IConfigurationService(org.jumpmind.symmetric.service.IConfigurationService) IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) Date(java.util.Date) Test(org.junit.Test)

Aggregations

IOutgoingBatchService (org.jumpmind.symmetric.service.IOutgoingBatchService)13 OutgoingBatches (org.jumpmind.symmetric.model.OutgoingBatches)8 IConfigurationService (org.jumpmind.symmetric.service.IConfigurationService)7 Test (org.junit.Test)7 Date (java.util.Date)6 NodeChannel (org.jumpmind.symmetric.model.NodeChannel)6 FixMethodOrder (org.junit.FixMethodOrder)5 INodeService (org.jumpmind.symmetric.service.INodeService)3 BigDecimal (java.math.BigDecimal)2 NodeSecurity (org.jumpmind.symmetric.model.NodeSecurity)2 IRegistrationService (org.jumpmind.symmetric.service.IRegistrationService)2 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 NumberMapper (org.jumpmind.db.sql.mapper.NumberMapper)1 ISymmetricEngine (org.jumpmind.symmetric.ISymmetricEngine)1 IStagedResource (org.jumpmind.symmetric.io.stage.IStagedResource)1 IStagingManager (org.jumpmind.symmetric.io.stage.IStagingManager)1 BatchAckResult (org.jumpmind.symmetric.model.BatchAckResult)1 Channel (org.jumpmind.symmetric.model.Channel)1 Node (org.jumpmind.symmetric.model.Node)1 NodeHost (org.jumpmind.symmetric.model.NodeHost)1