use of org.apache.dubbo.remoting.exchange.ExchangeChannel in project dubbo by alibaba.
the class ExchangeServerPeer method getExchangeChannel.
@Override
public ExchangeChannel getExchangeChannel(InetSocketAddress remoteAddress) {
String host = remoteAddress.getAddress() != null ? remoteAddress.getAddress().getHostAddress() : remoteAddress.getHostName();
int port = remoteAddress.getPort();
ExchangeChannel channel = super.getExchangeChannel(remoteAddress);
if (channel == null) {
for (Map.Entry<URL, ExchangeClient> entry : clients.entrySet()) {
URL url = entry.getKey();
if (url.getIp().equals(host) && url.getPort() == port) {
return entry.getValue();
}
}
}
return channel;
}
use of org.apache.dubbo.remoting.exchange.ExchangeChannel in project dubbo by alibaba.
the class NettyClientTest method main.
public static void main(String[] args) throws RemotingException, InterruptedException {
ExchangeChannel client = Exchangers.connect(URL.valueOf("exchange://10.20.153.10:20880?client=netty3&heartbeat=1000"));
Thread.sleep(60 * 1000 * 50);
}
use of org.apache.dubbo.remoting.exchange.ExchangeChannel in project dubbo by alibaba.
the class ReplierDispatcherTest method testDataPackage.
@Test
public void testDataPackage() throws Exception {
ExchangeChannel client = Exchangers.connect(URL.valueOf("exchange://localhost:" + port + "?" + CommonConstants.TIMEOUT_KEY + "=60000"));
Random random = new Random();
for (int i = 5; i < 100; i++) {
StringBuilder sb = new StringBuilder();
for (int j = 0; j < i * 100; j++) sb.append("(").append(random.nextLong()).append(")");
Data d = new Data();
d.setData(sb.toString());
Assertions.assertEquals(client.request(d).get().toString(), "hello world");
}
clients.put(Thread.currentThread().getName(), client);
}
Aggregations