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


Java Client类代码示例

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


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

示例1: testClientReconnectMethod

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

示例2: connect

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

示例3: getChannel

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

示例4: connect

import com.alibaba.dubbo.remoting.Client; //导入依赖的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

示例5: HeaderExchangeClient

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


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