当前位置: 首页>>代码示例>>Java>>正文


Java Channel.getUrl方法代码示例

本文整理汇总了Java中com.alibaba.dubbo.remoting.Channel.getUrl方法的典型用法代码示例。如果您正苦于以下问题:Java Channel.getUrl方法的具体用法?Java Channel.getUrl怎么用?Java Channel.getUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.dubbo.remoting.Channel的用法示例。


在下文中一共展示了Channel.getUrl方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isClientSide

import com.alibaba.dubbo.remoting.Channel; //导入方法依赖的package包/类
protected boolean isClientSide(Channel channel) {
	String side = (String) channel.getAttribute(Constants.SIDE_KEY);
	if ("client".equals(side)) {
		return true;
	} else if ("server".equals(side)) {
		return false;
	} else {
		InetSocketAddress address = channel.getRemoteAddress();
		URL url = channel.getUrl();
		boolean client = url.getPort() == address.getPort()
				&& NetUtils.filterLocalHost(url.getIp()).equals(
						NetUtils.filterLocalHost(address.getAddress()
								.getHostAddress()));
		channel.setAttribute(Constants.SIDE_KEY, client ? "client"
				: "server");
		return client;
	}
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:AbstractCodec.java

示例2: isClientSide

import com.alibaba.dubbo.remoting.Channel; //导入方法依赖的package包/类
protected boolean isClientSide(Channel channel) {
    String side = (String) channel.getAttribute(Constants.SIDE_KEY);
    if ("client".equals(side)) {
        return true;
    } else if ("server".equals(side)) {
        return false;
    } else {
        InetSocketAddress address = channel.getRemoteAddress();
        URL url = channel.getUrl();
        boolean client = url.getPort() == address.getPort()
            && NetUtils.filterLocalHost(url.getIp()).equals(
            NetUtils.filterLocalHost(address.getAddress()
                                         .getHostAddress()));
        channel.setAttribute(Constants.SIDE_KEY, client ? "client"
            : "server");
        return client;
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:19,代码来源:DeprecatedTelnetCodec.java

示例3: checkPayload

import com.alibaba.dubbo.remoting.Channel; //导入方法依赖的package包/类
static void checkPayload(Channel channel, long size) throws IOException {
    int payload = Constants.DEFAULT_PAYLOAD;
    if (channel != null && channel.getUrl() != null) {
        payload = channel.getUrl().getPositiveParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD);
    }
    if (size > payload) {
        IOException e = new IOException("Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel);
        logger.error(e);
        throw e;
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:12,代码来源:DeprecatedTelnetCodec.java

示例4: isClientSide

import com.alibaba.dubbo.remoting.Channel; //导入方法依赖的package包/类
private boolean isClientSide(Channel channel) {
    InetSocketAddress address = channel.getRemoteAddress();
    URL url = channel.getUrl();
    return url.getPort() == address.getPort() && 
                NetUtils.filterLocalHost(channel.getUrl().getIp())
                .equals(NetUtils.filterLocalHost(address.getAddress().getHostAddress()));
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:8,代码来源:DubboProtocol.java

示例5: checkPayload

import com.alibaba.dubbo.remoting.Channel; //导入方法依赖的package包/类
protected static void checkPayload(Channel channel, long size) throws IOException {
    int payload = Constants.DEFAULT_PAYLOAD;
    if (channel != null && channel.getUrl() != null) {
        payload = channel.getUrl().getParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD);
    }
    if (payload > 0 && size > payload) {
    	IOException e = new IOException("Data length too large: " + size + ", max payload: " + payload + ", channel: " + channel);
    	logger.error(e);
        throw e;
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:AbstractCodec.java

示例6: isClientSide

import com.alibaba.dubbo.remoting.Channel; //导入方法依赖的package包/类
private static boolean isClientSide(Channel channel) {
    InetSocketAddress address = channel.getRemoteAddress();
    URL url = channel.getUrl();
    return url.getPort() == address.getPort() && 
                NetUtils.filterLocalHost(url.getIp())
                .equals(NetUtils.filterLocalHost(address.getAddress().getHostAddress()));
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:8,代码来源:HeaderExchangeHandler.java

示例7: received

import com.alibaba.dubbo.remoting.Channel; //导入方法依赖的package包/类
public void received(Channel channel, Object message) throws RemotingException {
    channel.setAttribute(KEY_READ_TIMESTAMP, System.currentTimeMillis());
    ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
    try {
        if (message instanceof Request) {
            // handle request.
            Request request = (Request) message;
            if (request.isEvent()) {
                handlerEvent(channel, request);
            } else {
                if (request.isTwoWay()) {
                    Response response = handleRequest(exchangeChannel, request);
                    channel.send(response);
                } else {
                    handler.received(exchangeChannel, request.getData());
                }
            }
        } else if (message instanceof Response) {
            handleResponse(channel, (Response) message);
        } else if (message instanceof String) {
            if (isClientSide(channel)) {
                Exception e = new Exception("Dubbo client can not supported string message: " + message + " in channel: " + channel + ", url: " + channel.getUrl());
                logger.error(e.getMessage(), e);
            } else {
                String echo = handler.telnet(channel, (String) message);
                if (echo != null && echo.length() > 0) {
                    channel.send(echo);
                }
            }
        } else {
            handler.received(exchangeChannel, message);
        }
    } finally {
        HeaderExchangeChannel.removeChannelIfDisconnected(channel);
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:37,代码来源:HeaderExchangeHandler.java


注:本文中的com.alibaba.dubbo.remoting.Channel.getUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。