/** * Enable SSL by using the provided SSL information. * * @param sslConfig the SSL configuration * @return instance of {@code Builder}. */ public Builder enableSSL(SSLConfig sslConfig) { return enableSSL(new SSLHandlerFactory(sslConfig)); }
/** * Calls {@link BodyConsumer#finished(HttpResponder)} method. The current bodyConsumer will be set to {@code null} * after the call. */ private void bodyConsumerFinish() { BodyConsumer consumer = bodyConsumer; bodyConsumer = null; try { consumer.finished(responder); } catch (Throwable t) { exceptionHandler.handle(t, request, responder); } }
SparkDriverHttpService(String programName, String hostname, HttpHandler...handlers) { this.httpServer = NettyHttpService.builder(programName + "-http-service") .setHttpHandlers(handlers) .setExceptionHandler(new HttpExceptionHandler()) .setHost(hostname) .build(); }
/** * Get the address the service has bound to. * * @return Address the service has bound to. */ public InetSocketAddress getBindAddress() { return httpService.getBindAddress(); } }
@Override protected void startUp() throws Exception { httpServer.start(); }
/** * Stops the HTTP service gracefully and release all resources. Same as calling {@link #stop(long, long, TimeUnit)} * with {@code 0} second quiet period and {@code 5} seconds timeout. * * @throws Exception if there is exception raised during shutdown. */ public void stop() throws Exception { stop(0, 5, TimeUnit.SECONDS); }
@Override public BodyConsumer getResult() { bodyConsumer.finished(responder); return bodyConsumer; } });
@Override public void close() throws IOException { chunkResponder.close(); runHook(status); } };
@Override public long getContentLength() { return delegate.getContentLength(); }
/** * Calls {@link BodyConsumer#handleError(Throwable)}. The current * bodyConsumer will be set to {@code null} after the call. */ private void bodyConsumerError(Throwable cause) { BodyConsumer consumer = bodyConsumer; bodyConsumer = null; consumer.handleError(cause); }
/** * Creates a {@link Builder} for creating new instance of {@link NettyHttpService}. * * @param serviceName name of the http service. The name will be used to name threads created for the service. * @return builder for creating a NettyHttpService */ public static Builder builder(String serviceName) { return new Builder(serviceName); }
SparkDriverHttpService(String programName, String hostname, HttpHandler...handlers) { this.httpServer = NettyHttpService.builder(programName + "-http-service") .setHttpHandlers(handlers) .setExceptionHandler(new HttpExceptionHandler()) .setHost(hostname) .build(); }
/** * Get the address the service has bound to. * * @return Address the service has bound to. */ public InetSocketAddress getBindAddress() { return httpService.getBindAddress(); } }
@Override protected void startUp() throws Exception { httpServer.start(); }
@Override protected void shutDown() throws Exception { httpServer.stop(); }
SparkDriverHttpService(String programName, String hostname, HttpHandler...handlers) { this.httpServer = NettyHttpService.builder(programName + "-http-service") .setHttpHandlers(handlers) .setExceptionHandler(new HttpExceptionHandler()) .setHost(hostname) .build(); }
/** * Get the address the service has bound to. * * @return Address the service has bound to. */ public InetSocketAddress getBindAddress() { return httpService.getBindAddress(); }
@Override protected void startUp() throws Exception { httpServer.start(); }