com.alibaba.dubbo.remoting.ChannelHandler Java Examples
The following examples show how to use
com.alibaba.dubbo.remoting.ChannelHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractServer.java From dubbo3 with Apache License 2.0 | 6 votes |
public AbstractServer(URL url, ChannelHandler handler) throws RemotingException { super(url, handler); localAddress = getUrl().toInetSocketAddress(); String host = url.getParameter(Constants.ANYHOST_KEY, false) || NetUtils.isInvalidLocalHost(getUrl().getHost()) ? NetUtils.ANYHOST : getUrl().getHost(); bindAddress = new InetSocketAddress(host, getUrl().getRealPort()); this.accepts = url.getParameter(Constants.ACCEPTS_KEY, Constants.DEFAULT_ACCEPTS); this.idleTimeout = url.getParameter(Constants.IDLE_TIMEOUT_KEY, Constants.DEFAULT_IDLE_TIMEOUT); try { doOpen(); if (logger.isInfoEnabled()) { logger.info("Start " + getClass().getSimpleName() + " bind " + getBindAddress() + ", export " + getLocalAddress()); } } catch (Throwable t) { throw new RemotingException(url.toInetSocketAddress(), null, "Failed to bind " + getClass().getSimpleName() + " on " + getLocalAddress() + ", cause: " + t.getMessage(), t); } if (handler instanceof WrappedChannelHandler ){ executor = ((WrappedChannelHandler)handler).getExecutor(); } }
Example #2
Source File: ChannelHandlerDispatcher.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Override public void disconnected(Channel channel) { for (ChannelHandler listener : channelHandlers) { try { listener.disconnected(channel); } catch (Throwable t) { logger.error(t.getMessage(), t); } } }
Example #3
Source File: MinaHandler.java From dubbox with Apache License 2.0 | 5 votes |
public MinaHandler(URL url, ChannelHandler handler) { if (url == null) { throw new IllegalArgumentException("url == null"); } if (handler == null) { throw new IllegalArgumentException("handler == null"); } this.url = url; this.handler = handler; }
Example #4
Source File: ChannelEventRunnable.java From dubbo3 with Apache License 2.0 | 5 votes |
public ChannelEventRunnable(Channel channel, ChannelHandler handler, ChannelState state, Object message, Throwable exception) { this.channel = channel; this.handler = handler; this.state = state; this.message = message; this.exception = exception; }
Example #5
Source File: AbstractServer.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
public AbstractServer(URL url, ChannelHandler handler) throws RemotingException { super(url, handler); localAddress = getUrl().toInetSocketAddress(); // 获取bind.ip参数值,默认从url中查询host属性 String bindIp = getUrl().getParameter(Constants.BIND_IP_KEY, getUrl().getHost()); // 获取bind.port参数值,默认从url中查询port属性 int bindPort = getUrl().getParameter(Constants.BIND_PORT_KEY, getUrl().getPort()); // 查询anyhost参数值,默认false if (url.getParameter(Constants.ANYHOST_KEY, false) || NetUtils.isInvalidLocalHost(bindIp)) { bindIp = NetUtils.ANYHOST; } bindAddress = new InetSocketAddress(bindIp, bindPort); // 查询accepts参数,服务端可以接收处理的最大线程数,默认0不限制 this.accepts = url.getParameter(Constants.ACCEPTS_KEY, Constants.DEFAULT_ACCEPTS); // idle.timeout 空闲超时时间,默认600s this.idleTimeout = url.getParameter(Constants.IDLE_TIMEOUT_KEY, Constants.DEFAULT_IDLE_TIMEOUT); try { // 创建server doOpen(); if (logger.isInfoEnabled()) { logger.info("Start " + getClass().getSimpleName() + " bind " + getBindAddress() + ", export " + getLocalAddress()); } } catch (Throwable t) { throw new RemotingException(url.toInetSocketAddress(), null, "Failed to bind " + getClass().getSimpleName() + " on " + getLocalAddress() + ", cause: " + t.getMessage(), t); } //fixme replace this with better method DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); executor = (ExecutorService) dataStore.get(Constants.EXECUTOR_SERVICE_COMPONENT_KEY, Integer.toString(url.getPort())); }
Example #6
Source File: ChannelEventRunnable.java From dubbox with Apache License 2.0 | 5 votes |
public ChannelEventRunnable(Channel channel, ChannelHandler handler, ChannelState state, Object message, Throwable exception) { this.channel = channel; this.handler = handler; this.state = state; this.message = message; this.exception = exception; }
Example #7
Source File: WrappedChannelHandler.java From dubbo3 with Apache License 2.0 | 5 votes |
public WrappedChannelHandler(ChannelHandler handler, URL url) { this.handler = handler; this.url = url; executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url); String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY; if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) { componentKey = Constants.CONSUMER_SIDE; } DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); dataStore.put(componentKey, Integer.toString(url.getPort()), executor); }
Example #8
Source File: Netty4CodecAdapter.java From dubbo-plus with Apache License 2.0 | 5 votes |
public Netty4CodecAdapter(Codec2 codec, URL url, ChannelHandler handler) { this.codec = codec; this.url = url; this.handler = handler; int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE); this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE; }
Example #9
Source File: MinaCodecAdapter.java From dubbox with Apache License 2.0 | 5 votes |
public MinaCodecAdapter(Codec2 codec, URL url, ChannelHandler handler) { this.codec = codec; this.url = url; this.handler = handler; int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE); this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE; }
Example #10
Source File: AbstractPeer.java From dubbox with Apache License 2.0 | 5 votes |
public ChannelHandler getChannelHandler() { if (handler instanceof ChannelHandlerDelegate) { return ((ChannelHandlerDelegate) handler).getHandler(); } else { return handler; } }
Example #11
Source File: MinaChannel.java From dubbox with Apache License 2.0 | 5 votes |
private MinaChannel(IoSession session, URL url, ChannelHandler handler){ super(url, handler); if (session == null) { throw new IllegalArgumentException("mina session == null"); } this.session = session; }
Example #12
Source File: ChannelEventRunnable.java From dubbox with Apache License 2.0 | 5 votes |
public ChannelEventRunnable(Channel channel, ChannelHandler handler, ChannelState state, Object message, Throwable exception) { this.channel = channel; this.handler = handler; this.state = state; this.message = message; this.exception = exception; }
Example #13
Source File: AbstractPeer.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Override public ChannelHandler getChannelHandler() { if (handler instanceof ChannelHandlerDelegate) { return ((ChannelHandlerDelegate) handler).getHandler(); } else { return handler; } }
Example #14
Source File: NettyHandler.java From dubbox with Apache License 2.0 | 5 votes |
public NettyHandler(URL url, ChannelHandler handler){ if (url == null) { throw new IllegalArgumentException("url == null"); } if (handler == null) { throw new IllegalArgumentException("handler == null"); } this.url = url; this.handler = handler; }
Example #15
Source File: WrappedChannelHandler.java From dubbox with Apache License 2.0 | 5 votes |
public WrappedChannelHandler(ChannelHandler handler, URL url) { this.handler = handler; this.url = url; executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url); String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY; if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) { componentKey = Constants.CONSUMER_SIDE; } DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); dataStore.put(componentKey, Integer.toString(url.getPort()), executor); }
Example #16
Source File: AbstractPeer.java From dubbox with Apache License 2.0 | 5 votes |
public AbstractPeer(URL url, ChannelHandler handler) { if (url == null) { throw new IllegalArgumentException("url == null"); } if (handler == null) { throw new IllegalArgumentException("handler == null"); } this.url = url; this.handler = handler; }
Example #17
Source File: GrizzlyCodecAdapter.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public GrizzlyCodecAdapter(Codec2 codec, URL url, ChannelHandler handler) { this.codec = codec; this.url = url; this.handler = handler; int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE); this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE; }
Example #18
Source File: WrappedChannelHandler.java From dubbox with Apache License 2.0 | 5 votes |
public ChannelHandler getHandler() { if (handler instanceof ChannelHandlerDelegate) { return ((ChannelHandlerDelegate) handler).getHandler(); } else { return handler; } }
Example #19
Source File: GrizzlyCodecAdapter.java From dubbox with Apache License 2.0 | 5 votes |
public GrizzlyCodecAdapter(Codec2 codec, URL url, ChannelHandler handler) { this.codec = codec; this.url = url; this.handler = handler; int b = url.getPositiveParameter(Constants.BUFFER_KEY, Constants.DEFAULT_BUFFER_SIZE); this.bufferSize = b >= Constants.MIN_BUFFER_SIZE && b <= Constants.MAX_BUFFER_SIZE ? b : Constants.DEFAULT_BUFFER_SIZE; }
Example #20
Source File: MinaChannel.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
private MinaChannel(IoSession session, URL url, ChannelHandler handler) { super(url, handler); if (session == null) { throw new IllegalArgumentException("mina session == null"); } this.session = session; }
Example #21
Source File: NettyHandler.java From dubbo3 with Apache License 2.0 | 5 votes |
public NettyHandler(URL url, ChannelHandler handler){ if (url == null) { throw new IllegalArgumentException("url == null"); } if (handler == null) { throw new IllegalArgumentException("handler == null"); } this.url = url; this.handler = handler; }
Example #22
Source File: GrizzlyChannel.java From dubbox with Apache License 2.0 | 5 votes |
static GrizzlyChannel getOrAddChannel(Connection<?> connection, URL url, ChannelHandler handler) { if (connection == null) { return null; } GrizzlyChannel ret = ATTRIBUTE.get(connection); if (ret == null) { ret = new GrizzlyChannel(connection, url, handler); if (connection.isOpen()) { ATTRIBUTE.set(connection, ret); } } return ret; }
Example #23
Source File: HeaderExchangeChannel.java From dubbox with Apache License 2.0 | 4 votes |
public ChannelHandler getChannelHandler() { return channel.getChannelHandler(); }
Example #24
Source File: ChannelEventRunnable.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public ChannelEventRunnable(Channel channel, ChannelHandler handler, ChannelState state, Object message) { this(channel, handler, state, message, null); }
Example #25
Source File: ChannelHandlerDispatcher.java From dubbo3 with Apache License 2.0 | 4 votes |
public ChannelHandlerDispatcher removeChannelHandler(ChannelHandler handler) { this.channelHandlers.remove(handler); return this; }
Example #26
Source File: ExecutionDispatcher.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Override public ChannelHandler dispatch(ChannelHandler handler, URL url) { return new ExecutionChannelHandler(handler, url); }
Example #27
Source File: ChannelEventRunnable.java From dubbox with Apache License 2.0 | 4 votes |
public ChannelEventRunnable(Channel channel, ChannelHandler handler, ChannelState state, Object message) { this(channel, handler, state, message, null); }
Example #28
Source File: ExchangeHandlerDispatcher.java From dubbox with Apache License 2.0 | 4 votes |
public ExchangeHandlerDispatcher(Replier<?> replier, ChannelHandler... handlers){ replierDispatcher = new ReplierDispatcher(replier); handlerDispatcher = new ChannelHandlerDispatcher(handlers); telnetHandler = new TelnetHandlerAdapter(); }
Example #29
Source File: ChannelEventRunnable.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
public ChannelEventRunnable(Channel channel, ChannelHandler handler, ChannelState state, Object message) { this(channel, handler, state, message, null); }
Example #30
Source File: MockedClient.java From dubbox with Apache License 2.0 | 4 votes |
public void removeChannelListener(ChannelHandler listener) { //this.listener = null; }