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


Java Channel.getRemoteAddress方法代码示例

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


在下文中一共展示了Channel.getRemoteAddress方法的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: getInvoker

import com.alibaba.dubbo.remoting.Channel; //导入方法依赖的package包/类
Invoker<?> getInvoker(Channel channel, Invocation inv) throws RemotingException{
    boolean isCallBackServiceInvoke = false;
    boolean isStubServiceInvoke = false;
    int port = channel.getLocalAddress().getPort();
    String path = inv.getAttachments().get(Constants.PATH_KEY);
    //如果是客户端的回调服务.
    isStubServiceInvoke = Boolean.TRUE.toString().equals(inv.getAttachments().get(Constants.STUB_EVENT_KEY));
    if (isStubServiceInvoke){
        port = channel.getRemoteAddress().getPort();
    }
    //callback
    isCallBackServiceInvoke = isClientSide(channel) && !isStubServiceInvoke;
    if(isCallBackServiceInvoke){
        path = inv.getAttachments().get(Constants.PATH_KEY)+"."+inv.getAttachments().get(Constants.CALLBACK_SERVICE_KEY);
        inv.getAttachments().put(IS_CALLBACK_SERVICE_INVOKE, Boolean.TRUE.toString());
    }
    String serviceKey = serviceKey(port, path, inv.getAttachments().get(Constants.VERSION_KEY), inv.getAttachments().get(Constants.GROUP_KEY));

    DubboExporter<?> exporter = (DubboExporter<?>) exporterMap.get(serviceKey);
    
    if (exporter == null)
        throw new RemotingException(channel, "Not found exported service: " + serviceKey + " in " + exporterMap.keySet() + ", may be version or group mismatch " + ", channel: consumer: " + channel.getRemoteAddress() + " --> provider: " + channel.getLocalAddress() + ", message:" + inv);

    return exporter.getInvoker();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:26,代码来源:DubboProtocol.java

示例3: 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

示例4: sent

import com.alibaba.dubbo.remoting.Channel; //导入方法依赖的package包/类
public void sent(Channel channel, Object message) throws RemotingException {
    Throwable exception = null;
    try {
        channel.setAttribute(KEY_WRITE_TIMESTAMP, System.currentTimeMillis());
        ExchangeChannel exchangeChannel = HeaderExchangeChannel.getOrAddChannel(channel);
        try {
            handler.sent(exchangeChannel, message);
        } finally {
            HeaderExchangeChannel.removeChannelIfDisconnected(channel);
        }
    } catch (Throwable t) {
        exception = t;
    }
    if (message instanceof Request) {
        Request request = (Request) message;
        DefaultFuture.sent(channel, request);
    }
    if (exception != null) {
        if (exception instanceof RuntimeException) {
            throw (RuntimeException) exception;
        } else if (exception instanceof RemotingException) {
            throw (RemotingException) exception;
        } else {
            throw new RemotingException(channel.getLocalAddress(), channel.getRemoteAddress(),
                                        exception.getMessage(), exception);
        }
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:29,代码来源:HeaderExchangeHandler.java

示例5: 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:dachengxi,项目名称:EatDubbo,代码行数:8,代码来源:HeaderExchangeHandler.java

示例6: 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:zhuxiaolei,项目名称:dubbo2,代码行数:8,代码来源:DubboProtocol.java

示例7: getRemoteAddress

import com.alibaba.dubbo.remoting.Channel; //导入方法依赖的package包/类
public InetSocketAddress getRemoteAddress() {
    Channel channel = getChannel();
    if (channel == null)
        return getUrl().toInetSocketAddress();
    return channel.getRemoteAddress();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:7,代码来源:AbstractClient.java


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