use of alluxio.network.protocol.databuffer.DataBuffer in project alluxio by Alluxio.
the class DataServerReadHandlerTest method cancelRequest.
/**
* Cancels the read request immediately after the read request is sent.
*/
@Test
public void cancelRequest() throws Exception {
long fileSize = PACKET_SIZE * 10 + 1;
populateInputFile(fileSize, 0, fileSize - 1);
RPCProtoMessage readRequest = buildReadRequest(0, fileSize);
Protocol.ReadRequest request = readRequest.getMessage().getMessage();
RPCProtoMessage cancelRequest = new RPCProtoMessage(new ProtoMessage(request.toBuilder().setCancel(true).build()), null);
mChannel.writeInbound(readRequest);
mChannel.writeInbound(cancelRequest);
// Make sure we can still get EOF after cancelling though the read request is not necessarily
// fulfilled.
boolean eof = false;
long maxIterations = 100;
while (maxIterations > 0) {
Object response = waitForOneResponse(mChannel);
DataBuffer buffer = checkReadResponse(response, Protocol.Status.Code.OK);
if (buffer == null) {
eof = true;
break;
}
buffer.release();
maxIterations--;
Assert.assertTrue(mChannel.isOpen());
}
Assert.assertTrue(eof);
}
Aggregations