use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class GrpcTransport method createHttpClientOptions.
private HttpClientOptions createHttpClientOptions() {
HttpClientOptions httpClientOptions = new HttpClientOptions();
httpClientOptions.setProtocolVersion(HttpVersion.HTTP_2);
httpClientOptions.setHttp2ClearTextUpgrade(false);
String key = System.getProperty("store.key");
if (key != null && !key.isEmpty()) {
httpClientOptions.setUseAlpn(true);
httpClientOptions.setSsl(true);
httpClientOptions.setKeyStoreOptions(new JksOptions().setPath(System.getProperty("store.key")).setPassword(System.getProperty("store.pass")));
httpClientOptions.setTrustAll(true);
httpClientOptions.setVerifyHost(false);
}
return httpClientOptions;
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class RestTransportClient method init.
public void init(Vertx vertx) throws Exception {
HttpClientOptions httpClientOptions = createHttpClientOptions();
DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(clientMgr, TransportClientConfig.getThreadCount(), TransportClientConfig.getConnectionPoolPerThread(), httpClientOptions);
VertxUtils.blockDeploy(vertx, HttpClientVerticle.class, deployOptions);
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class AbstractClientPool method create.
public void create() {
// 这里面是同步接口,且好像直接在事件线程中用,保险起见,先使用独立的vertx实例
Vertx vertx = VertxUtils.getOrCreateVertxByName("registry", null);
HttpClientOptions httpClientOptions = createHttpClientOptions();
DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(this.clientMgr, ServiceRegistryConfig.INSTANCE.getWorkerPoolSize(), 1, httpClientOptions);
try {
VertxUtils.blockDeploy(vertx, HttpClientVerticle.class, deployOptions);
} catch (InterruptedException e) {
LOGGER.error("deploy a registry verticle failed, {}", e.getMessage());
}
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class HttpClientPool method createHttpClientOptions.
@Override
public HttpClientOptions createHttpClientOptions() {
HttpVersion ver = ServiceRegistryConfig.INSTANCE.getHttpVersion();
HttpClientOptions httpClientOptions = new HttpClientOptions();
httpClientOptions.setProtocolVersion(ver);
httpClientOptions.setConnectTimeout(ServiceRegistryConfig.INSTANCE.getConnectionTimeout());
httpClientOptions.setIdleTimeout(ServiceRegistryConfig.INSTANCE.getIdleConnectionTimeout());
if (ver == HttpVersion.HTTP_2) {
LOGGER.debug("service center client protocol version is HTTP/2");
httpClientOptions.setHttp2ClearTextUpgrade(false);
}
if (ServiceRegistryConfig.INSTANCE.isSsl()) {
LOGGER.debug("service center client performs requests over TLS");
buildSecureClientOptions(httpClientOptions);
}
return httpClientOptions;
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class TestServiceRegistryClientImpl method testPrivateMehtodCreateHttpClientOptions.
@Test
public void testPrivateMehtodCreateHttpClientOptions() {
Microservice oInstance = RegistryUtils.getMicroservice();
oClient.registerMicroservice(oInstance);
oClient.registerMicroserviceInstance(RegistryUtils.getMicroserviceInstance());
new MockUp<ServiceRegistryConfig>() {
@Mock
public HttpVersion getHttpVersion() {
return HttpVersion.HTTP_2;
}
@Mock
public boolean isSsl() {
return true;
}
};
try {
oClient.init();
HttpClientOptions httpClientOptions = Deencapsulation.invoke(oClient, "createHttpClientOptions");
Assert.assertNotNull(httpClientOptions);
Assert.assertEquals(80, httpClientOptions.getDefaultPort());
} catch (Exception e) {
Assert.assertNotNull(e);
}
}
Aggregations