public boolean sync(){
  if (ulog == null) {
    return false;
  }
  log.info(msg() + "START replicas=" + replicas+ " nUpdates="+ nUpdates);
  if (!(ulog.getState() == UpdateLog.State.ACTIVE || ulog.getState() == UpdateLog.State.REPLAYING)) {
    log.error(msg() + "ERROR, update log not in ACTIVE or REPLAY state. " + ulog);
  }
  if (debug) {
    if (startingVersions != null) {
      log.debug(msg() + "startingVersions=" + startingVersions.size()+ " "+ startingVersions);
    }
  }
  for (  String replica : replicas) {
    requestVersions(replica);
  }
  recentUpdates=ulog.getRecentUpdates();
  try {
    ourUpdates=recentUpdates.getVersions(nUpdates);
  }
  finally {
    recentUpdates.close();
  }
  Collections.sort(ourUpdates,absComparator);
  if (startingVersions != null) {
    if (startingVersions.size() == 0) {
      log.warn("no frame of reference to tell if we've missed updates");
      return false;
    }
    Collections.sort(startingVersions,absComparator);
    ourLowThreshold=percentile(startingVersions,0.8f);
    ourHighThreshold=percentile(startingVersions,0.2f);
    long smallestNewUpdate=Math.abs(ourUpdates.get(ourUpdates.size() - 1));
    if (Math.abs(startingVersions.get(0)) < smallestNewUpdate) {
      log.warn(msg() + "too many updates received since start - startingUpdates no longer overlaps with our currentUpdates");
      return false;
    }
    List<Long> newList=new ArrayList<>(ourUpdates);
    for (    Long ver : startingVersions) {
      if (Math.abs(ver) < smallestNewUpdate) {
        newList.add(ver);
      }
    }
    ourUpdates=newList;
  }
 else {
    if (ourUpdates.size() > 0) {
      ourLowThreshold=percentile(ourUpdates,0.8f);
      ourHighThreshold=percentile(ourUpdates,0.2f);
    }
 else {
      log.info(msg() + "DONE.  We have no versions.  sync failed.");
      return false;
    }
  }
  ourUpdateSet=new HashSet<>(ourUpdates);
  requestedUpdateSet=new HashSet<>(ourUpdates);
  for (; ; ) {
    ShardResponse srsp=shardHandler.takeCompletedOrError();
    if (srsp == null)     break;
    boolean success=handleResponse(srsp);
    if (!success) {
      log.info(msg() + "DONE. sync failed");
      shardHandler.cancelAll();
      return false;
    }
  }
  log.info(msg() + "DONE. sync succeeded");
  return true;
}

public boolean sync ( ) { if ( ulog == null ) { return false ; } log . info ( msg ( ) + "START replicas=" + replicas + " nUpdates=" + nUpdates ) ; if ( ! ( ulog . getState ( ) == UpdateLog . State . ACTIVE || ulog . getState ( ) == UpdateLog . State . REPLAYING ) ) { log . error ( msg ( ) + "ERROR, update log not in ACTIVE or REPLAY state. " + ulog ) ; } if ( debug ) { if ( startingVersions != null ) { log . debug ( msg ( ) + "startingVersions=" + startingVersions . size ( ) + " " + startingVersions ) ; } } for ( String replica : replicas ) { requestVersions ( replica ) ; } recentUpdates = ulog . getRecentUpdates ( ) ; try { ourUpdates = recentUpdates . getVersions ( nUpdates ) ; } finally { recentUpdates . close ( ) ; } Collections . sort ( ourUpdates , absComparator ) ; if ( startingVersions != null ) { if ( startingVersions . size ( ) == 0 ) { log . warn ( "no frame of reference to tell if we've missed updates" ) ; return false ; } Collections . sort ( startingVersions , absComparator ) ; ourLowThreshold = percentile ( startingVersions , 0.8f ) ; ourHighThreshold = percentile ( startingVersions , 0.2f ) ; long smallestNewUpdate = Math . abs ( ourUpdates . get ( ourUpdates . size ( ) - 1 ) ) ; if ( Math . abs ( startingVersions . get ( 0 ) ) < smallestNewUpdate ) { log . warn ( msg ( ) + "too many updates received since start - startingUpdates no longer overlaps with our currentUpdates" ) ; return false ; } List < Long > newList = new ArrayList < > ( ourUpdates ) ; for ( Long ver : startingVersions ) { if ( Math . abs ( ver ) < smallestNewUpdate ) { newList . add ( ver ) ; } } ourUpdates = newList ; } else { if ( ourUpdates . size ( ) > 0 ) { ourLowThreshold = percentile ( ourUpdates , 0.8f ) ; ourHighThreshold = percentile ( ourUpdates , 0.2f ) ; } else { log . info ( msg ( ) + "DONE.  We have no versions.  sync failed." ) ; return false ; } } ourUpdateSet = new HashSet < > ( ourUpdates ) ; requestedUpdateSet = new HashSet < > ( ourUpdates ) ; for ( ; ; ) { ShardResponse srsp = shardHandler . takeCompletedOrError ( ) ; if ( srsp == null ) break ; boolean success = handleResponse ( srsp ) ; if ( ! success ) { log . info ( msg ( ) + "DONE. sync failed" ) ; shardHandler . cancelAll ( ) ; return false ; } } log . info ( msg ( ) + "DONE. sync succeeded" ) ; return true ; }
returns true if peer sync was successful , meaning that this core may not be considered to have the latest updates when considering the last n updates between it and it ' s peers . a commit is not performed .
