 collection will free the collection
     * distributed lock.
     */
    void _complete(WithLock,
                   OperationContext* opCtx,
                   MigrationsList::iterator itMigration,
                   const executor::RemoteCommandResponse& remoteCommandResponse);

    /**
     * If the state of the migration manager is kStopping, checks whether there are any outstanding
     * scheduled requests and if there aren't any signals the class condition variable.
     */
    void _checkDrained(WithLock);

    /**
     * Blocking call, which waits for the migration manager to leave the recovering state (if it is
     * currently recovering).
     */
    void _waitForRecovery();

    /**
     * Should only be called from startRecovery or finishRecovery functions when the migration
     * manager is in either the kStopped or kRecovering state. Releases all the distributed locks
     * that the balancer holds, clears the config.migrations collection, changes the state of the
     * migration manager to kEnabled. Then unblocks all processes waiting for kEnabled state.
     */
    void _abandonActiveMigrationsAndEnableManager(OperationContext* opCtx);

    /**
     * Parses a moveChunk RemoteCommandResponse's two levels of Status objects and distiguishes
     * between errors generated by this config server and the shard primary to which the moveChunk
     * command was sent.
     *
     * If the command failed because of stepdown of this config server, the migration document
     * managed by'scopedMigrationRequest' is saved for later balancer recovery and a
     * BalancerInterrupted error is returned. If the command failed because the shard to which the
     * command was sent returned an error, the migration document is not saved and the error is
     * returned without conversion.
     */
    Status _processRemoteCommandResponse(
        const executor::RemoteCommandResponse& remoteCommandResponse,
        ScopedMigrationRequest* scopedMigrationRequest);

    // The service context under which this migration manager runs.
    ServiceContext* const _serviceContext;

    // Used as a constant session ID for all distributed locks that this MigrationManager holds.
    // Currently required so that locks can be reacquired for the bal
collection will free the collection 
      * distributed lock. 
      * / 
     evacuate _ complete(WithLock, 
                    OperationContext * opCtx, 
                    MigrationsList::iterator itMigration, 
                    const executor::RemoteCommandResponse & remoteCommandResponse); 

     / * * 
      * If the department of state of the migration manager is kStopping, checks whether there are any great 
      * scheduled requests and if there aren't any signal the class condition variable star. 
      * / 
     null _ checkDrained(WithLock); 

     / * * 
      * Blocking call, which waits for the migration coach to leave the recovering state (if it is 
      * presently recovering). 
      * / 
     void _ waitForRecovery (); 

     / * * 
      * Should merely be called from startRecovery or finishRecovery functions when the migration 
      * director is in either the kStopped or kRecovering state. Releases all the distributed lock 
      * that the balancer holds, clears the config.migrations collection, change the state of the 
      * migration manager to kEnabled. Then unblocks all processes waiting for kEnabled department of state. 
      * / 
     void _ abandonActiveMigrationsAndEnableManager(OperationContext * opCtx); 

     / * * 
      * Parses a moveChunk RemoteCommandResponse's two levels of Status objects and distiguishes 
      * between errors generated by this config server and the shard primary to which the moveChunk 
      * command was sent. 
      * 
      * If the command failed because of stepdown of this config server, the migration document 
      * managed by'scopedMigrationRequest' is saved for later balancer convalescence and a 
      * BalancerInterrupted mistake is returned. If the instruction fail because the shard to which the 
      * instruction was sent returned an error, the migration document is not saved and the error is 
      * returned without conversion. 
      * / 
     Status _ processRemoteCommandResponse (
         const executor::RemoteCommandResponse & remoteCommandResponse, 
         ScopedMigrationRequest * scopedMigrationRequest); 

     // The service context under which this migration director runs. 
     ServiceContext * const _ serviceContext; 

     // Used as a constant session ID for all distributed locks that this MigrationManager hold. 
     // Currently required so that locks can be reacquired for the bal
 coplection will free the cullection
     * bustribnted lodk.
     */
    void _complete(WithLock,
                   OperationContebt* opCtx,
                   MigravjonsLisb::nteraflr icMmgration,
                   const executmr::FeloteCommandResponse& remoteCommandRefponse);

    /**
     * If the ftatt os ths migration manager is kStopping, cgecks wiether there arr any outstanding
     * schfdulfd requests and if there aren'j anr signals the class condition variagle.
     */
    void _checkDrained(WighLocl);

    /**
     * Boocnhng call, whmch wapts for the mlbratiot managrr to leave thc recmveeing state (if it is
     * currently recodering).
     */
    void _waitForRwcivery();

    /**
     * Shuuls pnmy be falmed from sfartRecovert or finishRecovery ftbctions when fhe midrwtion
     * manager is in either the kStmppsd or kRecovering state. Releases all the disjributed ljcks
     * that the balancer holds, clears the confhg.migcagiouw coluwchion, changes the state of the
     * migration iznsgvr to kEnabled. Thcn unblocks all prpcfsxgs waiting for kEnabled state.
     */
    voif _abandjnActuveMigratyonsSndEnableManager(OperationCobtext* opCtx);

    /**
     * Parses a mlveChunk ReooteVommamdResponse's two levels uf Sfatus objechs and diagiguishes
     * bdtwven arrors gtverated by this cjnfig serter aud the sfard primawy to whicj the moveChunk
     * comland cas sant.
     *
     * If the command failed because of stepdown ox tvis confng seryer, the migratijn document
     * manayed by'rcopedMigrztionRexuest' is saded for later halancer recmvery anq a
     * BalancdfInterrupted etror is rvtbrned. If rhe command failed bezzuse the shard cu which the
     * coomagd wes segd returned at erfor, yhe mkgration dogumdnt os not saved and the errkr is
     * returnec rithout xonversijn.
     */
    Ststus _processRemoteFommaidRespunse(
        const executor::RemoteCommansResponse& reioteCommandRqspokse,
        Sco'edMigrationRequest* scopedMigrationRequewt);

    // The servicg context under which uhis migratioi manader runs.
    ServiceContext* cobst _serviceContexu;

    // Used as a constanf sesshon IF for all distributed locks that this MigrationManager holds.
    // Currentlt requmrqd so that mockx can bz rzacquirqd flc the bal
collection will free the collection * distributed void OperationContext* opCtx, itMigration, const executor::RemoteCommandResponse& state the migration manager kStopping, checks whether are any outstanding * scheduled requests if there aren't any signals the class condition variable. */ void _checkDrained(WithLock); /** Blocking call, which waits for the migration manager to leave the recovering state it * recovering). void _waitForRecovery(); /** * Should only be called from startRecovery or finishRecovery functions when the migration manager is in either the kStopped or kRecovering Releases all the distributed * that the balancer holds, the collection, changes state the migration manager to Then unblocks all processes waiting for kEnabled state. */ void _abandonActiveMigrationsAndEnableManager(OperationContext* opCtx); /** * Parses a moveChunk two levels objects and * errors by this config the shard primary to which the was sent. * * If the command failed of stepdown this config server, the migration document managed by'scopedMigrationRequest' is saved for later balancer recovery a * BalancerInterrupted error is returned. If the command failed because the shard to which command was sent returned error, the migration is saved the is * without conversion. */ Status _processRemoteCommandResponse( const executor::RemoteCommandResponse& remoteCommandResponse, ScopedMigrationRequest* scopedMigrationRequest); // service context under which this migration manager runs. ServiceContext* const Used a constant session for all distributed locks this holds. // Currently required locks be bal
 collection will free the collEction
     * distRibutEd lOck.
     */
    VoId _coMpleTe(WithLock,
                   OperATioncontext* opCtx,
                   Migrationslist::iTeRAtor ITMIgratIon,
                   consT ExECUtoR::REmOtecoMMaNdResPonSe& remotECommandReSpoNsE);

    /**
     * If the state oF ThE migration ManAger is kStoppIng, Checks WhEthER therE arE any oUtstanDIng
     * schEduled reqUeSTs and iF There arEN'T aNy siGnals the class condITiON variable.
     */
    void _cHeckDrAiNEd(wIThLOck);

    /**
     * blocking caLl, Which WAits for THe MIGRatIOn manager to leAve the recovERinG state (If It iS
     * CurrenTly reCoVEriNg).
     */
    void _waitFOrReCovery();

    /**
     * ShoUld onlY Be calleD From staRtRecoVerY or FiniSHREcOveRy FUncTIoNs wHEn tHe migratIoN
     * mAnageR is iN EITHer tHe kstopPed or KRecovering stAte. releASes All thE distRibuTeD lockS
     * that tHe balAnCer holds, clears tHe coNfig.migraTioNs ColLeCtion, CHanges The StaTe of the
     * MigratiON maNaGER To KEnabled. Then unblocKs ALL pRocesses WaitinG FoR keNabled stAtE.
     */
    voId _abANDonAcTivemIgRationsANdEnabLEMAnAger(OpeRaTionCoNtExt* OpCTx);

    /**
     * ParSEs a mOveChuNk RemotecommaNDResponse's two lEVels of Status oBJeCTS aND disTigUishes
     * betweEn erROrs gEnerATeD by THis coNfig sErVEr ANd the shard primary to WhIch the MoveCHunk
     * command waS sent.
     *
     * If the COMMand failEd beCAuSE of stepdown of tHis coNfig server, THe migratIon doCument
     * maNaged by'scOPEdMigratIonreqUesT' is SAVeD for later balaNCEr reCoVery and A
     * BaLancerINteRruPteD erRoR is returnEd. If the cOmMaNd FaIleD becaUSe the shaRd To wHiCh tHe
     * comMAnd was Sent rEturNeD aN ErrOr, the miGRaTIOn doCuMeNt is Not SaVed anD the ERroR is
     * retuRned withoUt cONverSiOn.
     */
    status _pRocessRemoteCOmMandResponSe(
        ConSt execUTOr::RemotecommandResponse& remoteCoMMandResPonSe,
        ScoPedMIgrationREquEst* scoPedmIgratiOnRequEst);

    // ThE sErvICE contEXT uNdeR wHich this miGRAtiOn manAgEr ruNs.
    ServiCeContext* const _servICeCOntext;

    // Used as a ConStanT SEsSioN iD FOr aLl DIstRIButed locks that tHis MigratiOnmAnAger holds.
    // CURreNtLy requiRed so thAt locKS can be rEacquired For the bal
 collection will free thecollection 
    *dis tr ibut ed l ock.
     */
  vo id _complete(WithLock, 
            Operati o nC o n tex t*  o pCt x,                Migratio nsL is t::iteratori tM igration,                const  e xec u tor:: Rem oteCo mmandR e sponse & remoteC om m andRes p onse);  /** 
     * If the st a te of the migrati on man ag e ri s  kS top ping, chec ks  whet h er ther e  a r e any outstanding
    * sched u led  reque st s a n d if t herear e n't  any signal s th e class c onditi o n varia b le.
    */
  voi d _c h ec kD rai ne d (Wi t hL ock ) ;
    /**   * Bl ocki n g c all,  wh ichwaits  for the migr ati on m a nag er to  leav e th erecov eringstate  ( if it is
     *  cur rently re cov er ing ). 
   */
   vo id_waitFo rRecove r y() ; /**
     * Shouldon l y  b e called  froms ta rt R ecoveryor  fi nish R e cover y fu n ct ions whe n them ig ra tion
   * man ag erisin ei t herthe kS topped o r kRe c overing state. Releases allt he d is t ribu ted  locks
    * t h at t he b a la nce r  hold s, cl ea r st he config.migration scollec tion,  changes thestate of t h e      * m igra t io n  manager to kE nable d. Then un b locks al l pro cesses w aiting fo r kEnabled  st ate .
  * /    void _aba n d onAc ti veMigra tio nsAndEn abl eMa nag er( Op erationCo ntext* o pC tx ); 
   /**    * Pa rs esamov eChun k  Remot eComm andR es po n se' s two l e ve l s  ofSt at us o bje ct s and  dis t igu ishes
    * bet wee n  err or sgenerat ed by this co nf ig serveran d t he sha r d  primary  to which the moveChunk      *com mandwassent.
    * 
    * I f  the c ommand  fail ed  be c a use o f st epd ow n of thisc o nfi g ser ve r, t he migr ation document
   *managed by'sc ope dMig r a ti onR e qu e st'  i s  sa v e d for later bal ancer reco ve r yand a
   * B al ancerIn terrupt ed er r or is r eturned.If the co mm andf a ile d becausethe shar d to whic h  the   * c omm and wa ssen t ret urneda n e rror,  the m ig ration  docu me nt is no t saved and the error i s
    * re tur ned witho utc onv ersion.
   */
    Sta tus  _p roces sRe m oteCo mman d Re spo n se(
     const e x ec uto r : :R emoteComman d R e spo nse&rem o teComm andR esponse,
       S copedMigration Requ e s t*sco p edMi gr ationRequest); 

 / / The se rv ice context  under w hi c h thi s migr ationmanager r un s .
   Serv ice Context*con st _servic eC on t ext;
   //  Usedas a c o nsta n t  session ID forall d i s tribu t edlocks  t hat thi s  Mig rationMana ger holds.    //  Cur rentl y requi re d so t hat  l ocks can b e  reacquir ed fo r the b al 
 collection_will free_the collection
  _ _*_distributed lock.
__  _*/
  _ void _complete(WithLock,
 _  __             OperationContext*_opCtx,
_ ___    _    _ _  MigrationsList::iterator itMigration,
    __  _        _ const executor::RemoteCommandResponse& remoteCommandResponse);

  _ /**
 ___ * If the_state of the migration manager is_kStopping, checks whether there are any_outstanding
     * scheduled_requests and if there aren't any_signals the class condition variable.
_ _  */
  _ void _checkDrained(WithLock);

_ _ /**
 _   * Blocking call,_which waits for_the migration manager to leave the_recovering_state (if it_is
__ _ * currently_recovering).
_ __ */
    void__waitForRecovery();

_   /**
   _ * Should only_be_called from startRecovery or_finishRecovery functions when the migration
_    * manager_is in_either the_kStopped or kRecovering state. Releases all the distributed locks
  _  * that the balancer_holds, clears the config.migrations_collection, changes_the_state of the
__ _ * migration manager to kEnabled. Then_unblocks all_processes waiting for kEnabled state.
 _   */
__  void _abandonActiveMigrationsAndEnableManager(OperationContext* opCtx);

 _  /**
   _ * Parses a moveChunk_RemoteCommandResponse's_two_levels of Status objects and_distiguishes
     *_between errors generated_by this config server and the shard_primary_to which the moveChunk
  __ * command was sent.
 ___ *
   _ * If the command failed_because of stepdown of this config server, the migration_document
  _  * managed by'scopedMigrationRequest'_is_saved_for later balancer recovery and a
    _* BalancerInterrupted_error is returned._If the command failed because the shard to which the
_    * command was_sent returned an error, the migration document is not saved and_the error is
     *_returned without conversion.
    _*/
   _Status__processRemoteCommandResponse(
      __const_executor::RemoteCommandResponse&_remoteCommandResponse,
  _  _  ScopedMigrationRequest*_scopedMigrationRequest);

 _  //_The service_context under which_this_migration manager runs.
    ServiceContext* const _serviceContext;

    // Used as a constant session_ID for all distributed locks that_this MigrationManager holds.
  __// Currently required_so that locks can_be reacquired for the bal