private int getNextAvailDirInTier(StorageTierView tierView, long blockSize) {
    int dirViewIndex = mTierAliasToLastDirMap.get(tierView.getTierViewAlias());
    for (int i = 0; i < tierView.getDirViews().size(); i++) { // try this many times
      dirViewIndex = (dirViewIndex + 1) % tierView.getDirViews().size();
      if (tierView.getDirView(dirViewIndex).getAvailableBytes() >= blockSize) {
        return dirViewIndex;
      }
    }
    return -1;
  }
private int getNextAvailDirInTier ( StorageTierView tierView , long blockSize ) { int dirViewIndex = mTierAliasToLastDirMap . get ( tierView . getTierViewAlias ( ) ) ; for ( int i = 0 ; i < tierView . getDirViews ( ) . size ( ) ; i ++ ) { dirViewIndex = ( dirViewIndex + 1 ) % tierView . getDirViews ( ) . size ( ) ; if ( tierView . getDirView ( dirViewIndex ) . getAvailableBytes ( ) >= blockSize ) { return dirViewIndex ; } } return - 1 ; }
Finds an available dir in a given tier for a block with blockSize.

@param tierView the tier to find a dir
@param blockSize the requested block size
@return the index of the dir if non-negative; -1 if fail to find a dir