类 ConnectionManager


  • @Service
    public class ConnectionManager
    extends com.alibaba.nacos.common.notify.listener.Subscriber<ConnectionLimitRuleChangeEvent>
    connect manager.
    版本:
    $Id: ConnectionManager.java, v 0.1 2020年07月13日 7:07 PM liuzunfei Exp $
    作者:
    liuzunfei
    • 字段详细资料

      • RULE_FILE_NAME

        public static final java.lang.String RULE_FILE_NAME
        另请参阅:
        常量字段值
      • KEEP_ALIVE_TIME

        private static final long KEEP_ALIVE_TIME
        4 times of client keep alive.
        另请参阅:
        常量字段值
      • loadClient

        private int loadClient
        current loader adjust count,only effective once,use to re balance.
      • redirectAddress

        java.lang.String redirectAddress
      • connectionForClientIp

        private java.util.Map<java.lang.String,​java.util.concurrent.atomic.AtomicInteger> connectionForClientIp
      • connections

        java.util.Map<java.lang.String,​Connection> connections
    • 构造器详细资料

      • ConnectionManager

        public ConnectionManager()
    • 方法详细资料

      • traced

        public boolean traced​(java.lang.String clientIp)
        if monitor detail.
        参数:
        clientIp - clientIp.
        返回:
      • initLimitRue

        @PostConstruct
        protected void initLimitRue()
      • checkValid

        public boolean checkValid​(java.lang.String connectionId)
        check connection id is valid.
        参数:
        connectionId - connectionId to be check.
        返回:
        is valid or not.
      • register

        public boolean register​(java.lang.String connectionId,
                                Connection connection)
        register a new connect.
        参数:
        connectionId - connectionId
        connection - connection
      • checkLimit

        private boolean checkLimit​(Connection connection)
      • unregister

        public void unregister​(java.lang.String connectionId)
        unregister a connection .
        参数:
        connectionId - connectionId.
      • getConnection

        public Connection getConnection​(java.lang.String connectionId)
        get by connection id.
        参数:
        connectionId - connection id.
        返回:
        connection of the id.
      • getConnectionByIp

        public java.util.List<Connection> getConnectionByIp​(java.lang.String clientIp)
        get by client ip.
        参数:
        clientIp - client ip.
        返回:
        connections of the client ip.
      • getCurrentConnectionCount

        public int getCurrentConnectionCount()
        get current connections count.
        返回:
        get all connection count
      • refreshActiveTime

        public void refreshActiveTime​(java.lang.String connectionId)
        regresh connection active time.
        参数:
        connectionId - connectionId.
      • start

        @PostConstruct
        public void start()
        Start Task:Expel the connection which active Time expire.
      • buildMeta

        private com.alibaba.nacos.api.remote.request.RequestMeta buildMeta()
      • loadCount

        public void loadCount​(int loadClient,
                              java.lang.String redirectAddress)
      • loadSingle

        public void loadSingle​(java.lang.String connectionId,
                               java.lang.String redirectAddress)
        send load request to spefic connetionId.
        参数:
        connectionId - connection id of client.
        redirectAddress - server address to redirect.
      • currentClientsCount

        public int currentClientsCount()
        get all client count.
        返回:
        client count.
      • currentClientsCount

        public int currentClientsCount​(java.util.Map<java.lang.String,​java.lang.String> filterLabels)
        get client count with labels filter.
        参数:
        filterLabels - label to filter client count.
        返回:
        count with the specific filter labels.
      • currentSdkClientCount

        public int currentSdkClientCount()
        get client count from sdk.
        返回:
        sdk client count.
      • currentClients

        public java.util.Map<java.lang.String,​Connection> currentClients()
      • isOverLimit

        private boolean isOverLimit()
        check if over limit.
        返回:
        over limit or not.
      • subscribeType

        public java.lang.Class<? extends com.alibaba.nacos.common.notify.Event> subscribeType()
        指定者:
        subscribeType 在类中 com.alibaba.nacos.common.notify.listener.Subscriber<ConnectionLimitRuleChangeEvent>
      • loadRuleFromLocal

        private void loadRuleFromLocal()
                                throws java.lang.Exception
        抛出:
        java.lang.Exception
      • getRuleFile

        private java.io.File getRuleFile()
      • registerFileWatch

        private void registerFileWatch()