Class SlaveController
- java.lang.Object
-
- org.apache.derby.impl.store.replication.slave.SlaveController
-
- All Implemented Interfaces:
- ModuleControl, ModuleSupportable, SlaveFactory
public class SlaveController extends java.lang.Object implements SlaveFactory, ModuleControl, ModuleSupportable
This is an implementation of the replication slave controller service. The service is booted when this instance of Derby will have the replication slave role for this database.
Note: The current version of the class is far from complete. Code to control the replication slave behavior will be added as more parts of the replication functionality is added to Derby.
- See Also:
SlaveFactory
-
-
Field Summary
-
Fields inherited from interface org.apache.derby.iapi.store.replication.slave.SlaveFactory
MODULE, REPLICATION_MODE, SLAVE_DB, SLAVE_MODE, SLAVE_PRE_MODE
-
-
Constructor Summary
Constructors Constructor and Description SlaveController()Empty constructor required by Monitor.bootServiceModule
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidboot(boolean create, java.util.Properties properties)Used by Monitor.bootServiceModule to start the service.booleancanSupport(java.util.Properties startParams)Used by Monitor.bootServiceModule to check if this class is usable for replication.voidfailover()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.booleanisStarted()Check whether or not slave replication mode has been successfully started.voidstartSlave(RawStoreFactory rawStore, LogFactory logFac)Start slave replication.voidstop()Will tear down the replication slave service.voidstopSlave(boolean forcedStop)Stop replication slave mode.
-
-
-
Constructor Detail
-
SlaveController
public SlaveController()
Empty constructor required by Monitor.bootServiceModule
-
-
Method Detail
-
boot
public void boot(boolean create, java.util.Properties properties) throws StandardExceptionUsed by Monitor.bootServiceModule to start the service. It will set up basic variables- Specified by:
bootin interfaceModuleControl- Parameters:
create- Currently ignoredproperties- Properties used to start the service in the correct mode- Throws:
StandardException- Standard Derby exception policy, thrown on error.- See Also:
Monitor,ModuleFactory
-
stop
public void stop()
Will tear down the replication slave service.- Specified by:
stopin interfaceModuleControl- See Also:
Monitor,ModuleFactory
-
canSupport
public boolean canSupport(java.util.Properties startParams)
Used by Monitor.bootServiceModule to check if this class is usable for replication. To be usable, we require that slave replication mode is specified in startParams by checking that a property with key SlaveFactory.REPLICATION_MODE has the value SlaveFactory.SLAVE_MODE.- Specified by:
canSupportin interfaceModuleSupportable- Parameters:
startParams- The properties used to start replication- Returns:
- true if slave repliation is specified, meaning that this MasterController is a suitable implementation for the SlaveFactory service. False otherwise.
- See Also:
ModuleSupportable.canSupport(java.util.Properties)
-
startSlave
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 thread that applies operations received from the master (in the form of log records) to the local slave database.- Specified by:
startSlavein interfaceSlaveFactory- 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
public void stopSlave(boolean forcedStop) throws StandardExceptionDescription copied from interface:SlaveFactoryStop 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.- Specified by:
stopSlavein interfaceSlaveFactory- 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.- See Also:
SlaveFactory.stopSlave(boolean)
-
failover
public void failover() throws StandardExceptionDescription copied from interface:SlaveFactoryUsed 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.
- Specified by:
failoverin interfaceSlaveFactory- Throws:
StandardException- Thrown if slave is connected with master- See Also:
MasterFactory,MasterController.flushedTo(long)
-
isStarted
public boolean isStarted()
Description copied from interface:SlaveFactoryCheck whether or not slave replication mode has been successfully started.- Specified by:
isStartedin interfaceSlaveFactory- Returns:
- true if slave replication mode has started successfully, false if slave mode startup is not yet confirmed
- See Also:
SlaveFactory.isStarted()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG