private void onMemberAddedOrReplaced(Member newMember) {
        String nodeId = newMember.getNodeId();
        Member localMember = localNodeStatusManager.getLocalMember();
        boolean isLocalNode = nodeId.equals(localMember.getNodeId());
        if (allKnownMembers.put(nodeId, newMember) == null) {
            LOGGER.info("A new member has been added: "
                    + newMember);
        }
        synchronized (this) {
            if (isLocalNode) {
                localNodeStatusManager.updateInfo(newMember);
            }
            if (newMember.getStatus()
                    .isActive()
                    && connectionService.isMemberConnected(nodeId)) {
                updateOtherActiveConnectedMemberList(true, newMember);
                if (notifyMembersChangeFuture != null) {
                    notifyMembersChangeFuture.cancel(false);
                }
                notifyMembersChangeFuture = scheduler.schedule(this::notifyMembersChangeListeners,
                        discoveryProperties.getDelayToNotifyMembersChangeSeconds(),
                        TimeUnit.SECONDS);
            }
        }
        // shouldLocalNodeBeClient is used to ensure there is
        // only one TCP connection between two peers
        boolean shouldLocalNodeBeClient = compareMemberPriority(localMember, newMember) < 0;
        if (!isLocalNode && shouldLocalNodeBeClient) {
            connectionService.connectMemberUntilSucceedOrRemoved(newMember);
        }
    }
@param newMember can be the local node
turms-server-common/src/main/java/im/turms/server/common/infra/cluster/service/discovery/DiscoveryService.java