List of usage examples for io.vertx.core.http HttpServerOptions setReceiveBufferSize
@Override public HttpServerOptions setReceiveBufferSize(int receiveBufferSize)
From source file:com.englishtown.vertx.jersey.impl.DefaultJerseyServer.java
License:Open Source License
@Override public void init(final JerseyOptions options, final Handler<AsyncResult<HttpServer>> doneHandler) { // Setup the http server options HttpServerOptions serverOptions = new HttpServerOptions().setHost(options.getHost()) .setPort(options.getPort()).setAcceptBacklog(options.getAcceptBacklog()); // Performance tweak // Enable https if (options.getSSL()) { serverOptions.setSsl(true);//from w w w .j a va 2s . co m } if (options.getKeyStoreOptions() != null) { serverOptions.setKeyStoreOptions(options.getKeyStoreOptions()); } Integer receiveBufferSize = options.getReceiveBufferSize(); if (receiveBufferSize != null && receiveBufferSize > 0) { // TODO: This doesn't seem to actually affect buffer size for dataHandler. Is this being used correctly or is it a Vertx bug? serverOptions.setReceiveBufferSize(receiveBufferSize); } // Create the http server server = options.getVertx().createHttpServer(serverOptions); // Init jersey handler jerseyHandler.init(options); // Set request handler for the baseUri server.requestHandler(jerseyHandler::handle); // Perform any additional server setup (add routes etc.) if (setupHandler != null) { setupHandler.handle(server); } // Start listening and log success/failure server.listen(ar -> { final String listenPath = (options.getSSL() ? "https" : "http") + "://" + serverOptions.getHost() + ":" + serverOptions.getPort(); if (ar.succeeded()) { logger.info("Http server listening for " + listenPath); } else { logger.error("Failed to start http server listening for " + listenPath, ar.cause()); } if (doneHandler != null) { doneHandler.handle(ar); } }); }
From source file:io.servicecomb.transport.rest.vertx.RestServerVerticle.java
License:Apache License
private HttpServerOptions createDefaultHttpServerOptions() { HttpServerOptions serverOptions = new HttpServerOptions(); serverOptions.setAcceptBacklog(ACCEPT_BACKLOG); serverOptions.setSendBufferSize(SEND_BUFFER_SIZE); serverOptions.setReceiveBufferSize(RECEIVE_BUFFER_SIZE); serverOptions.setUsePooledBuffers(true); if (endpointObject.isSslEnabled()) { SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null); SSLOption sslOption;/*from ww w. ja va2s . c o m*/ if (factory == null) { sslOption = SSLOption.buildFromYaml(SSL_KEY); } else { sslOption = factory.createSSLOption(); } SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass()); VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions); } return serverOptions; }
From source file:org.wisdom.framework.vertx.Server.java
License:Apache License
private void bind(int p, Handler<AsyncResult<Void>> completion) { // Get port number. final int thePort = pickAPort(port); HttpServerOptions options = new HttpServerOptions(); if (ssl) {/*from ww w . j a v a 2 s. c om*/ options.setSsl(true); options.setTrustStoreOptions(SSLServerContext.getTrustStoreOption(accessor)); options.setKeyStoreOptions(SSLServerContext.getKeyStoreOption(accessor)); if (authentication) { options.setClientAuth(ClientAuth.REQUIRED); } } if (hasCompressionEnabled()) { options.setCompressionSupported(true); } if (configuration.getIntegerWithDefault("vertx.acceptBacklog", -1) != -1) { options.setAcceptBacklog(configuration.getInteger("vertx.acceptBacklog")); } if (configuration.getIntegerWithDefault("vertx.maxWebSocketFrameSize", -1) != -1) { options.setMaxWebsocketFrameSize(configuration.getInteger("vertx.maxWebSocketFrameSize")); } if (configuration.getStringArray("wisdom.websocket.subprotocols").length > 0) { options.setWebsocketSubProtocols(configuration.get("wisdom.websocket.subprotocols")); } if (configuration.getStringArray("vertx.websocket-subprotocols").length > 0) { options.setWebsocketSubProtocols(configuration.get("vertx.websocket-subprotocols")); } if (configuration.getIntegerWithDefault("vertx.receiveBufferSize", -1) != -1) { options.setReceiveBufferSize(configuration.getInteger("vertx.receiveBufferSize")); } if (configuration.getIntegerWithDefault("vertx.sendBufferSize", -1) != -1) { options.setSendBufferSize(configuration.getInteger("vertx.sendBufferSize")); } http = vertx.createHttpServer(options).requestHandler(new HttpHandler(vertx, accessor, this)) .websocketHandler(new WebSocketHandler(accessor, this)); http.listen(thePort, host, event -> { if (event.succeeded()) { logger.info("Wisdom is going to serve HTTP requests on port {}.", thePort); port = thePort; completion.handle(Future.succeededFuture()); } else if (port == 0) { logger.debug("Cannot bind on port {} (port already used probably)", thePort, event.cause()); bind(0, completion); } else { logger.error("Cannot bind on port {} (port already used probably)", thePort, event.cause()); completion.handle(Future.failedFuture("Cannot bind on port " + thePort)); } }); }