Search in sources :

Example 16 with OutgoingBatches

use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.

the class SimpleIntegrationTest method test12SuspendIgnorePushLocalBatches.

@Test(timeout = 120000)
public void test12SuspendIgnorePushLocalBatches() throws Exception {
    // test suspend / ignore with local database specifying the suspends
    // and ignores
    logTestRunning();
    Date date = DateUtils.parseDate("2007-01-03", new String[] { "yyyy-MM-dd" });
    Order order = new Order("105", 100, null, date);
    order.getOrderDetails().add(new OrderDetail("105", 1, "STK", "110000065", 3, new BigDecimal("3.33")));
    assertNull(serverTestService.getOrder(order.getOrderId()));
    clientTestService.insertOrder(order);
    clientPush();
    assertNotNull(serverTestService.getOrder(order.getOrderId()));
    IConfigurationService clientConfigurationService = getClient().getConfigurationService();
    IOutgoingBatchService clientOutgoingBatchService = getClient().getOutgoingBatchService();
    NodeChannel c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setSuspendEnabled(true);
    clientConfigurationService.saveNodeChannel(c, true);
    order = new Order("106", 100, null, date);
    order.getOrderDetails().add(new OrderDetail("106", 1, "STK", "110000065", 3, new BigDecimal("3.33")));
    clientPush();
    OutgoingBatches batches = clientOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_ROOT_NODE.getNodeId(), false);
    assertEquals("There should be no outgoing batches since suspended locally", 0, batches.getBatches().size());
    assertNull(serverTestService.getOrder(order.getOrderId()));
    c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setIgnoreEnabled(true);
    clientConfigurationService.saveNodeChannel(c, true);
    clientPush();
    batches = clientOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_ROOT_NODE.getNodeId(), false);
    assertEquals("There should be no outgoing batches since suspended locally", 0, batches.getBatches().size());
    assertNull(serverTestService.getOrder(order.getOrderId()));
    // Cleanup!
    c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setSuspendEnabled(false);
    c.setIgnoreEnabled(false);
    clientConfigurationService.saveNodeChannel(c, true);
    clientPush();
}
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) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 17 with OutgoingBatches

use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.

the class AbstractIntegrationTest method assertNoPendingBatchesOnServer.

protected void assertNoPendingBatchesOnServer() {
    IOutgoingBatchService outgoingBatchService = getServer().getOutgoingBatchService();
    OutgoingBatches batches = outgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
    assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
}
Also used : IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches)

Example 18 with OutgoingBatches

use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.

the class FileSyncTest method testUpdateManual.

protected void testUpdateManual(ISymmetricEngine rootServer, ISymmetricEngine clientServer) throws Exception {
    OutgoingBatches batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
    List<OutgoingBatch> batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
    assertEquals(0, batches.size());
    IFileSyncService fileSyncService = rootServer.getFileSyncService();
    FileTriggerRouter fileTriggerRouter = fileSyncService.getFileTriggerRouter("all", "server_2_client");
    fileTriggerRouter.setConflictStrategy(FileConflictStrategy.MANUAL);
    fileSyncService.saveFileTriggerRouter(fileTriggerRouter);
    pull("client");
    File allFile1 = new File(allSvrSourceDir, "manual/test2.txt");
    allFile1.getParentFile().mkdirs();
    FileUtils.write(allFile1, "base value");
    File allFile1Target = new File(allClntTargetDir, allFile1.getParentFile().getName() + "/" + allFile1.getName());
    allFile1Target.getParentFile().mkdirs();
    pullFiles();
    assertEquals("base value", FileUtils.readFileToString(allFile1Target));
    batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
    batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
    assertEquals(0, batches.size());
    FileUtils.write(allFile1, "new value", true);
    pullFiles();
    assertEquals("base valuenew value", FileUtils.readFileToString(allFile1Target));
    batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
    batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
    assertEquals(0, batches.size());
}
Also used : FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) IFileSyncService(org.jumpmind.symmetric.service.IFileSyncService) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) OutgoingBatch(org.jumpmind.symmetric.model.OutgoingBatch) File(java.io.File)

Example 19 with OutgoingBatches

use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.

the class FileSyncTest method testCreateAndUpdateInSameBatch.

protected void testCreateAndUpdateInSameBatch(ISymmetricEngine rootServer, ISymmetricEngine clientServer) throws Exception {
    OutgoingBatches batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
    List<OutgoingBatch> batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
    assertEquals(0, batches.size());
    File allFile1 = new File(allSvrSourceDir, "createAndUpdate/test.txt");
    allFile1.getParentFile().mkdirs();
    FileUtils.write(allFile1, "create value ");
    trackChangesOnServer();
    FileUtils.write(allFile1, "plus update", true);
    trackChangesOnServer();
    File allFile1Target = new File(allClntTargetDir, allFile1.getParentFile().getName() + "/" + allFile1.getName());
    allFile1Target.getParentFile().mkdirs();
    pullFiles();
    batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
    batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
    assertEquals(0, batches.size());
    assertTrue(allFile1Target.exists());
    assertEquals("create value plus update", FileUtils.readFileToString(allFile1Target));
}
Also used : OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) OutgoingBatch(org.jumpmind.symmetric.model.OutgoingBatch) File(java.io.File)

Example 20 with OutgoingBatches

use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.

the class NonDmlEventsTest method testRoutingOfReloadEvents.

protected void testRoutingOfReloadEvents(ISymmetricEngine rootServer, ISymmetricEngine clientServer) throws Exception {
    rootServer.getParameterService().saveParameter(ParameterConstants.REST_API_ENABLED, true, "unit_test");
    rootServer.getRegistrationService().openRegistration(clientServer.getParameterService().getNodeGroupId(), "2");
    rootServer.getRegistrationService().openRegistration(clientServer.getParameterService().getNodeGroupId(), "3");
    RestService restService = getRegServer().getRestService();
    /* register a few more nodes to make sure that when we insert reload events they are only routed to the node we want */
    restService.postRegisterNode("2", clientServer.getParameterService().getNodeGroupId(), DatabaseNamesConstants.H2, "1.2", "host2");
    restService.postRegisterNode("3", clientServer.getParameterService().getNodeGroupId(), DatabaseNamesConstants.H2, "1.2", "host2");
    rootServer.route();
    assertEquals(0, rootServer.getOutgoingBatchService().countOutgoingBatchesUnsent(Constants.CHANNEL_RELOAD));
    Table serverTable = rootServer.getDatabasePlatform().readTableFromDatabase(null, null, "NODE_SPECIFIC");
    assertNotNull(serverTable);
    assertTrue(rootServer.getDataService().reloadTable(clientServer.getNodeService().findIdentityNodeId(), null, null, serverTable.getName()).startsWith("Successfully created"));
    rootServer.route();
    assertEquals(0, rootServer.getOutgoingBatchService().getOutgoingBatches("2", true).getBatchesForChannel(Constants.CHANNEL_RELOAD).size());
    assertEquals(0, rootServer.getOutgoingBatchService().getOutgoingBatches("3", true).getBatchesForChannel(Constants.CHANNEL_RELOAD).size());
    OutgoingBatches batches = rootServer.getOutgoingBatchService().getOutgoingBatches(clientServer.getNodeService().findIdentityNodeId(), true);
    assertEquals(1, batches.getBatchesForChannel(Constants.CHANNEL_RELOAD).size());
}
Also used : Table(org.jumpmind.db.model.Table) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) RestService(org.jumpmind.symmetric.web.rest.RestService)

Aggregations

OutgoingBatches (org.jumpmind.symmetric.model.OutgoingBatches)34 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)15 NodeChannel (org.jumpmind.symmetric.model.NodeChannel)14 IOutgoingBatchService (org.jumpmind.symmetric.service.IOutgoingBatchService)8 TriggerRouter (org.jumpmind.symmetric.model.TriggerRouter)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Date (java.util.Date)5 IConfigurationService (org.jumpmind.symmetric.service.IConfigurationService)5 FixMethodOrder (org.junit.FixMethodOrder)5 File (java.io.File)3 ProtocolDataWriter (org.jumpmind.symmetric.io.data.writer.ProtocolDataWriter)3 ChannelMap (org.jumpmind.symmetric.model.ChannelMap)3 BigDecimal (java.math.BigDecimal)2 List (java.util.List)2 IOutgoingBatchFilter (org.jumpmind.symmetric.ext.IOutgoingBatchFilter)2 IDataWriter (org.jumpmind.symmetric.io.data.IDataWriter)2 Channel (org.jumpmind.symmetric.model.Channel)2 FileTriggerRouter (org.jumpmind.symmetric.model.FileTriggerRouter)2 IFileSyncService (org.jumpmind.symmetric.service.IFileSyncService)2