예제 #1
0
        public void Test_ParseEmptyString_ReturnsEmptyGtidList()
        {
            var gtidList = GtidList.Parse("");

            Assert.Equal(0, gtidList.Gtids.Count);
            Assert.Equal("", gtidList.ToString());
        }
예제 #2
0
        public void Test_AddMultiDomainGtid_GtidMerged()
        {
            var gtidList = GtidList.Parse("1-2-120,2-3-130,3-4-50");

            gtidList.AddGtid(new Gtid(2, 4, 250));

            Assert.Equal(3, gtidList.Gtids.Count);
            Assert.Equal("1-2-120,2-4-250,3-4-50", gtidList.ToString());
        }
예제 #3
0
        public void Test_AddNewDomainGtid_GtidAdded()
        {
            var gtidList = GtidList.Parse("0-1-270");

            gtidList.AddGtid(new Gtid(1, 1, 271));

            Assert.Equal(2, gtidList.Gtids.Count);
            Assert.Equal("0-1-270,1-1-271", gtidList.ToString());
        }
예제 #4
0
        public void Test_AddExistingDomainGtid_GtidUpdated()
        {
            var gtidList = GtidList.Parse("0-1-270");

            gtidList.AddGtid(new Gtid(0, 1, 271));

            Assert.Equal(1, gtidList.Gtids.Count);
            Assert.Equal("0-1-271", gtidList.ToString());
        }
예제 #5
0
        static async Task Main(string[] args)
        {
            var client = new BinlogClient(options =>
            {
                options.Port              = 3306;
                options.UseSsl            = false;
                options.Username          = "******";
                options.Password          = "******";
                options.HeartbeatInterval = TimeSpan.FromSeconds(30);
                options.Blocking          = true;

                // Start replication from MariaDB GTID
                options.Binlog = BinlogOptions.FromGtid(GtidList.Parse("0-1-270"));

                // Start replication from MySQL GTID
                var gtidSet    = "d4c17f0c-4f11-11ea-93e3-325d3e1cd1c8:1-107, f442510a-2881-11ea-b1dd-27916133dbb2:1-7";
                options.Binlog = BinlogOptions.FromGtid(GtidSet.Parse(gtidSet));

                // Start replication from the position
                options.Binlog = BinlogOptions.FromPosition("mysql-bin.000008", 195);

                // Start replication from last master position.
                // Useful when you are only interested in new changes.
                options.Binlog = BinlogOptions.FromEnd();

                // Start replication from first event of first available master binlog.
                // Note that binlog files by default have expiration time and deleted.
                options.Binlog = BinlogOptions.FromStart();
            });

            await client.ReplicateAsync(async (binlogEvent) =>
            {
                var state = client.State;

                if (binlogEvent is TableMapEvent tableMap)
                {
                    await HandleTableMapEvent(tableMap);
                }
                else if (binlogEvent is WriteRowsEvent writeRows)
                {
                    await HandleWriteRowsEvent(writeRows);
                }
                else if (binlogEvent is UpdateRowsEvent updateRows)
                {
                    await HandleUpdateRowsEvent(updateRows);
                }
                else if (binlogEvent is DeleteRowsEvent deleteRows)
                {
                    await HandleDeleteRowsEvent(deleteRows);
                }
                else
                {
                    await PrintEventAsync(binlogEvent);
                }
            });
        }
예제 #6
0
        public void Test_ParseGtidLists_ReturnsMultipleResults()
        {
            var gtidList1 = GtidList.Parse("0-1-270");
            var gtidList2 = GtidList.Parse("1-2-120,2-3-130");
            var gtidList3 = GtidList.Parse("1-2-120, 2-3-130, 3-4-50");

            Assert.Equal(1, gtidList1.Gtids.Count);
            Assert.Equal(2, gtidList2.Gtids.Count);
            Assert.Equal(3, gtidList3.Gtids.Count);

            Assert.Equal("0-1-270", gtidList1.ToString());
            Assert.Equal("1-2-120,2-3-130", gtidList2.ToString());
            Assert.Equal("1-2-120,2-3-130,3-4-50", gtidList3.ToString());
        }
예제 #7
0
 public void Test_ParseNullString_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => GtidList.Parse(null).ToString());
 }
예제 #8
0
 public void Test_ParseNotUniqueDomains_ThrowsFormatException()
 {
     Assert.Throws <FormatException>(() => GtidList.Parse("1-1-270, 1-1-271").ToString());
 }
예제 #9
0
 /// <summary>
 /// Creates a new <see cref="GtidListEvent"/>.
 /// </summary>
 public GtidListEvent(EventHeader header, GtidList gtidList) : base(header)
 {
     GtidList = gtidList;
 }