/** * Handle the supplied event with a {@link GtidEventData} that signals the beginning of a GTID transaction. * We don't yet know whether this transaction contains any events we're interested in, but we have to record * it so that we know the position of this event and know we've processed the binlog to this point. * <p> * Note that this captures the current GTID and complete GTID set, regardless of whether the connector is * {@link MySqlTaskContext#gtidSourceFilter() filtering} the GTID set upon connection. We do this because * we actually want to capture all GTID set values found in the binlog, whether or not we process them. * However, only when we connect do we actually want to pass to MySQL only those GTID ranges that are applicable * per the configuration. * * @param event the GTID event to be processed; may not be null */ protected void handleGtidEvent(Event event) { logger.debug("GTID transaction: {}", event); GtidEventData gtidEvent = unwrapData(event); String gtid = gtidEvent.getGtid(); gtidSet.add(gtid); source.startGtid(gtid, gtidSet.toString()); // rather than use the client's GTID set ignoreDmlEventByGtidSource = false; if (gtidDmlSourceFilter != null && gtid != null) { String uuid = gtid.trim().substring(0, gtid.indexOf(":")); if (!gtidDmlSourceFilter.test(uuid)) { ignoreDmlEventByGtidSource = true; } } }
@Override public GtidEventData deserialize(ByteArrayInputStream inputStream) throws IOException { GtidEventData eventData = new GtidEventData(); byte flags = (byte) inputStream.readInteger(1); byte[] sid = inputStream.read(16); long gno = inputStream.readLong(8); eventData.setFlags(flags); eventData.setGtid(byteArrayToHex(sid, 0, 4) + "-" + byteArrayToHex(sid, 4, 2) + "-" + byteArrayToHex(sid, 6, 2) + "-" + byteArrayToHex(sid, 8, 2) + "-" + byteArrayToHex(sid, 10, 6) + ":" + String.format("%d", gno) ); return eventData; }
gtid = ((GtidEventData)event.getData()).getGtid();
case GTID: GtidEventData gtidEventData = (GtidEventData) EventDataWrapper.internal(event.getData()); gtid = gtidEventData.getGtid(); break; case XID: