org.apache.derby.impl.store.replication.master
Class MasterController
- java.lang.Object
-
- org.apache.derby.impl.store.replication.master.MasterController
-
- All Implemented Interfaces:
- ModuleControl, ModuleSupportable, MasterFactory
public class MasterController extends java.lang.Object implements MasterFactory, ModuleControl, ModuleSupportable
This is an implementation of the replication master controller service. The service is booted when this instance of Derby will have the replication master role for this database.
Note: The current version of the class is far from complete. Code to control the replication master behavior will be added as more parts of the replication functionality is added to Derby.
- See Also:
MasterFactory
-
-
Field Summary
-
Fields inherited from interface org.apache.derby.iapi.store.replication.master.MasterFactory
ASYNCHRONOUS_MODE, MODULE, REPLICATION_MODE
-
-
Constructor Summary
Constructors Constructor and Description MasterController()Empty constructor required by Monitor.bootServiceModule
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidappendLog(long greatestInstant, byte[] log, int logOffset, int logLength)Append a chunk of log records to the log buffer.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.voidflushedTo(long instant)Used by the LogFactory to notify the replication master controller that the log records up to this instant have been flushed to disk.voidstartFailover()Will perform all work needed to failovervoidstartMaster(RawStoreFactory rawStore, DataFactory dataFac, LogFactory logFac, java.lang.String slavehost, int slaveport, java.lang.String dbname)Will perform all the work that is needed to set up replication.voidstop()Will stop the replication master service.voidstopMaster()Will perform all work that is needed to shut down replication.voidworkToDo()Used to notify the log shipper that a log buffer element is full.
-
-
-
Constructor Detail
-
MasterController
public MasterController()
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. Currently only used to set up the replication mode.- Specified by:
bootin interfaceModuleControl- Parameters:
create- Currently ignoredproperties- Properties used to start the service in the correct mode. Currently initializes only the replicationMode property.- Throws:
StandardException- Standard Derby exception policy, thrown on error.- 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 asynchronous replication is specified in startParams by checking that a property with key MasterFactory.REPLICATION_MODE has the value MasterFactory.ASYNCHRONOUS_MODE.- Specified by:
canSupportin interfaceModuleSupportable- Parameters:
startParams- The properties used to boot replication- Returns:
- true if asynchronous replication is requested, meaning that this MasterController is a suitable implementation for the MasterFactory service. False otherwise
- See Also:
ModuleSupportable.canSupport(java.util.Properties)
-
stop
public void stop()
Will stop the replication master service.- Specified by:
stopin interfaceModuleControl- See Also:
Monitor,ModuleFactory
-
startMaster
public void startMaster(RawStoreFactory rawStore, DataFactory dataFac, LogFactory logFac, java.lang.String slavehost, int slaveport, java.lang.String dbname) throws StandardException
Will perform all the work that is needed to set up replication.- Specified by:
startMasterin interfaceMasterFactory- Parameters:
rawStore- The RawStoreFactory for the databasedataFac- The DataFactory for this databaselogFac- The LogFactory ensuring recoverability for this databaseslavehost- The hostname of the slaveslaveport- The port the slave is listening ondbname- The master database that is being replicated.- Throws:
StandardException- Standard Derby exception policy, 1) thrown on replication startup error 2) thrown if the master has already been booted. 3) thrown if the specified replication mode is not supported.
-
stopMaster
public void stopMaster() throws StandardExceptionWill perform all work that is needed to shut down replication.- Specified by:
stopMasterin interfaceMasterFactory- Throws:
StandardException- If the replication master has been stopped already.
-
startFailover
public void startFailover() throws StandardExceptionDescription copied from interface:MasterFactoryWill perform all work needed to failover- Specified by:
startFailoverin interfaceMasterFactory- Throws:
StandardException- 1) If the failover succeeds, an exception is thrown to indicate that the master database was shutdown after a successful failover 2) If a failure occurs during network communication with slave.- See Also:
MasterFactory.startFailover()
-
appendLog
public void appendLog(long greatestInstant, byte[] log, int logOffset, int logLength)Append a chunk of log records to the log buffer. The method is not threadsafe; only one thread should access this method at a time.- Specified by:
appendLogin interfaceMasterFactory- Parameters:
greatestInstant- the instant of the log record that was added last to this chunk of loglog- the chunk of log recordslogOffset- offset in log to start copy fromlogLength- number of bytes to copy, starting from logOffset
-
flushedTo
public void flushedTo(long instant)
Used by the LogFactory to notify the replication master controller that the log records up to this instant have been flushed to disk. The master controller takes action according to the current replication strategy when this method is called. When the asynchronous replication strategy is used, the method does not force log shipping to the slave; the log records may be shipped now or later at the MasterController's discretion. However, if another strategy like 2-safe replication is implemented in the future, a call to this method may force log shipment before returning control to the caller. Currently, only asynchronous replication is supported. Not implemented yet- Specified by:
flushedToin interfaceMasterFactory- Parameters:
instant- The highest log instant that has been flushed to disk- See Also:
MasterFactory.flushedTo(long),LogFactory.flush(org.apache.derby.iapi.store.raw.log.LogInstant)
-
workToDo
public void workToDo()
Used to notify the log shipper that a log buffer element is full.- Specified by:
workToDoin interfaceMasterFactory
-
-
DataMelt 3.0 © DataMelt by jWork.ORG