Search in sources :

Example 41 with DataGap

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);
}
Also used : DataGap(org.jumpmind.symmetric.model.DataGap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 42 with DataGap

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);
}
Also used : DataGap(org.jumpmind.symmetric.model.DataGap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 43 with DataGap

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);
}
Also used : DataGap(org.jumpmind.symmetric.model.DataGap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 44 with DataGap

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);
}
Also used : DataGap(org.jumpmind.symmetric.model.DataGap)

Example 45 with DataGap

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);
}
Also used : DataGap(org.jumpmind.symmetric.model.DataGap) ArrayList(java.util.ArrayList) Date(java.util.Date) Test(org.junit.Test)

Aggregations

DataGap (org.jumpmind.symmetric.model.DataGap)49 ArrayList (java.util.ArrayList)32 Test (org.junit.Test)28 Data (org.jumpmind.symmetric.model.Data)7 Date (java.util.Date)6 ISqlRowMapper (org.jumpmind.db.sql.ISqlRowMapper)6 TransformedData (org.jumpmind.symmetric.io.data.transform.TransformedData)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 ISqlTemplate (org.jumpmind.db.sql.ISqlTemplate)5 HashSet (java.util.HashSet)3 List (java.util.List)3 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)3 Row (org.jumpmind.db.sql.Row)2 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)2 ProcessInfoKey (org.jumpmind.symmetric.model.ProcessInfoKey)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)1 MemoryUsage (java.lang.management.MemoryUsage)1