use of akka.cluster.ClusterEvent.MemberEvent in project transporter by wang4ever.
the class AccpetActor method dispatch.
/**
* 转发路由消息
*
* @param msg
*/
private void dispatch(Object msg) {
if (msg instanceof MemberUp) {
MemberUp mUp = (MemberUp) msg;
logger.warn("Member is Up: {}", mUp.member());
// Join cluster node.
this.clusterService.joining(this.getHostAndPort(mUp.member()));
} else if (msg instanceof UnreachableMember) {
UnreachableMember mUnreachable = (UnreachableMember) msg;
logger.warn("Member detected as unreachable: {}", mUnreachable.member());
// Leaving cluster node.
this.clusterService.leaving(this.getHostAndPort(mUnreachable.member()));
} else if (msg instanceof MemberRemoved) {
MemberRemoved mRemoved = (MemberRemoved) msg;
logger.warn("Member is Removed: {}", mRemoved.member());
// Remove cluster node.
this.clusterService.leaving(this.getHostAndPort(mRemoved.member()));
} else if (msg instanceof MemberEvent) {
MemberRemoved mEvent = (MemberRemoved) msg;
logger.warn("Member is event: {}", mEvent.member());
} else if (msg instanceof TransportMessage) {
TransportMessage tmsg = (TransportMessage) msg;
// Routing by point to point or point pairs.
if (!StringUtils.isEmpty(tmsg.getToGroupId())) {
TransportProcessors.sentGroupMsg(channelRepository, tmsg);
if (logger.isInfoEnabled())
logger.info("Actor Forward to toGroupId={}.", tmsg.getToGroupId());
} else if (!StringUtils.isEmpty(tmsg.getToDeviceId())) {
TransportProcessors.sentMsg(channelRepository, tmsg);
if (logger.isInfoEnabled())
logger.info("Actor Forward to toDeviceId={}.", tmsg.getToDeviceId());
}
} else {
this.unhandled(msg);
}
}
Aggregations