本文整理汇总了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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}