com.cloudtran.replicator.link
Interface LinkInitializer

All Known Implementing Classes:
AbstractLinkInitializer, LoopbackInitializer

public interface LinkInitializer

The LinkInitializer is responsible creating an array of protocol-specific LinkProviders using an array of initialization strings or InetSocketAddress's.

The architecture of the replicator is

At start of day or after a primary replicator failure, a replicator is elected (see {link ReplicatorElecter}) to be the primary.

The new primary replicator will establish a point-to-point link with the each remote data center configured. It does this by trying to connect to each machine in the config string if it is a client, or waiting for an inbound connection if it is a server. At some point, there will be primary replicators running at both ends of the link and the DC-DC connection is established. So the local elected replicator will have one point-to-point link to each remote data center, via its elected replicator.

Note that the local data center can start operations before a link is established and continue operations when the DC-DC connection is down.

The addresses for a given remote data center is given by the ct.replicator.in/outbound.remoteDcName configuration properties. In the case of an inbound (server) connection, there are no addresses specified (just the port to listen on) and a wildcard address is used. For outbound (client) connections, the addresses are specified in IP or hostname format.


Method Summary
 List<LinkProvider> initialize(boolean thisEndIsServer, String remoteDataCenterName, int port, List<InetAddress> inetAddresses)
          Same as the String form, but the initialization string is converted into a list of InetAddress's.
 List<LinkProvider> initialize(boolean thisEndIsServer, String remoteDataCenterName, int port, String[] addressStrings)
          Given an array of addressStrings, create a Link for each string, and return the array of Links.
 

Method Detail

initialize

List<LinkProvider> initialize(boolean thisEndIsServer,
                              String remoteDataCenterName,
                              int port,
                              String[] addressStrings)
Given an array of addressStrings, create a Link for each string, and return the array of Links.

The Links returned must implement the chosen protocol for the LinkProvider.

Normally, user implementations of LinkInitializer can extend {link AbstractLinkInitializer} and use its implementation of this method, leaving only the InetSocketAddress version of this initialize() to be implemented.

Parameters:
thisEndIsServer - tells the mode for this connection. thisEndIsServer means, set up a server connection on this link. Otherwise, set up a client connection.
remoteDataCenterName - the name of the remote data center, which appears in the config property after "ct.replicator.in/outbound.". For example, "ct.replicator.inbound.East=..." turns into remoteDataCenterName="East".
port - The port number to listen on (for server connections) or to connect to (for client connections).
addressStrings - the list of IP (w.x.y.z) or hostname (myserver.mycorp.com) addresses from the config string for the link, broken apart by commas (',') and trimmed (leading and trailing whitespace removed).
Returns:
This method should return if the links can be configured; otherwise, it should not proceed - it should exit the main process.

initialize

List<LinkProvider> initialize(boolean thisEndIsServer,
                              String remoteDataCenterName,
                              int port,
                              List<InetAddress> inetAddresses)
Same as the String form, but the initialization string is converted into a list of InetAddress's. The format of the string will be validated, but no connection is made by the replication framework, so the initialize() method must be prepared for the remote machine to be temporarily unavailable.

Returns:
null if the links cannot be configured.