當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceNode類代碼示例

本文整理匯總了Java中com.mpush.api.srd.ServiceNode的典型用法代碼示例。如果您正苦於以下問題:Java ServiceNode類的具體用法?Java ServiceNode怎麽用?Java ServiceNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ServiceNode類屬於com.mpush.api.srd包,在下文中一共展示了ServiceNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: refresh

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
/**
 * 從zk中獲取可提供服務的機器,並以在線用戶量排序
 */
private void refresh() {
    //1.從緩存中拿取可用的長鏈接服務器節點
    List<ServiceNode> nodes = discovery.lookup(ServiceNames.CONN_SERVER);
    if (nodes.size() > 0) {
        //2.對serverNodes可以按某種規則排序,以便實現負載均衡,比如:隨機,輪詢,鏈接數量等
        this.serverNodes = nodes
                .stream()
                .map(this::convert)
                .sorted(ServerNode::compareTo)
                .collect(Collectors.toList());
    }
}
 
開發者ID:mpusher,項目名稱:alloc,代碼行數:16,代碼來源:AllocHandler.java

示例2: convert

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
private ServerNode convert(ServiceNode node) {
    String public_ip = node.getAttr(ServiceNames.ATTR_PUBLIC_IP);
    if (public_ip == null) {
        public_ip = node.getHost();
    }
    long onlineUserNum = getOnlineUserNum(public_ip);
    return new ServerNode(public_ip, node.getPort(), onlineUserNum);
}
 
開發者ID:mpusher,項目名稱:alloc,代碼行數:9,代碼來源:AllocHandler.java

示例3: removeClient

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
private void removeClient(ServiceNode node) {
    if (node != null) {
        List<Connection> clients = connections.remove(getHostAndPort(node.getHost(), node.getPort()));
        if (clients != null) {
            clients.forEach(Connection::close);
        }
    }
}
 
開發者ID:mpusher,項目名稱:mpush,代碼行數:9,代碼來源:GatewayTCPConnectionFactory.java

示例4: cs

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
public static ServiceNode cs() {
    CommonServiceNode node = new CommonServiceNode();
    node.setHost(ConfigTools.getConnectServerRegisterIp());
    node.setPort(CC.mp.net.connect_server_port);
    node.setPersistent(false);
    node.setServiceName(ServiceNames.CONN_SERVER);
    node.setAttrs(CC.mp.net.connect_server_register_attr);
    return node;
}
 
開發者ID:mpusher,項目名稱:mpush,代碼行數:10,代碼來源:ServerNodes.java

示例5: ws

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
public static ServiceNode ws() {
    CommonServiceNode node = new CommonServiceNode();
    node.setHost(ConfigTools.getConnectServerRegisterIp());
    node.setPort(CC.mp.net.ws_server_port);
    node.setPersistent(false);
    node.setServiceName(ServiceNames.WS_SERVER);
    //node.addAttr(ATTR_PUBLIC_IP, ConfigTools.getPublicIp());
    return node;
}
 
開發者ID:mpusher,項目名稱:mpush,代碼行數:10,代碼來源:ServerNodes.java

示例6: gs

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
public static ServiceNode gs() {
    CommonServiceNode node = new CommonServiceNode();
    node.setHost(ConfigTools.getGatewayServerRegisterIp());
    node.setPort(CC.mp.net.gateway_server_port);
    node.setPersistent(false);
    node.setServiceName(ServiceNames.GATEWAY_SERVER);
    return node;
}
 
開發者ID:mpusher,項目名稱:mpush,代碼行數:9,代碼來源:ServerNodes.java

示例7: onServiceAdded

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
@Override
public void onServiceAdded(String s, ServiceNode serviceNode) {
    refresh();
}
 
開發者ID:mpusher,項目名稱:alloc,代碼行數:5,代碼來源:AllocHandler.java

示例8: onServiceUpdated

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
@Override
public void onServiceUpdated(String s, ServiceNode serviceNode) {
    refresh();
}
 
開發者ID:mpusher,項目名稱:alloc,代碼行數:5,代碼來源:AllocHandler.java

示例9: onServiceRemoved

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
@Override
public void onServiceRemoved(String s, ServiceNode serviceNode) {
    refresh();
}
 
開發者ID:mpusher,項目名稱:alloc,代碼行數:5,代碼來源:AllocHandler.java

示例10: onServiceAdded

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
@Override
public void onServiceAdded(String path, ServiceNode node) {
    addConnection(node);
}
 
開發者ID:mpusher,項目名稱:mpush,代碼行數:5,代碼來源:GatewayUDPConnectionFactory.java

示例11: onServiceUpdated

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
@Override
public void onServiceUpdated(String path, ServiceNode node) {
    addConnection(node);
}
 
開發者ID:mpusher,項目名稱:mpush,代碼行數:5,代碼來源:GatewayUDPConnectionFactory.java

示例12: onServiceRemoved

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
@Override
public void onServiceRemoved(String path, ServiceNode node) {
    ip_address.remove(node.hostAndPort());
    logger.warn("Gateway Server zkNode={} was removed.", node);
}
 
開發者ID:mpusher,項目名稱:mpush,代碼行數:6,代碼來源:GatewayUDPConnectionFactory.java

示例13: addConnection

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
private void addConnection(ServiceNode node) {
    ip_address.put(node.hostAndPort(), new InetSocketAddress(node.getHost(), node.getPort()));
}
 
開發者ID:mpusher,項目名稱:mpush,代碼行數:4,代碼來源:GatewayUDPConnectionFactory.java

示例14: onServiceAdded

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
@Override
public void onServiceAdded(String path, ServiceNode node) {
    asyncAddConnection(node);
}
 
開發者ID:mpusher,項目名稱:mpush,代碼行數:5,代碼來源:GatewayTCPConnectionFactory.java

示例15: onServiceUpdated

import com.mpush.api.srd.ServiceNode; //導入依賴的package包/類
@Override
public void onServiceUpdated(String path, ServiceNode node) {
    removeClient(node);
    asyncAddConnection(node);
}
 
開發者ID:mpusher,項目名稱:mpush,代碼行數:6,代碼來源:GatewayTCPConnectionFactory.java


注:本文中的com.mpush.api.srd.ServiceNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。