Search in sources :

Example 1 with AckMessage

use of com.baidu.hugegraph.computer.core.network.message.AckMessage in project hugegraph-computer by hugegraph.

the class NettyServerHandler method ackStartMessage.

private void ackStartMessage(ChannelHandlerContext ctx) {
    AckMessage startAck = new AckMessage(AbstractMessage.START_SEQ);
    ctx.writeAndFlush(startAck).addListener(this.listenerOnWrite);
    this.serverSession.completeStateStart();
    Channel channel = ctx.channel();
    this.handler.onStarted(TransportUtil.remoteConnectionId(channel));
    // Add an schedule task to check and respond ack
    if (this.respondAckTask == null) {
        EventLoop eventExecutors = ctx.channel().eventLoop();
        this.respondAckTask = eventExecutors.scheduleWithFixedDelay(() -> this.checkAndRespondAck(ctx), INITIAL_DELAY, this.serverSession.minAckInterval(), TimeUnit.MILLISECONDS);
    }
}
Also used : AckMessage(com.baidu.hugegraph.computer.core.network.message.AckMessage) EventLoop(io.netty.channel.EventLoop) Channel(io.netty.channel.Channel) SocketChannel(io.netty.channel.socket.SocketChannel)

Example 2 with AckMessage

use of com.baidu.hugegraph.computer.core.network.message.AckMessage in project hugegraph-computer by hugegraph.

the class NettyServerHandler method ackFinishMessage.

private void ackFinishMessage(ChannelHandlerContext ctx, int finishId) {
    AckMessage finishAck = new AckMessage(finishId);
    ctx.writeAndFlush(finishAck).addListener(this.listenerOnWrite);
    this.serverSession.completeStateFinish();
    Channel channel = ctx.channel();
    this.handler.onFinished(TransportUtil.remoteConnectionId(channel));
    // Cancel and remove the task to check respond ack
    if (this.respondAckTask != null) {
        this.respondAckTask.cancel(false);
        this.respondAckTask = null;
    }
}
Also used : AckMessage(com.baidu.hugegraph.computer.core.network.message.AckMessage) Channel(io.netty.channel.Channel) SocketChannel(io.netty.channel.socket.SocketChannel)

Example 3 with AckMessage

use of com.baidu.hugegraph.computer.core.network.message.AckMessage in project hugegraph-computer by hugegraph.

the class NettyServerHandler method ackDataMessage.

private void ackDataMessage(ChannelHandlerContext ctx, int ackId) {
    AckMessage ackMessage = new AckMessage(ackId);
    ctx.writeAndFlush(ackMessage).addListener(this.listenerOnWrite);
    this.serverSession.onDataAckSent(ackId);
}
Also used : AckMessage(com.baidu.hugegraph.computer.core.network.message.AckMessage)

Aggregations

AckMessage (com.baidu.hugegraph.computer.core.network.message.AckMessage)3 Channel (io.netty.channel.Channel)2 SocketChannel (io.netty.channel.socket.SocketChannel)2 EventLoop (io.netty.channel.EventLoop)1