com.alibaba.dubbo.remoting.Client Java Examples
The following examples show how to use
com.alibaba.dubbo.remoting.Client.
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: ClientReconnectTest.java From dubbo-remoting-netty4 with Apache License 2.0 | 6 votes |
/** * 测试client重连方法不会导致重连线程失效. */ public void testClientReconnectMethod() throws RemotingException, InterruptedException{ int port = NetUtils.getAvailablePort(); String url = "exchange://127.0.0.3:"+port + "/client.reconnect.test?transporter=netty4&check=false&" +Constants.RECONNECT_KEY+"="+10 //1ms reconnect,保证有足够频率的重连 +"&reconnect.waring.period=100"; DubboAppender.doStart(); Client client = Exchangers.connect(url); try { client.reconnect(); } catch (Exception e) { //do nothing } Thread.sleep(1500);//重连线程的运行 Assert.assertTrue("have more then one warn msgs . bug was :" + LogUtil.findMessage(Level.WARN, "client reconnect to "),LogUtil.findMessage(Level.WARN, "client reconnect to ") >1); DubboAppender.doStop(); }
Example #2
Source File: ClientReconnectTest.java From dubbox with Apache License 2.0 | 6 votes |
/** * 测试client重连方法不会导致重连线程失效. */ @Test public void testClientReconnectMethod() throws RemotingException, InterruptedException{ int port = NetUtils.getAvailablePort(); String url = "exchange://127.0.0.3:"+port + "/client.reconnect.test?check=false&" +Constants.RECONNECT_KEY+"="+10 //1ms reconnect,保证有足够频率的重连 +"&reconnect.waring.period=1"; DubboAppender.doStart(); Client client = Exchangers.connect(url); try { client.reconnect(); } catch (Exception e) { //do nothing } Thread.sleep(1500);//重连线程的运行 Assert.assertTrue("have more then one warn msgs . bug was :" + LogUtil.findMessage(Level.WARN, "client reconnect to "),LogUtil.findMessage(Level.WARN, "client reconnect to ") >1); DubboAppender.doStop(); }
Example #3
Source File: ClientReconnectTest.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
/** * 测试client重连方法不会导致重连线程失效. */ @Test public void testClientReconnectMethod() throws RemotingException, InterruptedException{ int port = NetUtils.getAvailablePort(); String url = "exchange://127.0.0.3:"+port + "/client.reconnect.test?check=false&" +Constants.RECONNECT_KEY+"="+10 //1ms reconnect,保证有足够频率的重连 +"&reconnect.waring.period=1"; DubboAppender.doStart(); Client client = Exchangers.connect(url); try { client.reconnect(); } catch (Exception e) { //do nothing } Thread.sleep(1500);//重连线程的运行 Assert.assertTrue("have more then one warn msgs . bug was :" + LogUtil.findMessage(Level.WARN, "client reconnect to "),LogUtil.findMessage(Level.WARN, "client reconnect to ") >1); DubboAppender.doStop(); }
Example #4
Source File: ClientReconnectTest.java From dubbox with Apache License 2.0 | 6 votes |
/** * 测试client重连方法不会导致重连线程失效. */ @Test public void testClientReconnectMethod() throws RemotingException, InterruptedException{ int port = NetUtils.getAvailablePort(); String url = "exchange://127.0.0.3:"+port + "/client.reconnect.test?check=false&" +Constants.RECONNECT_KEY+"="+10 //1ms reconnect,保证有足够频率的重连 +"&reconnect.waring.period=1"; DubboAppender.doStart(); Client client = Exchangers.connect(url); try { client.reconnect(); } catch (Exception e) { //do nothing } Thread.sleep(1500);//重连线程的运行 Assert.assertTrue("have more then one warn msgs . bug was :" + LogUtil.findMessage(Level.WARN, "client reconnect to "),LogUtil.findMessage(Level.WARN, "client reconnect to ") >1); DubboAppender.doStop(); }
Example #5
Source File: HeaderExchangeClient.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
public HeaderExchangeClient(Client client, boolean needHeartbeat) { if (client == null) { throw new IllegalArgumentException("client == null"); } this.client = client; this.channel = new HeaderExchangeChannel(client); String dubbo = client.getUrl().getParameter(Constants.DUBBO_VERSION_KEY); this.heartbeat = client.getUrl().getParameter(Constants.HEARTBEAT_KEY, dubbo != null && dubbo.startsWith("1.0.") ? Constants.DEFAULT_HEARTBEAT : 0); this.heartbeatTimeout = client.getUrl().getParameter(Constants.HEARTBEAT_TIMEOUT_KEY, heartbeat * 3); if (heartbeatTimeout < heartbeat * 2) { throw new IllegalStateException("heartbeatTimeout < heartbeatInterval * 2"); } if (needHeartbeat) { startHeartbeatTimer(); } }
Example #6
Source File: ClientReconnectTest.java From dubbox with Apache License 2.0 | 6 votes |
/** * 测试client重连方法不会导致重连线程失效. */ public void testClientReconnectMethod() throws RemotingException, InterruptedException{ int port = NetUtils.getAvailablePort(); String url = "exchange://127.0.0.3:"+port + "/client.reconnect.test?transporter=netty4&check=false&" +Constants.RECONNECT_KEY+"="+10 //1ms reconnect,保证有足够频率的重连 +"&reconnect.waring.period=100"; DubboAppender.doStart(); Client client = Exchangers.connect(url); try { client.reconnect(); } catch (Exception e) { //do nothing } Thread.sleep(1500);//重连线程的运行 Assert.assertTrue("have more then one warn msgs . bug was :" + LogUtil.findMessage(Level.WARN, "client reconnect to "),LogUtil.findMessage(Level.WARN, "client reconnect to ") >1); DubboAppender.doStop(); }
Example #7
Source File: ClientReconnectTest.java From dubbox with Apache License 2.0 | 6 votes |
/** * 测试client重连方法不会导致重连线程失效. */ @Test public void testClientReconnectMethod() throws RemotingException, InterruptedException{ int port = NetUtils.getAvailablePort(); String url = "exchange://127.0.0.3:"+port + "/client.reconnect.test?check=false&" +Constants.RECONNECT_KEY+"="+10 //1ms reconnect,保证有足够频率的重连 +"&reconnect.waring.period=1"; DubboAppender.doStart(); Client client = Exchangers.connect(url); try { client.reconnect(); } catch (Exception e) { //do nothing } Thread.sleep(1500);//重连线程的运行 Assert.assertTrue("have more then one warn msgs . bug was :" + LogUtil.findMessage(Level.WARN, "client reconnect to "),LogUtil.findMessage(Level.WARN, "client reconnect to ") >1); DubboAppender.doStop(); }
Example #8
Source File: HeaderExchangeClient.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public HeaderExchangeClient(Client client){ if (client == null) { throw new IllegalArgumentException("client == null"); } this.client = client; this.channel = new HeaderExchangeChannel(client); String dubbo = client.getUrl().getParameter(Constants.DUBBO_VERSION_KEY); this.heartbeat = client.getUrl().getParameter( Constants.HEARTBEAT_KEY, dubbo != null && dubbo.startsWith("1.0.") ? Constants.DEFAULT_HEARTBEAT : 0 ); this.heartbeatTimeout = client.getUrl().getParameter( Constants.HEARTBEAT_TIMEOUT_KEY, heartbeat * 3 ); if ( heartbeatTimeout < heartbeat * 2 ) { throw new IllegalStateException( "heartbeatTimeout < heartbeatInterval * 2" ); } startHeatbeatTimer(); }
Example #9
Source File: HeaderExchangeClient.java From dubbox with Apache License 2.0 | 5 votes |
public HeaderExchangeClient(Client client){ if (client == null) { throw new IllegalArgumentException("client == null"); } this.client = client; this.channel = new HeaderExchangeChannel(client); String dubbo = client.getUrl().getParameter(Constants.DUBBO_VERSION_KEY); this.heartbeat = client.getUrl().getParameter( Constants.HEARTBEAT_KEY, dubbo != null && dubbo.startsWith("1.0.") ? Constants.DEFAULT_HEARTBEAT : 0 ); this.heartbeatTimeout = client.getUrl().getParameter( Constants.HEARTBEAT_TIMEOUT_KEY, heartbeat * 3 ); if ( heartbeatTimeout < heartbeat * 2 ) { throw new IllegalStateException( "heartbeatTimeout < heartbeatInterval * 2" ); } startHeatbeatTimer(); }
Example #10
Source File: AbstractGroup.java From dubbox with Apache License 2.0 | 5 votes |
protected Client connect(URL url) throws RemotingException { if (servers.containsKey(url)) { return null; } Client client = clients.get(url); if (client == null) { // TODO 有并发间隙 client = Transporters.connect(url, dispatcher); clients.put(url, client); } return client; }
Example #11
Source File: ServerPeer.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@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; }
Example #12
Source File: AbstractGroup.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
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; }
Example #13
Source File: AbstractExchangeGroup.java From dubbox with Apache License 2.0 | 5 votes |
protected Client connect(URL url) throws RemotingException { if (servers.containsKey(url)) { return null; } ExchangeClient client = clients.get(url); if (client == null) { // TODO 有并发间隙 client = Exchangers.connect(url, dispatcher); clients.put(url, client); } return client; }
Example #14
Source File: AbstractExchangeGroup.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
protected Client connect(URL url) throws RemotingException { if (servers.containsKey(url)) { return null; } ExchangeClient client = clients.get(url); if (client == null) { // TODO exist concurrent gap client = Exchangers.connect(url, dispatcher); clients.put(url, client); } return client; }
Example #15
Source File: HeaderExchangeClient.java From dubbox with Apache License 2.0 | 5 votes |
public HeaderExchangeClient(Client client){ if (client == null) { throw new IllegalArgumentException("client == null"); } this.client = client; this.channel = new HeaderExchangeChannel(client); String dubbo = client.getUrl().getParameter(Constants.DUBBO_VERSION_KEY); this.heartbeat = client.getUrl().getParameter( Constants.HEARTBEAT_KEY, dubbo != null && dubbo.startsWith("1.0.") ? Constants.DEFAULT_HEARTBEAT : 0 ); this.heartbeatTimeout = client.getUrl().getParameter( Constants.HEARTBEAT_TIMEOUT_KEY, heartbeat * 3 ); if ( heartbeatTimeout < heartbeat * 2 ) { throw new IllegalStateException( "heartbeatTimeout < heartbeatInterval * 2" ); } startHeatbeatTimer(); }
Example #16
Source File: AbstractGroup.java From dubbox with Apache License 2.0 | 5 votes |
protected Client connect(URL url) throws RemotingException { if (servers.containsKey(url)) { return null; } Client client = clients.get(url); if (client == null) { // TODO 有并发间隙 client = Transporters.connect(url, dispatcher); clients.put(url, client); } return client; }
Example #17
Source File: AbstractExchangeGroup.java From dubbox with Apache License 2.0 | 5 votes |
protected Client connect(URL url) throws RemotingException { if (servers.containsKey(url)) { return null; } ExchangeClient client = clients.get(url); if (client == null) { // TODO 有并发间隙 client = Exchangers.connect(url, dispatcher); clients.put(url, client); } return client; }
Example #18
Source File: ServerPeer.java From dubbox with Apache License 2.0 | 5 votes |
@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; }
Example #19
Source File: ServerPeer.java From dubbox with Apache License 2.0 | 5 votes |
@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; }
Example #20
Source File: AbstractGroup.java From dubbox with Apache License 2.0 | 5 votes |
protected Client connect(URL url) throws RemotingException { if (servers.containsKey(url)) { return null; } Client client = clients.get(url); if (client == null) { // TODO 有并发间隙 client = Transporters.connect(url, dispatcher); clients.put(url, client); } return client; }
Example #21
Source File: HeaderExchangeClient.java From dubbox with Apache License 2.0 | 5 votes |
public HeaderExchangeClient(Client client){ if (client == null) { throw new IllegalArgumentException("client == null"); } this.client = client; this.channel = new HeaderExchangeChannel(client); String dubbo = client.getUrl().getParameter(Constants.DUBBO_VERSION_KEY); this.heartbeat = client.getUrl().getParameter( Constants.HEARTBEAT_KEY, dubbo != null && dubbo.startsWith("1.0.") ? Constants.DEFAULT_HEARTBEAT : 0 ); this.heartbeatTimeout = client.getUrl().getParameter( Constants.HEARTBEAT_TIMEOUT_KEY, heartbeat * 3 ); if ( heartbeatTimeout < heartbeat * 2 ) { throw new IllegalStateException( "heartbeatTimeout < heartbeatInterval * 2" ); } startHeatbeatTimer(); }
Example #22
Source File: AbstractExchangeGroup.java From dubbox with Apache License 2.0 | 5 votes |
protected Client connect(URL url) throws RemotingException { if (servers.containsKey(url)) { return null; } ExchangeClient client = clients.get(url); if (client == null) { // TODO 有并发间隙 client = Exchangers.connect(url, dispatcher); clients.put(url, client); } return client; }
Example #23
Source File: AbstractExchangeGroup.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
protected Client connect(URL url) throws RemotingException { if (servers.containsKey(url)) { return null; } ExchangeClient client = clients.get(url); if (client == null) { // TODO 有并发间隙 client = Exchangers.connect(url, dispatcher); clients.put(url, client); } return client; }
Example #24
Source File: ServerPeer.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
@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; }
Example #25
Source File: AbstractGroup.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
protected Client connect(URL url) throws RemotingException { if (servers.containsKey(url)) { return null; } Client client = clients.get(url); if (client == null) { // TODO 有并发间隙 client = Transporters.connect(url, dispatcher); clients.put(url, client); } return client; }
Example #26
Source File: HeaderExchangeClient.java From dubbo3 with Apache License 2.0 | 5 votes |
public HeaderExchangeClient(Client client){ if (client == null) { throw new IllegalArgumentException("client == null"); } this.client = client; this.channel = new HeaderExchangeChannel(client); String dubbo = client.getUrl().getParameter(Constants.DUBBO_VERSION_KEY); this.heartbeat = client.getUrl().getParameter( Constants.HEARTBEAT_KEY, dubbo != null && dubbo.startsWith("1.0.") ? Constants.DEFAULT_HEARTBEAT : 0 ); this.heartbeatTimeout = client.getUrl().getParameter( Constants.HEARTBEAT_TIMEOUT_KEY, heartbeat * 3 ); if ( heartbeatTimeout < heartbeat * 2 ) { throw new IllegalStateException( "heartbeatTimeout < heartbeatInterval * 2" ); } startHeatbeatTimer(); }
Example #27
Source File: ServerPeer.java From dubbox with Apache License 2.0 | 5 votes |
@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; }
Example #28
Source File: ClientReconnectTest.java From dubbox with Apache License 2.0 | 4 votes |
public Client startClient(int port , int reconnectPeriod) throws RemotingException{ final String url = "exchange://127.0.0.1:"+port + "/client.reconnect.test?check=false&"+Constants.RECONNECT_KEY+"="+reconnectPeriod; return Exchangers.connect(url); }
Example #29
Source File: ClientDelegate.java From dubbox with Apache License 2.0 | 4 votes |
public ClientDelegate(Client client){ setClient(client); }
Example #30
Source File: ClientDelegate.java From dubbo3 with Apache License 2.0 | 4 votes |
public Client getClient() { return client; }