Class FrontCacheClient
java.lang.Object
org.frontcache.client.FrontCacheClient
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbackup()Triggers a backup of the on-disk (L2) index on the edge.<T extends org.frontcache.io.ActionResponse>
TOne management call, answered as JSON.<T extends org.frontcache.io.ActionResponse>
TcallStreaming(Map<String, String> params, String rawContentTypePrefix, OutputStream os, Class<T> type) A management call whose answer may be a raw body: streamed intoos- never through memory - when itsContent-Typestarts withrawContentTypePrefix, otherwise read as JSON (a refusal, or a ping from a node that does not know the action).<T extends org.frontcache.io.ActionResponse>
TcallWithBody(Map<String, String> queryParams, InputStream body, long length, String contentType, Class<T> type) A management call whose payload is the request BODY, with the parameters in the query string.dumpKeys()Triggers dumping of cached keys to a file on the edge (./warmer dir).booleangetBots()Deprecated.pre-2.7 shape: a single-entry map keyed by domain.The raw conf/bots.conf of this edge - what the console's Bot Configs screen renders.booleanWrites keys to provided output streamFetches all cached keys from the remote node and returns them as a Set.getConfigFile(ConfigFile configFile) The raw content of any of the five editable config files, by logical id.Deprecated.pre-2.7 shape: a single-entry map keyed by domain.The raw conf/dynamic-urls.conf of this edge - what the console's Dynamic URLs screen renders.Deprecated.pre-2.7 shape: a single-entry map keyed by domain.The raw conf/fallbacks.conf of this edge - what the console's Fallback Config screen renders.getFromCache(String key) Deprecated.pre-2.7 name ofgetResilienceConfig()Deprecated.pre-2.7 name ofgetResilienceConfigActionResponse()getName()http://localhost:8080/ -> localhost:8080The cheap, pollable view of a node - cache sizes per tier plus JVM heap, CPU and uptime.getPluginConfig(String pluginId) A plugin's raw config on the edge.Asks for the raw resilience config, falling back to the pre-2.7 action name when the edge does not recognize the current one.inthashCode()static booleanisPing(org.frontcache.io.ActionResponse response) Whetherresponseis the ping a node answers an action it does not know with.purge()Triggers purge of expired entries on the edge.booleanputToCache(String key, WebResponse webResponse) Pushes a WebResponse entry into the remote node's cache.Reloads the edge's conf/dynamic-urls.conf.reloadPluginConfig(String pluginId) Re-reads a plugin's config on the edge -reload-plugin-config?plugin=<id>: the file already on the node's disk, applied (a running plugin keeps the config it had when it refuses the new one; one whose last start failed on its config is started).Reloads the edge's conf/resilience.properties.removeFromCache(String filter) setConfig(ConfigFile configFile, String content, String baseHash, boolean apply) Writes one config file on the edge and applies it.setPluginConfig(String pluginId, String fileName, String content, String baseHash, boolean apply) Writes a plugin's config on the edge and applies it -set-configwithfile=plugin:<id>, so every gate ofsetConfig(ConfigFile, String, String, boolean)applies.toString()
-
Field Details
-
CONNECTION_TIMEOUT
public static int CONNECTION_TIMEOUT
-
-
Constructor Details
-
FrontCacheClient
-
-
Method Details
-
removeFromCache
-
removeFromCacheAll
- Returns:
-
purge
Triggers purge of expired entries on the edge.- Returns:
- raw edge response, or an error message string
-
backup
Triggers a backup of the on-disk (L2) index on the edge.- Returns:
- BackupActionResponse with the status message, or null if the edge is not available
-
getCacheState
-
getCacheStateActionResponse
- Returns:
-
getNodeStatsActionResponse
The cheap, pollable view of a node - cache sizes per tier plus JVM heap, CPU and uptime.The fallback is the point
The console upgrades independently of the fleet, in either order, so this has to work against a node that has never heard ofget-node-stats. Such a node answers an unrecognized action with a PING response rather than an error, which would otherwise render as a panel of dashes with nothing in any log. Detecting the ping and retrying withget-cache-stategets the one number an older node does have - the entry count - and leaves the restUNKNOWNso the console can show it as "not reported" instead of zero. Same shape asgetResilienceConfigActionResponse(), which does this for the 2.7 rename.- Returns:
- the node's stats, or null when the edge could not be reached at all
-
getCachedKeys
Writes keys to provided output stream- Parameters:
os-- Returns:
-
dumpKeys
Triggers dumping of cached keys to a file on the edge (./warmer dir).- Returns:
- DumpKeysActionResponse with the status message, or null if the edge is not available
-
getFallbackConfigsActionResponse
- Returns:
-
getFallbackEntries
- Returns:
- the fallback entries this edge has loaded, or null when the edge could not be reached
-
getFallbackConfigs
Deprecated.pre-2.7 shape: a single-entry map keyed by domain. UsegetFallbackEntries(). -
getBotsActionResponse
- Returns:
-
getBotKeywords
-
getBotRules
- Returns:
- the bot classification rules this edge is running, in evaluation order and with their
hit counts, or null when the edge could not be reached OR is older than 2.9.0 (which
knows only
getBotKeywords())
-
getBots
Deprecated.pre-2.7 shape: a single-entry map keyed by domain. UsegetBotKeywords(). -
getDynamicURLsActionResponse
- Returns:
-
getDynamicUrlPatterns
-
getDynamicURLs
Deprecated.pre-2.7 shape: a single-entry map keyed by domain. UsegetDynamicUrlPatterns(). -
getFallbacksConfigActionResponse
The raw conf/fallbacks.conf of this edge - what the console's Fallback Config screen renders. The parsed counterpart isgetFallbackEntries(); note the two action names are one letter apart, seeFrontcacheAction.GET_FALLBACKS_CONFIG.- Returns:
- the response, which carries either the file or a "not found" error; null if the edge could not be reached at all
-
getFallbacksConfig
-
getDynamicURLsConfigActionResponse
The raw conf/dynamic-urls.conf of this edge - what the console's Dynamic URLs screen renders. The parsed counterpart isgetDynamicURLsActionResponse().- Returns:
- the response, which carries either the file or a "not found" error; null if the edge could not be reached at all
-
getDynamicURLsConfig
-
getBotsConfigActionResponse
The raw conf/bots.conf of this edge - what the console's Bot Configs screen renders. The parsed counterpart isgetBotsActionResponse().- Returns:
- the response, which carries either the file or a "not found" error; null if the edge could not be reached at all
-
getBotsConfig
-
getGuardRulesActionResponse
- Returns:
- guard rules this edge is running, in evaluation order, with hit counts
-
getGuardRules
-
getGuardConfigActionResponse
- Returns:
-
getGuardConfig
-
getResilienceConfigActionResponse
Asks for the raw resilience config, falling back to the pre-2.7 action name when the edge does not recognize the current one. The fallback is needed because an unknown action is not an error on the wire: the management servlet answers it with a ping response, which would render the console's panel empty with nothing in any log to explain why. A ping is therefore the signal to retry with the old name - a precise test, since this client never sendspingitself.- Returns:
- the response, or null when the edge could not be reached
-
getResilienceConfig
- Returns:
- the raw contents of the edge's conf/resilience.properties, or null when the edge could not be reached
-
getConfigFile
The raw content of any of the five editable config files, by logical id. Dispatches to the per-file getters rather than replacing them: each one carries its own wire-format compatibility (the resilience getter retries with the pre-2.7 action name, the others read a field an older node may not send), and folding that into one call would drop it.- Returns:
- the file's content, null when the edge could not be reached or has no such file
-
setConfig
public SetConfigActionResponse setConfig(ConfigFile configFile, String content, String baseHash, boolean apply) Writes one config file on the edge and applies it.A ping means the node predates this action
An unrecognized action is answered with a ping, not an error, so without this check a save to an older node would parse into a response withresponseStatus=OKandwritten=false- i.e. the console would report a success that never happened. That is the worst outcome available here, and a mixed fleet is the normal state: the console upgrades independently of the nodes, in either order.- Parameters:
baseHash- sha-256 of the content being replaced, or null to skip the concurrency check- Returns:
- the outcome, or null when the edge could not be reached at all
-
setPluginConfig
public SetConfigActionResponse setPluginConfig(String pluginId, String fileName, String content, String baseHash, boolean apply) Writes a plugin's config on the edge and applies it -set-configwithfile=plugin:<id>, so every gate ofsetConfig(ConfigFile, String, String, boolean)applies. A node that predates plugin configs refuses the id as an unknown file.- Parameters:
fileName- the file asgetPluginConfig(String)named it, for messages only- Returns:
- the outcome, or null when the edge could not be reached at all
-
getPluginConfig
A plugin's raw config on the edge.- Returns:
- the answer - status ERROR when the edge has no such plugin,
pluginConfignull when its file is absent - or null when the edge could not be reached. A node that predates the action (a ping) is answered as one with no such plugin.
-
reloadPluginConfig
Re-reads a plugin's config on the edge -reload-plugin-config?plugin=<id>: the file already on the node's disk, applied (a running plugin keeps the config it had when it refuses the new one; one whose last start failed on its config is started).- Returns:
- the answer -
appliedfalse with status ERROR and the reasons inerrorswhen the plugin refused it or has no config - or null when the edge could not be reached. A node that predates the action (a ping) is answered as an ERROR, never as a reload that succeeded.
-
call
public <T extends org.frontcache.io.ActionResponse> T call(Map<String, String> params, Class<T> type) One management call, answered as JSON. The action isparams.get("action"). A node that does not know the action answers a ping, which parses into any response class withresponseStatus=OK- so a caller must checkisPing(ActionResponse)before reading the answer as a success. That is how a module's client tells "this node has no such action" (a Community node, or one that predates it) from an answer.- Returns:
- the answer, or null when the node could not be reached or did not answer JSON
-
callWithBody
public <T extends org.frontcache.io.ActionResponse> T callWithBody(Map<String, String> queryParams, InputStream body, long length, String contentType, Class<T> type) A management call whose payload is the request BODY, with the parameters in the query string. Jetty refuses a form body over 200,000 bytes (on the console's container and the node's), so a large payload cannot be a form field.- Parameters:
length- the body's length, or -1 to send it chunked- Returns:
- as
call(Map, Class)
-
callStreaming
public <T extends org.frontcache.io.ActionResponse> T callStreaming(Map<String, String> params, String rawContentTypePrefix, OutputStream os, Class<T> type) throws IOExceptionA management call whose answer may be a raw body: streamed intoos- never through memory - when itsContent-Typestarts withrawContentTypePrefix, otherwise read as JSON (a refusal, or a ping from a node that does not know the action).- Returns:
- null when the body was streamed, otherwise the JSON answer
- Throws:
IOException- when the node could not be reached or the answer could not be read
-
isPing
public static boolean isPing(org.frontcache.io.ActionResponse response) Whetherresponseis the ping a node answers an action it does not know with. -
reloadResilience
Reloads the edge's conf/resilience.properties.- Returns:
- the outcome -
getWarnings()carries what could not be applied - or null when the edge could not be reached
-
reloadDynamicURLs
Reloads the edge's conf/dynamic-urls.conf.- Returns:
- the outcome -
getPatternCount()is how many patterns survived the parse - or null when the edge could not be reached
-
getHystrixConfigActionResponse
Deprecated.pre-2.7 name ofgetResilienceConfigActionResponse() -
getHystrixConfig
Deprecated.pre-2.7 name ofgetResilienceConfig() -
getFromCacheActionResponse
- Returns:
-
getFromCache
-
putToCache
Pushes a WebResponse entry into the remote node's cache. Used by the replication engine to write entries from a source edge to a target edge.- Parameters:
key- the cache key (normalised path)webResponse- the entry to store- Returns:
- true if the entry was stored successfully
-
getCachedKeysSet
-
getFrontCacheURL
-
getName
-
hashCode
-
equals
-
toString
-