use of alluxio.master.file.contexts.InternalOperationContext in project alluxio by Alluxio.
the class RpcContextTest method testCallTrackers.
@Test
public void testCallTrackers() throws Throwable {
InternalOperationContext opCtx = new InternalOperationContext();
// Add a call tracker that's always cancelled.
opCtx = opCtx.withTracker(new CallTracker() {
@Override
public boolean isCancelled() {
return true;
}
@Override
public Type getType() {
return Type.GRPC_CLIENT_TRACKER;
}
});
// Add a call tracker that's never cancelled.
opCtx = opCtx.withTracker(new CallTracker() {
@Override
public boolean isCancelled() {
return false;
}
@Override
public Type getType() {
return Type.STATE_LOCK_TRACKER;
}
});
// Create RPC context.
RpcContext rpcCtx = new RpcContext(mMockBDC, mMockJC, opCtx);
// Verify the RPC is cancelled due to tracker that's always cancelled.
assertTrue(rpcCtx.isCancelled());
// Verify cancellation throws.
mException.expect(RuntimeException.class);
rpcCtx.throwIfCancelled();
}
Aggregations