use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method testGapRouting.
public void testGapRouting() throws Exception {
try {
if (getDbDialect().canGapsOccurInCapturedDataIds()) {
setUpDefaultTriggerRouterForTable1();
resetBatches();
Assert.assertEquals(1, getDataService().findDataGaps().size());
// route again to make sure we still only have one gap
getRouterService().routeData(true);
Assert.assertEquals(1, getDataService().findDataGaps().size());
insertGaps(2, 1, 2);
getRouterService().routeData(true);
// route again to calculate gaps
getRouterService().routeData(true);
Assert.assertEquals(1, getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false).getBatches().size());
List<DataGap> gaps = getDataService().findDataGaps();
Assert.assertEquals(2, gaps.size());
DataGap gap = gaps.get(0);
Assert.assertEquals(0, gap.getEndId() - gap.getStartId());
// route again to make sure the gaps don't disappear
getRouterService().routeData(true);
getRouterService().routeData(true);
gaps = getDataService().findDataGaps();
Assert.assertEquals(2, gaps.size());
gap = gaps.get(0);
Assert.assertEquals(0, gap.getEndId() - gap.getStartId());
}
} catch (Exception ex) {
logger.error("", ex);
throw ex;
}
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method testGapWithGapAtEnd.
public void testGapWithGapAtEnd() {
if (getDbDialect().canGapsOccurInCapturedDataIds()) {
setUpDefaultTriggerRouterForTable1();
resetBatches();
Assert.assertEquals(1, getDataService().findDataGaps().size());
long startId = getSqlTemplate().queryForLong("select max(start_id) from sym_data_gap");
getSqlTemplate().update("update sym_data_gap set status='OK'");
getDataService().insertDataGap(new DataGap(startId, startId + 10));
getDataService().insertDataGap(new DataGap(startId + 11, startId + 11 + getParameterService().getLong(ParameterConstants.ROUTING_LARGEST_GAP_SIZE)));
insertGaps(8, 0, 1);
routeAndCreateGaps();
Assert.assertEquals(1, getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false).getBatches().size());
List<DataGap> gaps = getDataService().findDataGaps();
Assert.assertEquals(2, gaps.size());
DataGap gap = gaps.get(0);
Assert.assertEquals(startId + 8, gap.getStartId());
routeAndCreateGaps();
}
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method testGapWithGapAtBegining.
public void testGapWithGapAtBegining() {
if (getDbDialect().canGapsOccurInCapturedDataIds()) {
setUpDefaultTriggerRouterForTable1();
resetBatches();
List<DataGap> gaps = getDataService().findDataGaps();
Assert.assertEquals(1, gaps.size());
// evidently, derby only leaves a gap of one, no matter how many
// rows you insert
String name = getPlatform().getName();
int gapsize = name.equals(DatabaseNamesConstants.DERBY) ? 1 : 10;
insert(TEST_TABLE_1, gapsize, true, null, NODE_GROUP_NODE_1.getNodeId(), true);
insert(TEST_TABLE_1, 10, true, null, NODE_GROUP_NODE_1.getNodeId(), false);
routeAndCreateGaps();
Assert.assertEquals(1, getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false).getBatches().size());
gaps = getDataService().findDataGaps();
Assert.assertEquals(2, gaps.size());
DataGap gap = gaps.get(0);
Assert.assertEquals("The gap's start id was " + gap.getStartId() + " end id was " + gap.getEndId(), gapsize - 1, gap.getEndId() - gap.getStartId());
routeAndCreateGaps();
gaps = getDataService().findDataGaps();
Assert.assertEquals(2, gaps.size());
gap = gaps.get(0);
Assert.assertEquals(gapsize - 1, gap.getEndId() - gap.getStartId());
}
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method testDataGapExpired.
public void testDataGapExpired() throws Exception {
if (getDbDialect().canGapsOccurInCapturedDataIds()) {
resetGaps();
testGapRouting();
List<DataGap> gaps = getDataService().findDataGaps();
Assert.assertEquals(2, gaps.size());
DataGap gap = gaps.get(0);
Assert.assertEquals(0, gap.getEndId() - gap.getStartId());
Calendar time = Calendar.getInstance();
time.add(Calendar.DATE, -10);
getSqlTemplate().update("update sym_data_gap set create_time=?", time.getTime());
routeAndCreateGaps();
;
gaps = getDataService().findDataGaps();
Assert.assertEquals("Gap should have expired", 2, gaps.size());
}
}
Aggregations