Search in sources :

Example 1 with InternalOperationContext

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();
}
Also used : InternalOperationContext(alluxio.master.file.contexts.InternalOperationContext) CallTracker(alluxio.master.file.contexts.CallTracker) Test(org.junit.Test)

Aggregations

CallTracker (alluxio.master.file.contexts.CallTracker)1 InternalOperationContext (alluxio.master.file.contexts.InternalOperationContext)1 Test (org.junit.Test)1