| Modifier and Type | Class and Description |
|---|---|
| private class | ReplicationMessageReceive.
Thread that sends ping messages to the master on request to check if the replication network is working |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | connectionConfirmed
Whether or not the connection with the master is confirmed to be working. |
| private static final int | DEFAULT_PING_TIMEOUT
The maximum number of millis to wait before giving up waiting for a ping response |
| private boolean | doSendPing
Whether or not the ping thread has been notified to check connection. |
| private boolean | killPingThread
Used to terminate the ping thread. |
| private Thread | pingThread
Thread used to send ping messages to master to check if the connection is working. |
| private final Object | receivePongSemaphore
Used for synchronization when waiting for a ping reply message |
| private final Object | sendPingSemaphore
Used for synchronization of the ping thread |
| private ServerSocket | serverSocket
Contains the |
| private final SlaveAddress | slaveAddress
Contains the address (hostname and port number) of the slave to replicate to. |
| private SocketConnection | socketConn
Contains the methods used to read and write to the Object streams
obtained from a |
| Access | Constructor and Description |
|---|---|
| public | ReplicationMessageReceive(SlaveAddress
the address (host name and port number) of the slave
to connect to. slaveAddress, String the name of the database. dbname)Constructor initializes the slave address used in replication. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private ServerSocket | Returns: an instance of theServerSocket class.Used to create a |
| private void | handleUnexpectedMessage(String
the name of the replicated database dbname, String the expected message type expextedMsgId, String the received message type receivedMsgId)Notify other replication peer that the message type was unexpected and throw a StandardException |
| public void | initConnection(int
The amount of time, in milliseconds, this method
will wait for a connection to be established. If no connection
has been established before the timeout, a
IOException is raised with cause
java.net.SocketTimeoutException timeout, long the slave log instant, used to check that
the master and slave log files are in synch. If no chunks of log
records have been received from the master yet, this is the
end position in the current log file. If a chunk of log has been
received, this is the instant of the log record received last.
Note that there is a difference! synchOnInstant, String the name of the replicated database dbname)Used to create the server socket, listen on the socket for connections from the master and verify compatibility with the database version of the master. |
| public synchronized boolean | Returns: true if the pong message was received before timing out after DEFAULT_PING_TIMEOUT millis, false otherwiseCheck if the repliation network is working. |
| private void | parseAndAckInstant(ReplicationMessage
the object containing the UID. initiatorMessage, long the slave log instant, used to check that
the master and slave log files are in synch. If no chunks of log
records have been received from the master yet, this is the
end position in the current log file. If a chunk of log has been
received, this is the instant of the log record received last.
Note that there is a difference! synchOnInstant, String the name of the replicated database dbname)Used to parse the log instant initiator message from the master and check that the master and slave log files are in synch. |
| private void | parseAndAckVersion(ReplicationMessage
the object containing the UID. initiatorMessage, String the name of the replicated database dbname)Used to parse the initiator message from the master and check if the
slave is compatible with the master by comparing the UID of the
|
| public ReplicationMessage | Returns: aReplicationMessage object that contains
the reply that is sent.Used to read a replication message sent by the master. |
| public void | sendMessage(ReplicationMessage
a message)ReplicationMessage object that contains
the message to be transmitted.Used to send a replication message to the master. |
| public void |
| connectionConfirmed | back to summary |
|---|---|
| private boolean connectionConfirmed Whether or not the connection with the master is confirmed to be working. Set to false by isConnectedToMaster, set to true when a pong (i.e., a response to a ping) is received. Field protected by receivePongSemephore | |
| DEFAULT_PING_TIMEOUT | back to summary |
|---|---|
| private static final int DEFAULT_PING_TIMEOUT The maximum number of millis to wait before giving up waiting for a ping response | |
| doSendPing | back to summary |
|---|---|
| private boolean doSendPing Whether or not the ping thread has been notified to check connection. Protected by sendPingSemaphore. | |
| killPingThread | back to summary |
|---|---|
| private boolean killPingThread Used to terminate the ping thread. | |
| pingThread | back to summary |
|---|---|
| private Thread pingThread Thread used to send ping messages to master to check if the connection is working. The ping message must be sent from a separate thread because failed message shipping over TCP does not timeout for two minutes (not configurable). | |
| receivePongSemaphore | back to summary |
|---|---|
| private final Object receivePongSemaphore Used for synchronization when waiting for a ping reply message | |
| sendPingSemaphore | back to summary |
|---|---|
| private final Object sendPingSemaphore Used for synchronization of the ping thread | |
| serverSocket | back to summary |
|---|---|
| private ServerSocket serverSocket Contains the | |
| slaveAddress | back to summary |
|---|---|
| private final SlaveAddress slaveAddress Contains the address (hostname and port number) of the slave to replicate to. | |
| socketConn | back to summary |
|---|---|
| private SocketConnection socketConn Contains the methods used to read and write to the Object streams
obtained from a | |
| ReplicationMessageReceive | back to summary |
|---|---|
| public ReplicationMessageReceive(SlaveAddress slaveAddress, String dbname) Constructor initializes the slave address used in replication. Accepts the host name and port number that constitute the slave address as parameters.
| |
| checkSocketConnection | back to summary |
|---|---|
| private void checkSocketConnection() throws IOException Verifies if the
| |
| createServerSocket | back to summary |
|---|---|
| private ServerSocket createServerSocket() throws IOException Used to create a
| |
| handleUnexpectedMessage | back to summary |
|---|---|
| private void handleUnexpectedMessage(String dbname, String expextedMsgId, String receivedMsgId) throws StandardException, IOException Notify other replication peer that the message type was unexpected and throw a StandardException
| |
| initConnection | back to summary |
|---|---|
| public void initConnection(int timeout, long synchOnInstant, String dbname) throws IOException, StandardException, ClassNotFoundException Used to create the server socket, listen on the socket for connections from the master and verify compatibility with the database version of the master.
| |
| isConnectedToMaster | back to summary |
|---|---|
| public synchronized boolean isConnectedToMaster() Check if the repliation network is working. Tries to send a ping message to the master and returns the network status based on the success or failure of sending this message and receiving a pong reply. MT: Currently, only one thread is allowed to check the network status at any time to keep the code complexity down.
| |
| parseAndAckInstant | back to summary |
|---|---|
| private void parseAndAckInstant(ReplicationMessage initiatorMessage, long synchOnInstant, String dbname) throws IOException, StandardException Used to parse the log instant initiator message from the master and check that the master and slave log files are in synch.
| |
| parseAndAckVersion | back to summary |
|---|---|
| private void parseAndAckVersion(ReplicationMessage initiatorMessage, String dbname) throws IOException, StandardException Used to parse the initiator message from the master and check if the
slave is compatible with the master by comparing the UID of the
| |
| readMessage | back to summary |
|---|---|
| public ReplicationMessage readMessage() throws ClassNotFoundException, IOException Used to read a replication message sent by the master. This method would wait on the connection from the master until a message is received or a connection failure occurs. Replication network layer specific messages (i.e. ping/pong messages) are handled internally and are not returned.
| |
| sendMessage | back to summary |
|---|---|
| public void sendMessage(ReplicationMessage message) throws IOException Used to send a replication message to the master.
| |
| tearDown | back to summary |
|---|---|
| public void tearDown() throws IOException Used to close the
| |
| Modifier and Type | Field and Description |
|---|---|
| private final ReplicationMessage |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | run()
Overrides java. Implements java. This method is run by the thread when it executes. |
| pingMsg | back to summary |
|---|---|
| private final ReplicationMessage pingMsg | |
| SlavePingThread | back to summary |
|---|---|
| pack-priv SlavePingThread(String dbname) | |
| run | back to summary |
|---|---|
| public void run() Overrides java. Implements java. Doc from java. This method is run by the thread when it executes. Subclasses of This method is not intended to be invoked directly. If this thread is a
platform thread created with a | |