/** * @return GTID set. Note that this value changes with each received GTID event (provided client is in GTID mode). * @see #setGtidSet(String) */ public String getGtidSet() { synchronized (gtidSetAccessLock) { return gtidSet != null ? gtidSet.toString() : null; } }
@Override public String getBinlogFilename() { return this.client.getBinlogFilename(); }
private void commitGtid() { if (gtid != null) { synchronized (gtidSetAccessLock) { gtidSet.add(gtid); } } }
public BinaryLogClientStatistics(BinaryLogClient binaryLogClient) { binaryLogClient.registerEventListener(this); binaryLogClient.registerLifecycleListener(this); }
public void startReplicator() throws Exception { this.client.connect(5000); replicatorStarted = true; }
BinaryLogClient createBinlogClient(String hostname, int port, String username, String password) { return new BinaryLogClient(hostname, port, username, password); }
@Override protected void beforeStop() throws Exception { this.binlogEventListener.stop(); this.client.disconnect(); }
@Override public boolean isConnected() { return this.client.isConnected(); }
public BinlogPosition getCurrentBinlogPosition() { return new BinlogPosition(client.getBinlogFilename(), client.getBinlogPosition()); } }
public GtidSet getGtidSet() { return new GtidSet(gtidSetStr); }
@Override public String getGtidSet() { return this.client.getGtidSet(); }
@Override public int hashCode() { return (int) getStart(); }
@Override public long getBinlogPosition() { return this.client.getBinlogPosition(); }
/** * Disconnect from the replication stream. * Note that this does not cause binlogFilename/binlogPosition to be cleared out. * As the result following {@link #connect()} resumes client from where it left off. */ public void disconnect() throws IOException { terminateKeepAliveThread(); terminateConnect(); }
@Override public int compareTo(Interval o) { return saturatedCast(this.start - o.start); }
private void terminateKeepAliveThread() { ExecutorService keepAliveThreadExecutor = this.keepAliveThreadExecutor; if (keepAliveThreadExecutor == null) { return; } keepAliveThreadExecutor.shutdownNow(); while (!awaitTerminationInterruptibly(keepAliveThreadExecutor, Long.MAX_VALUE, TimeUnit.NANOSECONDS)) { // ignore } }
/** * Determine if this interval is completely within the supplied interval. * @param other the interval to compare with * @return {@code true} if the {@link #getStart() start} is greater than or equal to the supplied interval's * {@link #getStart() start} and the {@link #getEnd() end} is less than or equal to the supplied * interval's {@link #getEnd() end}, or {@code false} otherwise */ public boolean isContainedWithin(Interval other) { if (other == this) { return true; } if (other == null) { return false; } return this.getStart() >= other.getStart() && this.getEnd() <= other.getEnd(); }
/** * @param gtidSet GTID set (can be an empty string). * <p>NOTE #1: Any value but null will switch BinaryLogClient into a GTID mode (this will also set binlogFilename * to "" (provided it's null) forcing MySQL to send events starting from the oldest known binlog (keep in mind * that connection will fail if gtid_purged is anything but empty (unless * {@link #setGtidSetFallbackToPurged(boolean)} is set to true))). * <p>NOTE #2: GTID set is automatically updated with each incoming GTID event (provided GTID mode is on). * @see #getGtidSet() * @see #setGtidSetFallbackToPurged(boolean) */ public void setGtidSet(String gtidSet) { if (gtidSet != null && this.binlogFilename == null) { this.binlogFilename = ""; } synchronized (gtidSetAccessLock) { this.gtidSet = gtidSet != null ? new GtidSet(gtidSet) : null; } }