类 ServerMemberManager

  • 所有已实现的接口:
    java.util.EventListener, org.springframework.context.ApplicationListener<org.springframework.boot.web.context.WebServerInitializedEvent>

    @Component("serverMemberManager")
    public class ServerMemberManager
    extends java.lang.Object
    implements org.springframework.context.ApplicationListener<org.springframework.boot.web.context.WebServerInitializedEvent>
    Cluster node management in Nacos.

    init() Cluster node manager initialization shutdown() The cluster node manager is down getSelf() Gets local node information getServerList() Gets the cluster node dictionary getMemberAddressInfos() Gets the address information of the healthy member node allMembers() Gets a list of member information objects allMembersWithoutSelf() Gets a list of cluster member nodes with the exception of this node hasMember(String) Is there a node memberChange(Collection) The final node list changes the method, making the full size more memberJoin(Collection) Node join, can automatically trigger memberLeave(Collection) When the node leaves, only the interface call can be manually triggered update(Member) Update the target node information isUnHealth(String) Whether the target node is healthy initAndStartLookup() Initializes the addressing mode

    作者:
    liaochuntao
    • 字段详细资料

      • asyncRestTemplate

        private final com.alibaba.nacos.common.http.client.NacosAsyncRestTemplate asyncRestTemplate
      • DEFAULT_SERVER_PORT

        private static final int DEFAULT_SERVER_PORT
        另请参阅:
        常量字段值
      • SERVER_PORT_PROPERTY

        private static final java.lang.String SERVER_PORT_PROPERTY
        另请参阅:
        常量字段值
      • SPRING_MANAGEMENT_CONTEXT_NAMESPACE

        private static final java.lang.String SPRING_MANAGEMENT_CONTEXT_NAMESPACE
        另请参阅:
        常量字段值
      • MEMBER_CHANGE_EVENT_QUEUE_SIZE_PROPERTY

        private static final java.lang.String MEMBER_CHANGE_EVENT_QUEUE_SIZE_PROPERTY
        另请参阅:
        常量字段值
      • DEFAULT_MEMBER_CHANGE_EVENT_QUEUE_SIZE

        private static final int DEFAULT_MEMBER_CHANGE_EVENT_QUEUE_SIZE
        另请参阅:
        常量字段值
      • isUseAddressServer

        private static boolean isUseAddressServer
      • DEFAULT_TASK_DELAY_TIME

        private static final long DEFAULT_TASK_DELAY_TIME
        另请参阅:
        常量字段值
      • serverList

        private volatile java.util.concurrent.ConcurrentSkipListMap<java.lang.String,​Member> serverList
        Cluster node list.
      • isInIpList

        private static volatile boolean isInIpList
        Is this node in the cluster list.
      • port

        private int port
        port.
      • localAddress

        private java.lang.String localAddress
        Address information for the local node.
      • lookup

        private MemberLookup lookup
        Addressing pattern instances.
      • self

        private volatile Member self
        self member obj.
      • memberAddressInfos

        private volatile java.util.Set<java.lang.String> memberAddressInfos
        here is always the node information of the "UP" state.
    • 构造器详细资料

      • ServerMemberManager

        public ServerMemberManager​(javax.servlet.ServletContext servletContext)
                            throws java.lang.Exception
        抛出:
        java.lang.Exception
    • 方法详细资料

      • init

        protected void init()
                     throws com.alibaba.nacos.api.exception.NacosException
        抛出:
        com.alibaba.nacos.api.exception.NacosException
      • initMemberAbilities

        private com.alibaba.nacos.api.ability.ServerAbilities initMemberAbilities()
      • registerClusterEvent

        private void registerClusterEvent()
      • initAndStartLookup

        private void initAndStartLookup()
                                 throws com.alibaba.nacos.api.exception.NacosException
        抛出:
        com.alibaba.nacos.api.exception.NacosException
      • switchLookup

        public void switchLookup​(java.lang.String name)
                          throws com.alibaba.nacos.api.exception.NacosException
        switch look up.
        参数:
        name - look up name.
        抛出:
        com.alibaba.nacos.api.exception.NacosException - exception.
      • isUseAddressServer

        public static boolean isUseAddressServer()
      • update

        public boolean update​(Member newMember)
        member information update.
        参数:
        newMember - Member
        返回:
        update is success
      • notifyMemberChange

        void notifyMemberChange​(Member member)
      • hasMember

        public boolean hasMember​(java.lang.String address)
        Whether the node exists within the cluster.
        参数:
        address - ip:port
        返回:
        is exists
      • getServerListUnhealth

        public java.util.List<java.lang.String> getServerListUnhealth()
      • getSelf

        public Member getSelf()
      • find

        public Member find​(java.lang.String address)
      • allMembers

        public java.util.Collection<Member> allMembers()
        return this cluster all members.
        返回:
        Collection all member
      • allMembersWithoutSelf

        public java.util.List<Member> allMembersWithoutSelf()
        return this cluster all members without self.
        返回:
        Collection all member without self
      • memberChange

        boolean memberChange​(java.util.Collection<Member> members)
      • memberJoin

        public boolean memberJoin​(java.util.Collection<Member> members)
        members join this cluster.
        参数:
        members - Collection new members
        返回:
        is success
      • memberLeave

        public boolean memberLeave​(java.util.Collection<Member> members)
        members leave this cluster.
        参数:
        members - Collection wait leave members
        返回:
        is success
      • isUnHealth

        public boolean isUnHealth​(java.lang.String address)
        this member Member.getState() is health.
        参数:
        address - ip:port
        返回:
        is health
      • isFirstIp

        public boolean isFirstIp()
      • onApplicationEvent

        public void onApplicationEvent​(org.springframework.boot.web.context.WebServerInitializedEvent event)
        指定者:
        onApplicationEvent 在接口中 org.springframework.context.ApplicationListener<org.springframework.boot.web.context.WebServerInitializedEvent>
      • shutdown

        @PreDestroy
        public void shutdown()
                      throws com.alibaba.nacos.api.exception.NacosException
        ServerMemberManager shutdown.
        抛出:
        com.alibaba.nacos.api.exception.NacosException - NacosException
      • getMemberAddressInfos

        public java.util.Set<java.lang.String> getMemberAddressInfos()
      • updateMember

        public void updateMember​(Member member)
      • setMemberAddressInfos

        public void setMemberAddressInfos​(java.util.Set<java.lang.String> memberAddressInfos)
      • getServerList

        public java.util.Map<java.lang.String,​Member> getServerList()
      • isInIpList

        public static boolean isInIpList()