forked from shyiko/mysql-binlog-connector-java
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Adding support Mariadb events, such as GTID and annotate rows event(sql) #45
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/main/java/com/github/shyiko/mysql/binlog/MariadbBinaryLogClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.github.shyiko.mysql.binlog; | ||
|
||
import com.github.shyiko.mysql.binlog.event.EventType; | ||
import com.github.shyiko.mysql.binlog.event.deserialization.AnnotateRowsEventDataDeserializer; | ||
import com.github.shyiko.mysql.binlog.event.deserialization.MariadbGtidEventDataDeserializer; | ||
import com.github.shyiko.mysql.binlog.event.deserialization.MariadbGtidListEventDataDeserializer; | ||
import com.github.shyiko.mysql.binlog.network.protocol.command.Command; | ||
import com.github.shyiko.mysql.binlog.network.protocol.command.DumpBinaryLogCommand; | ||
import com.github.shyiko.mysql.binlog.network.protocol.command.QueryCommand; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Mariadb replication stream client. | ||
* | ||
* @author <a href="mailto:[email protected]">Winger</a> | ||
*/ | ||
public class MariadbBinaryLogClient extends BinaryLogClient { | ||
|
||
private boolean useSendAnnotateRowsEvent; | ||
|
||
public MariadbBinaryLogClient(String username, String password) { | ||
super(username, password); | ||
} | ||
|
||
public MariadbBinaryLogClient(String schema, String username, String password) { | ||
super(schema, username, password); | ||
} | ||
|
||
public MariadbBinaryLogClient(String hostname, int port, String username, String password) { | ||
super(hostname, port, username, password); | ||
} | ||
|
||
public MariadbBinaryLogClient(String hostname, int port, String schema, String username, String password) { | ||
super(hostname, port, schema, username, password); | ||
} | ||
|
||
@Override | ||
protected GtidSet buildGtidSet(String gtidSet) { | ||
return new MariadbGtidSet(gtidSet); | ||
} | ||
|
||
@Override | ||
protected void setupGtidSet() throws IOException { | ||
//Mariadb ignore | ||
} | ||
|
||
@Override | ||
protected void requestBinaryLogStream() throws IOException { | ||
long serverId = isBlocking() ? this.getServerId() : 0; // http://bugs.mysql.com/bug.php?id=71178 | ||
Command dumpBinaryLogCommand; | ||
synchronized (gtidSetAccessLock) { | ||
if (gtidSet != null) { | ||
channel.write(new QueryCommand("SET @mariadb_slave_capability=4")); | ||
checkError(channel.read()); | ||
channel.write(new QueryCommand("SET @slave_connect_state = '" + gtidSet.toString() + "'")); | ||
checkError(channel.read()); | ||
channel.write(new QueryCommand("SET @slave_gtid_strict_mode = 0")); | ||
checkError(channel.read()); | ||
channel.write(new QueryCommand("SET @slave_gtid_ignore_duplicates = 0")); | ||
checkError(channel.read()); | ||
dumpBinaryLogCommand = new DumpBinaryLogCommand(serverId, "", 0L, isUseSendAnnotateRowsEvent()); | ||
|
||
} else { | ||
dumpBinaryLogCommand = new DumpBinaryLogCommand(serverId, getBinlogFilename(), getBinlogPosition()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be some different implementations of Mariadb,look at https://github.com/shyiko/mysql-binlog-connector-java/pull/135/commits/36fca51464ccb8eb900b2addc23ac7e6c1c623ff |
||
} | ||
} | ||
channel.write(dumpBinaryLogCommand); | ||
} | ||
|
||
@Override | ||
protected void ensureGtidEventDataDeserializer() { | ||
ensureEventDataDeserializer(EventType.ANNOTATE_ROWS, AnnotateRowsEventDataDeserializer.class); | ||
ensureEventDataDeserializer(EventType.MARIADB_GTID, MariadbGtidEventDataDeserializer.class); | ||
ensureEventDataDeserializer(EventType.MARIADB_GTID_LIST, MariadbGtidListEventDataDeserializer.class); | ||
} | ||
|
||
public boolean isUseSendAnnotateRowsEvent() { | ||
return useSendAnnotateRowsEvent; | ||
} | ||
|
||
public void setUseSendAnnotateRowsEvent(boolean useSendAnnotateRowsEvent) { | ||
this.useSendAnnotateRowsEvent = useSendAnnotateRowsEvent; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does maria-db not support the
gtid_purged
variable?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, u can find this in https://mariadb.com/kb/en/system-variable-differences-between-mariadb-100-and-mysql-56/