当前位置: 首页>>代码示例>>Java>>正文


Java Transporters类代码示例

本文整理汇总了Java中com.alibaba.dubbo.remoting.Transporters的典型用法代码示例。如果您正苦于以下问题:Java Transporters类的具体用法?Java Transporters怎么用?Java Transporters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Transporters类属于com.alibaba.dubbo.remoting包,在下文中一共展示了Transporters类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: join

import com.alibaba.dubbo.remoting.Transporters; //导入依赖的package包/类
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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:10,代码来源:AbstractGroup.java

示例2: connect

import com.alibaba.dubbo.remoting.Transporters; //导入依赖的package包/类
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;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:AbstractGroup.java

示例3: connect

import com.alibaba.dubbo.remoting.Transporters; //导入依赖的package包/类
public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeClient(Transporters.connect(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:4,代码来源:HeaderExchanger.java

示例4: bind

import com.alibaba.dubbo.remoting.Transporters; //导入依赖的package包/类
public ExchangeServer bind(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeServer(Transporters.bind(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:4,代码来源:HeaderExchanger.java

示例5: main

import com.alibaba.dubbo.remoting.Transporters; //导入依赖的package包/类
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();

    }
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:49,代码来源:HeartbeatServer.java

示例6: main

import com.alibaba.dubbo.remoting.Transporters; //导入依赖的package包/类
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();

}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:49,代码来源:HeartbeatClient.java


注:本文中的com.alibaba.dubbo.remoting.Transporters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。