Java ExchangeServer类代码示例(javaexchangeserver类代码示例汇总)

本文整理汇总了Java中com.alibaba.dubbo.remoting.exchange.ExchangeServer的典型用法代码示例。如果您正苦于以下问题:Java ExchangeServer类的具体用法?Java ExchangeServer怎么用?Java ExchangeServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Java ExchangeServer类代码示例(javaexchangeserver类代码示例汇总)

ExchangeServer类属于com.alibaba.dubbo.remoting.exchange包,在下文中一共展示了ExchangeServer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: check

import com.alibaba.dubbo.remoting.exchange.ExchangeServer; //导入依赖的package包/类
public Status check() {
    Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
    if (servers == null || servers.size() == 0) {
        return new Status(Status.Level.UNKNOWN);
    }
    Status.Level level = Status.Level.OK;
    StringBuilder buf = new StringBuilder();
    for (ExchangeServer server : servers) {
        if (! server.isBound()) {
            level = Status.Level.ERROR;
            buf.setLength(0);
            buf.append(server.getLocalAddress());
            break;
        }
        if (buf.length() > 0) {
            buf.append(",");
        }
        buf.append(server.getLocalAddress());
        buf.append("(clients:");
        buf.append(server.getChannels().size());
        buf.append(")");
    }
    return new Status(level, buf.toString());
} 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:ServerStatusChecker.java

示例2: createServer

import com.alibaba.dubbo.remoting.exchange.ExchangeServer; //导入依赖的package包/类
private ExchangeServer createServer(URL url) {
    //默认开启server关闭时发送readonly事件
    url = url.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString());
    //默认开启heartbeat
    url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
    String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER);

    if (str != null && str.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str))
        throw new RpcException("Unsupported server type: " + str + ", url: " + url);

    url = url.addParameter(Constants.CODEC_KEY, Version.isCompatibleVersion() ? COMPATIBLE_CODEC_NAME : DubboCodec.NAME);
    ExchangeServer server;
    try {
        server = Exchangers.bind(url, requestHandler);
    } catch (RemotingException e) {
        throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e);
    }
    str = url.getParameter(Constants.CLIENT_KEY);
    if (str != null && str.length() > 0) {
        Set<String> supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions();
        if (!supportedTypes.contains(str)) {
            throw new RpcException("Unsupported client type: " + str);
        }
    }
    return server;
} 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:27,代码来源:DubboProtocol.java

示例3: handle

import com.alibaba.dubbo.remoting.exchange.ExchangeServer; //导入依赖的package包/类
public Page handle(URL url) {
    List<List<String>> rows = new ArrayList<List<String>>();
    Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
    int clientCount = 0;
    if (servers != null && servers.size() > 0) {
        for (ExchangeServer s : servers) {
            List<String> row = new ArrayList<String>();
            String address = s.getUrl().getAddress();
            row.add(NetUtils.getHostName(address) + "/" + address);
            int clientSize = s.getExchangeChannels().size();
            clientCount += clientSize;
            row.add("<a href=\"clients.html?port=" + s.getUrl().getPort() + "\">Clients(" + clientSize + ")</a>");
            rows.add(row);
        }
    }
    return new Page("Servers", "Servers (" + rows.size() + ")", new String[]{"Server Address:", "Clients(" + clientCount + ")"}, rows);
} 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:ServersPageHandler.java

示例4: destroy

import com.alibaba.dubbo.remoting.exchange.ExchangeServer; //导入依赖的package包/类
public void destroy() {

        super.destroy();

        for (String key : new ArrayList<String>(serverMap.keySet())) {

            ExchangeServer server = serverMap.remove(key);

            if (server != null) {
                try {
                    if (logger.isInfoEnabled()) {
                        logger.info("Close dubbo server: " + server.getLocalAddress());
                    }
                    server.close(getServerShutdownTimeout());
                } catch (Throwable t) {
                    logger.warn(t.getMessage(), t);
                }
            } // ~ end of if ( server != null )

        } // ~ end of loop serverMap

    } 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:23,代码来源:ThriftProtocol.java

示例5: getServer

import com.alibaba.dubbo.remoting.exchange.ExchangeServer; //导入依赖的package包/类
private ExchangeServer getServer(URL url) {
    //默认开启server关闭时发送readonly事件
    url = url.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString());
    String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER);

    if (str != null && str.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str))
        throw new RpcException("Unsupported server type: " + str + ", url: " + url);

    ExchangeServer server;
    try {
        server = Exchangers.bind(url, handler);
    } catch (RemotingException e) {
        throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e);
    }
    str = url.getParameter(Constants.CLIENT_KEY);
    if (str != null && str.length() > 0) {
        Set<String> supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions();
        if (!supportedTypes.contains(str)) {
            throw new RpcException("Unsupported client type: " + str);
        }
    }
    return server;
} 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:24,代码来源:ThriftProtocol.java

示例6: handle

import com.alibaba.dubbo.remoting.exchange.ExchangeServer; //导入依赖的package包/类
public Page handle(URL url) {
    List<List<String>> rows = new ArrayList<>();
    Collection<ExchangeServer> servers = DubboProtocol.getDubboProtocol().getServers();
    int clientCount = 0;
    if (servers != null && servers.size() > 0) {
        for (ExchangeServer s : servers) {
            List<String> row = new ArrayList<>();
            String address = s.getUrl().getAddress();
            row.add(NetUtils.getHostName(address) + "/" + address);
            int clientSize = s.getExchangeChannels().size();
            clientCount += clientSize;
            row.add("<a href=\"clients.html?port=" + s.getUrl().getPort() + "\">Clients(" + clientSize + ")</a>");
            rows.add(row);
        }
    }
    return new Page("Servers", "Servers (" + rows.size() + ")", new String[]{"Server Address:", "Clients(" + clientCount + ")"}, rows);
} 
开发者ID:linux-china,项目名称:dubbo3,代码行数:18,代码来源:ServersPageHandler.java

本文标签属性:

示例:示例是什么意思

代码:代码生成器

java:java自行车

ExchangeServer:ExchangeServer

上一篇:Python NNBase.grad_check方法代码示例(pythonnn.base.nnbase.grad_check方法的典型用法代码示例)
下一篇:Java PLMediaPlayer.ERROR_CODE_READ_FRAME_TIMEOUT属性代码示例(javaplmediaplayer.error_code_read_frame_timeout属性的典型用法)

为您推荐