Class WebEngineStats
CC-DESIGN-WEBVIEW-WARNING section 8.2, work order CC-WEBENGINE-SERVER). This is what ServerAdmin shows: the ruling asks for "how many sessions arrive unpatched".In memory, since the server started (design D-11). Nothing is persisted: the counts start at zero with the server and the log line of WebEngineAdvisor is the history. In a hub cluster each server has its own counts.
A group row is one combination of application, platform, product, OS major, engine major and status: "demo, Android, Android System WebView, 7, 119, ENDED". A session is counted in exactly one row, and in the totals of its status:
connect(String, WebEngineStatus, Instant)counts a new session: one more connect and one more active session;move(WebEngineStats.Group, String, WebEngineStatus, Instant)moves a session that was classified again, at a reconnect, to the row of its new verdict: the active counts follow, and NO connect is counted a second time;disconnect(WebEngineStats.Group)ends a session: one less active.
Bounded. The OS and engine majors of a row come from the client's user agent, which the peer controls, so the number of rows is capped at 1000: a session whose row would be one too many is counted in the shared overflow row of its status (application null) and in the totals, which are always exact.
Thread safe: every method takes the one monitor of the instance, held for a map lookup and a few additions. No clock inside: "now" is a parameter.
- Author:
- Christopher Mindus
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe key of a group row, and what a session holds while it is counted: handed back tomove(WebEngineStats.Group, String, WebEngineStatus, Instant)anddisconnect(WebEngineStats.Group).static final recordOne group row of a snapshot.static final recordThe counts at one moment, detached from the live instance.static final recordThe two counts of a status or a row.Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe most group rows kept; sessions beyond are counted in the overflow row of their status, of which there is one per status on top of these.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionconnect(String appID, WebEngineStatus status, Instant now) Counts a new session: one more connect and one more active session, in the totals of its status and in its group row.voiddisconnect(WebEngineStats.Group group) Ends a counted session: one less active session in its status and its group row.getSince()Gets when counting started.move(WebEngineStats.Group from, String appID, WebEngineStatus status, Instant now) Moves a counted session to the group of a new verdict, at a reconnect: the active counts follow, no connect is counted.snapshot()Gets the counts as they are now.
Field Details
MAX_ROWS
public static final int MAX_ROWSThe most group rows kept; sessions beyond are counted in the overflow row of their status, of which there is one per status on top of these.- See Also:
Constructor Details
WebEngineStats
Creates the counts, all zero.- Parameters:
since- When counting starts: the server start.
Method Details
getSince
connect
Counts a new session: one more connect and one more active session, in the totals of its status and in its group row.- Parameters:
appID- The application ID.status- The verdict of the session.now- Now.- Returns:
- The group the session is counted in, to be handed to
move(WebEngineStats.Group, String, WebEngineStatus, Instant)anddisconnect(WebEngineStats.Group).
move
public WebEngineStats.Group move(WebEngineStats.Group from, String appID, WebEngineStatus status, Instant now) Moves a counted session to the group of a new verdict, at a reconnect: the active counts follow, no connect is counted.- Parameters:
from- The group the session is counted in, asconnect(String, WebEngineStatus, Instant)or this method returned it.appID- The application ID.status- The new verdict.now- Now.- Returns:
- The group the session is counted in now.
disconnect
Ends a counted session: one less active session in its status and its group row.- Parameters:
group- The group the session is counted in, null for a session that never was.
snapshot
Gets the counts as they are now.- Returns:
- The snapshot, unmodifiable.