Class VisitorTypes
java.lang.Object
org.frontcache.bots.VisitorTypes
The visitor types a node knows: the two roots,
bot and guest, and the types bots.conf
declares with @type <name> like <bot|guest> - at most 16, each based on a root.
A declared type IS its base everywhere it is not named. A request has one visitor type (the leaf,
customer) and so one client type (its root, guest); RequestContext.getClientType() keeps
returning the root, so every consumer that does not know about declared types sees exactly what it saw before
they existed. What selects by type (client=, client-type:) selects by is-a - a type is itself and
its base; what looks a type up (expireTimeMap) looks up the leaf, then the base - ttl(Map, String, String). Both need
only the leaf and the root the request carries, never this object, so a reload-bots that removes a type
cannot leave a request in flight without an answer.
A declaration may end with no-store (@type customer like guest no-store): a request of that type
never writes an entry, whatever the page's maxage says - it still reads one per its resolved TTL
(isNoStore(String)). One cached copy serves every type, so a type the origin renders differently for (a session
or tracking cookie) would otherwise have its render stored and served to everyone; the flag closes that by
configuration instead of by every page author remembering customer:0. It is decided when an entry would
be written, from the running vocabulary - not carried on the request - so a reload that adds it protects the
requests already in flight too.
Immutable. One snapshot per BotClassifier; active() is the running classifier's.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds a vocabulary from@typelines, refusing each bad one alone - the file's rule: one bad line costs that line. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe directive's keyword.static final intThe most types a bots.conf may declare.static final StringThe one flag a declaration may carry - seeisNoStore(String).static final VisitorTypesNo declarations - the two roots only. -
Method Summary
Modifier and TypeMethodDescriptionstatic VisitorTypesactive()static VisitorTypes.Builderbuilder()declared()static booleanis-a: a request whose visitor type isvisitorType(rootclientType) isnamewhennameis the leaf or the root.static booleanisDeclaration(String trimmedLine) booleanbooleanstatic booleannoStore()static VisitorTypesfor tests - a vocabulary from declaration lines, every one of which must be acceptedtoString()static LongThe expireTimeMap value that applies to a request: the leaf's if the entry names it, else the root's.
-
Field Details
-
MAX_DECLARED
public static final int MAX_DECLAREDThe most types a bots.conf may declare. It bounds every stored entry's expireTimeMap and the metric labels.- See Also:
-
DIRECTIVE
-
NO_STORE
The one flag a declaration may carry - seeisNoStore(String).- See Also:
-
ROOTS
No declarations - the two roots only. What a node without@typelines runs, and every node before.
-
-
Method Details
-
active
- Returns:
- the vocabulary of the running
BotClassifier, orROOTSbefore one is loaded. Never loads one: FCConfig and its static initializer are not this method's to start
-
isRoot
-
isKnown
- Returns:
- true for a root or a declared type
-
rootOf
-
declared
-
isNoStore
- Returns:
- true when
nameis a type declaredno-store: a request of it never writes an entry - not on a miss, not by a soft refresh - and reads one per its resolved TTL. Never true of a root, nor of a name this node does not know
-
noStore
-
describeKnown
- Returns:
- the known names, roots first, for messages
-
isA
-
ttl
The expireTimeMap value that applies to a request: the leaf's if the entry names it, else the root's. The roots are always in a mapWebResponsebuilt, so for a well-formed entry the answer is never null; an absent declared type means inherit, an absent root is a bug the callers log.- Returns:
- the stamp, or null when neither key is present
-
builder
-
of
for tests - a vocabulary from declaration lines, every one of which must be accepted -
isDeclaration
- Returns:
- true when the trimmed line is a declaration. Recognised by prefix, before a rule is told from a bare
keyword - no real User-Agent begins
@type
-
toString
-