use of org.apache.asterix.common.replication.IReplicationManager in project asterixdb by apache.
the class StartReplicationServiceTask method perform.
@Override
public void perform(IControllerService cs) throws HyracksDataException {
INcApplicationContext appContext = (INcApplicationContext) cs.getApplicationContext();
try {
//Open replication channel
appContext.getReplicationChannel().start();
final IReplicationManager replicationManager = appContext.getReplicationManager();
//Check the state of remote replicas
replicationManager.initializeReplicasState();
//Start replication after the state of remote replicas has been initialized.
replicationManager.startReplicationThreads();
} catch (Exception e) {
throw HyracksDataException.create(e);
}
}
use of org.apache.asterix.common.replication.IReplicationManager in project asterixdb by apache.
the class ReplicationCheckpointManager method tryCheckpoint.
/***
* Attempts to perform a soft checkpoint at the specified {@code checkpointTargetLSN}.
* If a checkpoint cannot be captured due to datasets having LSN < {@code checkpointTargetLSN},
* an asynchronous flush is triggered on them. If the checkpoint fails due to a replica index,
* a request is sent to the primary replica of the index to flush it.
* When a checkpoint is successful, all transaction log files that end with
* LSN < {@code checkpointTargetLSN} are deleted.
*/
@Override
public synchronized long tryCheckpoint(long checkpointTargetLSN) throws HyracksDataException {
LOGGER.info("Attemping soft checkpoint...");
final long minFirstLSN = txnSubsystem.getRecoveryManager().getMinFirstLSN();
boolean checkpointSucceeded = minFirstLSN >= checkpointTargetLSN;
if (!checkpointSucceeded) {
// Flush datasets with indexes behind target checkpoint LSN
final IDatasetLifecycleManager datasetLifecycleManager = txnSubsystem.getAsterixAppRuntimeContextProvider().getDatasetLifecycleManager();
datasetLifecycleManager.scheduleAsyncFlushForLaggingDatasets(checkpointTargetLSN);
// Request remote replicas to flush lagging indexes
final IReplicationManager replicationManager = txnSubsystem.getAsterixAppRuntimeContextProvider().getAppContext().getReplicationManager();
try {
replicationManager.requestFlushLaggingReplicaIndexes(checkpointTargetLSN);
} catch (IOException e) {
throw new HyracksDataException(e);
}
}
capture(minFirstLSN, false);
if (checkpointSucceeded) {
txnSubsystem.getLogManager().deleteOldLogFiles(minFirstLSN);
LOGGER.info(String.format("soft checkpoint succeeded with at LSN(%s)", minFirstLSN));
}
return minFirstLSN;
}
Aggregations