|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.store.replication.net.ReplicationMessageTransmit
public class ReplicationMessageTransmit
Used to send replication messages to the slave. Called by the
Master controller to transmit replication messages wrapped in
a ReplicationMessage
object to a receiver. The
receiver is implemented by the ReplicationMessageReceive
class.
Nested Class Summary | |
---|---|
private class |
ReplicationMessageTransmit.MasterReceiverThread
Thread that listens for messages from the slave. |
Field Summary | |
---|---|
private java.lang.String |
dbname
The name of the replicated database |
private int |
DEFAULT_MESSAGE_RESPONSE_TIMEOUT
Number of millis to wait for a response message before timing out |
private java.lang.Thread |
msgReceiver
The thread that listens for messages from the slave |
private ReplicationMessage |
receivedMsg
The message received from the slave as a response to sending a message. |
private java.lang.Object |
receiveSemaphore
Used to synchronize when waiting for a response message from the slave |
private SlaveAddress |
slaveAddress
Contains the address (hostname and port number) of the slave to replicate to. |
private SocketConnection |
socketConn
Used to write/read message objects to/from a connection. |
private boolean |
stopMessageReceiver
Whether or not to keep the message receiver thread alive. |
Constructor Summary | |
---|---|
ReplicationMessageTransmit(SlaveAddress slaveAddress)
Constructor initializes the slave address used in replication. |
Method Summary | |
---|---|
private void |
brokerConnection(long synchOnInstant)
Used to send initiator messages to the slave and receive information about the compatibility of the slave with the master. |
private void |
checkSocketConnection()
Verifies if the SocketConnection is valid. |
void |
initConnection(int timeout,
long synchOnInstant)
Used to create a Socket connection to the slave and
establish compatibility with the database version of the slave by
comparing the UID's of the ReplicationMessage classes
of the master and the slave. |
void |
sendMessage(ReplicationMessage message)
Used to send a replication message to the slave. |
ReplicationMessage |
sendMessageWaitForReply(ReplicationMessage message)
Send a replication message to the slave and return the message received as a response. |
private void |
startMessageReceiverThread(java.lang.String dbname)
|
void |
tearDown()
Tear down the network connection established with the other replication peer |
private boolean |
verifyMessageType(ReplicationMessage message,
int expectedType)
Used to parse a message received from the slave. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final int DEFAULT_MESSAGE_RESPONSE_TIMEOUT
private java.lang.Thread msgReceiver
private final java.lang.Object receiveSemaphore
private ReplicationMessage receivedMsg
private volatile boolean stopMessageReceiver
private final SlaveAddress slaveAddress
private SocketConnection socketConn
private java.lang.String dbname
Constructor Detail |
---|
public ReplicationMessageTransmit(SlaveAddress slaveAddress)
slaveAddress
- contains the address (host name and port number)
of the slave to connect to.Method Detail |
---|
public void initConnection(int timeout, long synchOnInstant) throws java.security.PrivilegedActionException, java.io.IOException, StandardException, java.lang.ClassNotFoundException
Socket
connection to the slave and
establish compatibility with the database version of the slave by
comparing the UID's of the ReplicationMessage
classes
of the master and the slave.
timeout
- the amount of time for which the connection should
block before being established.synchOnInstant
- the master log instant, used to check
that the master and slave log files are in synch. If no chunks
of log records have been shipped to the slave yet, this is the
end position in the current log file. If a chunk of log has
been shipped, this is the instant of the log record shipped
last. Note that there is a difference!
java.security.PrivilegedActionException
- if an exception occurs while trying
to open a connection.
java.io.IOException
- if an exception occurs while trying to create the
SocketConnection
class.
StandardException
- If an error message is received from the
server indicating incompatible software versions of master
and slave.
java.lang.ClassNotFoundException
- Class of a serialized object cannot
be found.public void tearDown() throws java.io.IOException
java.io.IOException
- if an exception occurs while trying to tear
down the network connectionpublic void sendMessage(ReplicationMessage message) throws java.io.IOException
message
- a ReplicationMessage
object that contains
the message to be transmitted.
java.io.IOException
- 1) if an exception occurs while transmitting
the message.
2) if the connection handle is invalid.public ReplicationMessage sendMessageWaitForReply(ReplicationMessage message) throws java.io.IOException, StandardException
message
- a ReplicationMessage object that contains the message to
be transmitted.
java.io.IOException
- 1) if an exception occurs while sending or receiving
a message.
2) if the connection handle is invalid.
StandardException
- if the response message has not been received
after DEFAULT_MESSAGE_RESPONSE_TIMEOUT millisprivate void brokerConnection(long synchOnInstant) throws java.io.IOException, StandardException, java.lang.ClassNotFoundException
synchOnInstant
- the master log instant, used to check
that the master and slave log files are in synch. If no chunks
of log records have been shipped to the slave yet, this is the
end position in the current log file. If a chunk of log has
been shipped, this is the instant of the log record shipped
last. Note that there is a difference!
java.io.IOException
- if an exception occurs during the sending or
reading of the message.
StandardException
- If an error message is received from the
server indicating a mis-match in
serialVersionUID or log files out of synch.
java.lang.ClassNotFoundException
- Class of a serialized object cannot
be found.private boolean verifyMessageType(ReplicationMessage message, int expectedType) throws StandardException
StandardException
- If an error message is received from
the server
java.lang.ClassNotFoundException
- Class of a serialized object cannot
be found.private void checkSocketConnection() throws java.io.IOException
SocketConnection
is valid.
java.io.IOException
- If the socket connection object is not
valid (is null).private void startMessageReceiverThread(java.lang.String dbname)
|
Built on Thu 2011-03-10 11:54:14+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |