use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class DataGapDetectorTest method testGapBusyExpireRun.
@Test
public void testGapBusyExpireRun() throws Exception {
List<DataGap> dataGaps = new ArrayList<DataGap>();
dataGaps.add(new DataGap(3, 3));
dataGaps.add(new DataGap(5, 6));
dataGaps.add(new DataGap(7, 50000006));
when(symmetricDialect.supportsTransactionViews()).thenReturn(true);
when(symmetricDialect.getDatabaseTime()).thenReturn(System.currentTimeMillis() + 60001L);
when(parameterService.getLong(ParameterConstants.ROUTING_STALE_GAP_BUSY_EXPIRE_TIME)).thenReturn(61000L);
detector.setLastBusyExpireRunTime(System.currentTimeMillis() - 61000);
runGapDetector(dataGaps, new ArrayList<Long>(), false);
verify(dataService).findDataGaps();
verify(dataService).countDataInRange(2, 4);
verify(dataService).countDataInRange(4, 7);
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(3, 3));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(5, 6));
verifyNoMoreInteractions(dataService);
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class DataGapDetectorTest method testGapsOverlapMultiple.
@Test
public void testGapsOverlapMultiple() throws Exception {
List<Long> dataIds = new ArrayList<Long>();
List<DataGap> dataGaps = new ArrayList<DataGap>();
dataGaps.add(new DataGap(1, 10));
dataGaps.add(new DataGap(3, 8));
dataGaps.add(new DataGap(4, 6));
dataGaps.add(new DataGap(4, 8));
dataGaps.add(new DataGap(4, 5));
dataGaps.add(new DataGap(5, 10));
dataGaps.add(new DataGap(6, 11));
runGapDetector(dataGaps, dataIds, true);
verify(dataService).findDataGaps();
verify(dataService, VerificationModeFactory.times(6)).deleteDataGap(sqlTransaction, new DataGap(1, 10));
verify(dataService, VerificationModeFactory.times(5)).insertDataGap(sqlTransaction, new DataGap(1, 10));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(3, 8));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(4, 6));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(4, 8));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(4, 5));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(5, 10));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(6, 11));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(1, 11));
verifyNoMoreInteractions(dataService);
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class DataGapDetectorTest method testGapsOverlapThenData.
@Test
public void testGapsOverlapThenData() throws Exception {
List<Long> dataIds = new ArrayList<Long>();
dataIds.add(30953883L);
List<DataGap> dataGaps = new ArrayList<DataGap>();
dataGaps.add(new DataGap(30953883, 80953883));
dataGaps.add(new DataGap(30953884, 80953883));
runGapDetector(dataGaps, dataIds, true);
verify(dataService).findDataGaps();
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(30953884, 80953883));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(30953883, 80953883));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(30953884, 80953883));
verifyNoMoreInteractions(dataService);
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class DataGapDetectorTest method checkInsertGap.
private void checkInsertGap(Set<DataGap> allGaps, DataGap gap) {
checkGap(gap);
if (allGaps.contains(gap)) {
throw new RuntimeException("Detected a duplicate data gap: " + gap);
}
for (DataGap gapAdded : allGaps) {
if (gap.overlaps(gapAdded)) {
throw new RuntimeException("Detected an overlapping data gap: " + gap);
}
}
allGaps.add(gap);
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class DataGapDetectorTest method testGapExpireOracleBusyChannel.
@Test
public void testGapExpireOracleBusyChannel() throws Exception {
List<DataGap> dataGaps = new ArrayList<DataGap>();
dataGaps.add(new DataGap(3, 3));
dataGaps.add(new DataGap(5, 6));
dataGaps.add(new DataGap(7, 50000006));
when(symmetricDialect.supportsTransactionViews()).thenReturn(true);
when(symmetricDialect.getEarliestTransactionStartTime()).thenReturn(new Date(System.currentTimeMillis() + 60001L));
when(dataService.countDataInRange(4, 7)).thenReturn(1);
detector.setLastBusyExpireRunTime(System.currentTimeMillis() - 61000);
runGapDetector(dataGaps, new ArrayList<Long>(), false);
verify(dataService).findDataGaps();
verify(dataService).countDataInRange(2, 4);
verify(dataService).countDataInRange(4, 7);
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(3, 3));
verifyNoMoreInteractions(dataService);
}
Aggregations