use of io.dingodb.net.netty.channel.impl.NetServiceConnectionSubChannel in project dingo by dingodb.
the class NetServiceNettyConnection method receive.
@Override
public void receive(Packet<Message> packet) {
ChannelId channelId = packet.header().channelId();
NetServiceConnectionSubChannel channel;
if (channelId == null || (channel = subChannels.get(channelId)) == null) {
throw new RuntimeException("Not found channel for channel id: " + channelId);
}
Logs.packetDbg(false, log, this, packet);
channel.receive(packet);
}
use of io.dingodb.net.netty.channel.impl.NetServiceConnectionSubChannel in project dingo by dingodb.
the class NetServiceNettyConnection method openSubChannel.
@Override
public ConnectionSubChannel<Message> openSubChannel(ChannelId targetChannelId) {
NetServiceConnectionSubChannel channel = subChannels.computeIfAbsent(generateChannelId(), cid -> new NetServiceConnectionSubChannel(cid, targetChannelId, this));
if (log.isDebugEnabled()) {
log.debug("Open channel from [{}] channel [{}], this channel: [{}], caller: [{}]", remoteAddress(), targetChannelId, channel.channelId(), log.isTraceEnabled() ? stackTrace() : stack(3));
}
channel.start();
return channel;
}
use of io.dingodb.net.netty.channel.impl.NetServiceConnectionSubChannel in project dingo by dingodb.
the class NetServiceLocalConnection method receive.
@Override
public void receive(Packet<Message> message) {
ChannelId channelId = message.header().channelId();
NetServiceConnectionSubChannel channel;
if (channelId == null || (channel = subChannels.get(channelId)) == null) {
throw new RuntimeException("Not found channel for channel id: " + channelId);
}
channel.receive(message);
}
use of io.dingodb.net.netty.channel.impl.NetServiceConnectionSubChannel in project dingo by dingodb.
the class NetServiceLocalConnection method closeSubChannel.
@Override
public void closeSubChannel(ChannelId channelId) {
NetServiceConnectionSubChannel subChannel = subChannels.remove(channelId);
if (subChannel == null || subChannel.status() == Channel.Status.CLOSE) {
return;
}
subChannel.status(Channel.Status.CLOSE);
subChannel.close();
}
use of io.dingodb.net.netty.channel.impl.NetServiceConnectionSubChannel in project dingo by dingodb.
the class NetServiceNettyConnection method openSubChannel.
@Override
public NetServiceConnectionSubChannel openSubChannel() {
NetServiceConnectionSubChannel channel = subChannels.computeIfAbsent(generateChannelId(), cid -> new NetServiceConnectionSubChannel(cid, null, this));
Future<Packet<Message>> ack = GenericMessageHandler.instance().waitAck(this, channel.channelId());
channel.send(MessagePacket.connectRemoteChannel(channel.channelId(), channel.nextSeq()));
try {
channel.targetChannelId(ack.get(heartbeat, TimeUnit.SECONDS).header().targetChannelId());
} catch (InterruptedException e) {
closeSubChannel(channel.channelId());
NetError.OPEN_CHANNEL_INTERRUPT.throwFormatError();
} catch (ExecutionException e) {
closeSubChannel(channel.channelId());
log.error("Open channel error, channel id: [{}], caller: [{}]", channel.channelId(), stack(2));
NetError.UNKNOWN.throwFormatError(e.getMessage());
} catch (TimeoutException e) {
closeSubChannel(channel.channelId());
OPEN_CHANNEL_TIME_OUT.throwFormatError();
}
if (log.isDebugEnabled()) {
log.debug("Open channel to [{}] channel [{}], this channel: [{}], caller: [{}]", remoteAddress(), channel.targetChannelId(), channel.channelId(), log.isTraceEnabled() ? stackTrace() : stack(3));
}
channel.start();
return channel;
}
Aggregations