use of alluxio.master.file.BlockDeletionContext in project alluxio by Alluxio.
the class UfsStatusCacheTest method testFetchCancel.
@Test
public void testFetchCancel() throws Exception {
spyUfs();
doAnswer((Answer<UfsStatus[]>) invocation -> {
Thread.sleep(30 * Constants.HOUR_MS);
return new UfsStatus[] { Mockito.mock(UfsStatus.class) };
}).when(mUfs).listStatus(any(String.class));
mCache.prefetchChildren(new AlluxioURI("/"), mMountTable);
final BlockDeletionContext bdc = mock(BlockDeletionContext.class);
final JournalContext jc = mock(JournalContext.class);
final OperationContext oc = mock(OperationContext.class);
when(oc.getCancelledTrackers()).thenReturn(Lists.newArrayList());
final RpcContext rpcContext = new RpcContext(bdc, jc, oc);
AtomicReference<RuntimeException> ref = new AtomicReference<>(null);
Thread t = new Thread(() -> {
try {
mCache.fetchChildrenIfAbsent(rpcContext, new AlluxioURI("/"), mMountTable);
fail("Should not have been able to fetch children");
} catch (RuntimeException e) {
ref.set(e);
} catch (InterruptedException | InvalidPathException e) {
// do nothing
}
});
t.start();
when(oc.getCancelledTrackers()).thenReturn(Lists.newArrayList(new CallTracker() {
@Override
public boolean isCancelled() {
return true;
}
@Override
public Type getType() {
return Type.GRPC_CLIENT_TRACKER;
}
}));
t.join();
final RuntimeException runtimeException = ref.get();
assertNotNull(runtimeException);
MatcherAssert.assertThat(runtimeException.getMessage(), Matchers.stringContainsInOrder("Call cancelled"));
}
Aggregations