com.alibaba.dubbo.remoting.Transporters Java Examples

The following examples show how to use com.alibaba.dubbo.remoting.Transporters. 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: AbstractGroup.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
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 #2
Source File: AbstractGroup.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Server server = servers.get(url);
    if (server == null) { // TODO 有并发间隙
        server = Transporters.bind(url, handler);
        servers.put(url, server);
        dispatcher.addChannelHandler(handler);
    }
    return new ServerPeer(server, clients, this);
}
 
Example #3
Source File: AbstractGroup.java    From dubbox with Apache License 2.0 5 votes vote down vote up
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 #4
Source File: AbstractGroup.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
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 #5
Source File: AbstractGroup.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Server server = servers.get(url);
    if (server == null) { // TODO 有并发间隙
        server = Transporters.bind(url, handler);
        servers.put(url, server);
        dispatcher.addChannelHandler(handler);
    }
    return new ServerPeer(server, clients, this);
}
 
Example #6
Source File: AbstractGroup.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Server server = servers.get(url);
    if (server == null) { // TODO 有并发间隙
        server = Transporters.bind(url, handler);
        servers.put(url, server);
        dispatcher.addChannelHandler(handler);
    }
    return new ServerPeer(server, clients, this);
}
 
Example #7
Source File: AbstractGroup.java    From dubbox with Apache License 2.0 5 votes vote down vote up
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 #8
Source File: AbstractGroup.java    From dubbox with Apache License 2.0 5 votes vote down vote up
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 #9
Source File: AbstractGroup.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Server server = servers.get(url);
    if (server == null) { // TODO 有并发间隙
        server = Transporters.bind(url, handler);
        servers.put(url, server);
        dispatcher.addChannelHandler(handler);
    }
    return new ServerPeer(server, clients, this);
}
 
Example #10
Source File: AbstractGroup.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Server server = servers.get(url);
    if (server == null) { // TODO exist concurrent gap
        server = Transporters.bind(url, handler);
        servers.put(url, server);
        dispatcher.addChannelHandler(handler);
    }
    return new ServerPeer(server, clients, this);
}
 
Example #11
Source File: HeaderExchanger.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeClient(Transporters.connect(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #12
Source File: HeartbeatClient.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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 #13
Source File: HeartbeatServer.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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: HeaderExchanger.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeServer(Transporters.bind(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #15
Source File: HeartbeatServer.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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 #16
Source File: HeaderExchanger.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeServer(Transporters.bind(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #17
Source File: HeaderExchanger.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeClient(Transporters.connect(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #18
Source File: HeartbeatClient.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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 #19
Source File: HeaderExchanger.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeServer(Transporters.bind(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #20
Source File: HeaderExchanger.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeClient(Transporters.connect(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #21
Source File: HeartbeatClient.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
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 #22
Source File: HeartbeatServer.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
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 #23
Source File: HeaderExchanger.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeServer(Transporters.bind(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #24
Source File: HeaderExchanger.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeClient(Transporters.connect(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #25
Source File: HeartbeatClient.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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 #26
Source File: HeartbeatServer.java    From dubbox with Apache License 2.0 4 votes vote down vote up
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 #27
Source File: HeaderExchanger.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeServer(Transporters.bind(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #28
Source File: HeaderExchanger.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeClient(Transporters.connect(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
Example #29
Source File: HeartbeatClient.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
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 #30
Source File: HeartbeatServer.java    From dubbo-2.6.5 with Apache License 2.0 4 votes vote down vote up
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();

    }