Class MaxwellContext


  • public class MaxwellContext
    extends Object
    Class containing runtime state
    • Field Detail

      • metricRegistry

        public com.codahale.metrics.MetricRegistry metricRegistry
        Contains various Maxwell metrics
      • healthCheckRegistry

        public com.codahale.metrics.health.HealthCheckRegistry healthCheckRegistry
        Contains Maxwell health checks
    • Method Detail

      • getConfig

        public MaxwellConfig getConfig()
        Get Maxwell configuration used in this context
        Returns:
        the Maxwell configuration
      • getReplicationConnection

        public Connection getReplicationConnection()
                                            throws SQLException
        Get the a connection from the replication pool
        Returns:
        a connection to the replication pool
        Throws:
        SQLException - if we can't connect
      • getReplicationConnectionPool

        public ConnectionPool getReplicationConnectionPool()
        Get the replication pool
        Returns:
        the replication (connection to replicate from) connection pool
      • getMaxwellConnectionPool

        public ConnectionPool getMaxwellConnectionPool()
        Get a connection from the maxwell (metadata) pool
        Returns:
        the maxwell (connection to store metadata in) connection pool
      • getSchemaConnectionPool

        public ConnectionPool getSchemaConnectionPool()
        Get a connection from the schema pool
        Returns:
        the schema (connection to capture from) connection pool
      • getMaxwellConnection

        public Connection getMaxwellConnection()
                                        throws SQLException
        get a connection from the maxwell pool
        Returns:
        a connection from the maxwell pool
        Throws:
        SQLException - if we can't connect
      • getRawMaxwellConnection

        public Connection getRawMaxwellConnection()
                                           throws SQLException
        get a database-less connection from the maxwell pool Used to create the maxwell schema.
        Returns:
        a connection to the maxwell pool, without a database name specific
        Throws:
        SQLException - if we can't connect
      • start

        public void start()
                   throws IOException
        Start the HTTP server and position store thread
        Throws:
        IOException - if the HTTP server can't be started
      • heartbeat

        public long heartbeat()
                       throws Exception
        Manually trigger a heartbeat to be sent
        Returns:
        Timestamp of the heartbeeat
        Throws:
        Exception - If we can't send a heartbeat
      • addTask

        public void addTask​(StoppableTask task)
        Add a task (usually a thread) that will be stopped upon shutdown
        Parameters:
        task - The task
      • terminate

        public Thread terminate​(Exception error)
        Begin the Maxwell shutdown process
        Parameters:
        error - An exception that caused the shutdown, or null
        Returns:
        A thread that will complete shutdown.
        See Also:
        terminate()
      • getError

        public Exception getError()
        Get the Exception that triggered shutdown
        Returns:
        An error that caused maxwell to shutdown
      • getPositionStoreThread

        public PositionStoreThread getPositionStoreThread()
        Get or spawn a thread that persists the current position into the metadata database.
        Returns:
        Position store thread
      • getInitialPosition

        public Position getInitialPosition()
                                    throws SQLException
        Retrieve Maxwell's starting position from the metadata database
        Returns:
        The initial binlog position
        Throws:
        SQLException - If the position can't be retrieved from the database
      • setPosition

        public void setPosition​(RowMap r)
        If the passed RowMap is a transaction-commit, update maxwell's position
        Parameters:
        r - A processed Rowmap
      • setPosition

        public void setPosition​(Position position)
        Set Maxwell's next binlog position
        Parameters:
        position - The new position
      • getPosition

        public Position getPosition()
                             throws SQLException
        Get the last stored binlog position
        Returns:
        The last binlog position set
        Throws:
        SQLException - If we have database issues
      • getPositionStore

        public MysqlPositionStore getPositionStore()
        Get the position store service object
        Returns:
        The mysql position store
      • getServerID

        public Long getServerID()
                         throws SQLException
        Get the replication connection's server id
        Returns:
        a server id
        Throws:
        SQLException - if we have connection issues
      • getMysqlVersion

        public MysqlVersion getMysqlVersion()
                                     throws SQLException
        Get the replication connection's mysql version
        Returns:
        The mysql version
        Throws:
        SQLException - if we have connection issues
      • getCaseSensitivity

        public CaseSensitivity getCaseSensitivity()
                                           throws SQLException
        Get the replication connection's case sensitivity settings
        Returns:
        case sensitivity settings
        Throws:
        SQLException - if we have connection issues
      • runBootstrapNow

        public void runBootstrapNow()
        only used in test code. interrupt the bootstrap thread to quicken tests.
      • getFilter

        public Filter getFilter()
        get the current active filter
        Returns:
        the currently active Filter
      • getReplayMode

        public boolean getReplayMode()
        Get the replayMode flag
        Returns:
        whether we are in "replay mode" (--replay)
      • setReplicator

        public void setReplicator​(Replicator replicator)
        Set the current binlog replicator
        Parameters:
        replicator - the replicator
      • getMetrics

        public Metrics getMetrics()
        Get the current metrics registry
        Returns:
        the current metrics registry
      • getHeartbeatNotifier

        public HeartbeatNotifier getHeartbeatNotifier()
        Get the heartbeat notifier object, which can be asked to broadcast heartbeats
        Returns:
        a heartbeat notifier
      • getDiagnosticContext

        public MaxwellDiagnosticContext getDiagnosticContext()
        Get the context for maxwell diagnostics
        Returns:
        the maxwell diagnostic context
      • isMariaDB

        public boolean isMariaDB()
        Is the replication host running MariaDB?
        Returns:
        mariadbornot