|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.github.shyiko.mysql.binlog.BinaryLogClient
public class BinaryLogClient
MySQL replication stream client.
Nested Class Summary | |
---|---|
static class |
BinaryLogClient.AbstractLifecycleListener
Default (no-op) implementation of BinaryLogClient.LifecycleListener . |
static interface |
BinaryLogClient.EventListener
BinaryLogClient 's event listener. |
static interface |
BinaryLogClient.LifecycleListener
BinaryLogClient 's lifecycle listener. |
Constructor Summary | |
---|---|
BinaryLogClient(String hostname,
int port,
String username,
String password)
Alias for BinaryLogClient(hostname, port, <no schema> = null, username, password). |
|
BinaryLogClient(String hostname,
int port,
String schema,
String username,
String password)
|
|
BinaryLogClient(String username,
String password)
Alias for BinaryLogClient("localhost", 3306, <no schema> = null, username, password). |
|
BinaryLogClient(String schema,
String username,
String password)
Alias for BinaryLogClient("localhost", 3306, schema, username, password). |
Method Summary | |
---|---|
void |
connect()
Connect to the replication stream. |
void |
connect(long timeoutInMilliseconds)
Connect to the replication stream in a separate thread. |
void |
disconnect()
Disconnect from the replication stream. |
String |
getBinlogFilename()
|
long |
getBinlogPosition()
|
List<BinaryLogClient.EventListener> |
getEventListeners()
|
String |
getGtidSet()
|
long |
getKeepAliveConnectTimeout()
|
long |
getKeepAliveInterval()
|
List<BinaryLogClient.LifecycleListener> |
getLifecycleListeners()
|
long |
getServerId()
|
boolean |
isConnected()
|
boolean |
isKeepAlive()
|
void |
registerEventListener(BinaryLogClient.EventListener eventListener)
Register event listener. |
void |
registerLifecycleListener(BinaryLogClient.LifecycleListener lifecycleListener)
Register lifecycle listener. |
void |
setBinlogFilename(String binlogFilename)
|
void |
setBinlogPosition(long binlogPosition)
|
void |
setEventDeserializer(EventDeserializer eventDeserializer)
|
void |
setGtidSet(String gtidSet)
|
void |
setKeepAlive(boolean keepAlive)
|
void |
setKeepAliveConnectTimeout(long keepAliveConnectTimeout)
|
void |
setKeepAliveInterval(long keepAliveInterval)
|
void |
setServerId(long serverId)
|
void |
setSocketFactory(SocketFactory socketFactory)
|
void |
setThreadFactory(ThreadFactory threadFactory)
|
void |
unregisterEventListener(BinaryLogClient.EventListener eventListener)
Unregister single event listener. |
void |
unregisterEventListener(Class<? extends BinaryLogClient.EventListener> listenerClass)
Unregister all event listener of specific type. |
void |
unregisterLifecycleListener(BinaryLogClient.LifecycleListener eventListener)
Unregister single lifecycle listener. |
void |
unregisterLifecycleListener(Class<? extends BinaryLogClient.LifecycleListener> listenerClass)
Unregister all lifecycle listener of specific type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BinaryLogClient(String username, String password)
BinaryLogClient(String, int, String, String, String)
public BinaryLogClient(String schema, String username, String password)
BinaryLogClient(String, int, String, String, String)
public BinaryLogClient(String hostname, int port, String username, String password)
BinaryLogClient(String, int, String, String, String)
public BinaryLogClient(String hostname, int port, String schema, String username, String password)
hostname
- mysql server hostnameport
- mysql server portschema
- database name, nullable. Note that this parameter has nothing to do with event filtering. It's
used only during the authentication.username
- login namepassword
- passwordMethod Detail |
---|
public long getServerId()
setServerId(long)
public void setServerId(long serverId)
serverId
- server id (in the range from 1 to 2^32 - 1). This value MUST be unique across whole replication
group (that is, different from any other server id being used by any master or slave). Keep in mind that each
binary log client (mysql-binlog-connector-java/BinaryLogClient, mysqlbinlog, etc) should be treated as a
simplified slave and thus MUST also use a different server id.getServerId()
public String getBinlogFilename()
getBinlogFilename
in interface BinaryLogClientMXBean
EventType.ROTATE
, for example).setBinlogFilename(String)
public void setBinlogFilename(String binlogFilename)
setBinlogFilename
in interface BinaryLogClientMXBean
binlogFilename
- binary log filename.
Special values are:
getBinlogFilename()
public long getBinlogPosition()
getBinlogPosition
in interface BinaryLogClientMXBean
setBinlogPosition(long)
public void setBinlogPosition(long binlogPosition)
setBinlogPosition
in interface BinaryLogClientMXBean
binlogPosition
- binary log position. Any value less than 4 gets automatically adjusted to 4 on connect.getBinlogPosition()
public String getGtidSet()
setGtidSet(String)
public void setGtidSet(String gtidSet)
gtidSet
- GTID set (can be an empty string).
NOTE #1: Any value but null will switch BinaryLogClient into a GTID mode (in which case GTID set will be updated with each incoming GTID event) as well as set binlogFilename to "" (empty string) (meaning BinaryLogClient will request events "outside of the set" starting from the oldest known binlog).
NOTE #2: setBinlogFilename(String)
and setBinlogPosition(long)
can be used to specify the
exact position from which MySQL server should start streaming events (taking into account GTID set).
getGtidSet()
public boolean isKeepAlive()
setKeepAlive(boolean)
public void setKeepAlive(boolean keepAlive)
keepAlive
- true if "keep alive" thread should be automatically started (recommended and true by default),
false otherwise.isKeepAlive()
public long getKeepAliveInterval()
setKeepAliveInterval(long)
public void setKeepAliveInterval(long keepAliveInterval)
keepAliveInterval
- "keep alive" interval in milliseconds.getKeepAliveInterval()
public long getKeepAliveConnectTimeout()
setKeepAliveConnectTimeout(long)
public void setKeepAliveConnectTimeout(long keepAliveConnectTimeout)
keepAliveConnectTimeout
- "keep alive" connect timeout in milliseconds.getKeepAliveConnectTimeout()
public void setEventDeserializer(EventDeserializer eventDeserializer)
eventDeserializer
- custom event deserializerpublic void setSocketFactory(SocketFactory socketFactory)
socketFactory
- custom socket factory. If not provided, socket will be created with "new Socket()".public void setThreadFactory(ThreadFactory threadFactory)
threadFactory
- custom thread factory. If not provided, threads will be created using simple "new Thread()".public void connect() throws IOException
AuthenticationException
- if authentication fails
ServerException
- if MySQL server responds with an error
IOException
- if anything goes wrong while trying to connectpublic void connect(long timeoutInMilliseconds) throws IOException, TimeoutException
connect
in interface BinaryLogClientMXBean
timeoutInMilliseconds
- timeout in milliseconds
AuthenticationException
- if authentication fails
ServerException
- if MySQL server responds with an error
IOException
- if anything goes wrong while trying to connect
TimeoutException
- if client was unable to connect within given time limitpublic boolean isConnected()
isConnected
in interface BinaryLogClientMXBean
public List<BinaryLogClient.EventListener> getEventListeners()
public void registerEventListener(BinaryLogClient.EventListener eventListener)
public void unregisterEventListener(Class<? extends BinaryLogClient.EventListener> listenerClass)
public void unregisterEventListener(BinaryLogClient.EventListener eventListener)
public List<BinaryLogClient.LifecycleListener> getLifecycleListeners()
public void registerLifecycleListener(BinaryLogClient.LifecycleListener lifecycleListener)
public void unregisterLifecycleListener(Class<? extends BinaryLogClient.LifecycleListener> listenerClass)
public void unregisterLifecycleListener(BinaryLogClient.LifecycleListener eventListener)
public void disconnect() throws IOException
connect()
resumes client from where it left off.
disconnect
in interface BinaryLogClientMXBean
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |