Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About binlogFileName #14

Open
welyss opened this issue Jan 14, 2016 · 1 comment
Open

About binlogFileName #14

welyss opened this issue Jan 14, 2016 · 1 comment

Comments

@welyss
Copy link

welyss commented Jan 14, 2016

In rotate event, i can obtain a correct value with "((RotateEvent)event).getBinlogFileName".
But after that, in the other event(include rotate event), i get a incorrect value with "event.getHeader().getBinlogFileName", i think when rotate event, only the value of RotateEvent instance has been changed, not the others?

@joungjo
Copy link

joungjo commented Nov 16, 2016

You can do this to solve the problem.

first change class RotateEventParser.

Add contribute private ReplicationBasedBinlogParser r , and add constructor like below

-private ReplicationBasedBinlogParser r;
public RotateEventParser(ReplicationBasedBinlogParser r) {
super(RotateEvent.EVENT_TYPE);
this.r = r;
}

Second change method parse in this class like below

public void parse(XInputStream is, BinlogEventV4Header header, BinlogParserContext context)
throws IOException {
final RotateEvent event = new RotateEvent(header);
event.setBinlogPosition(is.readLong(8));
event.setBinlogFileName(is.readFixedLengthString(is.available()));
/*
* change this line like this
*/
r.setBinlogFileName(event.getBinlogFileName().toString());
context.getEventListener().onEvents(event);
}

Third change method getDefaultBinlogParser in class OpenParser like below

  • protected ReplicationBasedBinlogParser getDefaultBinlogParser() throws Exception {
    //
    final ReplicationBasedBinlogParser r = new ReplicationBasedBinlogParser();
    r.registerEventParser(new StopEventParser());
    /*
    * change this line like this
    */
    r.registerEventParser(new RotateEventParser(r));
    r.registerEventParser(new IntvarEventParser());
    r.registerEventParser(new XidEventParser());
    r.registerEventParser(new RandEventParser());
    r.registerEventParser(new QueryEventParser());
    r.registerEventParser(new UserVarEventParser());
    r.registerEventParser(new IncidentEventParser());
    r.registerEventParser(new TableMapEventParser());
    r.registerEventParser(new WriteRowsEventParser());
    r.registerEventParser(new UpdateRowsEventParser());
    r.registerEventParser(new DeleteRowsEventParser());
    r.registerEventParser(new WriteRowsEventV2Parser());
    r.registerEventParser(new UpdateRowsEventV2Parser());
    r.registerEventParser(new DeleteRowsEventV2Parser());
    r.registerEventParser(new FormatDescriptionEventParser());
    r.registerEventParser(new GtidEventParser());

    //
    r.setTransport(this.transport);
    r.setBinlogFileName(this.binlogFileName);
    return r;
    

    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants