core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java
public RecoveryResponse recoverToTarget() throws IOException {
        try (Translog.View translogView = shard.acquireTranslogView()) {
            logger.trace("captured translog id [{}] for recovery", translogView.minTranslogGeneration());
            final IndexCommit 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 {
                try {
                    shard.releaseSnapshot(phase1Snapshot);
                } catch (IOException ex) {
                    logger.warn("releasing snapshot caused exception", ex);
                }
            }

            logger.trace("snapshot translog for recovery. current size is [{}]", translogView.totalOperations());
            try {
                phase2(translogView.snapshot());
            } catch (Throwable e) {
                throw new RecoveryEngineException(shard.shardId(), 2, "phase2 failed", e);
            }

            finalizeRecovery();
        }
        return response;
    }
/**
     * performs the recovery from the local engine to the target
     */
performs the recovery from the local engine to the target
performs the recovery from the local engine to the target
public RecoveryResponse recoverToTarget() throws IOException {
        try (Translog.View translogView = shard.acquireTranslogView()) {
            logger.trace("captured translog id [{}] for recovery", translogView.minTranslogGeneration());
            final IndexCommit 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 {
                try {
                    shard.releaseSnapshot(phase1Snapshot);
                } catch (IOException ex) {
                    logger.warn("releasing snapshot caused exception", ex);
                }
            }
            logger.trace("snapshot translog for recovery. current size is [{}]", translogView.totalOperations());
            try {
                phase2(translogView.snapshot());
            } catch (Throwable e) {
                throw new RecoveryEngineException(shard.shardId(), 2, "phase2 failed", e);
            }
            finalizeRecovery();
        }
        return response;
    }
public RecoveryResponse recoverToTarget ( ) throws IOException { try ( Translog . View translogView = shard . acquireTranslogView ( ) ) { logger . trace ( "captured translog id [{}] for recovery" , translogView . minTranslogGeneration ( ) ) ; final IndexCommit 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 { try { shard . releaseSnapshot ( phase1Snapshot ) ; } catch ( IOException ex ) { logger . warn ( "releasing snapshot caused exception" , ex ) ; } } logger . trace ( "snapshot translog for recovery. current size is [{}]" , translogView . totalOperations ( ) ) ; try { phase2 ( translogView . snapshot ( ) ) ; } catch ( Throwable e ) { throw new RecoveryEngineException ( shard . shardId ( ) , 2 , "phase2 failed" , e ) ; } finalizeRecovery ( ) ; } return response ; }
performs the recovery from the local engine to the target
performs the recovery from the local engine to the target