| | |
| | | |
| | | /** |
| | | * This class Implement a protocol session using a basic socket and relying on |
| | | * the innate encoding/decoding capabilities of the ReplicationMessage |
| | | * the innate encoding/decoding capabilities of the ReplicationMsg |
| | | * by using the getBytes() and generateMsg() methods of those classes. |
| | | */ |
| | | public class SocketSession implements ProtocolSession |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public synchronized void publish(ReplicationMessage msg) |
| | | public synchronized void publish(ReplicationMsg msg) |
| | | throws IOException |
| | | { |
| | | byte[] buffer = msg.getBytes(); |
| | | publish(msg, ProtocolVersion.getCurrentVersion()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public synchronized void publish(ReplicationMsg msg, short reqProtocolVersion) |
| | | throws IOException |
| | | { |
| | | byte[] buffer = msg.getBytes(reqProtocolVersion); |
| | | String str = String.format("%08x", buffer.length); |
| | | |
| | | if (debugEnabled()) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ReplicationMessage receive() throws IOException, |
| | | ClassNotFoundException, DataFormatException |
| | | public ReplicationMsg receive() throws IOException, |
| | | ClassNotFoundException, DataFormatException, |
| | | NotSupportedOldVersionPDUException |
| | | { |
| | | /* Read the first 8 bytes containing the packet length */ |
| | | int length = 0; |
| | |
| | | /* We do not want the heartbeat to close the session when */ |
| | | /* we are processing a message even a time consuming one. */ |
| | | lastReceiveTime=0; |
| | | return ReplicationMessage.generateMsg(buffer); |
| | | return ReplicationMsg.generateMsg(buffer); |
| | | } |
| | | catch (OutOfMemoryError e) |
| | | { |