Search in sources :

Example 1 with TriggerRouter

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

the class AbstractTriggerRouterServiceTest method test11BinaryColumnTypesForOracle.

@Test
public void test11BinaryColumnTypesForOracle() {
    ISymmetricDialect dialect = getDbDialect();
    if (DatabaseNamesConstants.ORACLE.equals(dialect.getName())) {
        getSqlTemplate().update(CREATE_ORACLE_BINARY_TYPE);
        TriggerRouter trouter = new TriggerRouter();
        Trigger trigger = trouter.getTrigger();
        trigger.setSourceTableName("test_oracle_binary_types");
        trigger.setChannelId(TestConstants.TEST_CHANNEL_ID);
        Router router = trouter.getRouter();
        router.getNodeGroupLink().setSourceNodeGroupId(TestConstants.TEST_ROOT_NODE_GROUP);
        router.getNodeGroupLink().setTargetNodeGroupId(TestConstants.TEST_ROOT_NODE_GROUP);
        getTriggerRouterService().saveTriggerRouter(trouter);
        ITriggerRouterService triggerService = getTriggerRouterService();
        triggerService.syncTriggers();
        Assert.assertEquals("Some triggers must have failed to build.", 0, triggerService.getFailedTriggers().size());
        getSqlTemplate().update(INSERT_ORACLE_BINARY_TYPE_1);
        String csvString = getNextDataRow();
        Assert.assertEquals(EXPECTED_INSERT_ORALCE_BINARY_TYPE_1, csvString);
    }
}
Also used : ISymmetricDialect(org.jumpmind.symmetric.db.ISymmetricDialect) Trigger(org.jumpmind.symmetric.model.Trigger) ITriggerRouterService(org.jumpmind.symmetric.service.ITriggerRouterService) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Router(org.jumpmind.symmetric.model.Router) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Test(org.junit.Test)

Example 2 with TriggerRouter

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

the class AbstractTriggerRouterServiceTest method test12BinaryColumnTypesForPostgres.

@Test
public void test12BinaryColumnTypesForPostgres() {
    ISymmetricDialect dialect = getDbDialect();
    if (DatabaseNamesConstants.POSTGRESQL.equals(dialect.getName())) {
        getSqlTemplate().update(DROP_POSTGRES_BINARY_TYPE);
        getSqlTemplate().update(CREATE_POSTGRES_BINARY_TYPE);
        TriggerRouter trouter = new TriggerRouter();
        Trigger trigger = trouter.getTrigger();
        trigger.setSourceTableName("test_postgres_binary_types");
        trigger.setChannelId(TestConstants.TEST_CHANNEL_ID);
        Router router = trouter.getRouter();
        router.getNodeGroupLink().setSourceNodeGroupId(TestConstants.TEST_ROOT_NODE_GROUP);
        router.getNodeGroupLink().setTargetNodeGroupId(TestConstants.TEST_ROOT_NODE_GROUP);
        getTriggerRouterService().saveTriggerRouter(trouter);
        ITriggerRouterService triggerService = getTriggerRouterService();
        triggerService.syncTriggers();
        Assert.assertEquals("Some triggers must have failed to build.", 0, triggerService.getFailedTriggers().size());
        // new SerialBlob("test 1 2 3".getBytes())
        ISqlTransaction transaction = getSqlTemplate().startSqlTransaction();
        try {
            getSqlTemplate().update(INSERT_POSTGRES_BINARY_TYPE_1, "test 1 2 3".getBytes());
            transaction.commit();
        } finally {
            transaction.close();
        }
        String csvString = getNextDataRow();
        Assert.assertEquals(EXPECTED_INSERT_POSTGRES_BINARY_TYPE_1, csvString);
    }
}
Also used : ISymmetricDialect(org.jumpmind.symmetric.db.ISymmetricDialect) ISqlTransaction(org.jumpmind.db.sql.ISqlTransaction) Trigger(org.jumpmind.symmetric.model.Trigger) ITriggerRouterService(org.jumpmind.symmetric.service.ITriggerRouterService) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Router(org.jumpmind.symmetric.model.Router) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Test(org.junit.Test)

Example 3 with TriggerRouter

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

the class AbstractRouterServiceTest method testSyncIncomingBatch.

public void testSyncIncomingBatch() throws Exception {
    resetBatches();
    TriggerRouter trigger1 = getTestRoutingTableTrigger(TEST_TABLE_1);
    trigger1.getTrigger().setSyncOnIncomingBatch(true);
    trigger1.getRouter().setRouterExpression(null);
    trigger1.getRouter().setRouterType(null);
    getTriggerRouterService().saveTriggerRouter(trigger1);
    NodeChannel testChannel = getConfigurationService().getNodeChannel(TestConstants.TEST_CHANNEL_ID, false);
    testChannel.setMaxBatchToSend(1000);
    testChannel.setMaxBatchSize(50);
    testChannel.setBatchAlgorithm("default");
    getConfigurationService().saveChannel(testChannel, true);
    getTriggerRouterService().syncTriggers();
    insert(TEST_TABLE_1, 10, true, NODE_GROUP_NODE_1.getNodeId());
    getRouterService().routeData(true);
    OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false);
    filterForChannels(batches, testChannel);
    Assert.assertEquals("Should have been 0.  We did the insert as if the data had come from node 1.", 0, batches.getBatches().size());
    batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false);
    filterForChannels(batches, testChannel);
    Assert.assertEquals(1, batches.getBatches().size());
    resetBatches();
}
Also used : TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) NodeChannel(org.jumpmind.symmetric.model.NodeChannel)

Example 4 with TriggerRouter

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

the class AbstractRouterServiceTest method testColumnMatchOnNull.

public void testColumnMatchOnNull() {
    NodeChannel testChannel = getConfigurationService().getNodeChannel(TestConstants.TEST_CHANNEL_ID, false);
    TriggerRouter trigger = getTestRoutingTableTrigger(TEST_TABLE_1);
    trigger.getRouter().setRouterType("column");
    trigger.getRouter().setRouterExpression("ROUTING_VARCHAR=NULL");
    getTriggerRouterService().saveTriggerRouter(trigger);
    getTriggerRouterService().syncTriggers();
    resetBatches();
    update(TEST_TABLE_1, "Not Routed");
    Assert.assertEquals(0, countBatchesForChannel(getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel));
    getRouterService().routeData(true);
    Assert.assertEquals(0, countBatchesForChannel(getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel));
    resetBatches();
    update(TEST_TABLE_1, null);
    Assert.assertEquals(0, countBatchesForChannel(getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel));
    getRouterService().routeData(true);
    Assert.assertEquals(1, countBatchesForChannel(getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel));
}
Also used : TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) NodeChannel(org.jumpmind.symmetric.model.NodeChannel)

Example 5 with TriggerRouter

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

the class AbstractRouterServiceTest method setUpDefaultTriggerRouterForTable1.

protected void setUpDefaultTriggerRouterForTable1() {
    TriggerRouter triggerRouter = getTestRoutingTableTrigger(TEST_TABLE_1);
    triggerRouter.getRouter().setRouterType("default");
    triggerRouter.getRouter().setRouterExpression(null);
    getTriggerRouterService().saveTriggerRouter(triggerRouter);
    NodeChannel testChannel = getConfigurationService().getNodeChannel(TestConstants.TEST_CHANNEL_ID, false);
    testChannel.setMaxBatchToSend(1000);
    testChannel.setMaxBatchSize(50);
    testChannel.setBatchAlgorithm("default");
    getConfigurationService().saveChannel(testChannel, true);
    getTriggerRouterService().syncTriggers();
}
Also used : TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) NodeChannel(org.jumpmind.symmetric.model.NodeChannel)

Aggregations

TriggerRouter (org.jumpmind.symmetric.model.TriggerRouter)64 ArrayList (java.util.ArrayList)22 Trigger (org.jumpmind.symmetric.model.Trigger)20 Router (org.jumpmind.symmetric.model.Router)18 NodeChannel (org.jumpmind.symmetric.model.NodeChannel)14 TriggerHistory (org.jumpmind.symmetric.model.TriggerHistory)13 ITriggerRouterService (org.jumpmind.symmetric.service.ITriggerRouterService)12 Test (org.junit.Test)12 List (java.util.List)10 Node (org.jumpmind.symmetric.model.Node)8 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)7 OutgoingBatches (org.jumpmind.symmetric.model.OutgoingBatches)7 Table (org.jumpmind.db.model.Table)6 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 Data (org.jumpmind.symmetric.model.Data)5 TableReloadRequest (org.jumpmind.symmetric.model.TableReloadRequest)5 ConfigurationChangedDataRouter (org.jumpmind.symmetric.route.ConfigurationChangedDataRouter)4 FileSyncDataRouter (org.jumpmind.symmetric.route.FileSyncDataRouter)4