Search in sources :

Example 1 with DateTieredCompactionRequest

use of org.apache.hadoop.hbase.regionserver.compactions.DateTieredCompactionRequest in project hbase by apache.

the class AbstractTestDateTieredCompactionPolicy method compactEquals.

protected void compactEquals(long now, ArrayList<StoreFile> candidates, long[] expectedFileSizes, long[] expectedBoundaries, boolean isMajor, boolean toCompact) throws IOException {
    ManualEnvironmentEdge timeMachine = new ManualEnvironmentEdge();
    EnvironmentEdgeManager.injectEdge(timeMachine);
    timeMachine.setValue(now);
    DateTieredCompactionRequest request;
    DateTieredCompactionPolicy policy = (DateTieredCompactionPolicy) store.storeEngine.getCompactionPolicy();
    if (isMajor) {
        for (StoreFile file : candidates) {
            ((MockStoreFile) file).setIsMajor(true);
        }
        assertEquals(toCompact, policy.shouldPerformMajorCompaction(candidates));
        request = (DateTieredCompactionRequest) policy.selectMajorCompaction(candidates);
    } else {
        assertEquals(toCompact, policy.needsCompaction(candidates, ImmutableList.<StoreFile>of()));
        request = (DateTieredCompactionRequest) policy.selectMinorCompaction(candidates, false, false);
    }
    List<StoreFile> actual = Lists.newArrayList(request.getFiles());
    assertEquals(Arrays.toString(expectedFileSizes), Arrays.toString(getSizes(actual)));
    assertEquals(Arrays.toString(expectedBoundaries), Arrays.toString(request.getBoundaries().toArray()));
}
Also used : DateTieredCompactionRequest(org.apache.hadoop.hbase.regionserver.compactions.DateTieredCompactionRequest) DateTieredCompactionPolicy(org.apache.hadoop.hbase.regionserver.compactions.DateTieredCompactionPolicy) ManualEnvironmentEdge(org.apache.hadoop.hbase.util.ManualEnvironmentEdge)

Aggregations

DateTieredCompactionPolicy (org.apache.hadoop.hbase.regionserver.compactions.DateTieredCompactionPolicy)1 DateTieredCompactionRequest (org.apache.hadoop.hbase.regionserver.compactions.DateTieredCompactionRequest)1 ManualEnvironmentEdge (org.apache.hadoop.hbase.util.ManualEnvironmentEdge)1