com.cloudtran.replicator.link.rabbitmq
Class RmqLinkProvider

java.lang.Object
  extended by com.cloudtran.replicator.link.AbstractLinkProvider
      extended by com.cloudtran.replicator.link.rabbitmq.RmqLinkProvider
All Implemented Interfaces:
LinkProvider

public class RmqLinkProvider
extends AbstractLinkProvider

A link to the other end must operate through four queues, representing two two-way channels. The implemented of this interface must provide these queues.


Constructor Summary
RmqLinkProvider()
           
 
Method Summary
 void connect()
          This call is issued at start of day or after a crash on the other side causes our link to go down.
 void disconnect()
           
 void receiveBytes(byte[] array, int offset, int len)
          The receiveBytes method reads 'len' bytes into a byte array starting at the specified offset.
 void reset()
          This method resets the link, i.e.
 void sendBytes(byte[] array, int offset, int len)
          The sendBytes method writes out from a byte array.
 
Methods inherited from class com.cloudtran.replicator.link.AbstractLinkProvider
deserialize, getLocalDataCentreName, getRemoteDataCentreName, serialize, setLink, signalL2Connected, test
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RmqLinkProvider

public RmqLinkProvider()
Method Detail

disconnect

public void disconnect()

reset

public void reset()
Description copied from interface: LinkProvider
This method resets the link, i.e. disconnects. It is issued at start of day, when the link is signalled down, when another Link in the DcConnection connects, or after a crash on the other side. ... Or when the connection is reopened, so it needs to handle redundant calls. This method is called from the DCConnection; it shouldn't be called by the LinkProvider implementer.


connect

public void connect()
Description copied from interface: LinkProvider
This call is issued at start of day or after a crash on the other side causes our link to go down. This is executed synchronously by the DCConnection. The LinkProvider should normally poll the connection on an asynchronous thread, because the connection establishment at one end must wait for the other data center to start. When the link is connected, the provider signals back to the link's signalL2Connected() method, which the sends 'prod_L2UP' into the DCconnection FSM.


sendBytes

public void sendBytes(byte[] array,
                      int offset,
                      int len)
               throws IOException
Description copied from interface: LinkProvider
The sendBytes method writes out from a byte array. It must be thread-safe: if necessary, add 'synchronized' on the implementation If the link is down or there is a problem with the underlying connection, the IOException is thrown. The caller should call FSM(prod_L2Down) to reset the link and the FSM. (This method cannot do that itself, because it may be called inside an FSM action itself and would deadlock on the FSM synchronization.)

Throws:
IOException

receiveBytes

public void receiveBytes(byte[] array,
                         int offset,
                         int len)
                  throws IOException
Description copied from interface: LinkProvider
The receiveBytes method reads 'len' bytes into a byte array starting at the specified offset. The caller is responsible for ensuring that the expected number of bytes will be read (e.g. by having a preceding length value). It must be thread-safe: if necessary, add 'synchronized' on the implementation If the link is down or there is a problem with the underlying connection, the IOException is thrown. The caller should call FSM(prod_L2Down) to reset the link and the FSM. (This method cannot do that itself, because it may be called inside an FSM action itself and would deadlock on the FSM synchronization.)

Throws:
IOException