@Test
public void testFileReuseForNextTask() {
JobID jobID = new JobID();
String filePath = f.toURI().toString();
fileCache.createTmpFile("test_file", new DistributedCacheEntry(filePath, false), jobID);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted error", e);
}
fileCache.deleteTmpFile("test_file", new DistributedCacheEntry(filePath, false), jobID);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted error", e);
}
//new task comes after 1 second
try {
Assert.assertTrue("Local cache file should not be deleted when another task comes in 5 seconds!", lfs.exists(fileCache.getTempDir(jobID, "cacheFile")));
} catch (IOException e) {
throw new RuntimeException("Interrupted error", e);
}
fileCache.createTmpFile("test_file", new DistributedCacheEntry(filePath, false), jobID);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted error", e);
}
fileCache.deleteTmpFile("test_file", new DistributedCacheEntry(filePath, false), jobID);
try {
Thread.sleep(7000);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted error", e);
}