Class BinlogConnectorReplicator

  • All Implemented Interfaces:
    com.github.shyiko.mysql.binlog.BinaryLogClient.LifecycleListener, Replicator, StoppableTask

    public class BinlogConnectorReplicator
    extends RunLoopProcess
    implements Replicator, com.github.shyiko.mysql.binlog.BinaryLogClient.LifecycleListener
    • Field Detail

      • BINLOG_QUEUE_SIZE

        public static int BINLOG_QUEUE_SIZE
      • ACCESS_DENIED_ERROR_CODE

        public static final int ACCESS_DENIED_ERROR_CODE
        See Also:
        Constant Field Values
      • client

        protected final com.github.shyiko.mysql.binlog.BinaryLogClient client
    • Method Detail

      • work

        public void work()
                  throws Exception
        get a single row from the replicator and pass it to the producer or bootstrapper. This is the top-level function in the run-loop.
        Specified by:
        work in class RunLoopProcess
        Throws:
        Exception
      • onCommunicationFailure

        public void onCommunicationFailure​(com.github.shyiko.mysql.binlog.BinaryLogClient client,
                                           Exception ex)
        Listener for communication errors so we can stop everything and exit on this case
        Specified by:
        onCommunicationFailure in interface com.github.shyiko.mysql.binlog.BinaryLogClient.LifecycleListener
        Parameters:
        ex - Exception thrown by the BinaryLogClient
      • getLastHeartbeatRead

        public Long getLastHeartbeatRead()
        Get the last heartbeat that the replicator has processed. We pass along the value of the heartbeat to the producer inside the row map.
        Specified by:
        getLastHeartbeatRead in interface Replicator
        Returns:
        the millisecond value ot the last heartbeat read
      • isMaxwellRow

        protected boolean isMaxwellRow​(RowMap row)
        Is this RowMap an update to one of maxwell's own tables? We don't output updates to maxwell.positions, and updates to maxwell.heartbeats are always treated specially.
        Parameters:
        row - The RowMap in question
        Returns:
        whether the update is something maxwell itself generated
      • getRow

        public RowMap getRow()
                      throws Exception
        The main entry point into the event reading loop.

        We maintain a buffer of events in a transaction, and each subsequent call to `getRow` can grab one from the buffer. If that buffer is empty, we'll go check the open-replicator buffer for rows to process. If that buffer is empty, we return null.

        Specified by:
        getRow in interface Replicator
        Returns:
        either a RowMap or null
        Throws:
        Exception
      • onConnect

        public void onConnect​(com.github.shyiko.mysql.binlog.BinaryLogClient client)
        Specified by:
        onConnect in interface com.github.shyiko.mysql.binlog.BinaryLogClient.LifecycleListener
      • onEventDeserializationFailure

        public void onEventDeserializationFailure​(com.github.shyiko.mysql.binlog.BinaryLogClient client,
                                                  Exception ex)
        Specified by:
        onEventDeserializationFailure in interface com.github.shyiko.mysql.binlog.BinaryLogClient.LifecycleListener
      • onDisconnect

        public void onDisconnect​(com.github.shyiko.mysql.binlog.BinaryLogClient client)
        Specified by:
        onDisconnect in interface com.github.shyiko.mysql.binlog.BinaryLogClient.LifecycleListener