use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class TriggerRouterService method buildTriggerRoutersForSymmetricTables.
protected TriggerRouter buildTriggerRoutersForSymmetricTables(String version, Trigger trigger, NodeGroupLink nodeGroupLink) {
TriggerRouter triggerRouter = new TriggerRouter();
triggerRouter.setTrigger(trigger);
Router router = triggerRouter.getRouter();
router.setRouterId(buildSymmetricTableRouterId(trigger.getTriggerId(), nodeGroupLink.getSourceNodeGroupId(), nodeGroupLink.getTargetNodeGroupId()));
if (TableConstants.getTableName(tablePrefix, TableConstants.SYM_FILE_SNAPSHOT).equals(trigger.getSourceTableName())) {
router.setRouterType(FileSyncDataRouter.ROUTER_TYPE);
} else {
router.setRouterType(ConfigurationChangedDataRouter.ROUTER_TYPE);
}
router.setNodeGroupLink(nodeGroupLink);
router.setLastUpdateTime(trigger.getLastUpdateTime());
triggerRouter.setLastUpdateTime(trigger.getLastUpdateTime());
return triggerRouter;
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class TriggerRouterService method buildTriggerRoutersForSymmetricTables.
public List<TriggerRouter> buildTriggerRoutersForSymmetricTables(String version, NodeGroupLink nodeGroupLink, String... tablesToExclude) {
int initialLoadOrder = 1;
List<Trigger> triggers = buildTriggersForSymmetricTables(version, tablesToExclude);
List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>(triggers.size());
for (int j = 0; j < triggers.size(); j++) {
Trigger trigger = triggers.get(j);
TriggerRouter triggerRouter = buildTriggerRoutersForSymmetricTables(version, trigger, nodeGroupLink);
triggerRouter.setInitialLoadOrder(initialLoadOrder++);
triggerRouters.add(triggerRouter);
}
return triggerRouters;
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class TriggerRouterService method getTriggerRoutersByChannel.
public Map<String, List<TriggerRouter>> getTriggerRoutersByChannel(String nodeGroupId, boolean refreshCache) {
long triggerRouterCacheTimeoutInMs = parameterService.getLong(ParameterConstants.CACHE_TIMEOUT_TRIGGER_ROUTER_IN_MS);
Map<String, List<TriggerRouter>> testValue = triggerRouterCacheByChannel;
if (testValue == null || refreshCache || System.currentTimeMillis() - this.triggerRouterPerChannelCacheTime > triggerRouterCacheTimeoutInMs) {
synchronized (cacheLock) {
testValue = triggerRouterCacheByChannel;
if (testValue == null || refreshCache || System.currentTimeMillis() - this.triggerRouterPerChannelCacheTime > triggerRouterCacheTimeoutInMs) {
final Map<String, List<TriggerRouter>> newValue = new HashMap<String, List<TriggerRouter>>();
this.triggerRouterPerChannelCacheTime = System.currentTimeMillis();
List<TriggerRouter> triggerRouters = enhanceTriggerRouters(sqlTemplate.query(getTriggerRouterSql("selectGroupTriggersSql"), new TriggerRouterMapper(), nodeGroupId, nodeGroupId));
for (TriggerRouter triggerRouter : triggerRouters) {
List<TriggerRouter> list = newValue.get(triggerRouter.getTrigger().getChannelId());
if (list == null) {
list = new ArrayList<TriggerRouter>();
newValue.put(triggerRouter.getTrigger().getChannelId(), list);
}
list.add(triggerRouter);
}
triggerRouterCacheByChannel = newValue;
testValue = newValue;
}
}
}
return testValue;
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class TriggerRouterService method getTriggerRouterForCurrentNode.
public TriggerRouter getTriggerRouterForCurrentNode(String triggerId, String routerId, boolean refreshCache) {
TriggerRouter triggerRouter = null;
List<TriggerRouter> triggerRouters = getTriggerRoutersForCurrentNode(refreshCache).get(triggerId);
if (triggerRouters != null) {
for (TriggerRouter testTriggerRouter : triggerRouters) {
if (ConfigurationChangedDataRouter.ROUTER_TYPE.equals(testTriggerRouter.getRouter().getRouterType()) || testTriggerRouter.getRouter().getRouterId().equals(routerId) || routerId.equals(Constants.UNKNOWN_ROUTER_ID)) {
triggerRouter = testTriggerRouter;
break;
}
}
}
if (triggerRouter == null) {
log.warn("Could not find trigger router [{}:{}] in list {}", new Object[] { triggerId, routerId, triggerRouters == null ? 0 : triggerRouters.toString() });
}
return triggerRouter;
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class RouterServiceTest method testNotProducesCommonBatchesOneTableOneChannelNonDefaultRouter.
@Test
public void testNotProducesCommonBatchesOneTableOneChannelNonDefaultRouter() {
List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>();
triggerRouters.add(new TriggerRouter(new Trigger("a", CHANNEL_2_TEST.getChannelId()), new Router("test", SOURCE_NODE_GROUP, TARGET_NODE_GROUP, "column")));
assertTrue(!routerService.producesCommonBatches(CHANNEL_2_TEST, SOURCE_NODE_GROUP, triggerRouters));
}
Aggregations