Search in sources :

Example 1 with MasterFactory

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);
}
Also used : RawTransaction(org.apache.derby.iapi.store.raw.xact.RawTransaction) UpdateServiceProperties(org.apache.derby.impl.services.monitor.UpdateServiceProperties) Properties(java.util.Properties) MasterFactory(org.apache.derby.iapi.store.replication.master.MasterFactory)

Example 2 with MasterFactory

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();
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) MasterFactory(org.apache.derby.iapi.store.replication.master.MasterFactory)

Example 3 with MasterFactory

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();
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) MasterFactory(org.apache.derby.iapi.store.replication.master.MasterFactory)

Aggregations

MasterFactory (org.apache.derby.iapi.store.replication.master.MasterFactory)3 StandardException (org.apache.derby.shared.common.error.StandardException)2 Properties (java.util.Properties)1 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)1 UpdateServiceProperties (org.apache.derby.impl.services.monitor.UpdateServiceProperties)1