@@ -0,0 +1,2310 @@
+/*%0A * Licensed to the University of California, Berkeley under one or more contributor license%0A * agreements. See the NOTICE file distributed with this work for additional information regarding%0A * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance with the License. You may obtain a%0A * copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software distributed under the License%0A * is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express%0A * or implied. See the License for the specific language governing permissions and limitations under%0A * the License.%0A */%0A%0Apackage tachyon.worker.block.evictor;%0A%0Aimport tachyon.worker.block.BlockMetadataManagerView;%0Aimport tachyon.worker.block.BlockStoreLocation;%0Aimport tachyon.worker.block.meta.StorageDirView;%0Aimport tachyon.worker.block.meta.StorageTierView;%0A%0A/**%0A * Utility functions for the evictor package%0A */%0Apublic class EvictorUtils %7B%0A%0A  /**%0A   * @return a StorageDirView in the range of location that already has availableBytes larger than%0A   *         bytesToBeAvailable, otherwise null%0A   */%0A  public static StorageDirView selectDirWithRequestedSpace(long bytesToBeAvailable,%0A      BlockStoreLocation location, BlockMetadataManagerView mManagerView) %7B%0A    if (location.equals(BlockStoreLocation.anyTier())) %7B%0A      for (StorageTierView tierView : mManagerView.getTierViews()) %7B%0A        for (StorageDirView dirView : tierView.getDirViews()) %7B%0A          if (dirView.getAvailableBytes() %3E= bytesToBeAvailable) %7B%0A            return dirView;%0A          %7D%0A        %7D%0A      %7D%0A      return null;%0A    %7D%0A%0A    int tierAlias = location.tierAlias();%0A    StorageTierView tierView = mManagerView.getTierView(tierAlias);%0A    if (location.equals(BlockStoreLocation.anyDirInTier(tierAlias))) %7B%0A      for (StorageDirView dirView : tierView.getDirViews()) %7B%0A        if (dirView.getAvailableBytes() %3E= bytesToBeAvailable) %7B%0A          return dirView;%0A        %7D%0A      %7D%0A      return null;%0A    %7D%0A%0A    StorageDirView dirView = tierView.getDirView(location.dir());%0A    return (dirView.getAvailableBytes() %3E= bytesToBeAvailable) ? dirView : null;%0A  %7D%0A  %0A%7D%0A

add utility function of evictor