use of org.jumpmind.symmetric.route.DataGapRouteReader in project symmetric-ds by JumpMind.
the class RouterService method startReading.
protected IDataToRouteReader startReading(ChannelRouterContext context) {
IDataToRouteReader reader = new DataGapRouteReader(context, engine);
if (parameterService.is(ParameterConstants.SYNCHRONIZE_ALL_JOBS)) {
reader.run();
} else {
if (readThread == null) {
readThread = Executors.newCachedThreadPool(new ThreadFactory() {
final AtomicInteger threadNumber = new AtomicInteger(1);
final String namePrefix = parameterService.getEngineName().toLowerCase() + "-router-reader-";
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName(namePrefix + threadNumber.getAndIncrement());
if (t.isDaemon()) {
t.setDaemon(false);
}
if (t.getPriority() != Thread.NORM_PRIORITY) {
t.setPriority(Thread.NORM_PRIORITY);
}
return t;
}
});
}
readThread.execute(reader);
}
return reader;
}
use of org.jumpmind.symmetric.route.DataGapRouteReader in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method testDontSelectOldDataDuringRouting.
public void testDontSelectOldDataDuringRouting() throws Exception {
NodeChannel testChannel = getConfigurationService().getNodeChannel(TestConstants.TEST_CHANNEL_ID, false);
testChannel.setUseOldDataToRoute(false);
testChannel.setMaxBatchSize(50);
testChannel.setBatchAlgorithm("nontransactional");
getConfigurationService().saveChannel(testChannel, true);
TriggerRouter trigger = getTestRoutingTableTrigger(TEST_TABLE_1);
trigger.getRouter().setRouterType("column");
trigger.getRouter().setRouterExpression("ROUTING_VARCHAR=:NODE_ID");
getTriggerRouterService().saveTriggerRouter(trigger);
// clean setup
deleteAll(TEST_TABLE_1);
insert(TEST_TABLE_1, 100, true);
getRouterService().routeData(true);
resetBatches();
// delete
deleteAll(TEST_TABLE_1);
ISqlTransaction transaction = getSqlTemplate().startSqlTransaction();
ChannelRouterContext context = new ChannelRouterContext(TestConstants.TEST_ROOT_EXTERNAL_ID, testChannel, transaction);
context.setDataGaps(engine.getDataService().findDataGaps());
DataGapRouteReader reader = new DataGapRouteReader(context, engine);
reader.run();
List<Data> list = new ArrayList<Data>();
do {
Data data = reader.take();
if (data != null) {
list.add(data);
} else {
break;
}
} while (true);
transaction.close();
Assert.assertEquals(100, list.size());
for (Data data : list) {
Assert.assertNull(data.toParsedOldData());
Assert.assertNotNull(data.toParsedPkData());
}
}
Aggregations