use of org.apache.dubbo.remoting.Channel in project dubbo by alibaba.
the class AbstractClient method removeAttribute.
@Override
public void removeAttribute(String key) {
Channel channel = getChannel();
if (channel == null) {
return;
}
channel.removeAttribute(key);
}
use of org.apache.dubbo.remoting.Channel in project dubbo by alibaba.
the class AbstractTimerTask method run.
@Override
public void run(Timeout timeout) throws Exception {
Collection<Channel> c = channelProvider.getChannels();
for (Channel channel : c) {
if (channel.isClosed()) {
continue;
}
doTask(channel);
}
reput(timeout, tick);
}
use of org.apache.dubbo.remoting.Channel in project dubbo by alibaba.
the class TraceTelnetHandlerTest method testTraceTelnetAddTracer.
@Test
public void testTraceTelnetAddTracer() throws Exception {
String method = "sayHello";
String message = "org.apache.dubbo.qos.legacy.service.DemoService sayHello 1";
Class<?> type = DemoService.class;
DubboProtocol.getDubboProtocol().export(mockInvoker);
handler.telnet(mockChannel, message);
String key = type.getName() + "." + method;
Field tracers = TraceFilter.class.getDeclaredField("TRACERS");
tracers.setAccessible(true);
ConcurrentHashMap<String, Set<Channel>> map = (ConcurrentHashMap<String, Set<Channel>>) tracers.get(new ConcurrentHashMap<String, Set<Channel>>());
Set<Channel> channels = map.getOrDefault(key, null);
Assertions.assertNotNull(channels);
Assertions.assertTrue(channels.contains(mockChannel));
}
use of org.apache.dubbo.remoting.Channel 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;
}
use of org.apache.dubbo.remoting.Channel in project dubbo by alibaba.
the class NettyTransporterTest method shouldConnectToNetty4Server.
@Test
public void shouldConnectToNetty4Server() throws Exception {
final CountDownLatch lock = new CountDownLatch(1);
int port = NetUtils.getAvailablePort();
URL url = new URL("telnet", "localhost", port, new String[] { Constants.BIND_PORT_KEY, String.valueOf(port) });
new NettyTransporter().bind(url, new ChannelHandlerAdapter() {
@Override
public void connected(Channel channel) {
lock.countDown();
}
});
new NettyTransporter().connect(url, new ChannelHandlerAdapter() {
@Override
public void sent(Channel channel, Object message) throws RemotingException {
channel.send(message);
channel.close();
}
});
lock.await();
}
Aggregations