public class HTTPServerConfig extends Object
Constructor and Description |
---|
HTTPServerConfig()
Create a server configuration for the default port (
DEFAULT_PORT ). |
HTTPServerConfig(int serverPort) |
HTTPServerConfig(int serverPort,
boolean verbose) |
Modifier and Type | Method and Description |
---|---|
List<String> |
getAbTest() |
Pattern |
getAbTestClients()
Clients that a A/B test runs on; null -> disabled
|
int |
getAbTestRollout() |
String |
getAllowOriginUrl()
Value to set as the "Access-Control-Allow-Origin" http header.
|
int |
getDatabaseDownIntervalSeconds()
Number of seconds to skip database requests when a potential downtime has been detected
|
int |
getDatabaseErrorRateThreshold()
Rate in percent of requests (0-100) of errors during database queries until circuit breaker opens
|
int |
getDatabaseTimeoutRateThreshold()
Rate in percent of requests (0-100) of timeouts during database queries until circuit breaker opens
|
int |
getDbMaxConnections() |
long |
getDbTimeoutSeconds()
timeout for database requests (for now, only requests for credentials to log in)
|
int |
getDictLimitTeam() |
int |
getDictLimitUser() |
List<String> |
getDisabledRuleIds() |
File |
getFasttextBinary()
Get binary path for fasttext language detection
|
File |
getFasttextModel()
Get model path for fasttext language detection
|
boolean |
getGracefulDatabaseFailure()
Whether requests with credentials should be treated as anonymous requests in case of DB errors/timeout or
throw an error
|
int |
getMaxPipelinePoolSize() |
int |
getMaxPort() |
int |
getMinPort() |
String |
getMotherTongue() |
File |
getNgramLangIdentData() |
protected String |
getOptionalProperty(Properties props,
String propertyName,
String defaultValue) |
String |
getPasswortLoginAccessListPath() |
int |
getPipelineExpireTime() |
int |
getPort() |
List<String> |
getPreferedLanguages() |
int |
getPrometheusPort() |
protected String |
getProperty(Properties props,
String propertyName,
File config) |
String |
getRedisCertificate() |
long |
getRedisConnectionMilliseconds()
Timeout for establishing the initial connection, including e.g.
|
int |
getRedisDatabase() |
long |
getRedisDictTTLSeconds() |
String |
getRedisHost() |
String |
getRedisKey() |
String |
getRedisKeyPassword() |
String |
getRedisPassword() |
int |
getRedisPort() |
long |
getRedisTimeoutMilliseconds()
Timeout for regular commands
|
String |
getRequestLimitAccessToken() |
int |
getRequestLimitWhitelistLimit() |
List<String> |
getRequestLimitWhitelistUsers() |
String |
getSentinelHost() |
String |
getSentinelMasterId() |
String |
getSentinelPassword() |
int |
getSentinelPort() |
URI |
getServerURL() |
int |
getSlowRuleLoggingThreshold() |
int |
getStyleGuideLimitTeam() |
int |
getStyleGuideLimitUser() |
int |
getTextCheckerQueueSize() |
boolean |
isAnonymousAccessAllowed() |
boolean |
isLocalApiMode() |
boolean |
isPipelineCachingEnabled() |
boolean |
isPipelinePrewarmingEnabled() |
boolean |
isPremiumOnly() |
boolean |
isPrometheusMonitoring() |
boolean |
isPublicAccess() |
boolean |
isRedisUseSentinel()
Allow using redis sentinel for automated failover
|
boolean |
isRedisUseSSL() |
boolean |
isRestrictManagedAccounts() |
boolean |
isSkipLoggingChecks() |
boolean |
isVerbose() |
void |
setAbTest(String abTest) |
void |
setAbTestClients(String pattern)
Clients that a A/B test runs on; null -> disabled
|
void |
setAbTestRollout(int abTestRollout) |
void |
setAllowOriginUrl(String allowOriginUrl) |
void |
setDatabaseDownIntervalSeconds(int databaseDownIntervalSeconds) |
void |
setDatabaseErrorRateThreshold(int databaseErrorRateThreshold) |
void |
setDatabaseTimeoutRateThreshold(int databaseTimeoutRateThreshold) |
void |
setDbMaxConnections(int dbMaxConnections) |
void |
setDbTimeoutSeconds(long dbTimeoutSeconds)
timeout for database requests (for now, only requests for credentials to log in)
|
void |
setFasttextBinary(File binary)
Set binary path for fasttext language detection
|
void |
setFasttextModel(File model)
Set model path for fasttext language detection
|
void |
setGracefulDatabaseFailure(boolean gracefulDatabaseFailure)
Whether requests with credentials should be treated as anonymous requests in case of DB errors/timeout or
throw an error
|
void |
setLanguageModelDirectory(String langModelDir) |
void |
setMaxPipelinePoolSize(int maxPipelinePoolSize) |
void |
setMaxTextHardLength(int len) |
void |
setMaxTextLengthAnonymous(int len) |
void |
setMaxTextLengthLoggedIn(int len) |
void |
setMaxTextLengthPremium(int len) |
void |
setNgramLangIdentData(File ngramLangIdentData) |
void |
setPipelineCaching(boolean pipelineCaching) |
void |
setPipelineExpireTime(int pipelineExpireTime) |
void |
setPipelinePrewarming(boolean pipelinePrewarming) |
void |
setPremiumOnly(boolean premiumOnly) |
void |
setRedisCertificate(String redisCertificate) |
void |
setRedisKey(String redisKey) |
void |
setRedisKeyPassword(String redisKeyPassword) |
void |
setRedisUseSentinel(boolean redisUseSentinel) |
void |
setRequestLimit(int requestLimit) |
void |
setRequestLimitAccessToken(String requestLimitAccessToken) |
void |
setRequestLimitPeriodInSeconds(int requestLimitPeriodInSeconds) |
void |
setRequestLimitWhitelistLimit(int requestLimitWhitelistLimit) |
void |
setRequestLimitWhitelistUsers(List<String> requestLimitWhitelistUsers) |
void |
setRestrictManagedAccounts(boolean restrictManagedAccounts) |
void |
setSentinelHost(String sentinelHost) |
void |
setSentinelMasterId(String sentinelMasterId) |
void |
setSentinelPassword(String sentinelPassword) |
void |
setSentinelPort(int sentinelPort) |
void |
setServerURL(String url) |
void |
setTextCheckerQueueSize(int textCheckerQueueSize) |
public static final String DEFAULT_HOST
public static final int DEFAULT_PORT
protected boolean verbose
protected boolean publicAccess
protected int port
protected int minPort
protected int maxPort
protected String allowOriginUrl
protected boolean logIp
protected String logIpMatchingPattern
protected URI serverURL
protected int maxTextLengthAnonymous
protected int maxTextLengthLoggedIn
protected int maxTextLengthPremium
protected int maxTextHardLength
protected long maxCheckTimeMillisAnonymous
protected long maxCheckTimeMillisLoggedIn
protected long maxCheckTimeMillisPremium
protected int maxCheckThreads
protected int maxTextCheckerThreads
protected int textCheckerQueueSize
protected org.languagetool.server.HTTPServerConfig.Mode mode
protected File languageModelDir
protected boolean pipelineCaching
protected boolean pipelinePrewarming
protected int maxPipelinePoolSize
protected int pipelineExpireTime
protected File fasttextModel
protected File fasttextBinary
protected int requestLimit
protected int requestLimitInBytes
protected int timeoutRequestLimit
protected int requestLimitPeriodInSeconds
protected int requestLimitWhitelistLimit
protected int ipFingerprintFactor
protected boolean trustXForwardForHeader
protected int maxWorkQueueSize
protected File rulesConfigFile
protected File remoteRulesConfigFile
protected int cacheSize
protected long cacheTTLSeconds
protected float maxErrorsPerWordRate
protected int maxSpellingSuggestions
protected boolean premiumAlways
protected boolean premiumOnly
protected String requestLimitAccessToken
protected boolean gracefulDatabaseFailure
protected boolean restrictManagedAccounts
protected String dbDriver
protected String dbUrl
protected String dbUsername
protected String dbPassword
protected long dbTimeoutSeconds
protected int dbMaxConnections
protected int databaseTimeoutRateThreshold
protected int databaseErrorRateThreshold
protected int databaseDownIntervalSeconds
protected boolean dbLogging
protected boolean prometheusMonitoring
protected int prometheusPort
protected GlobalConfig globalConfig
protected boolean stoppable
protected String passwortLoginAccessListPath
@Nullable protected String redisHost
protected int redisPort
protected int redisDatabase
protected boolean redisUseSSL
protected String redisCertificate
protected String redisKey
protected String redisKeyPassword
@Nullable protected String redisPassword
protected long redisDictTTL
protected long redisTimeout
protected long redisConnectionTimeout
protected boolean redisUseSentinel
protected String sentinelHost
protected int sentinelPort
protected String sentinelPassword
protected String sentinelMasterId
protected boolean skipLoggingRuleMatches
protected boolean skipLoggingChecks
protected int slowRuleLoggingThreshold
protected Pattern abTestClients
protected int abTestRollout
protected File ngramLangIdentData
protected boolean localApiMode
protected String motherTongue
protected int dictLimitUser
protected int dictLimitTeam
protected int styleGuideLimitUser
protected int styleGuideLimitTeam
public HTTPServerConfig()
DEFAULT_PORT
).public HTTPServerConfig(int serverPort)
serverPort
- the port to bind topublic HTTPServerConfig(int serverPort, boolean verbose)
serverPort
- the port to bind toverbose
- when set to true, the input text will be logged in case there is an exceptionpublic void setPremiumOnly(boolean premiumOnly)
public boolean isAnonymousAccessAllowed()
public boolean isRestrictManagedAccounts()
public void setRestrictManagedAccounts(boolean restrictManagedAccounts)
public void setLanguageModelDirectory(String langModelDir)
public boolean isVerbose()
public boolean isPublicAccess()
public int getPort()
public int getMinPort()
public int getMaxPort()
@Nullable public String getAllowOriginUrl()
null
will not return that header at all. With *
your server can be used from any other web site
from Javascript/Ajax (search Cross-origin resource sharing (CORS) for details).public void setAllowOriginUrl(String allowOriginUrl)
@Nullable public URI getServerURL()
public void setServerURL(@Nullable String url)
url
- prefix / base URL for API requestspublic void setMaxTextLengthAnonymous(int len)
len
- the maximum text length allowed (in number of characters), texts that are longer
will cause an exception when being checked, unless the user can provide
an API keypublic void setMaxTextLengthLoggedIn(int len)
public void setMaxTextLengthPremium(int len)
public void setMaxTextHardLength(int len)
len
- the maximum text length allowed (in number of characters), texts that are longer
will cause an exception when being checked even if the user can provide an API keypublic List<String> getRequestLimitWhitelistUsers()
public void setRequestLimitWhitelistUsers(List<String> requestLimitWhitelistUsers)
public int getRequestLimitWhitelistLimit()
public void setRequestLimitWhitelistLimit(int requestLimitWhitelistLimit)
public void setRequestLimit(int requestLimit)
public void setRequestLimitPeriodInSeconds(int requestLimitPeriodInSeconds)
public String getRequestLimitAccessToken()
public void setRequestLimitAccessToken(String requestLimitAccessToken)
@Nullable public File getFasttextModel()
public void setFasttextModel(File model)
@Nullable public File getFasttextBinary()
public void setFasttextBinary(File binary)
public int getTextCheckerQueueSize()
public void setTextCheckerQueueSize(int textCheckerQueueSize)
public boolean isPipelineCachingEnabled()
public boolean isPipelinePrewarmingEnabled()
public int getMaxPipelinePoolSize()
public int getPipelineExpireTime()
public void setPipelineCaching(boolean pipelineCaching)
public void setPipelinePrewarming(boolean pipelinePrewarming)
public void setMaxPipelinePoolSize(int maxPipelinePoolSize)
public void setPipelineExpireTime(int pipelineExpireTime)
public long getDbTimeoutSeconds()
public void setDbTimeoutSeconds(long dbTimeoutSeconds)
public int getDatabaseTimeoutRateThreshold()
public void setDatabaseTimeoutRateThreshold(int databaseTimeoutRateThreshold)
public int getDatabaseErrorRateThreshold()
public void setDatabaseErrorRateThreshold(int databaseErrorRateThreshold)
public int getDatabaseDownIntervalSeconds()
public void setDatabaseDownIntervalSeconds(int databaseDownIntervalSeconds)
public boolean getGracefulDatabaseFailure()
public void setGracefulDatabaseFailure(boolean gracefulDatabaseFailure)
public boolean isPrometheusMonitoring()
public int getPrometheusPort()
@Nullable public String getRedisHost()
public int getRedisPort()
public int getRedisDatabase()
public boolean isRedisUseSSL()
@Nullable public String getRedisPassword()
public long getRedisDictTTLSeconds()
public long getRedisTimeoutMilliseconds()
public long getRedisConnectionMilliseconds()
public int getSlowRuleLoggingThreshold()
public boolean isSkipLoggingChecks()
public void setAbTest(@Nullable String abTest)
@Experimental @Nullable public Pattern getAbTestClients()
@Experimental public void setAbTestClients(@Nullable String pattern)
@Experimental public void setAbTestRollout(int abTestRollout)
abTestRollout
- percentage [0,100] of users to include in ab test rollout@Experimental public int getAbTestRollout()
public void setNgramLangIdentData(File ngramLangIdentData)
@Nullable public File getNgramLangIdentData()
protected String getProperty(Properties props, String propertyName, File config)
IllegalConfigurationException
- if property is not setprotected String getOptionalProperty(Properties props, String propertyName, String defaultValue)
public boolean isPremiumOnly()
public boolean isRedisUseSentinel()
public void setRedisUseSentinel(boolean redisUseSentinel)
public String getSentinelHost()
public void setSentinelHost(String sentinelHost)
public int getSentinelPort()
public void setSentinelPort(int sentinelPort)
public String getSentinelPassword()
public void setSentinelPassword(String sentinelPassword)
public String getSentinelMasterId()
public void setSentinelMasterId(String sentinelMasterId)
public String getRedisCertificate()
public void setRedisCertificate(String redisCertificate)
public String getRedisKey()
public void setRedisKey(String redisKey)
public String getRedisKeyPassword()
public void setRedisKeyPassword(String redisKeyPassword)
public String getPasswortLoginAccessListPath()
public boolean isLocalApiMode()
public String getMotherTongue()
public int getDictLimitUser()
public int getDictLimitTeam()
public int getStyleGuideLimitUser()
public int getStyleGuideLimitTeam()
public int getDbMaxConnections()
public void setDbMaxConnections(int dbMaxConnections)
dbMaxConnections
- max number of active connections in DB connection pool