public boolean runRepair() throws IOException, InterruptedException {
  _startTimeInMillis=System.currentTimeMillis();
  List<StringTokenRange> localRanges=getLocalRanges(keySpaceName);
  if (localRanges == null) {
    _success=false;
    return false;
  }
  _totalRepairSessions=localRanges.size();
  if (_totalRepairSessions == 0) {
    _log.info("Nothing to repair for keyspace {}",keySpaceName);
    return _success;
  }
  _log.info("Run repair job for {}. Total # local ranges {}",this.keySpaceName,_totalRepairSessions);
  _completedRepairSessions=_lastToken == null ? 0 : indexOfRange(localRanges,_lastToken);
  if (_completedRepairSessions == -1) {
    _log.error("Recorded last working range \"{}\" is not found, starting from beginning",_lastToken);
    _completedRepairSessions=0;
  }
 else {
    _log.info("Last token is {}, progress is {}%, starting repair from token #{}",new Object[]{_lastToken,getProgress(),_completedRepairSessions});
  }
  ScheduledFuture<?> jobMonitorHandle=startMonitor(svcProxy);
  lock.lock();
  try {
    _aborted=false;
    _success=true;
    while (_completedRepairSessions < _totalRepairSessions) {
      String currentDigest=DbRepairRunnable.getClusterStateDigest();
      if (!clusterStateDigest.equals(currentDigest)) {
        _log.error("Cluster state changed from {} to {}, repair failed",clusterStateDigest,currentDigest);
        _success=false;
        break;
      }
      StringTokenRange range=localRanges.get(_completedRepairSessions);
      repairRange(range);
      if (!_success) {
        _log.error("Fail to repair range {} {}. Stopping the job",range.begin,range.end);
        break;
      }
      _lastToken=range.end;
      _completedRepairSessions++;
      _log.info("{} repair sessions finished. Current progress {}%",_completedRepairSessions,getProgress());
    }
  }
  finally {
    lock.unlock();
    jobMonitorHandle.cancel(false);
    _log.info("Stopped repair job monitor");
  }
  if (_success) {
    _lastToken=null;
  }
  long repairMillis=System.currentTimeMillis() - _startTimeInMillis;
  _log.info("Db repair consumes {} ",repairMillis > MIN_MINUTE_FOR_REPAIR_TIME_IN_LOG * TimeUtils.MINUTES ? repairMillis / TimeUtils.MINUTES + " minutes" : repairMillis / TimeUtils.SECONDS + " seconds");
  return _success;
}

public boolean runRepair ( ) throws IOException , InterruptedException { _startTimeInMillis = System . currentTimeMillis ( ) ; List < StringTokenRange > localRanges = getLocalRanges ( keySpaceName ) ; if ( localRanges == null ) { _success = false ; return false ; } _totalRepairSessions = localRanges . size ( ) ; if ( _totalRepairSessions == 0 ) { _log . info ( "Nothing to repair for keyspace {}" , keySpaceName ) ; return _success ; } _log . info ( "Run repair job for {}. Total # local ranges {}" , this . keySpaceName , _totalRepairSessions ) ; _completedRepairSessions = _lastToken == null ? 0 : indexOfRange ( localRanges , _lastToken ) ; if ( _completedRepairSessions == - 1 ) { _log . error ( "Recorded last working range \"{}\" is not found, starting from beginning" , _lastToken ) ; _completedRepairSessions = 0 ; } else { _log . info ( "Last token is {}, progress is {}%, starting repair from token #{}" , new Object [ ] { _lastToken , getProgress ( ) , _completedRepairSessions } ) ; } ScheduledFuture < ? > jobMonitorHandle = startMonitor ( svcProxy ) ; lock . lock ( ) ; try { _aborted = false ; _success = true ; while ( _completedRepairSessions < _totalRepairSessions ) { String currentDigest = DbRepairRunnable . getClusterStateDigest ( ) ; if ( ! clusterStateDigest . equals ( currentDigest ) ) { _log . error ( "Cluster state changed from {} to {}, repair failed" , clusterStateDigest , currentDigest ) ; _success = false ; break ; } StringTokenRange range = localRanges . get ( _completedRepairSessions ) ; repairRange ( range ) ; if ( ! _success ) { _log . error ( "Fail to repair range {} {}. Stopping the job" , range . begin , range . end ) ; break ; } _lastToken = range . end ; _completedRepairSessions ++ ; _log . info ( "{} repair sessions finished. Current progress {}%" , _completedRepairSessions , getProgress ( ) ) ; } } finally { lock . unlock ( ) ; jobMonitorHandle . cancel ( false ) ; _log . info ( "Stopped repair job monitor" ) ; } if ( _success ) { _lastToken = null ; } long repairMillis = System . currentTimeMillis ( ) - _startTimeInMillis ; _log . info ( "Db repair consumes {} " , repairMillis > MIN_MINUTE_FOR_REPAIR_TIME_IN_LOG * TimeUtils . MINUTES ? repairMillis / TimeUtils . MINUTES + " minutes" : repairMillis / TimeUtils . SECONDS + " seconds" ) ; return _success ; }
execute db repair job for local primary ranges on dht ring . if _lasttoken is not null , the repair job starts from _lasttoken it is supposed to execute this method on all nodes of the cluster so that full dht ring is repaired .
