use of org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig in project incubator-servicecomb-java-chassis by apache.
the class HighwayClient method createTcpClientConfig.
private TcpClientConfig createTcpClientConfig() {
TcpClientConfig tcpClientConfig = new TcpClientConfig();
DynamicLongProperty prop = AbstractTransport.getRequestTimeoutProperty();
prop.addCallback(new Runnable() {
public void run() {
tcpClientConfig.setRequestTimeoutMillis(prop.get());
}
});
tcpClientConfig.setRequestTimeoutMillis(prop.get());
SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
SSLOption sslOption;
if (factory == null) {
sslOption = SSLOption.buildFromYaml(SSL_KEY);
} else {
sslOption = factory.createSSLOption();
}
SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
VertxTLSBuilder.buildClientOptionsBase(sslOption, sslCustom, tcpClientConfig);
return tcpClientConfig;
}
use of org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig in project java-chassis by ServiceComb.
the class HighwayClient method init.
public void init(Vertx vertx) throws Exception {
TcpClientConfig normalConfig = createTcpClientConfig();
normalConfig.setSsl(false);
TcpClientConfig sslConfig = createTcpClientConfig();
sslConfig.setSsl(true);
clientMgr = new ClientPoolManager<>(vertx, new HighwayClientPoolFactory(normalConfig, sslConfig));
DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(clientMgr, HighwayConfig.getClientThreadCount());
VertxUtils.blockDeploy(vertx, ClientVerticle.class, deployOptions);
}
use of org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig in project java-chassis by ServiceComb.
the class HighwayClient method createTcpClientConfig.
private TcpClientConfig createTcpClientConfig() {
TcpClientConfig tcpClientConfig = new TcpClientConfig();
// global request timeout to be login timeout
tcpClientConfig.setMsLoginTimeout(DynamicPropertyFactory.getInstance().getLongProperty("servicecomb.request.timeout", TcpClientConfig.DEFAULT_LOGIN_TIMEOUT).get());
SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
SSLOption sslOption;
if (factory == null) {
sslOption = SSLOption.buildFromYaml(SSL_KEY);
} else {
sslOption = factory.createSSLOption();
}
SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
VertxTLSBuilder.buildClientOptionsBase(sslOption, sslCustom, tcpClientConfig);
return tcpClientConfig;
}
use of org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig in project incubator-servicecomb-java-chassis by apache.
the class HighwayClient method init.
public void init(Vertx vertx) throws Exception {
TcpClientConfig normalConfig = createTcpClientConfig();
normalConfig.setSsl(false);
TcpClientConfig sslConfig = createTcpClientConfig();
sslConfig.setSsl(true);
clientMgr = new ClientPoolManager<>(vertx, new HighwayClientPoolFactory(normalConfig, sslConfig));
DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(clientMgr, HighwayConfig.getClientThreadCount());
VertxUtils.blockDeploy(vertx, ClientVerticle.class, deployOptions);
}
use of org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig in project java-chassis by ServiceComb.
the class TestHighwayClient method testLoginTimeout.
@Test
public void testLoginTimeout(@Mocked Vertx vertx) {
TcpClientConfig tcpClientConfig = Deencapsulation.invoke(client, "createTcpClientConfig");
Assert.assertEquals(2000, tcpClientConfig.getMsLoginTimeout());
}
Aggregations