Examples of EvictStrategy


Examples of tachyon.worker.eviction.EvictStrategy

    createBlockFile(mStorageDirs[1], BlockInfo.computeBlockId(5, 0), 600);
    Thread.sleep(10);
    createBlockFile(mStorageDirs[2], BlockInfo.computeBlockId(6, 0), 500);

    Set<Integer> pinList = new HashSet<Integer>();
    EvictStrategy eviction = new EvictLRU(true);

    pinList.add(1);
    Pair<StorageDir, List<tachyon.worker.hierarchy.BlockInfo>> lruResult =
        eviction.getDirCandidate(mStorageDirs, pinList, 300);
    Assert.assertEquals(mStorageDirs[1], lruResult.getFirst());
    Assert.assertEquals(1, lruResult.getSecond().size());
    Assert.assertEquals(lruResult.getSecond().get(0).getBlockId(), BlockInfo.computeBlockId(2, 0));

    pinList.add(2);
    lruResult = eviction.getDirCandidate(mStorageDirs, pinList, 300);
    Assert.assertEquals(mStorageDirs[2], lruResult.getFirst());
    Assert.assertEquals(1, lruResult.getSecond().size());
    Assert.assertEquals(lruResult.getSecond().get(0).getBlockId(), BlockInfo.computeBlockId(3, 0));

    eviction = new EvictLRU(false);
    lruResult = eviction.getDirCandidate(mStorageDirs, pinList, 300);
    Assert.assertEquals(mStorageDirs[0], lruResult.getFirst());
    Assert.assertEquals(1, lruResult.getSecond().size());
    Assert.assertEquals(lruResult.getSecond().get(0).getBlockId(), BlockInfo.computeBlockId(1, 0));

    lruResult = eviction.getDirCandidate(mStorageDirs, pinList, 1001);
    Assert.assertEquals(null, lruResult);
  }
View Full Code Here

Examples of tachyon.worker.eviction.EvictStrategy

    createBlockFile(mStorageDirs[1], BlockInfo.computeBlockId(5, 0), 300);
    Thread.sleep(10);
    createBlockFile(mStorageDirs[2], BlockInfo.computeBlockId(6, 0), 450);

    Set<Integer> pinList = new HashSet<Integer>();
    EvictStrategy eviction = new EvictPartialLRU(true);

    pinList.add(1);
    Pair<StorageDir, List<tachyon.worker.hierarchy.BlockInfo>> lruResult =
        eviction.getDirCandidate(mStorageDirs, pinList, 600);
    Assert.assertEquals(mStorageDirs[1], lruResult.getFirst());
    Assert.assertEquals(1, lruResult.getSecond().size());
    Assert.assertEquals(lruResult.getSecond().get(0).getBlockId(), BlockInfo.computeBlockId(2, 0));

    pinList.add(2);
    lruResult = eviction.getDirCandidate(mStorageDirs, pinList, 600);
    Assert.assertEquals(mStorageDirs[2], lruResult.getFirst());
    Assert.assertEquals(2, lruResult.getSecond().size());
    Assert.assertEquals(lruResult.getSecond().get(0).getBlockId(), BlockInfo.computeBlockId(3, 0));
    Assert.assertEquals(lruResult.getSecond().get(1).getBlockId(), BlockInfo.computeBlockId(6, 0));

    eviction = new EvictLRU(false);
    lruResult = eviction.getDirCandidate(mStorageDirs, pinList, 400);
    Assert.assertEquals(mStorageDirs[0], lruResult.getFirst());
    Assert.assertEquals(1, lruResult.getSecond().size());
    Assert.assertEquals(lruResult.getSecond().get(0).getBlockId(), BlockInfo.computeBlockId(1, 0));

    lruResult = eviction.getDirCandidate(mStorageDirs, pinList, 1001);
    Assert.assertEquals(null, lruResult);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.