Class Flags
- java.lang.Object
-
- com.linecorp.armeria.common.Flags
-
public final class Flags extends Object
The system properties that affect Armeria's runtime behavior.
-
-
Method Summary
Modifier and Type Method Description static ExceptionVerbosity
annotatedServiceExceptionVerbosity()
Returns the verbosity of exceptions logged by annotated HTTP services.static List<String>
cachedHeaders()
Returns the value of thecachedHeaders
parameter which contains a comma-separated list of headers whose values are cached usingheaderValueCache
.static Optional<String>
compositeServiceCacheSpec()
Returns the value of thecompositeServiceCache
parameter.static String
defaultBackoffSpec()
Returns the default value of thebackoffSpec
parameter when instantiating aBackoff
usingBackoff.of(String)
.static long
defaultClientIdleTimeoutMillis()
Returns the default client-side idle timeout of a connection for keep-alive in milliseconds.static long
defaultConnectTimeoutMillis()
Returns the default client-side timeout of a socket connection attempt in milliseconds.static int
defaultHttp1MaxChunkSize()
Returns the default maximum length of each chunk in an HTTP/1 response content.static int
defaultHttp1MaxHeaderSize()
Returns the default maximum length of all headers in an HTTP/1 response.static int
defaultHttp1MaxInitialLineLength()
Returns the default maximum length of an HTTP/1 response initial line.static int
defaultHttp2InitialConnectionWindowSize()
Returns the default value of theServerBuilder.http2InitialConnectionWindowSize(int)
andClientFactoryBuilder.http2InitialConnectionWindowSize(int)
option.static int
defaultHttp2InitialStreamWindowSize()
Returns the default value of theServerBuilder.http2InitialStreamWindowSize(int)
andClientFactoryBuilder.http2InitialStreamWindowSize(int)
option.static int
defaultHttp2MaxFrameSize()
Returns the default value of theServerBuilder.http2MaxFrameSize(int)
andClientFactoryBuilder.http2MaxFrameSize(int)
option.static long
defaultHttp2MaxHeaderListSize()
Returns the default value of theServerBuilder.http2MaxHeaderListSize(long)
andClientFactoryBuilder.http2MaxHeaderListSize(long)
option.static long
defaultHttp2MaxStreamsPerConnection()
Returns the default value of theServerBuilder.http2MaxStreamsPerConnection(long)
option.static long
defaultMaxRequestLength()
Returns the default server-side maximum length of a request.static long
defaultMaxResponseLength()
Returns the default client-side maximum length of a response.static int
defaultMaxTotalAttempts()
Returns the default maximum number of total attempts.static long
defaultRequestTimeoutMillis()
Returns the default server-side timeout of a request in milliseconds.static long
defaultResponseTimeoutMillis()
Returns the default client-side timeout of a response in milliseconds.static long
defaultServerIdleTimeoutMillis()
Returns the default server-side idle timeout of a connection for keep-alive in milliseconds.static boolean
defaultUseHttp1Pipelining()
Returns the default value of theClientFactoryBuilder.useHttp1Pipelining(boolean)
option.static boolean
defaultUseHttp2Preface()
Returns the default value of theClientFactoryBuilder.useHttp2Preface(boolean)
option.static long
defaultWriteTimeoutMillis()
Returns the default client-side timeout of a socket write attempt in milliseconds.static boolean
dumpOpenSslInfo()
Returns whether information about the OpenSSL environment should be dumped when first starting the application, including supported ciphers.static Optional<String>
fileServiceCacheSpec()
Returns the value of thefileServiceCache
parameter.static Optional<String>
headerValueCacheSpec()
Returns the value of theheaderValueCache
parameter.static int
maxNumConnections()
Returns the default server-side maximum number of connections.static int
numCommonBlockingTaskThreads()
Returns the default number of blocking task executor threads.static int
numCommonWorkers()
Returns the default number of common worker group threads.static Optional<String>
parsedPathCacheSpec()
Returns the value of theparsedPathCache
parameter.static Optional<String>
routeCacheSpec()
Returns the value of therouteCache
parameter.static Optional<String>
routeDecoratorCacheSpec()
Returns the value of therouteDecoratorCache
parameter.static boolean
useEpoll()
Returns whether the JNI-based/dev/epoll
socket I/O is enabled.static boolean
useJdkDnsResolver()
EnablesDefaultAddressResolverGroup
that resolves domain name using JDK's built-in domain name lookup mechanism.static boolean
useOpenSsl()
Returns whether the JNI-based TLS support with OpenSSL is enabled.static Sampler<Class<? extends Throwable>>
verboseExceptionSampler()
Returns theSampler
that determines whether to retain the stack trace of the exceptions that are thrown frequently by Armeria.static String
verboseExceptionSamplerSpec()
Returns the specification string of theSampler
that determines whether to retain the stack trace of the exceptions that are thrown frequently by Armeria.static boolean
verboseResponses()
Returns whether the verbose response mode is enabled.static boolean
verboseSocketExceptions()
Returns whether to log the socket exceptions which are mostly harmless.
-
-
-
Method Detail
-
verboseExceptionSampler
public static Sampler<Class<? extends Throwable>> verboseExceptionSampler()
Returns theSampler
that determines whether to retain the stack trace of the exceptions that are thrown frequently by Armeria.- See Also:
verboseExceptionSamplerSpec()
-
verboseExceptionSamplerSpec
public static String verboseExceptionSamplerSpec()
Returns the specification string of theSampler
that determines whether to retain the stack trace of the exceptions that are thrown frequently by Armeria. A sampled exception will have the stack trace while the others will have an empty stack trace to eliminate the cost of capturing the stack trace.The default value of this flag is "rate-limit=10", which retains the stack trace of the exceptions at the maximum rate of 10 exceptions/sec. Specify the
-Dcom.linecorp.armeria.verboseExceptions=<specification>
JVM option to override the default. SeeSampler.of(String)
for the specification string format.
-
verboseSocketExceptions
public static boolean verboseSocketExceptions()
Returns whether to log the socket exceptions which are mostly harmless. If enabled, the following exceptions will be logged:ClosedChannelException
ClosedSessionException
IOException
- 'Connection reset/closed/aborted by peer'- 'Broken pipe'
Http2Exception
- 'Stream closed'SSLException
- 'SSLEngine closed already'
It is recommended to keep this flag disabled, because it increases the amount of log messages for the errors you usually do not have control over, e.g. unexpected socket disconnection due to network or remote peer issues.
This flag is disabled by default. Specify the
-Dcom.linecorp.armeria.verboseSocketExceptions=true
JVM option to enable it.- See Also:
Exceptions.isExpected(Throwable)
-
verboseResponses
public static boolean verboseResponses()
Returns whether the verbose response mode is enabled. When enabled, the server responses will contain the exception type and its full stack trace, which may be useful for debugging while potentially insecure. When disabled, the server responses will not expose such server-side details to the client.This flag is disabled by default. Specify the
-Dcom.linecorp.armeria.verboseResponses=true
JVM option or useServerBuilder.verboseResponses(boolean)
to enable it.
-
useEpoll
public static boolean useEpoll()
Returns whether the JNI-based/dev/epoll
socket I/O is enabled. When enabled on Linux, Armeria uses/dev/epoll
directly for socket I/O. When disabled,java.nio
socket API is used instead.This flag is enabled by default for supported platforms. Specify the
-Dcom.linecorp.armeria.useEpoll=false
JVM option to disable it.
-
useOpenSsl
public static boolean useOpenSsl()
Returns whether the JNI-based TLS support with OpenSSL is enabled. When enabled, Armeria uses OpenSSL for processing TLS connections. When disabled, the current JVM's defaultSSLEngine
is used instead.This flag is enabled by default for supported platforms. Specify the
-Dcom.linecorp.armeria.useOpenSsl=false
JVM option to disable it.
-
dumpOpenSslInfo
public static boolean dumpOpenSslInfo()
Returns whether information about the OpenSSL environment should be dumped when first starting the application, including supported ciphers.This flag is disabled by default. Specify the
-Dcom.linecorp.armeria.dumpOpenSslInfo=true
JVM option to enable it.
-
maxNumConnections
public static int maxNumConnections()
Returns the default server-side maximum number of connections.The default value of this flag is 2147483647. Specify the
-Dcom.linecorp.armeria.maxNumConnections=<integer>
JVM option to override the default value.
-
numCommonWorkers
public static int numCommonWorkers()
Returns the default number of common worker group threads. Note that this value has effect only if a user did not specify a worker group.The default value of this flag is
2 * <numCpuCores>
. Specify the-Dcom.linecorp.armeria.numCommonWorkers=<integer>
JVM option to override the default value.
-
numCommonBlockingTaskThreads
public static int numCommonBlockingTaskThreads()
Returns the default number of blocking task executor threads. Note that this value has effect only if a user did not specify a blocking task executor.The default value of this flag is 200. Specify the
-Dcom.linecorp.armeria.numCommonBlockingTaskThreads=<integer>
JVM option to override the default value.
-
defaultMaxRequestLength
public static long defaultMaxRequestLength()
Returns the default server-side maximum length of a request. Note that this value has effect only if a user did not specify it.The default value of this flag is 10485760L. Specify the
-Dcom.linecorp.armeria.defaultMaxRequestLength=<long>
to override the default value.0
disables the length limit.
-
defaultMaxResponseLength
public static long defaultMaxResponseLength()
Returns the default client-side maximum length of a response. Note that this value has effect only if a user did not specify it.The default value of this flag is 10485760L. Specify the
-Dcom.linecorp.armeria.defaultMaxResponseLength=<long>
to override the default value.0
disables the length limit.
-
defaultRequestTimeoutMillis
public static long defaultRequestTimeoutMillis()
Returns the default server-side timeout of a request in milliseconds. Note that this value has effect only if a user did not specify it.The default value of this flag is 10000L. Specify the
-Dcom.linecorp.armeria.defaultRequestTimeoutMillis=<long>
to override the default value.0
disables the timeout.
-
defaultResponseTimeoutMillis
public static long defaultResponseTimeoutMillis()
Returns the default client-side timeout of a response in milliseconds. Note that this value has effect only if a user did not specify it.The default value of this flag is 15000L. Specify the
-Dcom.linecorp.armeria.defaultResponseTimeoutMillis=<long>
to override the default value.0
disables the timeout.
-
defaultConnectTimeoutMillis
public static long defaultConnectTimeoutMillis()
Returns the default client-side timeout of a socket connection attempt in milliseconds. Note that this value has effect only if a user did not specify it.The default value of this flag is 3200L. Specify the
-Dcom.linecorp.armeria.defaultConnectTimeoutMillis=<integer>
JVM option to override the default value.
-
defaultWriteTimeoutMillis
public static long defaultWriteTimeoutMillis()
Returns the default client-side timeout of a socket write attempt in milliseconds. Note that this value has effect only if a user did not specify it.The default value of this flag is 1000L. Specify the
-Dcom.linecorp.armeria.defaultWriteTimeoutMillis=<integer>
JVM option to override the default value.0
disables the timeout.
-
defaultServerIdleTimeoutMillis
public static long defaultServerIdleTimeoutMillis()
Returns the default server-side idle timeout of a connection for keep-alive in milliseconds. Note that this value has effect only if a user did not specify it.The default value of this flag is 15000L. Specify the
-Dcom.linecorp.armeria.defaultServerIdleTimeoutMillis=<integer>
JVM option to override the default value.
-
defaultClientIdleTimeoutMillis
public static long defaultClientIdleTimeoutMillis()
Returns the default client-side idle timeout of a connection for keep-alive in milliseconds. Note that this value has effect only if a user did not specify it.This default value of this flag is 10000L. Specify the
-Dcom.linecorp.armeria.defaultClientIdleTimeoutMillis=<integer>
JVM option to override the default value.
-
defaultHttp1MaxInitialLineLength
public static int defaultHttp1MaxInitialLineLength()
Returns the default maximum length of an HTTP/1 response initial line. Note that this value has effect only if a user did not specify it.This default value of this flag is 4096. Specify the
-Dcom.linecorp.armeria.defaultHttp1MaxInitialLineLength=<integer>
JVM option to override the default value.
-
defaultHttp1MaxHeaderSize
public static int defaultHttp1MaxHeaderSize()
Returns the default maximum length of all headers in an HTTP/1 response. Note that this value has effect only if a user did not specify it.This default value of this flag is 8192. Specify the
-Dcom.linecorp.armeria.defaultHttp1MaxHeaderSize=<integer>
JVM option to override the default value.
-
defaultHttp1MaxChunkSize
public static int defaultHttp1MaxChunkSize()
Returns the default maximum length of each chunk in an HTTP/1 response content. The content or a chunk longer than this value will be split into smaller chunks so that their lengths never exceed it. Note that this value has effect only if a user did not specify it.The default value of this flag is 8192. Specify the
-Dcom.linecorp.armeria.defaultHttp1MaxChunkSize=<integer>
JVM option to override the default value.
-
defaultUseHttp2Preface
public static boolean defaultUseHttp2Preface()
Returns the default value of theClientFactoryBuilder.useHttp2Preface(boolean)
option. Note that this value has effect only if a user did not specify it.This flag is enabled by default. Specify the
-Dcom.linecorp.armeria.defaultUseHttp2Preface=false
JVM option to disable it.
-
defaultUseHttp1Pipelining
public static boolean defaultUseHttp1Pipelining()
Returns the default value of theClientFactoryBuilder.useHttp1Pipelining(boolean)
option. Note that this value has effect only if a user did not specify it.This flag is disabled by default. Specify the
-Dcom.linecorp.armeria.defaultUseHttp1Pipelining=true
JVM option to enable it.
-
defaultHttp2InitialConnectionWindowSize
public static int defaultHttp2InitialConnectionWindowSize()
Returns the default value of theServerBuilder.http2InitialConnectionWindowSize(int)
andClientFactoryBuilder.http2InitialConnectionWindowSize(int)
option. Note that this value has effect only if a user did not specify it.The default value of this flag is 1048576. Specify the
-Dcom.linecorp.armeria.defaultHttp2InitialConnectionWindowSize=<integer>
JVM option to override the default value.
-
defaultHttp2InitialStreamWindowSize
public static int defaultHttp2InitialStreamWindowSize()
Returns the default value of theServerBuilder.http2InitialStreamWindowSize(int)
andClientFactoryBuilder.http2InitialStreamWindowSize(int)
option. Note that this value has effect only if a user did not specify it.The default value of this flag is 1048576. Specify the
-Dcom.linecorp.armeria.defaultHttp2InitialStreamWindowSize=<integer>
JVM option to override the default value.
-
defaultHttp2MaxFrameSize
public static int defaultHttp2MaxFrameSize()
Returns the default value of theServerBuilder.http2MaxFrameSize(int)
andClientFactoryBuilder.http2MaxFrameSize(int)
option. Note that this value has effect only if a user did not specify it.The default value of this flag is 16384. Specify the
-Dcom.linecorp.armeria.defaultHttp2MaxFrameSize=<integer>
JVM option to override the default value.
-
defaultHttp2MaxStreamsPerConnection
public static long defaultHttp2MaxStreamsPerConnection()
Returns the default value of theServerBuilder.http2MaxStreamsPerConnection(long)
option. Note that this value has effect only if a user did not specify it.The default value of this flag is 2147483647L. Specify the
-Dcom.linecorp.armeria.defaultHttp2MaxStreamsPerConnection=<integer>
JVM option to override the default value.
-
defaultHttp2MaxHeaderListSize
public static long defaultHttp2MaxHeaderListSize()
Returns the default value of theServerBuilder.http2MaxHeaderListSize(long)
andClientFactoryBuilder.http2MaxHeaderListSize(long)
option. Note that this value has effect only if a user did not specify it.The default value of this flag is 8192L. Specify the
-Dcom.linecorp.armeria.defaultHttp2MaxHeaderListSize=<integer>
JVM option to override the default value.
-
defaultBackoffSpec
public static String defaultBackoffSpec()
Returns the default value of thebackoffSpec
parameter when instantiating aBackoff
usingBackoff.of(String)
. Note that this value has effect only if a user did not specify thedefaultBackoffSpec
in the constructor call.The default value of this flag is "exponential=200:10000,jitter=0.2". Specify the
-Dcom.linecorp.armeria.defaultBackoffSpec=<spec>
JVM option to override the default value.
-
defaultMaxTotalAttempts
public static int defaultMaxTotalAttempts()
Returns the default maximum number of total attempts. Note that this value has effect only if a user did not specify it when creating aRetryingHttpClient
or aRetryingRpcClient
.The default value of this flag is 10. Specify the
-Dcom.linecorp.armeria.defaultMaxTotalAttempts=<integer>
JVM option to override the default value.
-
routeCacheSpec
public static Optional<String> routeCacheSpec()
Returns the value of therouteCache
parameter. It would be used to create a CaffeineCache
instance usingCaffeineSpec
for routing a request. TheCache
would hold the mappings ofRoutingContext
and the designatedServiceConfig
for a request to improve server performance.The default value of this flag is "maximumSize=4096". Specify the
-Dcom.linecorp.armeria.routeCache=<spec>
JVM option to override the default value. For example,-Dcom.linecorp.armeria.routeCache=maximumSize=4096,expireAfterAccess=600s
. Also, specify-Dcom.linecorp.armeria.routeCache=off
JVM option to disable it.
-
routeDecoratorCacheSpec
public static Optional<String> routeDecoratorCacheSpec()
Returns the value of therouteDecoratorCache
parameter. It would be used to create a CaffeineCache
instance usingCaffeineSpec
for mapping a route to decorator. TheCache
would hold the mappings ofRoutingContext
and the designated dispatcherService
s for a request to improve server performance.The default value of this flag is "maximumSize=4096". Specify the
-Dcom.linecorp.armeria.routeDecoratorCache=<spec>
JVM option to override the default value. For example,-Dcom.linecorp.armeria.routeDecoratorCache=maximumSize=4096,expireAfterAccess=600s
. Also, specify-Dcom.linecorp.armeria.routeDecoratorCache=off
JVM option to disable it.
-
parsedPathCacheSpec
public static Optional<String> parsedPathCacheSpec()
Returns the value of theparsedPathCache
parameter. It would be used to create a CaffeineCache
instance usingCaffeineSpec
for mapping raw HTTP paths to parsed pair of path and query, after validation.The default value of this flag is "maximumSize=4096". Specify the
-Dcom.linecorp.armeria.parsedPathCache=<spec>
JVM option to override the default value. For example,-Dcom.linecorp.armeria.parsedPathCache=maximumSize=4096,expireAfterAccess=600s
. Also, specify-Dcom.linecorp.armeria.parsedPathCache=off
JVM option to disable it.
-
headerValueCacheSpec
public static Optional<String> headerValueCacheSpec()
Returns the value of theheaderValueCache
parameter. It would be used to create a CaffeineCache
instance usingCaffeineSpec
for mapping raw HTTP ASCII header values toString
.The default value of this flag is "maximumSize=4096". Specify the
-Dcom.linecorp.armeria.headerValueCache=<spec>
JVM option to override the default value. For example,-Dcom.linecorp.armeria.headerValueCache=maximumSize=4096,expireAfterAccess=600s
. Also, specify-Dcom.linecorp.armeria.headerValueCache=off
JVM option to disable it.
-
fileServiceCacheSpec
public static Optional<String> fileServiceCacheSpec()
Returns the value of thefileServiceCache
parameter. It would be used to create a CaffeineCache
instance usingCaffeineSpec
for caching file entries.The default value of this flag is "maximumSize=1024". Specify the
-Dcom.linecorp.armeria.fileServiceCache=<spec>
JVM option to override the default value. For example,-Dcom.linecorp.armeria.fileServiceCache=maximumSize=1024,expireAfterAccess=600s
. Also, specify-Dcom.linecorp.armeria.fileServiceCache=off
JVM option to disable it.
-
cachedHeaders
public static List<String> cachedHeaders()
Returns the value of thecachedHeaders
parameter which contains a comma-separated list of headers whose values are cached usingheaderValueCache
.The default value of this flag is ":authority,:scheme,:method,accept-encoding,content-type". Specify the
-Dcom.linecorp.armeria.cachedHeaders=<csv>
JVM option to override the default value.
-
compositeServiceCacheSpec
public static Optional<String> compositeServiceCacheSpec()
Returns the value of thecompositeServiceCache
parameter. It would be used to create a CaffeineCache
instance usingCaffeineSpec
for routing a request. TheCache
would hold the mappings ofRoutingContext
and the designatedServiceConfig
for a request to improve server performance.The default value of this flag is "maximumSize=256". Specify the
-Dcom.linecorp.armeria.compositeServiceCache=<spec>
JVM option to override the default value. For example,-Dcom.linecorp.armeria.compositeServiceCache=maximumSize=256,expireAfterAccess=600s
. Also, specify-Dcom.linecorp.armeria.compositeServiceCache=off
JVM option to disable it.
-
annotatedServiceExceptionVerbosity
public static ExceptionVerbosity annotatedServiceExceptionVerbosity()
Returns the verbosity of exceptions logged by annotated HTTP services. The value of this property is one of the following:ExceptionVerbosity.ALL
- logging all exceptions raised from annotated HTTP servicesExceptionVerbosity.UNHANDLED
- logging exceptions which are not handled byExceptionHandler
s provided by a user and are not well-known exceptionsExceptionVerbosity.NONE
- no logging exceptions
WARN
level.The default value of this flag is "unhandled". Specify the
-Dcom.linecorp.armeria.annotatedServiceExceptionVerbosity=<all|unhandled|none>
JVM option to override the default value.- See Also:
ExceptionVerbosity
-
useJdkDnsResolver
public static boolean useJdkDnsResolver()
EnablesDefaultAddressResolverGroup
that resolves domain name using JDK's built-in domain name lookup mechanism. Note that JDK's built-in resolver performs a blocking name lookup from the caller thread, and thus this flag should be enabled only when the default asynchronous resolver does not work as expected, for example by always throwing aDnsNameResolverTimeoutException
.This flag is disabled by default. Specify the
-Dcom.linecorp.armeria.useJdkDnsResolver=true
JVM option to enable it.
-
-