Class ServerQuirkSummary
The format is deliberately trivial —
DIRECTION:PROPERTY=COUNT@LASTSEEN, entries separated by ;,
where the stamp is an epoch day. It has to
be read by whoever opens the row in a database client while diagnosing a
server, and a JSON blob in a column is read by nobody. It also has to survive
being written by an older build and read by a newer one, which it does the
only way a format this small can: an entry that cannot be read is dropped and
the rest of the summary still parses. An entry written before the stamp
existed simply has none, and ServerQuirkSummary.Tally.UNKNOWN_DAY says so rather than
pretending to a date.
Bounded, because a column is not a log. At most
MAX_ENTRIES entries survive a write, the largest counts first, so a
server producing a new proprietary property on every copy cannot grow the row
without limit. Property names are truncated to MAX_PROPERTY — a name
longer than that is not a property name anybody will act on, and the column
has a length.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne thing a server was seen doing, as the summary keys it.static final recordWhat a summary is allowed to forget on one write.static final recordHow often a behaviour has been seen, and when it was last seen. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intHow many observations one server's summary keeps.static final intHow much of a property name is kept. -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringformat(Map<ServerQuirkSummary.Observation, ServerQuirkSummary.Tally> observations) Writes a summary back, largest counts first and bounded in both directions.Reads a stored summary.
-
Field Details
-
MAX_ENTRIES
public static final int MAX_ENTRIESHow many observations one server's summary keeps.- See Also:
-
MAX_PROPERTY
public static final int MAX_PROPERTYHow much of a property name is kept.- See Also:
-
-
Method Details
-
parse
Reads a stored summary.Never throws: this parses a value a previous build wrote, and a summary that cannot be read must leave the drawer showing less rather than leave the registration unreadable. An unreadable entry is dropped on its own.
- Parameters:
summary- the stored value, may be null or blank- Returns:
- the observations and their counts, in the order they were stored, never null
-
format
public static String format(Map<ServerQuirkSummary.Observation, ServerQuirkSummary.Tally> observations) Writes a summary back, largest counts first and bounded in both directions.- Parameters:
observations- the observations and their counts- Returns:
- the value to store, null when there is nothing to store
-