Search in sources :

Example 1 with TcpClientConfig

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;
}
Also used : TcpClientConfig(org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig) SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) DynamicLongProperty(com.netflix.config.DynamicLongProperty)

Example 2 with 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);
}
Also used : DeploymentOptions(io.vertx.core.DeploymentOptions) TcpClientConfig(org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig)

Example 3 with TcpClientConfig

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;
}
Also used : TcpClientConfig(org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig) SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom)

Example 4 with 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);
}
Also used : DeploymentOptions(io.vertx.core.DeploymentOptions) TcpClientConfig(org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig)

Example 5 with TcpClientConfig

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());
}
Also used : TcpClientConfig(org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig) Test(org.junit.Test)

Aggregations

TcpClientConfig (org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig)5 DeploymentOptions (io.vertx.core.DeploymentOptions)2 SSLCustom (org.apache.servicecomb.foundation.ssl.SSLCustom)2 SSLOption (org.apache.servicecomb.foundation.ssl.SSLOption)2 SSLOptionFactory (org.apache.servicecomb.foundation.ssl.SSLOptionFactory)2 DynamicLongProperty (com.netflix.config.DynamicLongProperty)1 Test (org.junit.Test)1