Skip to content

Commit

Permalink
Have HeartbeatScheduler throw an exception when await fails
Browse files Browse the repository at this point in the history
  • Loading branch information
aaudiber committed Jul 22, 2016
1 parent caf925d commit 0618182
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 135 deletions.
Expand Up @@ -132,7 +132,8 @@ public static void await(String name) throws InterruptedException {
}

/**
* Waits until the given thread can be executed or the given timeout expires.
* Waits until the given thread can be executed, throwing an unchecked exception of the given
* timeout expires.
*
* @param name a name of the thread to wait for
* @param time the maximum time to wait
Expand All @@ -141,14 +142,14 @@ public static void await(String name) throws InterruptedException {
* else {@code true}
* @throws InterruptedException if the waiting thread is interrupted
*/
public static boolean await(String name, long time, TimeUnit unit) throws InterruptedException {
public static void await(String name, long time, TimeUnit unit) throws InterruptedException {
try (LockResource r = new LockResource(sLock)) {
while (!sTimers.containsKey(name)) {
if (!sCondition.await(time, unit)) {
return false;
throw new RuntimeException(
"Timed out waiting for thread " + name + " to be ready for scheduling");
}
}
}
return true;
}
}
Expand Up @@ -126,14 +126,12 @@ public void run() {
sExecutorService.submit(ht);

// Wait for the DummyHeartbeatExecutor executor to be ready to execute its heartbeat.
Assert.assertTrue("Initial wait failed.",
HeartbeatScheduler.await(mThreadName, 5, TimeUnit.SECONDS));
HeartbeatScheduler.await(mThreadName, 5, TimeUnit.SECONDS);

final int numIterations = 100000;
for (int i = 0; i < numIterations; i++) {
HeartbeatScheduler.schedule(mThreadName);
Assert.assertTrue("Iteration " + i + " failed.",
HeartbeatScheduler.await(mThreadName, 5, TimeUnit.SECONDS));
HeartbeatScheduler.await(mThreadName, 5, TimeUnit.SECONDS);
}

Assert.assertEquals("The executor counter is wrong.", numIterations, executor.getCounter());
Expand Down
26 changes: 12 additions & 14 deletions core/server/src/test/java/alluxio/master/block/BlockMasterTest.java
Expand Up @@ -102,13 +102,15 @@ public void countBytes() throws Exception {
long worker1 = mMaster.getWorkerId(NET_ADDRESS_1);
long worker2 = mMaster.getWorkerId(NET_ADDRESS_2);
List<String> tiers = Arrays.asList("MEM", "SSD");
Map<String, Long> worker1Capacity = ImmutableMap.of("MEM", 10L, "SSD", 20L);
Map<String, Long> worker2Capacity = ImmutableMap.of("MEM", 1000L, "SSD", 2000L);
Map<String, Long> worker1Used = ImmutableMap.of("MEM", 1L, "SSD", 2L);
Map<String, Long> worker2Used = ImmutableMap.of("MEM", 100L, "SSD", 200L);
Map<String, Long> worker1TotalBytesOnTiers = ImmutableMap.of("MEM", 10L, "SSD", 20L);
Map<String, Long> worker2TotalBytesOnTiers = ImmutableMap.of("MEM", 1000L, "SSD", 2000L);
Map<String, Long> worker1UsedBytesOnTiers = ImmutableMap.of("MEM", 1L, "SSD", 2L);
Map<String, Long> worker2UsedBytesOnTiers = ImmutableMap.of("MEM", 100L, "SSD", 200L);
Map<String, List<Long>> noExistingBlocks = new HashMap<>();
mMaster.workerRegister(worker1, tiers, worker1Capacity, worker1Used, noExistingBlocks);
mMaster.workerRegister(worker2, tiers, worker2Capacity, worker2Used, noExistingBlocks);
mMaster.workerRegister(worker1, tiers, worker1TotalBytesOnTiers, worker1UsedBytesOnTiers,
noExistingBlocks);
mMaster.workerRegister(worker2, tiers, worker2TotalBytesOnTiers, worker2UsedBytesOnTiers,
noExistingBlocks);

// Check that byte counts are summed correctly.
Assert.assertEquals(3030, mMaster.getCapacityBytes());
Expand All @@ -133,11 +135,9 @@ public void detectLostWorkers() throws Exception {
mClock.setTimeMs(System.currentTimeMillis() + Constants.HOUR_MS);

// Run the lost worker detector.
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_WORKER_DETECTION, 1,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_WORKER_DETECTION, 1, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.MASTER_LOST_WORKER_DETECTION);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_WORKER_DETECTION, 1,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_WORKER_DETECTION, 1, TimeUnit.SECONDS);

// Make sure the worker is detected as lost.
Set<WorkerInfo> info = mMaster.getLostWorkersInfo();
Expand All @@ -158,11 +158,9 @@ public void workerReregisterRemembersLostWorker() throws Exception {
mClock.setTimeMs(System.currentTimeMillis() + Constants.HOUR_MS);

// Run the lost worker detector.
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_WORKER_DETECTION, 1,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_WORKER_DETECTION, 1, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.MASTER_LOST_WORKER_DETECTION);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_WORKER_DETECTION, 1,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_WORKER_DETECTION, 1, TimeUnit.SECONDS);

// Reregister the worker.
mMaster.getWorkerId(NET_ADDRESS_1);
Expand Down
Expand Up @@ -240,14 +240,12 @@ public void getNewBlockIdForFileTest() throws Exception {

private void executeTtlCheckOnce() throws Exception {
// Wait for the TTL check executor to be ready to execute its heartbeat.
Assert.assertTrue(
HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 1, TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 1, TimeUnit.SECONDS);
// Execute the TTL check executor heartbeat.
HeartbeatScheduler.schedule(HeartbeatContext.MASTER_TTL_CHECK);
// Wait for the TLL check executor to be ready to execute its heartbeat again. This is needed to
// avoid a race between the subsequent test logic and the heartbeat thread.
Assert.assertTrue(
HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 1, TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 1, TimeUnit.SECONDS);
}

@Test
Expand Down Expand Up @@ -1063,8 +1061,7 @@ public void workerHeartbeatTest() throws Exception {
*/
@Test
public void lostFilesDetectionTest() throws Exception {
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_FILES_DETECTION, 5,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_FILES_DETECTION, 5, TimeUnit.SECONDS);

createFileWithSingleBlock(NESTED_FILE_URI);
long fileId = mFileSystemMaster.getFileId(NESTED_FILE_URI);
Expand All @@ -1078,8 +1075,7 @@ public void lostFilesDetectionTest() throws Exception {

// run the detector
HeartbeatScheduler.schedule(HeartbeatContext.MASTER_LOST_FILES_DETECTION);
Assert.assertTrue(HeartbeatScheduler
.await(HeartbeatContext.MASTER_LOST_FILES_DETECTION, 5, TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_FILES_DETECTION, 5, TimeUnit.SECONDS);

fileInfo = mFileSystemMaster.getFileInfo(fileId);
Assert.assertEquals(PersistenceState.LOST.name(), fileInfo.getPersistenceState());
Expand Down
10 changes: 3 additions & 7 deletions tests/src/test/java/alluxio/IntegrationTestUtils.java
Expand Up @@ -19,7 +19,6 @@

import com.google.common.base.Function;
import com.google.common.base.Throwables;
import org.junit.Assert;
import org.powermock.reflect.Whitebox;

import java.util.Arrays;
Expand Down Expand Up @@ -93,8 +92,7 @@ public static String randomString() {
public static void waitForBlocksToBeFreed(final BlockWorker bw, final Long... blockIds) {
try {
// Schedule 1st heartbeat from worker.
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);

// Waiting for the blocks to be added into the heartbeat reportor, so that they will be
Expand All @@ -109,13 +107,11 @@ public Boolean apply(Void input) {
}, 100 * Constants.SECOND_MS);

// Schedule 2nd heartbeat from worker.
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);

// Ensure the 2nd heartbeat is finished.
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
Expand Down
Expand Up @@ -66,10 +66,8 @@ public final void before() throws Exception {

@Test
public void freeAndDeleteIntegrationTest() throws Exception {
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5,
TimeUnit.SECONDS));
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_FILES_DETECTION, 5,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5, TimeUnit.SECONDS);
HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_FILES_DETECTION, 5, TimeUnit.SECONDS);
AlluxioURI filePath = new AlluxioURI(PathUtils.uniqPath());
FileOutStream os = mFileSystem.createFile(filePath, mWriteBoth);
os.write((byte) 0);
Expand Down Expand Up @@ -118,8 +116,7 @@ public void freeAndDeleteIntegrationTest() throws Exception {

// Execute the lost files detection.
HeartbeatScheduler.schedule(HeartbeatContext.MASTER_LOST_FILES_DETECTION);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_FILES_DETECTION, 5,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_FILES_DETECTION, 5, TimeUnit.SECONDS);

// Verify the blocks are not in mLostBlocks.
Assert.assertTrue(bm.getLostBlocks().isEmpty());
Expand Down
Expand Up @@ -75,11 +75,9 @@ public void lockBlockTest1() throws Exception {
FileSystemTestUtils.createByteFile(mFileSystem, uniqPath + numOfFiles, fileSize, mWriteBoth);
files.add(new AlluxioURI(uniqPath + numOfFiles));

Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);

Assert.assertFalse(mFileSystem.getStatus(files.get(0)).getInMemoryPercentage() == 100);
for (int k = 1; k <= numOfFiles; k++) {
Expand Down Expand Up @@ -114,11 +112,9 @@ public void lockBlockTest2() throws Exception {
URIStatus info = mFileSystem.getStatus(files.get(k));
Assert.assertTrue(info.getInMemoryPercentage() == 100);
}
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
URIStatus info = mFileSystem.getStatus(files.get(numOfFiles));
Assert.assertTrue(info.getInMemoryPercentage() == 100);
}
Expand Down Expand Up @@ -148,11 +144,9 @@ public void lockBlockTest3() throws Exception {
}
FileSystemTestUtils.createByteFile(mFileSystem, uniqPath + numOfFiles, fileSize, mWriteBoth);
files.add(new AlluxioURI(uniqPath + numOfFiles));
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
URIStatus info = mFileSystem.getStatus(files.get(0));
Assert.assertFalse(info.getInMemoryPercentage() == 100);
for (int k = 1; k <= numOfFiles; k++) {
Expand Down Expand Up @@ -183,11 +177,9 @@ public void unlockBlockTest1() throws Exception {
}
FileSystemTestUtils.createByteFile(mFileSystem, uniqPath + numOfFiles, fileSize, mWriteBoth);
files.add(new AlluxioURI(uniqPath + numOfFiles));
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
URIStatus info = mFileSystem.getStatus(files.get(0));
Assert.assertFalse(info.getInMemoryPercentage() == 100);
for (int k = 1; k <= numOfFiles; k++) {
Expand Down Expand Up @@ -225,11 +217,9 @@ public void unlockBlockTest2() throws Exception {
URIStatus info = mFileSystem.getStatus(files.get(k));
Assert.assertTrue(info.getInMemoryPercentage() == 100);
}
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
URIStatus info = mFileSystem.getStatus(files.get(numOfFiles));
Assert.assertTrue(info.getInMemoryPercentage() == 100);
}
Expand Down Expand Up @@ -260,11 +250,9 @@ public void unlockBlockTest3() throws Exception {
}
FileSystemTestUtils.createByteFile(mFileSystem, uniqPath + numOfFiles, fileSize, mWriteBoth);
files.add(new AlluxioURI(uniqPath + numOfFiles));
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
URIStatus info = mFileSystem.getStatus(files.get(0));
Assert.assertFalse(info.getInMemoryPercentage() == 100);
for (int k = 1; k <= numOfFiles; k++) {
Expand Down
Expand Up @@ -514,16 +514,14 @@ public void seekAroundLocalBlock() throws Exception {
*/
@Test
public void remoteReadLockTest() throws Exception {
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);

String uniqPath = PathUtils.uniqPath();
for (int k = MIN_LEN + DELTA; k <= MAX_LEN; k += DELTA) {
AlluxioURI uri = new AlluxioURI(uniqPath + "/file_" + k);
FileSystemTestUtils.createByteFile(mFileSystem, uri, mWriteAlluxio, k);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);

long blockId = mFileSystem.getStatus(uri).getBlockIds().get(0);
BlockInfo info = AlluxioBlockStore.get().getInfo(blockId);
Expand All @@ -534,8 +532,7 @@ public void remoteReadLockTest() throws Exception {
Assert.assertEquals(0, is.read());
mFileSystem.delete(uri);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);

// The file has been deleted.
Assert.assertFalse(mFileSystem.exists(uri));
Expand Down
Expand Up @@ -552,11 +552,9 @@ public void ttlExpiredCreateFileTest() throws Exception {
Assert.assertEquals(ttl, folderInfo.getTtl());
// Sleep for the ttl expiration.
CommonUtils.sleepMs(2 * TTL_CHECKER_INTERVAL_MS);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 10, TimeUnit.SECONDS);
HeartbeatScheduler.schedule(HeartbeatContext.MASTER_TTL_CHECK);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 10, TimeUnit.SECONDS);
mThrown.expect(FileDoesNotExistException.class);
mFsMaster.getFileInfo(fileId);
}
Expand Down
21 changes: 7 additions & 14 deletions tests/src/test/java/alluxio/shell/command/PinCommandTest.java
Expand Up @@ -70,10 +70,8 @@ public void setIsPinnedTest() throws Exception {
*/
@Test
public void setPinTest() throws Exception {
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_PIN_LIST_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
HeartbeatScheduler.await(HeartbeatContext.WORKER_PIN_LIST_SYNC, 10, TimeUnit.SECONDS);

AlluxioURI filePathA = new AlluxioURI("/testFileA");
AlluxioURI filePathB = new AlluxioURI("/testFileB");
Expand All @@ -82,28 +80,23 @@ public void setPinTest() throws Exception {

FileSystemTestUtils.createByteFile(mFileSystem, filePathA, WriteType.MUST_CACHE, fileSize);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
Assert.assertTrue(fileExists(filePathA));
Assert.assertEquals(0, mFsShell.run("pin", filePathA.toString()));
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_PIN_LIST_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_PIN_LIST_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_PIN_LIST_SYNC, 10, TimeUnit.SECONDS);

FileSystemTestUtils.createByteFile(mFileSystem, filePathB, WriteType.MUST_CACHE, fileSize);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
Assert.assertTrue(fileExists(filePathB));
Assert.assertEquals(0, mFsShell.run("unpin", filePathB.toString()));
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_PIN_LIST_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_PIN_LIST_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_PIN_LIST_SYNC, 10, TimeUnit.SECONDS);

FileSystemTestUtils.createByteFile(mFileSystem, filePathC, WriteType.MUST_CACHE, fileSize);
HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC);
Assert.assertTrue(HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10,
TimeUnit.SECONDS));
HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 10, TimeUnit.SECONDS);
Assert.assertTrue(fileExists(filePathC));

// fileA is in memory because it is pinned, but fileB should have been evicted to hold fileC.
Expand Down

0 comments on commit 0618182

Please sign in to comment.