use of com.baidu.hugegraph.computer.core.network.buffer.NioBuffer in project hugegraph-computer by hugegraph.
the class NettyEncodeDecodeHandlerTest method testSendMsgWithEncoderExceptionMock.
@Test
public void testSendMsgWithEncoderExceptionMock() throws IOException {
NettyTransportClient client = (NettyTransportClient) this.oneClient();
client.startSession();
int requestId = 1;
int partition = 1;
byte[] bytes = StringEncoding.encode("mock msg");
ByteBuffer buffer = ByteBuffer.wrap(bytes);
NetworkBuffer body = new NioBuffer(buffer);
DataMessage dataMessage = new DataMessage(null, requestId, partition, body);
ChannelFutureListenerOnWrite listener = new ChannelFutureListenerOnWrite(clientHandler);
ChannelFutureListenerOnWrite spyListener = Mockito.spy(listener);
client.channel().writeAndFlush(dataMessage).addListener(spyListener);
Mockito.verify(clientHandler, Mockito.timeout(3000L).times(1)).onChannelActive(Mockito.any());
Mockito.verify(clientHandler, Mockito.timeout(3000L).times(1)).exceptionCaught(Mockito.any(), Mockito.any());
Mockito.verify(spyListener, Mockito.timeout(3000L).times(1)).onFailure(Mockito.any(), Mockito.any());
}
use of com.baidu.hugegraph.computer.core.network.buffer.NioBuffer in project hugegraph-computer by hugegraph.
the class ClientSession method sendAsync.
public synchronized void sendAsync(MessageType messageType, int partition, ByteBuffer buffer) {
E.checkArgument(this.state == TransportState.ESTABLISHED, "The state must be ESTABLISHED instead of %s " + "at sendAsync()", this.state);
int requestId = this.nextRequestId();
NetworkBuffer networkBuffer = new NioBuffer(buffer);
DataMessage dataMessage = new DataMessage(messageType, requestId, partition, networkBuffer);
this.sendFunction.apply(dataMessage);
this.updateFlowBlocking();
}
Aggregations