public int releaseExtraResources(){
synchronized (lock) {
    int numReleasedResources=0;
    if (requestsQueue.isEmpty()) {
      log.debug("Resource Requests Queue is empty.");
      if (hostAffinityEnabled) {
        List<String> allocatedHosts=getAllocatedHosts();
        for (        String host : allocatedHosts) {
          numReleasedResources+=releaseResourcesForHost(host);
        }
      }
 else {
        numReleasedResources+=releaseResourcesForHost(ANY_HOST);
      }
      clearState();
    }
    return numReleasedResources;
  }
}

public int releaseExtraResources ( ) { synchronized ( lock ) { int numReleasedResources = 0 ; if ( requestsQueue . isEmpty ( ) ) { log . debug ( "Resource Requests Queue is empty." ) ; if ( hostAffinityEnabled ) { List < String > allocatedHosts = getAllocatedHosts ( ) ; for ( String host : allocatedHosts ) { numReleasedResources += releaseResourcesForHost ( host ) ; } } else { numReleasedResources += releaseResourcesForHost ( ANY_HOST ) ; } clearState ( ) ; } return numReleasedResources ; } }
if requestqueue is empty , all extra resources in the buffer should be released and update the entire system ' s state needs to be synchronized because it is modifying shared state buffers
