Skip to content

Commit

Permalink
Merge pull request #1097 from uronce-cc/lru-clean-up
Browse files Browse the repository at this point in the history
[TACHYON-599] Cleanup LRUEvictor after using narrowed view
  • Loading branch information
haoyuan committed Jul 12, 2015
2 parents 9af906e + 5b184ac commit 22b95fa
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions servers/src/main/java/tachyon/worker/block/evictor/LRUEvictor.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ private StorageDirView selectDirWithRequestedSpace(long bytesToBeAvailable,
* tier, they will be evicted, otherwise, only blocks to be freed in the bottom tier will be
* evicted.
*
* this method is only used in {@link #freeSpace(long, tachyon.worker.block.BlockStoreLocation)}
* this method is only used in {@link #freeSpaceWithView}
*
* @param bytesToBeAvailable bytes to be available after eviction
* @param location target location to evict blocks from
* @param plan the plan to be recursively updated, is empty when first called in
* {@link #freeSpace(long, tachyon.worker.block.BlockStoreLocation)}
* {@link #freeSpaceWithView}
* @return the first StorageDirView in the range of location to evict/move bytes from, or null if
* there is no plan
*/
Expand All @@ -139,8 +139,8 @@ private StorageDirView cascadingEvict(long bytesToBeAvailable, BlockStoreLocatio
if (block.getBlockLocation().belongTo(location)) {
int tierAlias = block.getParentDir().getParentTier().getTierAlias();
int dirIndex = block.getParentDir().getDirIndex();
dirCandidates.add(mManagerView.getTierView(tierAlias).getDirView(dirIndex),
blockId, block.getBlockSize());
dirCandidates.add(mManagerView.getTierView(tierAlias).getDirView(dirIndex), blockId,
block.getBlockSize());
}
}
} catch (IOException ioe) {
Expand Down Expand Up @@ -187,31 +187,7 @@ private StorageDirView cascadingEvict(long bytesToBeAvailable, BlockStoreLocatio
public EvictionPlan freeSpaceWithView(long bytesToBeAvailable, BlockStoreLocation location,
BlockMetadataManagerView view) throws IOException {
mManagerView = view;
return freeSpace(bytesToBeAvailable, location);
}

/**
* This method should only be accessed by {@link freeSpaceWithView} in this class.
* Frees space in the given block store location.
* After eviction, at least one StorageDir in the location
* has the specific amount of free space after eviction. The location can be a specific
* StorageDir, or {@link BlockStoreLocation#anyTier} or {@link BlockStoreLocation#anyDirInTier}.
* The view is generated and passed by the calling {@link BlockStore}.
*
* <P>
* This method returns null if Evictor fails to propose a feasible plan to meet the requirement,
* or an eviction plan with toMove and toEvict fields to indicate how to free space. If both
* toMove and toEvict of the plan are empty, it indicates that Evictor has no actions to take and
* the requirement is already met.
*
* @param availableBytes the amount of free space in bytes to be ensured after eviction
* @param location the location in block store
* @return an eviction plan (possibly with empty fields) to get the free space, or null if no plan
* is feasible
* @throws IOException if given block location is invalid
*/
private EvictionPlan freeSpace(long bytesToBeAvailable, BlockStoreLocation location)
throws IOException {
List<Pair<Long, BlockStoreLocation>> toMove = new ArrayList<Pair<Long, BlockStoreLocation>>();
List<Long> toEvict = new ArrayList<Long>();
EvictionPlan plan = new EvictionPlan(toMove, toEvict);
Expand Down

0 comments on commit 22b95fa

Please sign in to comment.