Search in sources :

Example 1 with SnapshotIndexCommit

use of org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit in project crate by crate.

the class BlobRecoverySourceHandler method recoverToTarget.

/**
     * performs the recovery from the local engine to the target
     */
public RecoveryResponse recoverToTarget() {
    final Engine engine = shard.engine();
    assert engine.getTranslog() != null : "translog must not be null";
    try (Translog.View translogView = engine.getTranslog().newView()) {
        logger.trace("captured translog id [{}] for recovery", translogView.minTranslogGeneration());
        final SnapshotIndexCommit phase1Snapshot;
        try {
            phase1Snapshot = shard.snapshotIndex(false);
        } catch (Throwable e) {
            IOUtils.closeWhileHandlingException(translogView);
            throw new RecoveryEngineException(shard.shardId(), 1, "Snapshot failed", e);
        }
        try {
            phase1(phase1Snapshot, translogView);
        } catch (Throwable e) {
            throw new RecoveryEngineException(shard.shardId(), 1, "phase1 failed", e);
        } finally {
            Releasables.closeWhileHandlingException(phase1Snapshot);
        }
        logger.trace("snapshot translog for recovery. current size is [{}]", translogView.totalOperations());
        try (Translog.Snapshot phase2Snapshot = translogView.snapshot()) {
            phase2(phase2Snapshot);
        } catch (Throwable e) {
            throw new RecoveryEngineException(shard.shardId(), 2, "phase2 failed", e);
        }
        finalizeRecovery();
    }
    return response;
}
Also used : RecoveryEngineException(org.elasticsearch.index.engine.RecoveryEngineException) Engine(org.elasticsearch.index.engine.Engine) SnapshotIndexCommit(org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit) Translog(org.elasticsearch.index.translog.Translog)

Aggregations

SnapshotIndexCommit (org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit)1 Engine (org.elasticsearch.index.engine.Engine)1 RecoveryEngineException (org.elasticsearch.index.engine.RecoveryEngineException)1 Translog (org.elasticsearch.index.translog.Translog)1