private IHANotifyReleaseTimeResponse doRunWithBarrierLock() throws Exception {
  final IHANotifyReleaseTimeRequest req2=newHANotifyReleaseTimeRequest(serviceId,req.getNewCommitCounter(),req.getNewCommitTime());
  didNotifyLeader=true;
  final IHANotifyReleaseTimeResponse consensusReleaseTime=leader.notifyEarliestCommitTime(req2);
  lock.lock();
  try {
    if (log.isInfoEnabled())     log.info("Validating consensus releaseTime on follower: consensus=" + consensusReleaseTime);
    final TxState txState=getEarliestActiveTx();
    final long t2=consensusReleaseTime.getCommitTime();
    if (txState != null && txState.getReadsOnCommitTime() < t2) {
      throw new AssertionError("The releaseTime consensus would release a commit point with active readers" + ": consensus=" + consensusReleaseTime + ", earliestActiveTx="+ txState);
    }
    final long newReleaseTime=Math.max(0L,consensusReleaseTime.getCommitTime() - 1);
    if (log.isInfoEnabled())     log.info("Advancing releaseTime on follower: " + newReleaseTime);
    setReleaseTime(newReleaseTime);
  }
  finally {
    lock.unlock();
  }
  return consensusReleaseTime;
}

private IHANotifyReleaseTimeResponse doRunWithBarrierLock ( ) throws Exception { final IHANotifyReleaseTimeRequest req2 = newHANotifyReleaseTimeRequest ( serviceId , req . getNewCommitCounter ( ) , req . getNewCommitTime ( ) ) ; didNotifyLeader = true ; final IHANotifyReleaseTimeResponse consensusReleaseTime = leader . notifyEarliestCommitTime ( req2 ) ; lock . lock ( ) ; try { if ( log . isInfoEnabled ( ) ) log . info ( "Validating consensus releaseTime on follower: consensus=" + consensusReleaseTime ) ; final TxState txState = getEarliestActiveTx ( ) ; final long t2 = consensusReleaseTime . getCommitTime ( ) ; if ( txState != null && txState . getReadsOnCommitTime ( ) < t2 ) { throw new AssertionError ( "The releaseTime consensus would release a commit point with active readers" + ": consensus=" + consensusReleaseTime + ", earliestActiveTx=" + txState ) ; } final long newReleaseTime = Math . max ( 0L , consensusReleaseTime . getCommitTime ( ) - 1 ) ; if ( log . isInfoEnabled ( ) ) log . info ( "Advancing releaseTime on follower: " + newReleaseTime ) ; setReleaseTime ( newReleaseTime ) ; } finally { lock . unlock ( ) ; } return consensusReleaseTime ; }
this code is mutex with runwithbarrierlock ( ) in hajournalserver ' s docastleadersvoteandjoin ( ) .
