Examples of ExchangeClient


Examples of com.alibaba.dubbo.remoting.exchange.ExchangeClient

        final AtomicInteger error = new AtomicInteger();
        for (int n = 0; n < concurrent; n++) {
            new Thread(new Runnable() {
                public void run() {
                    for (int i = 0; i < runs; i++) {
                        ExchangeClient client = null;
                        try {
                            client = Exchangers.connect(url);
                            int c = count.incrementAndGet();
                            if (c % 100 == 0) {
                                System.out.println("count: " + count.get() + ", error: " + error.get());
                            }
                        } catch (Exception e) {
                            error.incrementAndGet();
                            e.printStackTrace();
                            System.out.println("count: " + count.get() + ", error: " + error.get());
                            if ("exit".equals(onerror)) {
                                System.exit(-1);
                            } else if ("break".equals(onerror)) {
                                break;
                            } else if ("sleep".equals(onerror)) {
                                try {
                                    Thread.sleep(30000);
                                } catch (InterruptedException e1) {
                                }
                            }
                        } finally {
                            if (client != null) {
                                client.close();
                            }
                        }
                    }
                }
            }).start();
View Full Code Here

Examples of com.alibaba.dubbo.remoting.exchange.ExchangeClient

        final String serialization = PerformanceUtils.getProperty(Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION);
        final int timeout = PerformanceUtils.getIntProperty(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
        int sleep = PerformanceUtils.getIntProperty("sleep", 60*1000*60);
       
        final String url = "exchange://" + server + "?transporter=" + transporter + "&serialization=" + serialization + "&timeout=" + timeout;
        ExchangeClient exchangeClient =initClient(url);
        Thread.sleep(sleep);
        closeClient(exchangeClient);
    }
View Full Code Here

Examples of com.alibaba.dubbo.remoting.exchange.ExchangeClient

        closeClient(exchangeClient);
    }
   
    public static  ExchangeClient initClient(String url){
        // 创建客户端
        ExchangeClient exchangeClient  = null;
        PeformanceTestHandler handler = new PeformanceTestHandler(url);
        boolean run = true;
        while(run){
            try{
                exchangeClient= Exchangers.connect(url,handler);
View Full Code Here

Examples of com.alibaba.dubbo.remoting.exchange.ExchangeClient

        }
       
        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();

    }
View Full Code Here

Examples of com.alibaba.dubbo.remoting.exchange.ExchangeClient

        ProtocolUtils.closeAll();
    }

    @Test
    public void testListClient() throws Exception {
        ExchangeClient client1 = Exchangers.connect("dubbo://127.0.0.1:20887/demo");
        ExchangeClient client2 = Exchangers.connect("dubbo://127.0.0.1:20887/demo");
        Thread.sleep(5000);
        String result = port.telnet(null, "-l 20887");
        String client1Addr = client1.getLocalAddress().toString();
        String client2Addr = client2.getLocalAddress().toString();
        System.out.printf("Result: %s %n", result);
        System.out.printf("Client 1 Address %s %n", client1Addr);
        System.out.printf("Client 2 Address %s %n", client2Addr);
        assertTrue(result.contains(client1Addr));
        assertTrue(result.contains(client2Addr));
View Full Code Here

Examples of com.alibaba.dubbo.remoting.exchange.ExchangeClient

            } else {
//                logger.warn(new IllegalStateException("client is closed,but stay in clientmap .client :"+ client));
                referenceClientMap.remove(key);
            }
        }
        ExchangeClient exchagneclient = initClient(url);
       
        client = new ReferenceCountExchangeClient(exchagneclient, ghostClientMap);
        referenceClientMap.put(key, client);
        ghostClientMap.remove(key);
        return client;
View Full Code Here

Examples of com.alibaba.dubbo.remoting.exchange.ExchangeClient

        if (str != null && str.length() > 0 && ! ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) {
            throw new RpcException("Unsupported client type: " + str + "," +
                    " supported client type is " + StringUtils.join(ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions(), " "));
        }
       
        ExchangeClient client ;
        try {
            //设置连接应该是lazy的
            if (url.getParameter(Constants.LAZY_CONNECT_KEY, false)){
                client = new LazyConnectExchangeClient(url ,requestHandler);
            } else {
View Full Code Here

Examples of com.alibaba.dubbo.remoting.exchange.ExchangeClient

                }
            }
        }
       
        for (String key : new ArrayList<String>(referenceClientMap.keySet())) {
            ExchangeClient client = referenceClientMap.remove(key);
            if (client != null) {
                try {
                    if (logger.isInfoEnabled()) {
                        logger.info("Close dubbo connect: " + client.getLocalAddress() + "-->" + client.getRemoteAddress());
                    }
                    client.close();
                } catch (Throwable t) {
                    logger.warn(t.getMessage(), t);
                }
            }
        }
       
        for (String key : new ArrayList<String>(ghostClientMap.keySet())) {
            ExchangeClient client = ghostClientMap.remove(key);
            if (client != null) {
                try {
                    if (logger.isInfoEnabled()) {
                        logger.info("Close dubbo connect: " + client.getLocalAddress() + "-->" + client.getRemoteAddress());
                    }
                    client.close();
                } catch (Throwable t) {
                    logger.warn(t.getMessage(), t);
                }
            }
        }
View Full Code Here

Examples of com.alibaba.dubbo.remoting.exchange.ExchangeClient

    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;
View Full Code Here

Examples of com.alibaba.dubbo.remoting.exchange.ExchangeClient

            } else {
//                logger.warn(new IllegalStateException("client is closed,but stay in clientmap .client :"+ client));
                referenceClientMap.remove(key);
            }
        }
        ExchangeClient exchagneclient = initClient(url);
       
        client = new ReferenceCountExchangeClient(exchagneclient, ghostClientMap);
        referenceClientMap.put(key, client);
        ghostClientMap.remove(key);
        return client;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.