use of org.apache.derby.iapi.store.replication.master.MasterFactory in project derby by apache.
the class RawStore method startReplicationMaster.
/**
* Start the replication master role for this database
* @param dbmaster The master database that is being replicated.
* @param host The hostname for the slave
* @param port The port the slave is listening on
* @param replicationMode The type of replication contract.
* Currently only asynchronous replication is supported, but
* 1-safe/2-safe/very-safe modes may be added later.
* @exception StandardException 1) If replication is started on a read-only
* database
* 2) If replication is started when unlogged
* operations are running
* 3) If an error occurs while trying to boot
* the master.
*/
public void startReplicationMaster(String dbmaster, String host, int port, String replicationMode) throws StandardException {
if (isReadOnly()) {
throw StandardException.newException(SQLState.LOGMODULE_DOES_NOT_SUPPORT_REPLICATION);
}
RawTransaction t = xactFactory.findUserTransaction(this, getContextService().getCurrentContextManager(), AccessFactoryGlobals.USER_TRANS_NAME);
// yes do not allow replication to start.
if (t.isBlockingBackup()) {
throw StandardException.newException(SQLState.REPLICATION_UNLOGGED_OPERATIONS_IN_PROGRESS);
}
Properties replicationProps = new Properties();
replicationProps.setProperty(MasterFactory.REPLICATION_MODE, replicationMode);
MasterFactory masterFactory = (MasterFactory) bootServiceModule(true, this, getMasterFactoryModule(), replicationProps);
masterFactory.startMaster(this, dataFactory, logFactory, host, port, dbmaster);
}
use of org.apache.derby.iapi.store.replication.master.MasterFactory in project derby by apache.
the class RawStore method failover.
/**
* @see org.apache.derby.iapi.store.raw.RawStoreFactory#failover(String dbname).
*/
public void failover(String dbname) throws StandardException {
MasterFactory masterFactory = null;
if (isReadOnly()) {
throw StandardException.newException(SQLState.LOGMODULE_DOES_NOT_SUPPORT_REPLICATION);
}
try {
masterFactory = (MasterFactory) findServiceModule(this, getMasterFactoryModule());
} catch (StandardException se) {
throw StandardException.newException(SQLState.REPLICATION_NOT_IN_MASTER_MODE);
}
masterFactory.startFailover();
}
use of org.apache.derby.iapi.store.replication.master.MasterFactory in project derby by apache.
the class RawStore method stopReplicationMaster.
/**
* Stop the replication master role for this database.
*
* @exception StandardException Standard Derby exception policy,
* thrown on error.
*/
public void stopReplicationMaster() throws StandardException {
MasterFactory masterFactory = null;
if (isReadOnly()) {
throw StandardException.newException(SQLState.LOGMODULE_DOES_NOT_SUPPORT_REPLICATION);
}
try {
masterFactory = (MasterFactory) findServiceModule(this, getMasterFactoryModule());
} catch (StandardException se) {
throw StandardException.newException(SQLState.REPLICATION_NOT_IN_MASTER_MODE);
}
masterFactory.stopMaster();
}
Aggregations