Source:
void downloadSnapshot( CatchupAddressProvider addressProvider ) throws StoreCopyFailedException { try { boolean isEmptyStore = localDatabase.isEmpty(); if ( !isEmptyStore ) { localDatabase.start(); localDatabase.stop(); } AdvertisedSocketAddress primary = addressProvider.primary(); StoreId remoteStoreId = remoteStore.getStoreId( primary ); if ( !isEmptyStore && !remoteStoreId.equals( localDatabase.storeId() ) ) { throw new StoreCopyFailedException( "StoreId mismatch and not empty" ); } startStopOnStoreCopy.stop(); localDatabase.stopForStoreCopy(); log.info( "Downloading snapshot from core server at %s", addressProvider ); CoreSnapshot coreSnapshot = catchUpClient.makeBlockingRequest( primary, new CoreSnapshotRequest(), new CatchUpResponseAdaptor<CoreSnapshot>() { @Override public void onCoreSnapshot( CompletableFuture<CoreSnapshot> signal, CoreSnapshot response ) { signal.complete( response ); } } ); if ( isEmptyStore ) { storeCopyProcess.replaceWithStoreFrom( addressProvider, remoteStoreId ); } else { StoreId localStoreId = localDatabase.storeId(); CatchupResult catchupResult = remoteStore.tryCatchingUp( primary, localStoreId, localDatabase.storeDir(), false ); if ( catchupResult == E_TRANSACTION_PRUNED ) { log.info( format( "Failed to pull transactions from %s (%s). They may have been pruned away", addressProvider, primary ) ); localDatabase.delete(); storeCopyProcess.replaceWithStoreFrom( addressProvider, localStoreId ); } else if ( catchupResult != SUCCESS_END_OF_STREAM ) { throw new StoreCopyFailedException( "Failed to download store: " + catchupResult ); } } snapshotService.installSnapshot( coreSnapshot ); log.info( "Core snapshot installed: " + coreSnapshot ); log.info( "Starting local database" ); localDatabase.start(); coreStateMachines.installCommitProcess( localDatabase.getCommitProcess() ); startStopOnStoreCopy.start(); } catch ( StoreCopyFailedException e ) { throw e; } catch ( Throwable e ) { throw new StoreCopyFailedException( e ); } }

Target:
void downloadSnapshot( CatchupAddressProvider addressProvider ) throws StoreCopyFailedException { try { boolean isEmptyStore = localDatabase.isEmpty(); if ( commitStateHelper.hasTxLogs( localDatabase.storeDir() ) ) { localDatabase.start(); localDatabase.stop(); } AdvertisedSocketAddress primary = addressProvider.primary(); StoreId remoteStoreId = remoteStore.getStoreId( primary ); if ( !isEmptyStore && !remoteStoreId.equals( localDatabase.storeId() ) ) { throw new StoreCopyFailedException( "StoreId mismatch and not empty" ); } startStopOnStoreCopy.stop(); localDatabase.stopForStoreCopy(); log.info( "Downloading snapshot from core server at %s", addressProvider ); CoreSnapshot coreSnapshot = catchUpClient.makeBlockingRequest( primary, new CoreSnapshotRequest(), new CatchUpResponseAdaptor<CoreSnapshot>() { @Override public void onCoreSnapshot( CompletableFuture<CoreSnapshot> signal, CoreSnapshot response ) { signal.complete( response ); } } ); if ( isEmptyStore ) { storeCopyProcess.replaceWithStoreFrom( addressProvider, remoteStoreId ); } else { StoreId localStoreId = localDatabase.storeId(); CatchupResult catchupResult = remoteStore.tryCatchingUp( primary, localStoreId, localDatabase.storeDir(), false ); if ( catchupResult == E_TRANSACTION_PRUNED ) { log.info( format( "Failed to pull transactions from (%s). They may have been pruned away", primary ) ); localDatabase.delete(); storeCopyProcess.replaceWithStoreFrom( addressProvider, localStoreId ); } else if ( catchupResult != SUCCESS_END_OF_STREAM ) { throw new StoreCopyFailedException( "Failed to download store: " + catchupResult ); } } snapshotService.installSnapshot( coreSnapshot ); log.info( "Core snapshot installed: " + coreSnapshot ); log.info( "Starting local database" ); localDatabase.start(); coreStateMachines.installCommitProcess( localDatabase.getCommitProcess() ); startStopOnStoreCopy.start(); } catch ( StoreCopyFailedException e ) { throw e; } catch ( Throwable e ) { throw new StoreCopyFailedException( e ); } }