Search in sources :

Example 1 with HistoryRecord

use of io.debezium.relational.history.HistoryRecord in project debezium by debezium.

the class MySqlTaskContextTest method historyRecord.

protected HistoryRecord historyRecord(String serverName, String binlogFilename, int position, String gtids, int event, int row, boolean snapshot) {
    Document source = Document.create(SourceInfo.SERVER_NAME_KEY, serverName);
    Document pos = Document.create(SourceInfo.BINLOG_FILENAME_OFFSET_KEY, binlogFilename, SourceInfo.BINLOG_POSITION_OFFSET_KEY, position);
    if (row >= 0) {
        pos = pos.set(SourceInfo.BINLOG_ROW_IN_EVENT_OFFSET_KEY, row);
    }
    if (event >= 0) {
        pos = pos.set(SourceInfo.EVENTS_TO_SKIP_OFFSET_KEY, event);
    }
    if (gtids != null && gtids.trim().length() != 0) {
        pos = pos.set(SourceInfo.GTID_SET_KEY, gtids);
    }
    if (snapshot) {
        pos = pos.set(SourceInfo.SNAPSHOT_KEY, true);
    }
    return new HistoryRecord(Document.create(HistoryRecord.Fields.SOURCE, source, HistoryRecord.Fields.POSITION, pos));
}
Also used : Document(io.debezium.document.Document) HistoryRecord(io.debezium.relational.history.HistoryRecord)

Example 2 with HistoryRecord

use of io.debezium.relational.history.HistoryRecord in project debezium by debezium.

the class MySqlTaskContextTest method shouldComparePositionsWithDifferentFields.

@Test
public void shouldComparePositionsWithDifferentFields() {
    String lastGtidStr = "01261278-6ade-11e6-b36a-42010af00790:1-400944168," + "30efb117-e42a-11e6-ba9e-42010a28002e:1-9," + "4d1a4918-44ba-11e6-bf12-42010af0040b:1-11604379," + "621dc2f6-803b-11e6-acc1-42010af000a4:1-7963838," + "716ec46f-d522-11e5-bb56-0242ac110004:1-35850702," + "c627b2bc-9647-11e6-a886-42010af0044a:1-10426868," + "d079cbb3-750f-11e6-954e-42010af00c28:1-11544291:11544293-11885648";
    config = simpleConfig().with(MySqlConnectorConfig.GTID_SOURCE_EXCLUDES, "96c2072e-e428-11e6-9590-42010a28002d").build();
    context = new MySqlTaskContext(config, false);
    context.start();
    context.source().setCompletedGtidSet(lastGtidStr);
    HistoryRecordComparator comparator = context.dbSchema().historyComparator();
    String server = "mysql-server-1";
    HistoryRecord rec1 = historyRecord(server, "mysql-bin.000008", 380941551, "01261278-6ade-11e6-b36a-42010af00790:1-378422946," + "4d1a4918-44ba-11e6-bf12-42010af0040b:1-11002284," + "716ec46f-d522-11e5-bb56-0242ac110004:1-34673215," + "96c2072e-e428-11e6-9590-42010a28002d:1-3," + "c627b2bc-9647-11e6-a886-42010af0044a:1-9541144", 0, 0, true);
    HistoryRecord rec2 = historyRecord(server, "mysql-bin.000016", 645115324, "01261278-6ade-11e6-b36a-42010af00790:1-400944168," + "30efb117-e42a-11e6-ba9e-42010a28002e:1-9," + "4d1a4918-44ba-11e6-bf12-42010af0040b:1-11604379," + "621dc2f6-803b-11e6-acc1-42010af000a4:1-7963838," + "716ec46f-d522-11e5-bb56-0242ac110004:1-35850702," + "c627b2bc-9647-11e6-a886-42010af0044a:1-10426868," + "d079cbb3-750f-11e6-954e-42010af00c28:1-11544291:11544293-11885648", 2, 1, false);
    assertThat(comparator.isAtOrBefore(rec1, rec2)).isTrue();
    assertThat(comparator.isAtOrBefore(rec2, rec1)).isFalse();
}
Also used : HistoryRecordComparator(io.debezium.relational.history.HistoryRecordComparator) HistoryRecord(io.debezium.relational.history.HistoryRecord) Test(org.junit.Test)

Aggregations

HistoryRecord (io.debezium.relational.history.HistoryRecord)2 Document (io.debezium.document.Document)1 HistoryRecordComparator (io.debezium.relational.history.HistoryRecordComparator)1 Test (org.junit.Test)1