Where a tenant's detector customisations and alarm state live. One JSON document per detector, in the tenant's own file storage, following the same approach as UserPrefsManager. None of this belongs in the database: it is configuration and observation rather than transactional data, it is read far more often than written, and it is naturally document-shaped. Defaults shipped by apps are instantiated on demand from their providers and never written here, so this store only holds what a tenant has changed or added: an override is a partial document naming only the fields the tenant altered, so an account that merely retuned a threshold is not frozen out of later improvements to the default's query, title or aggregation, while a custom detector is a complete document with no default behind it. Which one a document is comes from its own type field rather than from its filename. Deleting an override restores the default, which is what makes overriding safe to offer.
Methods
findDetectorDoc(String detectorName) · findAllDetectorDocs() · saveDetectorDoc(String detectorName, Map<String,Object> doc, String type) · saveDetectorDocJson(String detectorName, String json, String type) · deleteDetectorDoc(String detectorName) · findAlarmState(String detectorName) · saveAlarmState(AnomalyAlarmState state) · deleteAlarmState(String detectorName) · findAlarmStateNames()
findDetectorDoc(String detectorName)
Returns: Map<String,Object>
The tenant's stored document for a detector, if there is one.
| Parameter | Description |
|---|---|
detectorName | the detector's name. Must be a valid name |
findAllDetectorDocs()
Returns: Map<String,Map<String,Object>>
Every detector document the tenant has stored, keyed by detector name.
saveDetectorDoc(String detectorName, Map<String,Object> doc, String type)
Returns: void
Write a tenant's customisation of a detector.
| Parameter | Description |
|---|---|
detectorName | the detector's name. Must be a valid name |
doc | the document to store. For an override, only the changed fields. Must not be null |
type | the document type, either TYPE_OVERRIDE or TYPE_CUSTOM |
saveDetectorDocJson(String detectorName, String json, String type)
Returns: void
Write a tenant's customisation from a JSON document. This is the entry point for script. Handing over the JSON text rather than a map avoids relying on the script engine to convert a nested JavaScript object into a nested map, which it does not do reliably below the top level - and the caller already has the JSON, because that is how the settings arrived from the browser.
| Parameter | Description |
|---|---|
detectorName | the detector's name. Must be a valid name |
json | the document to store, as a JSON object. Must not be blank |
type | the document type, either TYPE_OVERRIDE or TYPE_CUSTOM |
deleteDetectorDoc(String detectorName)
Returns: boolean
Remove a tenant's customisation. For an override this restores the app-provided default; for a custom detector it deletes the detector.
| Parameter | Description |
|---|---|
detectorName | the detector's name. Must be a valid name |
findAlarmState(String detectorName)
Returns: AnomalyAlarmState
A detector's alarm state, or a fresh one if it has never run. Never returns null, so a caller can load, hand to the state machine and save back without branching on first use.
| Parameter | Description |
|---|---|
detectorName | the detector's name. Must be a valid name |
saveAlarmState(AnomalyAlarmState state)
Returns: void
Persist a detector's alarm state.
| Parameter | Description |
|---|---|
state | the state to persist. Must not be null and must name its detector |
deleteAlarmState(String detectorName)
Returns: boolean
Discard a detector's alarm state and history.
| Parameter | Description |
|---|---|
detectorName | the detector whose state and history to discard. Must be a valid name |
findAlarmStateNames()
Returns: List<String>
Names of every detector that has alarm state stored.