- Enclosing class:
Detector
Detector.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the Detector and binds every Rule's Conditions and every watched Expression to it.history(Collection<Event> events) Supplies Events known from before this Detector started (e.g.listener(EventListener listener) restore(byte[] snapshot) Makesbuild()produce a Detector in the state of aDetector.snapshot()instead of a fresh one, ready for the next Sample.retentionLimit(int n) Sets the Retention Limit: the maximum number of entries a singleaverageOverDurationwindow keeps (default 1,000,000), and the maximum number of timestamps kept per counted Rule forcount(...).within(...).Adds Rules, evaluated in the order they are added.samplingRate(double hz) Declares a regularly sampled series ofhzSamples per second (at most 1000, the millisecond resolution of timestamps), so Samples are pushed without timestamps.watch(Expression... expressions) Registers Expressions whose values the built Detector reports throughDetector.value(io.github.romanhaendler.rbed.Expression).
-
Method Details
-
rules
Adds Rules, evaluated in the order they are added. A Rule may only refer to Rules added before it. -
watch
Registers Expressions whose values the built Detector reports throughDetector.value(io.github.romanhaendler.rbed.Expression). They are bound after all Rules and need not be used by any Rule; their Channels count as used. May be called more than once; watching an Expression twice is harmless.Watching adds no allocation per Sample. Each moving average in a watched Expression keeps a window of its own, even if a Rule uses the same instance: its entries take memory, count in
Detector.retainedValues()and against the Retention Limit, and each push updates it. Everything else in a watched Expression adds no work per push. Watchinglatest(r).min/max/mean(c)makes Ruleraggregate Channelc, sor's Events gain Aggregates ofc; which Events are found, and when, is unchanged. -
restore
Makesbuild()produce a Detector in the state of aDetector.snapshot()instead of a fresh one, ready for the next Sample. The Rules, the sampling rate, the Retention Limit and the watched Expressions of this Builder must be those of the Detector that took the Snapshot. The listener is not part of a Snapshot: set it on this Builder.build()throwsIllegalArgumentException, with a message naming the cause, if the array is not a Snapshot, is corrupted or truncated, has a format version this rbed does not read, was taken with other Rules (also a renamed or changed Rule) or other options (sampling rate, Retention Limit, watched Expressions), or ifhistorywas also called (a Snapshot already contains the History that was known).- Throws:
NullPointerException- ifsnapshotis null
-
listener
-
samplingRate
Declares a regularly sampled series ofhzSamples per second (at most 1000, the millisecond resolution of timestamps), so Samples are pushed without timestamps. -
retentionLimit
Sets the Retention Limit: the maximum number of entries a singleaverageOverDurationwindow keeps (default 1,000,000), and the maximum number of timestamps kept per counted Rule forcount(...).within(...). When a full window or timestamp buffer gets a new entry, its oldest entry is dropped, and the Detector logs one warning throughSystem.Logger. SeeDetector.droppedValues().build()rejects a Rule or watched Expression usingaverageOverSamples(n)withnabove the limit.- Throws:
IllegalArgumentException- ifnis below 1
-
history
Supplies Events known from before this Detector started (e.g. stored before a restart), so thatConditions.after(io.github.romanhaendler.rbed.Rule)andAfter.unlesssee them. They must be Confirmed and Ended before the first Sample, and are not reported to the listener. -
build
Builds the Detector and binds every Rule's Conditions and every watched Expression to it.- Throws:
IllegalArgumentException- if a Rule references itself, a Rule added after it or a Rule not added, if a watched Expression references a Rule not added, or if History contains an Event of no added Rule. A Rule withoutwhenand duplicate Rule names are already rejected byrules.
-