Search in sources :

Example 1 with MemberEvent

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);
    }
}
Also used : MemberUp(akka.cluster.ClusterEvent.MemberUp) UnreachableMember(akka.cluster.ClusterEvent.UnreachableMember) MemberRemoved(akka.cluster.ClusterEvent.MemberRemoved) MemberEvent(akka.cluster.ClusterEvent.MemberEvent) TransportMessage(io.transport.core.protocol.message.internal.TransportMessage)

Aggregations

MemberEvent (akka.cluster.ClusterEvent.MemberEvent)1 MemberRemoved (akka.cluster.ClusterEvent.MemberRemoved)1 MemberUp (akka.cluster.ClusterEvent.MemberUp)1 UnreachableMember (akka.cluster.ClusterEvent.UnreachableMember)1 TransportMessage (io.transport.core.protocol.message.internal.TransportMessage)1