com.continuent.tungsten.replicator.management
Class OpenReplicatorManager

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by com.continuent.tungsten.replicator.management.OpenReplicatorManager
All Implemented Interfaces:
com.continuent.tungsten.fsm.core.StateChangeListener, com.continuent.tungsten.fsm.event.EventCompletionListener, OpenReplicatorContext, OpenReplicatorManagerMBean, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter

public class OpenReplicatorManager
extends javax.management.NotificationBroadcasterSupport
implements OpenReplicatorManagerMBean, OpenReplicatorContext, com.continuent.tungsten.fsm.core.StateChangeListener, com.continuent.tungsten.fsm.event.EventCompletionListener

This class provides overall management for the replication and is the starting class for a Tungsten Replicator instance. Replication logic is encapsulated in a replicator plugin.

Version:
1.0
Author:
Teemu Ollakka

Field Summary
static int FLUSH
           
static int MAJOR
           
static int MINOR
           
static int REPL
           
static java.lang.String SUFFIX
           
 
Fields inherited from interface com.continuent.tungsten.replicator.management.OpenReplicatorManagerMBean
signalConfigured, signalConsistencyFail, signalError, signalOfflineReached, signalRestored, signalShutdown, signalSynced
 
Constructor Summary
OpenReplicatorManager(java.lang.String serviceName)
          Creates a new ReplicatorManager object
 
Method Summary
 void advertiseInternal()
           
protected  java.lang.String assertPropertyDefault(java.lang.String key, java.lang.String value)
          Ensures that a required property has a default if unspecified.
protected  java.lang.String assertPropertySet(java.lang.String key)
           
 java.lang.String backup(java.lang.String backupAgentName, java.lang.String storageAgentName, long timeout)
          Spawns a backup of the database and optionally waits for completion.
 java.util.Map<java.lang.String,java.lang.String> capabilities()
          Gets the replicator capabilities.
 void clearDynamicProperties()
          Clear dynamic properties.
 void configure(java.util.Map<java.lang.String,java.lang.String> props)
          Re-read configuration properties.
 void configure(TungstenProperties tp)
          Local wrapper of configure to help with unit testing.
 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.
 DynamicMBeanHelper createHelper()
          Returns a helper that supplies MBean metadata.
protected  void doConfigure()
          Process configuration properties and instantiate/configure all plug-ins.
protected  boolean doHeartbeat(TungstenProperties props)
          Implements a heartbeat call.
 java.lang.String flush(long timeout)
          Creates a flush event, which in turn causes us to wait for the database to synchronize with THL.
 java.util.List<java.util.Map<java.lang.String,java.lang.String>> getClients()
          Returns clients (slaves) of this server.
 java.lang.String getClusterName()
          Gets the cluster name for this replication service
static TungstenProperties getConfigurationProperties(java.lang.String serviceName)
           
 java.util.concurrent.CountDownLatch getDoneLatch()
          Returns the doneLatch value.
 java.util.Map<java.lang.String,java.lang.String> getDynamicProperties()
          Return a copy of current dynamic properties.
 com.continuent.tungsten.fsm.event.EventDispatcher getEventDispatcher()
          Returns the event dispatcher for reporting interesting events.
 java.lang.Object getExtensionMBean(java.lang.String name)
          Returns the JMX API for a named extension.
static java.lang.String getHostName()
          Deprecated. Not used by multi-service Replicator any more. See ReplicationServiceManager.getHostName(TungstenProperties)
 java.lang.String getMasterConnectUri()
          Returns the master remote URI to which this replicator connects when operating as a slave.stop
 int getMasterListenPort()
          Returns the listen port used by a master pipeline
 java.lang.String getMasterListenUri()
          Returns the URI on which this master listens when operating as a slave.
 java.lang.String getMaxSeqNo()
          Returns the highest applied sequence number in the local transaction history log or -1 if log is not operating.
 java.lang.String[] getMinMaxSeqNo()
          Returns the lowest and the highest sequence numbers in the local transaction history log or -1 if log is not operating.
 java.lang.String getMinSeqNo()
          Returns the lowest sequence number in the local transaction history log or -1 if log is not operating.
 java.lang.String getPendingError()
          Returns description of last error if we are in OFFLINE:ERROR state or null if no error is pending.
 java.lang.String getPendingErrorCode()
           
 java.lang.String getPendingExceptionMessage()
          Returns message from exception that provoked the last error
 java.lang.String getRmiHost()
          Returns RMI port.
 int getRmiPort()
          Returns the rmiPort value.
 java.lang.String getRole()
          Returns the current replicator role.
 java.lang.String getServiceName()
          Gets the service name for this replication service
 java.lang.String getSimpleServiceName()
          Gets the simple name for this replication service
 java.lang.String getSiteName()
          Gets the site name for this replication service
 java.lang.String getSourceId()
          Returns current instance unique source identifier.
 java.lang.String getState()
          Returns the current replicator state.
 long getStateChangeTimeMillis()
           
 TungstenProperties getStatus()
          Returns detailed status in a single call.
 double getTimeInStateSeconds()
           
 double getUptimeSeconds()
           
 java.lang.Boolean getUseSSLConnection()
          Returns true if the Replicator uses SSL connections.
 java.lang.String getVersion()
          Returns the replicator product version.
 void heartbeat(java.util.Map<java.lang.String,java.lang.String> controlParams)
          Inserts a heartbeat event.
 boolean isAlive()
          Returns true so that clients can confirm connection liveness.
protected  boolean isConsistencyFailureStop()
           
 java.util.List<java.lang.String> listExtensionMBeans()
          Returns a list of the names of currently defined extension MBeans.
protected  OpenReplicatorPlugin loadAndConfigurePlugin(java.lang.String prefix, java.lang.String name)
          Generic code to load and configure a plugin.
 void offline()
          Sends the replicator into the offline state.
 void offlineDeferred(java.util.Map<java.lang.String,java.lang.String> controlParams)
          Issues a request to go offline at a particular event or sequence number.
 java.lang.Object onCompletion(com.continuent.tungsten.fsm.core.Event event, com.continuent.tungsten.fsm.event.EventStatus status)
          Log events as they are processed in the replicator state machine.
 void online()
          Puts the replicator into the online state using defaults for all control parameters.
 void online2(java.util.Map<java.lang.String,java.lang.String> controlParams)
          Puts the replicator into the online state.
 java.util.Map<java.lang.String,java.lang.String> properties(java.lang.String key)
          Return a copy of current properties.
 boolean provision(java.lang.String replicatorUri, long timeout)
          Provisions current database from a donor.
 int purge(java.util.Map<java.lang.String,java.lang.String> controlParams)
          Invoke purge on underlying replicator plugin.
 void registerMBean(java.lang.Object mbean, java.lang.Class<?> mbeanClass, java.lang.String name)
          Registers a JMX MBean from a lower-level service.
 java.lang.String restore(java.lang.String uri, long timeout)
          Spawns a restore of the database and optionally waits for completion.
 void setDoneLatch(java.util.concurrent.CountDownLatch doneLatch)
          Sets the doneLatch value.
 void setRmiHost(java.lang.String rmiHost)
          Sets RMI host.
 void setRmiPort(int rmiPort)
          Sets the rmiPort value.
 void setRole(java.lang.String role, java.lang.String uri)
          Sets the replicator role.
 void signal(int signal, java.lang.String msg)
          Notification signaling methods.
 void start(boolean forceOffline)
          Start Replicator Node Manager JMX service.
 void stateChanged(com.continuent.tungsten.fsm.core.Entity entity, com.continuent.tungsten.fsm.core.State oldState, com.continuent.tungsten.fsm.core.State newState)
          Log state changes coming from the state machine.
 java.util.Map<java.lang.String,java.lang.String> status()
          Gets status variables from replicator.
 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.
 void stop()
          Stop Replicator Node Manager JMX service.
 java.lang.String transitioningTo()
           
 boolean waitForAppliedSequenceNumber(java.lang.String seqno, long timeout)
          Wait for a particular event to be applied on the slave.
 boolean waitForState(java.lang.String stateName, long timeout)
          Waits for replicator to achieve a particular state.
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAJOR

public static final int MAJOR
See Also:
Constant Field Values

MINOR

public static final int MINOR
See Also:
Constant Field Values

SUFFIX

public static final java.lang.String SUFFIX
See Also:
Constant Field Values

REPL

public static final int REPL
See Also:
Constant Field Values

FLUSH

public static final int FLUSH
See Also:
Constant Field Values
Constructor Detail

OpenReplicatorManager

public OpenReplicatorManager(java.lang.String serviceName)
                      throws java.lang.Exception
Creates a new ReplicatorManager object

Parameters:
serviceName - name of the current replication service
Throws:
java.lang.Exception
Method Detail

advertiseInternal

public void advertiseInternal()

isConsistencyFailureStop

protected boolean isConsistencyFailureStop()

stateChanged

public void stateChanged(com.continuent.tungsten.fsm.core.Entity entity,
                         com.continuent.tungsten.fsm.core.State oldState,
                         com.continuent.tungsten.fsm.core.State newState)
Log state changes coming from the state machine.

Specified by:
stateChanged in interface com.continuent.tungsten.fsm.core.StateChangeListener

onCompletion

public java.lang.Object onCompletion(com.continuent.tungsten.fsm.core.Event event,
                                     com.continuent.tungsten.fsm.event.EventStatus status)
                              throws java.lang.InterruptedException
Log events as they are processed in the replicator state machine.

Specified by:
onCompletion in interface com.continuent.tungsten.fsm.event.EventCompletionListener
Throws:
java.lang.InterruptedException

getEventDispatcher

public com.continuent.tungsten.fsm.event.EventDispatcher getEventDispatcher()
Returns the event dispatcher for reporting interesting events.

Specified by:
getEventDispatcher in interface OpenReplicatorContext
See Also:
OpenReplicatorContext.getEventDispatcher()

registerMBean

public void registerMBean(java.lang.Object mbean,
                          java.lang.Class<?> mbeanClass,
                          java.lang.String name)
Registers a JMX MBean from a lower-level service.

Specified by:
registerMBean in interface OpenReplicatorContext
See Also:
OpenReplicatorContext.registerMBean(Object, Class, String)

isAlive

public boolean isAlive()
Description copied from interface: OpenReplicatorManagerMBean
Returns true so that clients can confirm connection liveness.

Specified by:
isAlive in interface OpenReplicatorManagerMBean
Returns:
true if the service is up and running, false otherwise

getVersion

public java.lang.String getVersion()
Description copied from interface: OpenReplicatorManagerMBean
Returns the replicator product version.

Specified by:
getVersion in interface OpenReplicatorManagerMBean
Returns:
the version number as a string

getSiteName

public java.lang.String getSiteName()
Description copied from interface: OpenReplicatorManagerMBean
Gets the site name for this replication service

Specified by:
getSiteName in interface OpenReplicatorManagerMBean
Returns:
the site name as a string

getClusterName

public java.lang.String getClusterName()
Description copied from interface: OpenReplicatorManagerMBean
Gets the cluster name for this replication service

Specified by:
getClusterName in interface OpenReplicatorManagerMBean
Returns:
the cluster name as a string

getSimpleServiceName

public java.lang.String getSimpleServiceName()
Description copied from interface: OpenReplicatorManagerMBean
Gets the simple name for this replication service

Specified by:
getSimpleServiceName in interface OpenReplicatorManagerMBean
Returns:
the simple name of this service as a string

getServiceName

public java.lang.String getServiceName()
Description copied from interface: OpenReplicatorManagerMBean
Gets the service name for this replication service

Specified by:
getServiceName in interface OpenReplicatorManagerMBean
Returns:
the service name as a string

getSourceId

public java.lang.String getSourceId()
Description copied from interface: OpenReplicatorManagerMBean
Returns current instance unique source identifier.

Specified by:
getSourceId in interface OpenReplicatorManagerMBean
Returns:
the source identifier as a string

getMasterConnectUri

public java.lang.String getMasterConnectUri()
Description copied from interface: OpenReplicatorManagerMBean
Returns the master remote URI to which this replicator connects when operating as a slave.stop

Specified by:
getMasterConnectUri in interface OpenReplicatorManagerMBean

getMasterListenUri

public java.lang.String getMasterListenUri()
Description copied from interface: OpenReplicatorManagerMBean
Returns the URI on which this master listens when operating as a slave.

Specified by:
getMasterListenUri in interface OpenReplicatorManagerMBean

getUseSSLConnection

public java.lang.Boolean getUseSSLConnection()
                                      throws java.net.URISyntaxException
Description copied from interface: OpenReplicatorManagerMBean
Returns true if the Replicator uses SSL connections.

Specified by:
getUseSSLConnection in interface OpenReplicatorManagerMBean
Throws:
java.net.URISyntaxException

getClients

public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getClients()
                                                                            throws java.lang.Exception
Description copied from interface: OpenReplicatorManagerMBean
Returns clients (slaves) of this server.

Specified by:
getClients in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception

getRole

public java.lang.String getRole()
Description copied from interface: OpenReplicatorManagerMBean
Returns the current replicator role.

Specified by:
getRole in interface OpenReplicatorManagerMBean
Returns:
the role as a string

getUptimeSeconds

public double getUptimeSeconds()

getState

public java.lang.String getState()
Description copied from interface: OpenReplicatorManagerMBean
Returns the current replicator state.

Specified by:
getState in interface OpenReplicatorManagerMBean

transitioningTo

public java.lang.String transitioningTo()

getTimeInStateSeconds

public double getTimeInStateSeconds()

getStateChangeTimeMillis

public long getStateChangeTimeMillis()

getPendingErrorCode

public java.lang.String getPendingErrorCode()

getPendingError

public java.lang.String getPendingError()
Description copied from interface: OpenReplicatorManagerMBean
Returns description of last error if we are in OFFLINE:ERROR state or null if no error is pending.

Specified by:
getPendingError in interface OpenReplicatorManagerMBean

getPendingExceptionMessage

public java.lang.String getPendingExceptionMessage()
Description copied from interface: OpenReplicatorManagerMBean
Returns message from exception that provoked the last error

Specified by:
getPendingExceptionMessage in interface OpenReplicatorManagerMBean

getMaxSeqNo

public java.lang.String getMaxSeqNo()
                             throws java.lang.Exception
Description copied from interface: OpenReplicatorManagerMBean
Returns the highest applied sequence number in the local transaction history log or -1 if log is not operating.

Specified by:
getMaxSeqNo in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception

getMinMaxSeqNo

public java.lang.String[] getMinMaxSeqNo()
                                  throws java.lang.Exception
Description copied from interface: OpenReplicatorManagerMBean
Returns the lowest and the highest sequence numbers in the local transaction history log or -1 if log is not operating.

Specified by:
getMinMaxSeqNo in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception

getMinSeqNo

public java.lang.String getMinSeqNo()
                             throws java.lang.Exception
Description copied from interface: OpenReplicatorManagerMBean
Returns the lowest sequence number in the local transaction history log or -1 if log is not operating.

Specified by:
getMinSeqNo in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception

configure

public void configure(java.util.Map<java.lang.String,java.lang.String> props)
               throws java.lang.Exception
Re-read configuration properties.

Specified by:
configure in interface OpenReplicatorManagerMBean
Parameters:
props - A map instance or null to reread local file
Throws:
java.lang.Exception

clearDynamicProperties

public void clearDynamicProperties()
                            throws java.lang.Exception
Clear dynamic properties. Clears all dynamic properties. The replicator must be in the OFFLINE state when this call is issued.

Specified by:
clearDynamicProperties in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.clearDynamicProperties()

properties

public java.util.Map<java.lang.String,java.lang.String> properties(java.lang.String key)
                                                            throws java.lang.Exception
Return a copy of current properties. Returns a map instance containing currently set properties, if any. This call can be issued in any replicator state.

Specified by:
properties in interface OpenReplicatorManagerMBean
Parameters:
key - optional key of a single property
Returns:
the current property(ies)
Throws:
java.lang.Exception

getDynamicProperties

public java.util.Map<java.lang.String,java.lang.String> getDynamicProperties()
                                                                      throws java.lang.Exception
Return a copy of current dynamic properties. Returns a map instance containing currently set dynamic properties, if any. This call can be issued in any replicator state.

Specified by:
getDynamicProperties in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.getDynamicProperties()

setRole

public void setRole(java.lang.String role,
                    java.lang.String uri)
             throws java.lang.Exception
Sets the replicator role. Sets replicator role. Not all replicators support all roles; check other documentation for details.

Specified by:
setRole in interface OpenReplicatorManagerMBean
Parameters:
role - The new replicator role; must be 'slave', 'master', or 'standby'
uri - Optional uri to identify master or slave.
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.setRole(java.lang.String, java.lang.String)

status

public java.util.Map<java.lang.String,java.lang.String> status()
                                                        throws java.lang.Exception
Gets status variables from replicator. Returns the detailed, current status information from the replicator.

Specified by:
status in interface OpenReplicatorManagerMBean
Returns:
detailed status information as a TungstenProperties instance
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.status()

getStatus

public TungstenProperties getStatus()
                             throws java.lang.Exception
Returns detailed status in a single call.

Specified by:
getStatus in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.getStatus()

statusList

public 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.

Specified by:
statusList in interface OpenReplicatorManagerMBean
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
See Also:
OpenReplicatorManagerMBean.statusList(java.lang.String)

start

public void start(boolean forceOffline)
           throws java.lang.Exception
Start Replicator Node Manager JMX service.

Specified by:
start in interface OpenReplicatorManagerMBean
Parameters:
forceOffline - true to prevent the replicator from putting its replication services online (if auto-enable is set to true)
Throws:
java.lang.Exception - Thrown if start-up fails. This includes failure to go online if the replicator is auto-enabled.

stop

public void stop()
          throws java.lang.Exception
Stop Replicator Node Manager JMX service.

Specified by:
stop in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception

online

public void online()
            throws java.lang.Exception
Puts the replicator into the online state using defaults for all control parameters.

Specified by:
online in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.online()

online2

public void online2(java.util.Map<java.lang.String,java.lang.String> controlParams)
             throws java.lang.Exception
Puts the replicator into the online state. This call returns when the request to go online has been accepted. The replicator must be in thstope OFFLINE state for this call to be processed.

The online operation accepts name-value control parameters that allow users to control replicator behavior when going online.

stop
Name Description Default
initEventId Sets initial native event ID at which to start extraction, overriding value from the last event extracted Replication starts at either last event ID extracted or, if there is none, the current event ID
skipApplyEvents Number of events to skip applying at startup 0
toEventId Replicate up to the indicated event ID None
toSeqno Replicate up to the indicated sequence number None
Due to the fact that the replicator may need to synchronize with a master it may be some time before the replicator actually reaches the online state. Use the OpenReplicatorManagerMBean.waitForState(String, long) call to wait synchronously for the replicator to go fully online.

Specified by:
online2 in interface OpenReplicatorManagerMBean
Parameters:
controlParams - 0 or more control parameters expressed as name-value pairs
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.online()

offline

public void offline()
             throws java.lang.Exception
Sends the replicator into the offline state. Puts the replicator into the offline state immediately without clean-up, returning once the replicator is offline. The replicator must be in the ONLINE or GOING-ONLINE state for this call to be processed.

This call is hazardous on slaves using parallel apply. It does not do a clean offline operation, which means that it is unsafe for doing failover operations, creating a backup that can restore when using different numbers of parallel apply channels or for changing any parameters associated with parallel apply. You should use offlineDeferred for clean shutdown.

Specified by:
offline in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.offline()

offlineDeferred

public void offlineDeferred(java.util.Map<java.lang.String,java.lang.String> controlParams)
                     throws java.lang.Exception
Issues a request to go offline at a particular event or sequence number. The replicator must be in the ONLINE state for this call to be processed.

The offline operation accepts name-value control parameters that allow users to control replicator behavior.

Name Description Parameter Default
atEventId Go offline at the requested event An event ID in native format None
atHeartbeat Go offline at the next heartbeat event. A heartbeat name or * to select any heartbeat *
atSeqno Go offline at the indicated sequence number A valid sequence number None
atTransaction Go offline cleanly at the next transaction. This is the best way to take a replicator offline as it ensures the replicator can reload backups when parallel apply is in effect or make change to parallel apply parameters Insert any value None
atTimestamp Go offline cleanly at the next transaction. This is the best way to take a replicator offline as it ensures the replicator can reload backups when parallel apply is in effect or make change to parallel apply parameters A timestamp String in yyyy-MM-dd HH:mm:ss format None

Specified by:
offlineDeferred in interface OpenReplicatorManagerMBean
Parameters:
controlParams - 0 or more control parameters expressed as name-value pairs
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.online()

flush

public java.lang.String flush(long timeout)
                       throws java.lang.Exception
Creates a flush event, which in turn causes us to wait for the database to synchronize with THL. Implements a flush operation to synchronize the state of the database with the transaction history log and return the sequence number of the log at the point where the database is synchronized. The replicator must be in the ONLINE:MASTER state for this call to be processed. This call is used to implement safe failover.

Specified by:
flush in interface OpenReplicatorManagerMBean
Parameters:
timeout - Number of seconds to wait. 0 is indefinite.
Returns:
The sequence number at which the log is synchronized
Throws:
java.lang.Exception - Thrown if we timeout or are canceled
See Also:
OpenReplicatorManagerMBean.flush(long)

purge

public int purge(java.util.Map<java.lang.String,java.lang.String> controlParams)
          throws java.lang.Exception
Invoke purge on underlying replicator plugin. Attempts to kill all non-replication logins on the DBMS server. May be called prior to flush() to ensure that all application activity stops prior to a failover. This avoids problems with blocked or long-running transactions that commit after failover starts. This operation works in both ONLINE and OFFLINE states so that it can be used to clear transactions during unplanned as well as planned failover.

The following control parameters are accepted:

Specified by:
purge in interface OpenReplicatorManagerMBean
Parameters:
controlParams - 0 or more control parameters expressed as name-value pairs
Returns:
Number of sessions killed
Throws:
java.lang.Exception - Thrown if we timeout or are canceled
See Also:
OpenReplicatorManagerMBean.purge(java.util.Map)

heartbeat

public void heartbeat(java.util.Map<java.lang.String,java.lang.String> controlParams)
               throws java.lang.Exception
Inserts a heartbeat event. Inserts a heartbeat event into the replicator transaction history. The replicator manager must be in the MASTER state for this call to be successful.

Specified by:
heartbeat in interface OpenReplicatorManagerMBean
Parameters:
controlParams - A map instance containing heartbeat parameters
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.heartbeat(Map)

waitForState

public boolean waitForState(java.lang.String stateName,
                            long timeout)
                     throws java.lang.Exception
Waits for replicator to achieve a particular state. Waits for the replicator to attain a specific state, such as "SLAVE". The wait time is configurable so that callers do not wait indefinitely. The wait will terminate automatically with an exception if the replicator goes into the error state (unless that is what you are waiting for).

Specified by:
waitForState in interface OpenReplicatorManagerMBean
Parameters:
stateName - Name of state on which to wait. This can be a parent state name--"OFFLINE" will also detect "OFFLINE:NORMAL" and "OFFLINE:ERROR".
timeout - Number of seconds to wait. 0 is indefinite.
Returns:
true if requested wait state is achieved, else false if the wait timed out
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.waitForState(java.lang.String, long)

waitForAppliedSequenceNumber

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

Specified by:
waitForAppliedSequenceNumber in interface OpenReplicatorManagerMBean
Parameters:
seqno - Id of the 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
See Also:
OpenReplicatorManagerMBean.waitForAppliedSequenceNumber(java.lang.String, long)

backup

public java.lang.String backup(java.lang.String backupAgentName,
                               java.lang.String storageAgentName,
                               long timeout)
                        throws java.lang.Exception
Spawns a backup of the database and optionally waits for completion. This command can only be run in the off-line state.

Specified by:
backup in interface OpenReplicatorManagerMBean
Parameters:
backupAgentName - Name of the backup agent to use or null to use the default backup
storageAgentName - Name of the storage agent to use or null to use the default storage
timeout - Number of seconds to wait. 0 is indefinite, negative means no wait.
Returns:
A URI for the backup if successful, otherwise a null if the backup is still pending
Throws:
java.lang.Exception - if there is a backup failure
See Also:
OpenReplicatorManagerMBean.backup(java.lang.String, java.lang.String, long)

restore

public java.lang.String restore(java.lang.String uri,
                                long timeout)
                         throws java.lang.Exception
Spawns a restore of the database and optionally waits for completion. This command can only be run in the off-line state.

Specified by:
restore in interface OpenReplicatorManagerMBean
Parameters:
uri - URI of the backup to load
timeout - Number of seconds to wait. 0 is indefinite, negative means no wait.
Returns:
the URI of the restored backup if the restore is known to have completed successfully, otherwise null, which means restore is still pending
Throws:
java.lang.Exception - if there is a restore failure
See Also:
OpenReplicatorManagerMBean.restore(java.lang.String, long)

createHelper

public DynamicMBeanHelper createHelper()
                                throws java.lang.Exception
Returns a helper that supplies MBean metadata.

Specified by:
createHelper in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception
See Also:
createHelper()

getExtensionMBean

public java.lang.Object getExtensionMBean(java.lang.String name)
                                   throws java.lang.Exception
Returns the JMX API for a named extension.

Specified by:
getExtensionMBean in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception
See Also:
createHelper()

listExtensionMBeans

public java.util.List<java.lang.String> listExtensionMBeans()
                                                     throws java.lang.Exception
Returns a list of the names of currently defined extension MBeans.

Specified by:
listExtensionMBeans in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.listExtensionMBeans()

provision

public boolean provision(java.lang.String replicatorUri,
                         long timeout)
                  throws java.lang.Exception
Provisions current database from a donor. Provisions a database from another copy and optionally waits for completion. This command can only be run from the off-line state.

Specified by:
provision in interface OpenReplicatorManagerMBean
Parameters:
replicatorUri - URI of donor replicator
timeout - Number of seconds to wait. 0 is indefinite, negative means no wait.
Returns:
true if the provision task is known to have completed successfully, otherwise false, which means provisioning is still pending
Throws:
java.lang.Exception - if there is a provisioning failure
See Also:
OpenReplicatorManagerMBean.provision(java.lang.String, long)

consistencyCheck

public 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.

Specified by:
consistencyCheck in interface OpenReplicatorManagerMBean
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
See Also:
OpenReplicatorManagerMBean.consistencyCheck(java.lang.String, java.lang.String, java.lang.String, int, int)

signal

public void signal(int signal,
                   java.lang.String msg)
            throws java.lang.Exception
Notification signaling methods. These sends a notification to the replicator manager. These methods are used by replicator providers, which need to signal of underlying state changes.

Specified by:
signal in interface OpenReplicatorManagerMBean
Parameters:
signal - one of signal* strings listed in this interface
msg - additional message passed along the signal
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.signal(int, java.lang.String)

capabilities

public java.util.Map<java.lang.String,java.lang.String> capabilities()
                                                              throws java.lang.Exception
Gets the replicator capabilities.

Specified by:
capabilities in interface OpenReplicatorManagerMBean
Throws:
java.lang.Exception
See Also:
OpenReplicatorManagerMBean.capabilities()

assertPropertyDefault

protected java.lang.String assertPropertyDefault(java.lang.String key,
                                                 java.lang.String value)
Ensures that a required property has a default if unspecified.


assertPropertySet

protected java.lang.String assertPropertySet(java.lang.String key)
                                      throws ReplicatorException
Throws:
ReplicatorException

loadAndConfigurePlugin

protected OpenReplicatorPlugin loadAndConfigurePlugin(java.lang.String prefix,
                                                      java.lang.String name)
                                               throws ReplicatorException
Generic code to load and configure a plugin.

Throws:
ReplicatorException

doConfigure

protected void doConfigure()
                    throws ReplicatorException
Process configuration properties and instantiate/configure all plug-ins. This method must be called before the configuration is usable.

Throws:
ReplicatorException - Thrown if configuration fails

configure

public void configure(TungstenProperties tp)
               throws java.lang.Exception
Local wrapper of configure to help with unit testing.

Throws:
java.lang.Exception

doHeartbeat

protected boolean doHeartbeat(TungstenProperties props)
                       throws java.lang.Exception
Implements a heartbeat call. This is meant to be called from within the HeartbeatAction.

Throws:
java.lang.Exception

getHostName

@Deprecated
public static java.lang.String getHostName()
Deprecated. Not used by multi-service Replicator any more. See ReplicationServiceManager.getHostName(TungstenProperties)

Returns the hostname to be used to bind ports for RMI use. This defaults to 'localhost' for backwards compatibility.


getMasterListenPort

public int getMasterListenPort()
Returns the listen port used by a master pipeline

Specified by:
getMasterListenPort in interface OpenReplicatorManagerMBean
Returns:
the listen port as an integer

getDoneLatch

public java.util.concurrent.CountDownLatch getDoneLatch()
Returns the doneLatch value.

Returns:
Returns the doneLatch.

setDoneLatch

public void setDoneLatch(java.util.concurrent.CountDownLatch doneLatch)
Sets the doneLatch value.

Parameters:
doneLatch - The doneLatch to set.

getRmiHost

public java.lang.String getRmiHost()
Returns RMI port.


setRmiHost

public void setRmiHost(java.lang.String rmiHost)
Sets RMI host.


getRmiPort

public int getRmiPort()
Returns the rmiPort value.

Returns:
Returns the rmiPort.

setRmiPort

public void setRmiPort(int rmiPort)
Sets the rmiPort value.

Parameters:
rmiPort - The rmiPort to set.

getConfigurationProperties

public static TungstenProperties getConfigurationProperties(java.lang.String serviceName)
                                                     throws ReplicatorException
Throws:
ReplicatorException