Interface SlaveFactory
- All Known Implementing Classes:
SlaveController
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
FieldsModifier and TypeFieldDescriptionstatic final String
The name of the Slave Factory, used to boot the service.static final String
Property key to specify replication modestatic final String
Property key to specify the name of the databasestatic final String
Property value used to indicate that the service should be booted in asynchronous replication mode.static final String
Property value used to indicate that the service should be booted in slave replication pre mode. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.boolean
Check whether or not slave replication mode has been successfully started.void
startSlave
(RawStoreFactory rawStore, LogFactory logFac) Start slave replication.void
stopSlave
(boolean forcedStop) Stop replication slave mode.
-
Field Details
-
MODULE
The name of the Slave Factory, used to boot the service.- See Also:
-
SLAVE_DB
Property key to specify the name of the database- See Also:
-
REPLICATION_MODE
Property key to specify replication mode- See Also:
-
SLAVE_MODE
Property value used to indicate that the service should be booted in asynchronous replication mode.- See Also:
-
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.- See Also:
-
-
Method Details
-
startSlave
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
- The RawStoreFactory for the databaselogFac
- The LogFactory ensuring recoverability for this database- Throws:
StandardException
- Thrown if the slave could not be started.
-
stopSlave
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
- Determines whether or not an exception should be thrown when this method is called while the network connection to the master is up.- Throws:
StandardException
- Thrown if slave is connected with master and forcedStop is false.
-
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. 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.
- Throws:
StandardException
- Thrown if slave is connected with master- See Also:
-
isStarted
boolean isStarted()Check whether or not slave replication mode has been successfully started.- Returns:
- true if slave replication mode has started successfully, false if slave mode startup is not yet confirmed
-