Class HTTPServerConfiguration
- All Implemented Interfaces:
Configurable<HTTPServerConfiguration>
- Author:
- Brian Pontarelli
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintThis configuration will affect the runtime memory requirement.longThis configuration is the minimum number of bytes per second that a client must send a request to the server before the server closes the connection.longThis configuration is the minimum number of bytes per second that a client must read the response from the server before the server closes the connection.intintThe number of worker threads.intintintThe size of the response buffer in bytes.booleanwithBaseDir(Path baseDir) Sets the base directory for this server.withClientTimeout(Duration duration) Sets the duration that the server will allow client connections to remain open.withCompressByDefault(boolean compressByDefault) Sets the default compression behavior for the HTTP response.withContextPath(String contextPath) Sets the prefix of the URIs that this server handles.withExpectValidator(ExpectValidator validator) Sets an ExpectValidator that is used if a client sends the server aExpect: 100-continueheader.withHandler(HTTPHandler handler) Sets the handler that will process the requests.withInstrumenter(Instrumenter instrumenter) Sets an instrumenter that the server will notify when events and conditions happen.withListener(HTTPListenerConfiguration listener) Adds a listener configuration for the server.withLoggerFactory(LoggerFactory loggerFactory) Sets the logger factory that all the HTTP server classes use to retrieve specific loggers.withMaxOutputBufferQueueLength(int outputBufferQueueLength) Sets the maximum length of the output buffer queue.withMaxPreambleLength(int maxLength) Sets the max preamble length (the start-line and headers constitute the head).withMinimumReadThroughput(long bytesPerSecond) This configures the minimum number of bytes per second that a client must send a request to the server before the server closes the connection.withMinimumWriteThroughput(long bytesPerSecond) This configures the minimum number of bytes per second that a client must read the response from the server before the server closes the connection.withMultipartBufferSize(int multipartBufferSize) Sets the size of the buffer that is used to process the multipart request body.withNumberOfWorkerThreads(int numberOfWorkerThreads) Sets the number of worker threads that will handle requests coming into the HTTP server.withPreambleBufferSize(int size) Sets the size of the preamble buffer (that is the buffer that reads the start-line and headers).This configures the duration of the initial delay before calculating and enforcing the minimum read throughput.withRequestBufferSize(int requestBufferSize) Sets the size of the buffer that is used to process the HTTP request.withResponseBufferSize(int responseBufferSize) Sets the size of the buffer that is used to process the HTTP response.withShutdownDuration(Duration duration) Sets the duration the server will wait for running requests to be completed.This configures the duration of the initial delay before calculating and enforcing the minimum write throughput.
-
Constructor Details
-
HTTPServerConfiguration
public HTTPServerConfiguration()
-
-
Method Details
-
configuration
- Specified by:
configurationin interfaceConfigurable<HTTPServerConfiguration>- Returns:
- This.
-
getBaseDir
-
getClientTimeoutDuration
-
getContextPath
-
getExpectValidator
-
getHandler
-
getInstrumenter
-
getListeners
-
getLoggerFactory
-
getMaxHeadLength
public int getMaxHeadLength() -
getMaxOutputBufferQueueLength
public int getMaxOutputBufferQueueLength()This configuration will affect the runtime memory requirement.The maximum memory requirement for the output buffer can be calculated multiplying this value by the values returned from
getResponseBufferSize()and *getNumberOfWorkerThreads().- Returns:
- the maximum output buffer queue length.
-
getMinimumReadThroughput
public long getMinimumReadThroughput()This configuration is the minimum number of bytes per second that a client must send a request to the server before the server closes the connection.- Returns:
- The minimum throughput for any connection with the server in bytes per second.
-
getMinimumWriteThroughput
public long getMinimumWriteThroughput()This configuration is the minimum number of bytes per second that a client must read the response from the server before the server closes the connection.- Returns:
- The minimum throughput for any connection with the server in bytes per second.
-
getMultipartBufferSize
public int getMultipartBufferSize() -
getNumberOfWorkerThreads
public int getNumberOfWorkerThreads()The number of worker threads. This configuration will affect the runtime memory requirement.The maximum memory requirement for the output buffer can be calculated multiplying this value by the values returned from
getMaxOutputBufferQueueLength()and *getResponseBufferSize().- Returns:
- the number of worker threads.
-
getPreambleBufferSize
public int getPreambleBufferSize() -
getReadThroughputCalculationDelay
- Returns:
- the duration that will be used to delay the calculation and enforcement of the minimum read throughput.
-
getRequestBufferSize
public int getRequestBufferSize() -
getResponseBufferSize
public int getResponseBufferSize()The size of the response buffer in bytes. This configuration will affect the runtime memory requirement.The maximum memory requirement for the output buffer can be calculated multiplying this value by the values returned from
getMaxOutputBufferQueueLength()and *getNumberOfWorkerThreads().- Returns:
- the response buffer size in bytes.
-
getShutdownDuration
-
getWriteThroughputCalculationDelay
- Returns:
- the duration that will be used to delay the calculation and enforcement of the minimum write throughput.
-
isCompressByDefault
public boolean isCompressByDefault() -
withBaseDir
Sets the base directory for this server. This is passed to the HTTPContext, which is available from this class. This defaults to the current working directory of the process.- Specified by:
withBaseDirin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
baseDir- The base dir.- Returns:
- This.
-
withClientTimeout
Sets the duration that the server will allow client connections to remain open. This includes Keep-Alive as well as read timeout. Defaults to 20 seconds.- Specified by:
withClientTimeoutin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
duration- The duration.- Returns:
- This.
-
withCompressByDefault
Sets the default compression behavior for the HTTP response. This behavior can be optionally set per response. SeeHTTPResponse.setCompress(boolean). Defaults to true.- Specified by:
withCompressByDefaultin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
compressByDefault- true if you want to compress by default, or false to not compress by default.- Returns:
- This.
-
withContextPath
Sets the prefix of the URIs that this server handles. Technically, the server will accept all inbound connections, but if a context path is set, it can assist the application with building URIs (in HTML for example). This value will be accessible via theHTTPRequest.getContextPath()method.- Specified by:
withContextPathin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
contextPath- The context path for the server.- Returns:
- This.
-
withExpectValidator
Sets an ExpectValidator that is used if a client sends the server aExpect: 100-continueheader.- Specified by:
withExpectValidatorin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
validator- The validator.- Returns:
- This.
-
withHandler
Sets the handler that will process the requests.- Specified by:
withHandlerin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
handler- The handler that processes the requests.- Returns:
- This.
-
withInstrumenter
Sets an instrumenter that the server will notify when events and conditions happen.- Specified by:
withInstrumenterin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
instrumenter- The instrumenter.- Returns:
- This.
-
withListener
Adds a listener configuration for the server. This will listen on the address and port of the configuration but will share the thread pool of the server.- Specified by:
withListenerin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
listener- The listener.- Returns:
- This.
-
withLoggerFactory
Sets the logger factory that all the HTTP server classes use to retrieve specific loggers. Defaults to theSystemOutLoggerFactory.- Specified by:
withLoggerFactoryin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
loggerFactory- The factory.- Returns:
- This.
-
withMaxOutputBufferQueueLength
Sets the maximum length of the output buffer queue. Defaults to 128.This parameter will affect the runtime memory requirement of the server. This can be calculated by multiplying this value by values returned from
getResponseBufferSize()andgetNumberOfWorkerThreads().- Specified by:
withMaxOutputBufferQueueLengthin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
outputBufferQueueLength- The length of the output buffer queue.- Returns:
- This.
-
withMaxPreambleLength
Sets the max preamble length (the start-line and headers constitute the head). Defaults to 64k- Specified by:
withMaxPreambleLengthin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
maxLength- The max preamble length.- Returns:
- This.
-
withMinimumReadThroughput
This configures the minimum number of bytes per second that a client must send a request to the server before the server closes the connection.- Specified by:
withMinimumReadThroughputin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
bytesPerSecond- The bytes per second throughput.- Returns:
- This.
-
withMinimumWriteThroughput
This configures the minimum number of bytes per second that a client must read the response from the server before the server closes the connection.- Specified by:
withMinimumWriteThroughputin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
bytesPerSecond- The bytes per second throughput.- Returns:
- This.
-
withMultipartBufferSize
Sets the size of the buffer that is used to process the multipart request body. This defaults to 16k.- Specified by:
withMultipartBufferSizein interfaceConfigurable<HTTPServerConfiguration>- Parameters:
multipartBufferSize- The size of the buffer.- Returns:
- This.
-
withNumberOfWorkerThreads
Sets the number of worker threads that will handle requests coming into the HTTP server. Defaults to 40.This parameter will affect the runtime memory requirement of the server. This can be calculated by multiplying this value by the returned from
getResponseBufferSize()andgetMaxOutputBufferQueueLength().- Specified by:
withNumberOfWorkerThreadsin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
numberOfWorkerThreads- The number of worker threads.- Returns:
- This.
-
withPreambleBufferSize
Sets the size of the preamble buffer (that is the buffer that reads the start-line and headers). Defaults to 4096.- Specified by:
withPreambleBufferSizein interfaceConfigurable<HTTPServerConfiguration>- Parameters:
size- The buffer size.- Returns:
- This.
-
withReadThroughputCalculationDelayDuration
This configures the duration of the initial delay before calculating and enforcing the minimum read throughput. Defaults to 5 seconds.This accounts for some warm up period, and exempts short-lived connections that may have smaller payloads that are more difficult to calculate a reasonable minimum read throughput.
- Specified by:
withReadThroughputCalculationDelayDurationin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
duration- The duration to delay the enforcement of the minimum read throughput.- Returns:
- This.
-
withRequestBufferSize
Sets the size of the buffer that is used to process the HTTP request. This defaults to 16k.- Specified by:
withRequestBufferSizein interfaceConfigurable<HTTPServerConfiguration>- Parameters:
requestBufferSize- The size of the buffer.- Returns:
- This.
-
withResponseBufferSize
Sets the size of the buffer that is used to process the HTTP response. This defaults to 16k.This parameter will affect the runtime memory requirement of the server. This can be calculated by multiplying this value by the returned from
getNumberOfWorkerThreads()andgetMaxOutputBufferQueueLength().- Specified by:
withResponseBufferSizein interfaceConfigurable<HTTPServerConfiguration>- Parameters:
responseBufferSize- The size of the buffer.- Returns:
- This.
-
withShutdownDuration
Sets the duration the server will wait for running requests to be completed. Defaults to 10 seconds.- Specified by:
withShutdownDurationin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
duration- The duration the server will wait for all running request processing threads to complete their work.- Returns:
- This.
-
withWriteThroughputCalculationDelayDuration
This configures the duration of the initial delay before calculating and enforcing the minimum write throughput. Defaults to 5 seconds.This accounts for some warm up period, and exempts short-lived connections that may have smaller payloads that are more difficult to calculate a reasonable minimum write throughput.
- Specified by:
withWriteThroughputCalculationDelayDurationin interfaceConfigurable<HTTPServerConfiguration>- Parameters:
duration- The duration to delay the enforcement of the minimum write throughput.- Returns:
- This.
-