Skip to content

Commit fe6691c

Browse files
author
Stanley Shyiko
committed
Added BinaryLogClient::useBinlogFilenamePositionInGtidMode to control DumpBinaryLogGtidCommand (shyiko#254)
1 parent 68c0ec7 commit fe6691c

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/main/java/com/github/shyiko/mysql/binlog/BinaryLogClient.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public X509Certificate[] getAcceptedIssuers() {
135135
private GtidSet gtidSet;
136136
private final Object gtidSetAccessLock = new Object();
137137
private boolean gtidSetFallbackToPurged;
138+
private boolean useBinlogFilenamePositionInGtidMode;
138139
private String gtid;
139140
private boolean tx;
140141

@@ -307,9 +308,7 @@ public String getGtidSet() {
307308
* to "" (provided it's null) forcing MySQL to send events starting from the oldest known binlog (keep in mind
308309
* that connection will fail if gtid_purged is anything but empty (unless
309310
* {@link #setGtidSetFallbackToPurged(boolean)} is set to true))).
310-
* <p>NOTE #2: {@link #setBinlogFilename(String)} and {@link #setBinlogPosition(long)} can be used to specify the
311-
* exact position from which MySQL server should start streaming events (taking into account GTID set).
312-
* <p>NOTE #3: GTID set is automatically updated with each incoming GTID event (provided GTID mode is on).
311+
* <p>NOTE #2: GTID set is automatically updated with each incoming GTID event (provided GTID mode is on).
313312
* @see #getGtidSet()
314313
* @see #setGtidSetFallbackToPurged(boolean)
315314
*/
@@ -337,6 +336,22 @@ public void setGtidSetFallbackToPurged(boolean gtidSetFallbackToPurged) {
337336
this.gtidSetFallbackToPurged = gtidSetFallbackToPurged;
338337
}
339338

339+
/**
340+
* @see #setUseBinlogFilenamePositionInGtidMode(boolean)
341+
*/
342+
public boolean isUseBinlogFilenamePositionInGtidMode() {
343+
return useBinlogFilenamePositionInGtidMode;
344+
}
345+
346+
/**
347+
* @param useBinlogFilenamePositionInGtidMode true if MySQL server should start streaming events from a given
348+
* {@link #getBinlogFilename()} and {@link #getBinlogPosition()} instead of "the oldest known binlog" when
349+
* {@link #getGtidSet()} is set, false otherwise (default).
350+
*/
351+
public void setUseBinlogFilenamePositionInGtidMode(boolean useBinlogFilenamePositionInGtidMode) {
352+
this.useBinlogFilenamePositionInGtidMode = useBinlogFilenamePositionInGtidMode;
353+
}
354+
340355
/**
341356
* @return true if "keep alive" thread should be automatically started (default), false otherwise.
342357
* @see #setKeepAlive(boolean)
@@ -644,7 +659,10 @@ private void requestBinaryLogStream() throws IOException {
644659
Command dumpBinaryLogCommand;
645660
synchronized (gtidSetAccessLock) {
646661
if (gtidSet != null) {
647-
dumpBinaryLogCommand = new DumpBinaryLogGtidCommand(serverId, binlogFilename, binlogPosition, gtidSet);
662+
dumpBinaryLogCommand = new DumpBinaryLogGtidCommand(serverId,
663+
useBinlogFilenamePositionInGtidMode ? binlogFilename : "",
664+
useBinlogFilenamePositionInGtidMode ? binlogPosition : 4,
665+
gtidSet);
648666
} else {
649667
dumpBinaryLogCommand = new DumpBinaryLogCommand(serverId, binlogFilename, binlogPosition);
650668
}

0 commit comments

Comments
 (0)