Top Description Fields Methods
org.apache.derby.iapi.store.replication.slave

public Interface SlaveFactory

Known Direct Implementers
org.apache.derby.impl.store.replication.slave.SlaveController
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.store.raw.RawStoreFactory, org.apache.derby.iapi.store.raw.log.LogFactory

This is the interface for the replication slave controller service. The slave controller service is booted when this instance of Derby will have the replication slave role for this database.

The replication slave service is responsible for managing all replication related functionality on the slave side of replication. This includes connecting to the master and apply log records received from the master.

Field Summary

Modifier and TypeField and Description
public static final String
MODULE

The name of the Slave Factory, used to boot the service.

public static final String
REPLICATION_MODE

Property key to specify replication mode

public static final String
SLAVE_DB

Property key to specify the name of the database

public static final String
SLAVE_MODE

Property value used to indicate that the service should be booted in asynchronous replication mode.

public static final String
SLAVE_PRE_MODE

Property value used to indicate that the service should be booted in slave replication pre mode.

Method Summary

Modifier and TypeMethod and Description
public void
failover()

Used to turn this slave instance of the database into a normal instance that clients can connect to, assuming that the connection with the master is down.

public boolean

Returns:

true if slave replication mode has started successfully, false if slave mode startup is not yet confirmed
isStarted
()

Check whether or not slave replication mode has been successfully started.

public void
startSlave(RawStoreFactory
The RawStoreFactory for the database
rawStore
,
LogFactory
The LogFactory ensuring recoverability for this database
logFac
)

Start slave replication.

public void
stopSlave(boolean
Determines whether or not an exception should be thrown when this method is called while the network connection to the master is up.
forcedStop
)

Stop replication slave mode.

Field Detail

MODULEback to summary
public static final String MODULE

The name of the Slave Factory, used to boot the service.

REPLICATION_MODEback to summary
public static final String REPLICATION_MODE

Property key to specify replication mode

SLAVE_DBback to summary
public static final String SLAVE_DB

Property key to specify the name of the database

SLAVE_MODEback to summary
public static final String SLAVE_MODE

Property value used to indicate that the service should be booted in asynchronous replication mode.

SLAVE_PRE_MODEback to summary
public static final String SLAVE_PRE_MODE

Property value used to indicate that the service should be booted in slave replication pre mode. The reason for having a slave pre mode is that when slave replication is started, we need to boot the database twice: Once to check authentication and authorization, and a second time to put the database in slave mode. It is imperative that the disk image of log files remain unmodified by the first boot since the master and slave log files have to be identical when slave mode starts. Booting in SLAVE_PRE_MODE ensures that the log files remain unmodified.

Method Detail

failoverback to summary
public void failover() throws StandardException

Used to turn this slave instance of the database into a normal instance that clients can connect to, assuming that the connection with the master is down. This is typically done in cases where a fatal error has happened on the master instance of the database, or when the master database is unreachable due to network problems.

By calling failover, this slave instance of the database will be recovered so that all committed operations that have been received from the master are reflected here. On the other hand, operations from transactions where the commit log record has not been received from the master will not be reflected.

Note that even though an operation has been executed (and even committed) on the master, it is not neccessarily reflected in the slave instance of the database. This depends on the replication strategy used by the MasterFactory.

Exceptions
StandardException:
Thrown if slave is connected with master
See Also
org.apache.derby.iapi.store.replication.master.MasterFactory, org.apache.derby.impl.store.replication.master.MasterController#flushedTo
isStartedback to summary
public boolean isStarted()

Check whether or not slave replication mode has been successfully started.

Returns:boolean

true if slave replication mode has started successfully, false if slave mode startup is not yet confirmed

startSlaveback to summary
public void startSlave(RawStoreFactory rawStore, LogFactory logFac) throws StandardException

Start slave replication. This method establishes a network connection with the associated replication master and starts a daemon that applies operations received from the master (in the form of log records) to the local slave database.

Parameters
rawStore:RawStoreFactory

The RawStoreFactory for the database

logFac:LogFactory

The LogFactory ensuring recoverability for this database

Exceptions
StandardException:
Thrown if the slave could not be started.
stopSlaveback to summary
public void stopSlave(boolean forcedStop) throws StandardException

Stop replication slave mode. Causes the database to abort the boot process, and should only be used when shutting down this database. If forcedStop is false, the method will fail with an exception if connected with the master. If forcedStop is true, the slave will be shut down even if connected to the master. A forcedStop value of true should only be used by system shutdown.

Parameters
forcedStop:boolean

Determines whether or not an exception should be thrown when this method is called while the network connection to the master is up.

Exceptions
StandardException:
Thrown if slave is connected with master and forcedStop is false.