use of io.vertx.core.http.HttpServerOptions in project vert.x by eclipse.
the class HttpRequestStreamTest method testClosingServerClosesRequestStreamEndHandler.
@Test
public void testClosingServerClosesRequestStreamEndHandler() {
this.server = vertx.createHttpServer(new HttpServerOptions().setPort(HttpTestBase.DEFAULT_HTTP_PORT));
ReadStream<HttpServerRequest> stream = server.requestStream();
AtomicBoolean closed = new AtomicBoolean();
stream.endHandler(v -> closed.set(true));
stream.handler(req -> {
});
server.listen(ar -> {
assertTrue(ar.succeeded());
assertFalse(closed.get());
server.close(v -> {
assertTrue(ar.succeeded());
assertTrue(closed.get());
testComplete();
});
});
await();
}
use of io.vertx.core.http.HttpServerOptions in project java-chassis by ServiceComb.
the class GrpcVerticle method startListen.
protected void startListen(Future<Void> startFuture) {
// 如果本地未配置grpc地址,则表示不必监听,只需要作为客户端使用即可
if (StringUtils.isEmpty(this.endpoint)) {
LOGGER.warn("grpc listen address is not configured, will not listen.");
startFuture.complete();
return;
}
Router mainRouter = Router.router(vertx);
mainRouter.route().handler(new GrpcBodyHandler());
new GrpcServer(mainRouter);
HttpServerOptions serverOptions = new HttpServerOptions();
serverOptions.setAcceptBacklog(ACCEPT_BACKLOG);
serverOptions.setSendBufferSize(SEND_BUFFER_SIZE);
serverOptions.setReceiveBufferSize(RECEIVE_BUFFER_SIZE);
serverOptions.setUsePooledBuffers(true);
String key = System.getProperty("store.key");
if (key != null && !key.isEmpty()) {
serverOptions.setUseAlpn(true);
serverOptions.setSsl(true);
serverOptions.setKeyStoreOptions(new JksOptions().setPath(System.getProperty("store.key")).setPassword(System.getProperty("store.pass")));
}
HttpServer server = vertx.createHttpServer(serverOptions).requestHandler(mainRouter::accept);
IpPort ipPort = NetUtils.parseIpPortFromURI(this.endpoint);
if (ipPort == null) {
LOGGER.error("wrong grpc listen address {}", this.endpoint);
return;
}
startListen(server, ipPort, startFuture);
}
Aggregations