use of io.dingodb.server.protocol.code.RaftServiceCode in project dingo by dingodb.
the class CoordinatorStateMachine method onMessage.
private void onMessage(Message message, Channel channel) {
ByteBuffer buffer = ByteBuffer.wrap(message.toBytes());
Code code = Code.valueOf(PrimitiveCodec.readZigZagInt(buffer));
if (code instanceof RaftServiceCode) {
switch((RaftServiceCode) code) {
case GET_LEADER_LOCATION:
getLeaderLocation(channel);
break;
case GET_ALL_LOCATION:
getAllLocation(channel);
break;
case LISTEN_LEADER:
log.info("New leader listener channel, remote: [{}]", channel.remoteAddress());
leaderListener.add(channel);
channel.closeListener(leaderListener::remove);
break;
default:
channel.send(UNSUPPORTED_CODE.message());
break;
}
} else if (code instanceof BaseCode) {
switch((BaseCode) code) {
case PING:
channel.registerMessageListener(this::onMessage);
channel.send(PONG.message());
break;
case OTHER:
break;
default:
channel.send(UNSUPPORTED_CODE.message());
break;
}
}
}
Aggregations