com.continuent.tungsten.replicator.management
Interface OpenReplicatorPlugin

All Known Implementing Classes:
ScriptPlugin, TungstenPlugin

public interface OpenReplicatorPlugin

Replicator management plug-in definition. This interface defines basic functions of a plug-in service that manages the overall replication service. OpenReplicatorPlugin instances have the following life-cycle:

  1. Instantiate from class name
  2. Call setters on plug-in instance to load values from global property file
  3. Call prepare() to set event dispatcher and allocate resources used by instance
  4. (Calls to administrative methods)
  5. Call release() to free resources
The default implementation of this interface controls the Tungsten native replicator.

NOTE:This interface should not be confused with the TungstenPlugin interface, which is a plugin within the native Tungsten replicator.

Version:
1.0
Author:
Robert Hodges
See Also:
ReplicatorPlugin, TungstenPlugin

Field Summary
static java.lang.String STATUS_APPLIED_LATENCY
          Latency in seconds between sent and applied events.
static java.lang.String STATUS_ERRMSG
          Current error message containing last error from replicator.
static java.lang.String STATUS_LAST_APPLIED
          ID of last replication event applied.
static java.lang.String STATUS_LAST_RECEIVED
          ID of last replication event received.
static java.lang.String STATUS_LAST_SENT
          ID of last replication event sent.
static java.lang.String STATUS_ROLE
          Current replication role, such as master, slave, or standby.
 
Method Summary
 void configure(TungstenProperties properties)
          Read configuration data and configure replication behavior appropriately.
 int consistencyCheck(java.lang.String method, java.lang.String schemaName, java.lang.String tableName, int rowOffset, int rowLimit)
          Initiates consistency check transaction on a given table.
 java.lang.String flush(long timeout)
          Implements a flush operation to synchronize the state of the database with the replication log and return a comparable event ID that can be used in a wait operation on a slave.
 ReplicatorCapabilities getCapabilities()
          gets the capabilties for the replicator
 ReplicatorRuntime getReplicatorRuntime()
           
 boolean heartbeat(TungstenProperties params)
          Inserts a heartbeat event into the transaction history.
 void offline(TungstenProperties params)
          Puts the replicator into the offline state, which turns off replication.
 void offlineDeferred(TungstenProperties params)
          Issues a request to go offline at a later point in replication.
 void online(TungstenProperties params)
          Puts the replicator into the online state, which turns on replication.
 void prepare(OpenReplicatorContext context)
          Prepare plug-in for use.
 void provision(java.lang.String uri)
          Performs a provision operation.
 int purge(TungstenProperties params)
          Kill logins other than the connection(s) used for replication.
 void release()
          Release all resources used by plug-in.
 void setRole(java.lang.String role, java.lang.String uri)
          Sets the replicator role.
 java.util.HashMap<java.lang.String,java.lang.String> status()
          Returns the current replicator status as a set of name-value pairs.
 java.util.List<java.util.Map<java.lang.String,java.lang.String>> statusList(java.lang.String name)
          Returns a list of status instances for a particular list of items.
 boolean waitForAppliedEvent(java.lang.String event, long timeout)
          Wait for a particular event to be applied on the slave.
 

Field Detail

STATUS_ROLE

static final java.lang.String STATUS_ROLE
Current replication role, such as master, slave, or standby.

See Also:
Constant Field Values

STATUS_ERRMSG

static final java.lang.String STATUS_ERRMSG
Current error message containing last error from replicator.

See Also:
Constant Field Values

STATUS_LAST_SENT

static final java.lang.String STATUS_LAST_SENT
ID of last replication event sent.

See Also:
Constant Field Values

STATUS_LAST_APPLIED

static final java.lang.String STATUS_LAST_APPLIED
ID of last replication event applied.

See Also:
Constant Field Values

STATUS_LAST_RECEIVED

static final java.lang.String STATUS_LAST_RECEIVED
ID of last replication event received.

See Also:
Constant Field Values

STATUS_APPLIED_LATENCY

static final java.lang.String STATUS_APPLIED_LATENCY
Latency in seconds between sent and applied events.

See Also:
Constant Field Values
Method Detail

prepare

void prepare(OpenReplicatorContext context)
             throws ReplicatorException
Prepare plug-in for use. It is invoked once after setters have been invoke but before the plug-in performs any operations and after

Parameters:
context - Context with access to replicator service resources
Throws:
ReplicatorException - Thrown if resource allocation fails

release

void release()
             throws ReplicatorException
Release all resources used by plug-in. This is called before the plug-in is deallocated.

Throws:
ReplicatorException - Thrown if resource deallocation fails

configure

void configure(TungstenProperties properties)
               throws ReplicatorException
Read configuration data and configure replication behavior appropriately. This may be called multiple times to process configuration data.

Throws:
ReplicatorException - Thrown if configuration is incomplete or fails

online

void online(TungstenProperties params)
            throws java.lang.Exception
Puts the replicator into the online state, which turns on replication.

Parameters:
params - Plugin-specific name-value pairs that alter online operation
Throws:
java.lang.Exception

offline

void offline(TungstenProperties params)
             throws java.lang.Exception
Puts the replicator into the offline state, which turns off replication.

Throws:
java.lang.Exception

offlineDeferred

void offlineDeferred(TungstenProperties params)
                     throws java.lang.Exception
Issues a request to go offline at a later point in replication. Not all plug-ins support deferred offline behavior.

Throws:
java.lang.Exception

heartbeat

boolean heartbeat(TungstenProperties params)
                  throws java.lang.Exception
Inserts a heartbeat event into the transaction history. The replicator plugin must be in the MASTER state for this call to be successful.

Returns:
true if the heartbeat is inserted.
Throws:
java.lang.Exception

flush

java.lang.String flush(long timeout)
                       throws java.lang.Exception
Implements a flush operation to synchronize the state of the database with the replication log and return a comparable event ID that can be used in a wait operation on a slave.

Parameters:
timeout - Number of seconds to wait. 0 is indefinite.
Returns:
The event ID at which the log is synchronized
Throws:
java.lang.Exception

waitForAppliedEvent

boolean waitForAppliedEvent(java.lang.String event,
                            long timeout)
                            throws java.lang.Exception
Wait for a particular event to be applied on the slave.

Parameters:
event - Event to wait for
timeout - Number of seconds to wait. 0 is indefinite.
Returns:
true if requested sequence number or greater applied, else false if the wait timed out
Throws:
java.lang.Exception - if there is a timeout or we are canceled

purge

int purge(TungstenProperties params)
          throws java.lang.Exception
Kill logins other than the connection(s) used for replication. This works on the master only.

The following control parameters are accepted:

Parameters:
params - 0 or more control parameters expressed as name-value pairs
Returns:
Number of sessions terminated
Throws:
java.lang.Exception - Thrown if we timeout or are canceled

status

java.util.HashMap<java.lang.String,java.lang.String> status()
                                                            throws java.lang.Exception
Returns the current replicator status as a set of name-value pairs. Values are defined as constants beginning with "STATUS_".

Throws:
java.lang.Exception

statusList

java.util.List<java.util.Map<java.lang.String,java.lang.String>> statusList(java.lang.String name)
                                                                            throws java.lang.Exception
Returns a list of status instances for a particular list of items.

Parameters:
name - Name of the status list. 'tasks' is supported by the native Tungsten replicator plugin.
Returns:
List of TungstenProperties instances containing task status
Throws:
java.lang.Exception

provision

void provision(java.lang.String uri)
               throws java.lang.Exception
Performs a provision operation. The provision operation is invoked on the replicator to be provisioned. The optional URI value provides the source for provisioning.

Parameters:
uri -
Throws:
java.lang.Exception

setRole

void setRole(java.lang.String role,
             java.lang.String uri)
             throws ReplicatorException
Sets the replicator role.

Parameters:
role - A supported role name, such as 'master', 'slave', or 'standby'
uri - An optional URI referring to another replicator if required for role (e.g., a slave typically points to a master)
Throws:
java.lang.Exception
ReplicatorException

consistencyCheck

int consistencyCheck(java.lang.String method,
                     java.lang.String schemaName,
                     java.lang.String tableName,
                     int rowOffset,
                     int rowLimit)
                     throws java.lang.Exception
Initiates consistency check transaction on a given table.

Parameters:
method - consistency check method to use
schemaName - name of the table schema
tableName - name of the table, if null all tables in schema are checked
rowOffset - start consistency check from this row (numeration starts with 0). If negative - whole table is checked.
rowLimit - limit consistency check to that many rows. If rowOffset is negative this is ignored.
Returns:
Executed consistency check's ID.
Throws:
java.lang.Exception

getCapabilities

ReplicatorCapabilities getCapabilities()
                                       throws java.lang.Exception
gets the capabilties for the replicator

Throws:
java.lang.Exception

getReplicatorRuntime

ReplicatorRuntime getReplicatorRuntime()