Skip to content

Commit

Permalink
consider cascading evictor when checking validity of eviction plan
Browse files Browse the repository at this point in the history
remove empty line
  • Loading branch information
cc committed Jul 9, 2015
1 parent 209d3d8 commit b488710
Showing 1 changed file with 43 additions and 8 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -243,19 +243,54 @@ public static boolean blocksInTheSameDir(EvictionPlan plan, BlockMetadataManager
} }


/** /**
* Assert plan is not null and both {@link #blocksInTheSameDir} and {@link #requestSpaceSatisfied} * Assume the plan is returned by a non-cascading evictor, check whether it is legal. a cascading
* to be true. This method is to be called in unit tests, if the return values of the two methods * evictor is an evictor that always tries to move from the target tier to the next tier and
* are not all true, the unit test will fail. * recursively move down 1 tier until finally blocks are evicted from the final tier.
* *
* @param bytesToBeAvailable the requested bytes to be available * @param bytesToBeAvailable the requested bytes to be available
* @param plan the eviction plan * @param plan the eviction plan, should not be null
* @param meta the meta data manager * @param metaManager the meta data manager
* @return true if and only if the plan is not null and both {@link #blocksInTheSameDir} and
* {@link #requestSpaceSatisfied} are true, otherwise false
* @throws IOException when fail to get meta data of a block
*/
public static boolean legalNonCascadingPlan(long bytesToBeAvailable, EvictionPlan plan,
BlockMetadataManager metaManager) throws IOException {
Preconditions.checkNotNull(plan);
return blocksInTheSameDir(plan, metaManager)
&& requestSpaceSatisfied(bytesToBeAvailable, plan, metaManager);
}

/**
* Assume the plan is returned by a cascading evictor, check whether it is legal. for explaination
* of cascading evictor, please refer to {@link #legalNonCascadingPlan}.
*
* @param bytesToBeAvailable the requested bytes to be available
* @param plan the eviction plan, should not be null
* @param metaManager the meta data manager
* @return true
* @throws IOException when fail to get meta data of a block
*/
// TODO: implement this with shared method in LRUEvictor after the
// PR: https://github.com/amplab/tachyon/pull/1079 is merged
public static boolean legalCascadingPlan(long bytesToBeAvailable, EvictionPlan plan,
BlockMetadataManager metaManager) throws IOException {
return true;
}

/**
* only when plan is not null and at least one of {@link #legalCascadingPlan},
* {@link #legalNonCascadingPlan} is true, the assertion will be passed, used in unit test.
*
* @param bytesToBeAvailable the requested bytes to be available
* @param plan the eviction plan, should not be null
* @param metaManager the meta data manager
* @throws IOException when fail to get meta data of a block * @throws IOException when fail to get meta data of a block
*/ */
public static void assertLegalPlan(long bytesToBeAvailable, EvictionPlan plan, public static void assertLegalPlan(long bytesToBeAvailable, EvictionPlan plan,
BlockMetadataManager meta) throws IOException { BlockMetadataManager metaManager) throws IOException {
Assert.assertNotNull(plan); Assert.assertNotNull(plan);
Assert.assertTrue(blocksInTheSameDir(plan, meta)); Assert.assertTrue(legalNonCascadingPlan(bytesToBeAvailable, plan, metaManager)
Assert.assertTrue(requestSpaceSatisfied(bytesToBeAvailable, plan, meta)); || legalCascadingPlan(bytesToBeAvailable, plan, metaManager));
} }
} }

0 comments on commit b488710

Please sign in to comment.