Java Code Examples for com.alibaba.dubbo.remoting.exchange.ExchangeClient#close()
The following examples show how to use
com.alibaba.dubbo.remoting.exchange.ExchangeClient#close() .
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: DubboInvoker.java From dubbo3 with Apache License 2.0 | 6 votes |
public void destroy() { //防止client被关闭多次.在connect per jvm的情况下,client.close方法会调用计数器-1,当计数器小于等于0的情况下,才真正关闭 if (!super.isDestroyed()) { //dubbo check ,避免多次关闭 destroyLock.lock(); try { if (super.isDestroyed()) { return; } super.destroy(); if (invokers != null) { invokers.remove(this); } for (ExchangeClient client : clients) { try { client.close(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } } finally { destroyLock.unlock(); } } }
Example 2
Source File: ThriftInvoker.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Override public void destroy() { // in order to avoid closing a client multiple times, a counter is used in case of connection per jvm, every // time when client.close() is called, counter counts down once, and when counter reaches zero, client will be // closed. if (super.isDestroyed()) { return; } else { // double check to avoid dup close destroyLock.lock(); try { if (super.isDestroyed()) { return; } super.destroy(); if (invokers != null) { invokers.remove(this); } for (ExchangeClient client : clients) { try { client.close(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } } finally { destroyLock.unlock(); } } }
Example 3
Source File: ThriftInvoker.java From dubbox with Apache License 2.0 | 5 votes |
public void destroy() { //防止client被关闭多次.在connect per jvm的情况下,client.close方法会调用计数器-1,当计数器小于等于0的情况下,才真正关闭 if (super.isDestroyed()){ return ; } else { //dubbo check ,避免多次关闭 destroyLock.lock(); try{ if (super.isDestroyed()){ return ; } super.destroy(); if(invokers != null) { invokers.remove(this); } for (ExchangeClient client : clients) { try { client.close(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } }finally { destroyLock.unlock(); } } }
Example 4
Source File: ThriftInvoker.java From dubbox with Apache License 2.0 | 5 votes |
public void destroy() { //防止client被关闭多次.在connect per jvm的情况下,client.close方法会调用计数器-1,当计数器小于等于0的情况下,才真正关闭 if (super.isDestroyed()){ return ; } else { //dubbo check ,避免多次关闭 destroyLock.lock(); try{ if (super.isDestroyed()){ return ; } super.destroy(); if(invokers != null) { invokers.remove(this); } for (ExchangeClient client : clients) { try { client.close(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } }finally { destroyLock.unlock(); } } }
Example 5
Source File: ThriftInvoker.java From dubbox with Apache License 2.0 | 5 votes |
public void destroy() { //防止client被关闭多次.在connect per jvm的情况下,client.close方法会调用计数器-1,当计数器小于等于0的情况下,才真正关闭 if (super.isDestroyed()){ return ; } else { //dubbo check ,避免多次关闭 destroyLock.lock(); try{ if (super.isDestroyed()){ return ; } super.destroy(); if(invokers != null) { invokers.remove(this); } for (ExchangeClient client : clients) { try { client.close(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } }finally { destroyLock.unlock(); } } }
Example 6
Source File: ThriftInvoker.java From dubbox with Apache License 2.0 | 5 votes |
public void destroy() { //防止client被关闭多次.在connect per jvm的情况下,client.close方法会调用计数器-1,当计数器小于等于0的情况下,才真正关闭 if (super.isDestroyed()){ return ; } else { //dubbo check ,避免多次关闭 destroyLock.lock(); try{ if (super.isDestroyed()){ return ; } super.destroy(); if(invokers != null) { invokers.remove(this); } for (ExchangeClient client : clients) { try { client.close(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } }finally { destroyLock.unlock(); } } }
Example 7
Source File: DubboInvoker.java From dubbox with Apache License 2.0 | 5 votes |
public void destroy() { //防止client被关闭多次.在connect per jvm的情况下,client.close方法会调用计数器-1,当计数器小于等于0的情况下,才真正关闭 if (super.isDestroyed()){ return ; } else { //dubbo check ,避免多次关闭 destroyLock.lock(); try{ if (super.isDestroyed()){ return ; } super.destroy(); if (invokers != null){ invokers.remove(this); } for (ExchangeClient client : clients) { try { client.close(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } }finally { destroyLock.unlock(); } } }
Example 8
Source File: ThriftInvoker.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public void destroy() { //防止client被关闭多次.在connect per jvm的情况下,client.close方法会调用计数器-1,当计数器小于等于0的情况下,才真正关闭 if (super.isDestroyed()){ return ; } else { //dubbo check ,避免多次关闭 destroyLock.lock(); try{ if (super.isDestroyed()){ return ; } super.destroy(); if(invokers != null) { invokers.remove(this); } for (ExchangeClient client : clients) { try { client.close(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } }finally { destroyLock.unlock(); } } }
Example 9
Source File: DubboInvoker.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public void destroy() { //防止client被关闭多次.在connect per jvm的情况下,client.close方法会调用计数器-1,当计数器小于等于0的情况下,才真正关闭 if (super.isDestroyed()){ return ; } else { //dubbo check ,避免多次关闭 destroyLock.lock(); try{ if (super.isDestroyed()){ return ; } super.destroy(); if (invokers != null){ invokers.remove(this); } for (ExchangeClient client : clients) { try { client.close(); } catch (Throwable t) { logger.warn(t.getMessage(), t); } } }finally { destroyLock.unlock(); } } }
Example 10
Source File: HeartbeatServer.java From dubbox with Apache License 2.0 | 4 votes |
public static void main( String[] args ) throws Exception { final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler( handler ); Thread serverThread = new Thread( new Runnable() { public void run() { try { exchangeServer = new HeaderExchangeServer( Transporters.bind( clientUrl.addParameter( Constants.HEARTBEAT_KEY, 1000 ), serverHandler ) ); serverStarted = true; } catch ( Exception e ) { e.printStackTrace(); } } } ); serverThread.setDaemon( true ); serverThread.start(); while ( !serverStarted ) { Thread.sleep( 1000 ); } HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler( handler ); ExchangeClient exchangeClient = new HeaderExchangeClient( Transporters.connect( clientUrl, clientHandler ) ); for ( int i = 0; i < 10; i++ ) { Thread.sleep( 1000 ); System.out.print( "." ); } System.out.println(); if ( clientHandler.getHeartBeatCount() > 0 ) { System.out.printf( "Client receives %d heartbeats", clientHandler.getHeartBeatCount() ); } else { throw new Exception( "Server heartbeat does not work." ); } exchangeClient.close(); exchangeServer.close(); }
Example 11
Source File: ChanelHandlerTest.java From dubbox with Apache License 2.0 | 4 votes |
public static void closeClient(ExchangeClient client){ if(client.isConnected()){ client.close(); } }
Example 12
Source File: ChanelHandlerTest.java From dubbo3 with Apache License 2.0 | 4 votes |
public static void closeClient(ExchangeClient client){ if(client.isConnected()){ client.close(); } }
Example 13
Source File: HeartbeatServer.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public static void main( String[] args ) throws Exception { final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler( handler ); Thread serverThread = new Thread( new Runnable() { public void run() { try { exchangeServer = new HeaderExchangeServer( Transporters.bind( clientUrl.addParameter( Constants.HEARTBEAT_KEY, 1000 ), serverHandler ) ); serverStarted = true; } catch ( Exception e ) { e.printStackTrace(); } } } ); serverThread.setDaemon( true ); serverThread.start(); while ( !serverStarted ) { Thread.sleep( 1000 ); } HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler( handler ); ExchangeClient exchangeClient = new HeaderExchangeClient( Transporters.connect( clientUrl, clientHandler ) ); for ( int i = 0; i < 10; i++ ) { Thread.sleep( 1000 ); System.out.print( "." ); } System.out.println(); if ( clientHandler.getHeartBeatCount() > 0 ) { System.out.printf( "Client receives %d heartbeats", clientHandler.getHeartBeatCount() ); } else { throw new Exception( "Server heartbeat does not work." ); } exchangeClient.close(); exchangeServer.close(); }
Example 14
Source File: ChanelHandlerTest.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public static void closeClient(ExchangeClient client){ if(client.isConnected()){ client.close(); } }
Example 15
Source File: HeartbeatClient.java From dubbox with Apache License 2.0 | 4 votes |
public static void main( String[] args ) throws Exception { final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler( handler ); Thread serverThread = new Thread( new Runnable() { public void run() { try { exchangeServer = new HeaderExchangeServer( Transporters.bind( serverUrl, serverHandler ) ); serverStarted = true; } catch ( Exception e ) { e.printStackTrace(); } } } ); serverThread.setDaemon( true ); serverThread.start(); while ( ! serverStarted ) { Thread.sleep( 1000 ); } URL url = serverUrl.addParameter( Constants.HEARTBEAT_KEY, 1000 ); HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler( handler ); ExchangeClient exchangeClient = new HeaderExchangeClient( Transporters.connect( url, clientHandler ) ); for( int i = 0; i < 10; i++ ) { Thread.sleep( 1000 ); System.out.print( "." ); } System.out.println(); if ( serverHandler.getHeartBeatCount() > 0 ) { System.out.printf( "Server receives %d heartbeats", serverHandler.getHeartBeatCount() ); } else { throw new Exception( "Client heartbeat does not work." ); } exchangeClient.close(); exchangeServer.close(); }
Example 16
Source File: HeartbeatServer.java From dubbox with Apache License 2.0 | 4 votes |
public static void main( String[] args ) throws Exception { final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler( handler ); Thread serverThread = new Thread( new Runnable() { public void run() { try { exchangeServer = new HeaderExchangeServer( Transporters.bind( clientUrl.addParameter( Constants.HEARTBEAT_KEY, 1000 ), serverHandler ) ); serverStarted = true; } catch ( Exception e ) { e.printStackTrace(); } } } ); serverThread.setDaemon( true ); serverThread.start(); while ( !serverStarted ) { Thread.sleep( 1000 ); } HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler( handler ); ExchangeClient exchangeClient = new HeaderExchangeClient( Transporters.connect( clientUrl, clientHandler ) ); for ( int i = 0; i < 10; i++ ) { Thread.sleep( 1000 ); System.out.print( "." ); } System.out.println(); if ( clientHandler.getHeartBeatCount() > 0 ) { System.out.printf( "Client receives %d heartbeats", clientHandler.getHeartBeatCount() ); } else { throw new Exception( "Server heartbeat does not work." ); } exchangeClient.close(); exchangeServer.close(); }
Example 17
Source File: ChanelHandlerTest.java From dubbox with Apache License 2.0 | 4 votes |
public static void closeClient(ExchangeClient client){ if(client.isConnected()){ client.close(); } }
Example 18
Source File: ChanelHandlerTest.java From dubbox with Apache License 2.0 | 4 votes |
public static void closeClient(ExchangeClient client){ if(client.isConnected()){ client.close(); } }
Example 19
Source File: HeartbeatClient.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler(handler); Thread serverThread = new Thread(new Runnable() { @Override public void run() { try { exchangeServer = new HeaderExchangeServer( Transporters.bind(serverUrl, serverHandler)); serverStarted = true; } catch (Exception e) { e.printStackTrace(); } } }); serverThread.setDaemon(true); serverThread.start(); while (!serverStarted) { Thread.sleep(1000); } URL url = serverUrl.addParameter(Constants.HEARTBEAT_KEY, 1000); HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler(handler); ExchangeClient exchangeClient = new HeaderExchangeClient(Transporters.connect(url, clientHandler),true); for (int i = 0; i < 10; i++) { Thread.sleep(1000); System.out.print("."); } System.out.println(); if (serverHandler.getHeartBeatCount() > 0) { System.out.printf("Server receives %d heartbeats", serverHandler.getHeartBeatCount()); } else { throw new Exception("Client heartbeat does not work."); } exchangeClient.close(); exchangeServer.close(); }
Example 20
Source File: HeartbeatServer.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler(handler); Thread serverThread = new Thread(new Runnable() { @Override public void run() { try { exchangeServer = new HeaderExchangeServer( Transporters.bind( clientUrl.addParameter(Constants.HEARTBEAT_KEY, 1000), serverHandler)); serverStarted = true; } catch (Exception e) { e.printStackTrace(); } } }); serverThread.setDaemon(true); serverThread.start(); while (!serverStarted) { Thread.sleep(1000); } HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler(handler); ExchangeClient exchangeClient = new HeaderExchangeClient(Transporters.connect(clientUrl, clientHandler),true); for (int i = 0; i < 10; i++) { Thread.sleep(1000); System.out.print("."); } System.out.println(); if (clientHandler.getHeartBeatCount() > 0) { System.out.printf("Client receives %d heartbeats", clientHandler.getHeartBeatCount()); } else { throw new Exception("Server heartbeat does not work."); } exchangeClient.close(); exchangeServer.close(); }