com.cloudtran.replicator.link
Interface LinkProvider

All Known Implementing Classes:
AbstractLinkProvider, LoopbackProvider

public interface LinkProvider

A link to the other end must operate through two queues, representing a two-way channel. The implementer of this interface must provide these queues. The LinkProvider should preferably serialize using the serialize/deserialize methods in AbstractLinkProvider. This uses PoF and should be line efficient. [We may add a zip option on top of this later.]


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.
 String getLocalDataCentreName()
           
 String getRemoteDataCentreName()
           
 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.
 void setLink(Link link)
          Set the link to get the disconnect message
 

Method Detail

setLink

void setLink(Link link)
Set the link to get the disconnect message

Parameters:
link -

reset

void reset()
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

void connect()
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.


getLocalDataCentreName

String getLocalDataCentreName()

getRemoteDataCentreName

String getRemoteDataCentreName()

sendBytes

void sendBytes(byte[] array,
               int offset,
               int len)
               throws IOException
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

void receiveBytes(byte[] array,
                  int offset,
                  int len)
                  throws IOException
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