Search in sources :

Example 1 with ExchangePeer

use of org.apache.dubbo.remoting.p2p.exchange.ExchangePeer in project dubbo by alibaba.

the class FileExchangeGroup method joinExchange.

public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] { full });
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
Also used : ExchangePeer(org.apache.dubbo.remoting.p2p.exchange.ExchangePeer) InetSocketAddress(java.net.InetSocketAddress) RemotingException(org.apache.dubbo.remoting.RemotingException) IOException(java.io.IOException)

Example 2 with ExchangePeer

use of org.apache.dubbo.remoting.p2p.exchange.ExchangePeer in project dubbo by alibaba.

the class MulticastExchangeGroup method join.

@Override
public ExchangePeer join(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    send(JOIN + " " + url.toFullString());
    return peer;
}
Also used : ExchangePeer(org.apache.dubbo.remoting.p2p.exchange.ExchangePeer)

Aggregations

ExchangePeer (org.apache.dubbo.remoting.p2p.exchange.ExchangePeer)2 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 RemotingException (org.apache.dubbo.remoting.RemotingException)1