本文整理汇总了Java中com.alibaba.dubbo.remoting.Transporters.connect方法的典型用法代码示例。如果您正苦于以下问题:Java Transporters.connect方法的具体用法?Java Transporters.connect怎么用?Java Transporters.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.remoting.Transporters
的用法示例。
在下文中一共展示了Transporters.connect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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))));
}
示例3: 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();
}
示例4: 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();
}
示例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),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();
}
示例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),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();
}
示例7: 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))), true);
}