Search in sources :

Example 1 with Client

use of org.apache.dubbo.remoting.Client in project dubbo by alibaba.

the class ServerPeer method getChannel.

@Override
public Channel getChannel(InetSocketAddress remoteAddress) {
    String host = remoteAddress.getAddress() != null ? remoteAddress.getAddress().getHostAddress() : remoteAddress.getHostName();
    int port = remoteAddress.getPort();
    Channel channel = super.getChannel(remoteAddress);
    if (channel == null) {
        for (Map.Entry<URL, Client> entry : clients.entrySet()) {
            URL url = entry.getKey();
            if (url.getIp().equals(host) && url.getPort() == port) {
                return entry.getValue();
            }
        }
    }
    return channel;
}
Also used : Channel(org.apache.dubbo.remoting.Channel) Client(org.apache.dubbo.remoting.Client) Map(java.util.Map) URL(org.apache.dubbo.common.URL)

Example 2 with Client

use of org.apache.dubbo.remoting.Client in project dubbo by alibaba.

the class AbstractGroup method connect.

protected Client connect(URL url) throws RemotingException {
    if (servers.containsKey(url)) {
        return null;
    }
    Client client = clients.get(url);
    if (client == null) {
        // TODO exist concurrent gap
        client = Transporters.connect(url, dispatcher);
        clients.put(url, client);
    }
    return client;
}
Also used : Client(org.apache.dubbo.remoting.Client)

Aggregations

Client (org.apache.dubbo.remoting.Client)2 Map (java.util.Map)1 URL (org.apache.dubbo.common.URL)1 Channel (org.apache.dubbo.remoting.Channel)1