class EventsBuffer extends NamedLogging
This in-memory fan-out buffer allows a DatabaseSequencer.single(...) instance to fully bypass reading events back from the database, since there's only a single writer.
Multiple readers may request an immutable snapshot of the buffer at any time. We use immutable scala.collection.immutable.Vector to allow efficient random access to find the reading start point using binary search.
The user of this buffer is responsible for providing the events in the right order.
The buffer is configured with a memory limit and only holds events up to this limit. The memory used by an event is merely an approximated value and not intended to be very precise, see com.digitalasset.canton.synchronizer.sequencer.store.EventsBuffer.approximateEventSize. There is no direct bound on the number of events that can be buffered, as long as the total sum of the memory used by all events is below the memory limit. This means there could be a few very big events or a lot of small events, or anything in between.
There are some invariants/restrictions:
- The EventsBuffer always keeps at least 1 element, even if the single event exceeds the memory limit.
- After adding elements to the buffer, old elements are removed from the buffer until the memory usage drops below the memory limit.
- Only a single process may write to the buffer.
- Annotations
- @SuppressWarnings()
- Alphabetic
- By Inheritance
- EventsBuffer
- NamedLogging
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new EventsBuffer(maxEventsBufferMemory: BytesUnit, loggerFactory: NamedLoggerFactory, cacheMetrics: CacheMetrics)
- maxEventsBufferMemory
the maximum amount of memory the buffered events may occupy
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def bufferEvents(events: NonEmpty[Seq[Sequenced[BytesPayload]]]): Unit
Appends events up to the memory limit to the buffer.
Appends events up to the memory limit to the buffer. May drop already buffered events and may not buffer all provided events to stay within the memory limit.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- implicit def errorLoggingContext(implicit traceContext: TraceContext): ErrorLoggingContext
- Attributes
- protected
- Definition Classes
- NamedLogging
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- final def invalidateBuffer(): Unit
Empty the buffer for events, i.e.
Empty the buffer for events, i.e. in case of a writer failure
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def logger: TracedLogger
- Attributes
- protected
- Definition Classes
- NamedLogging
- val loggerFactory: NamedLoggerFactory
- Definition Classes
- EventsBuffer → NamedLogging
- implicit def namedLoggingContext(implicit traceContext: TraceContext): NamedLoggingContext
- Attributes
- protected
- Definition Classes
- NamedLogging
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def noTracingLogger: Logger
- Attributes
- protected
- Definition Classes
- NamedLogging
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def prependEventsForPreloading(events: NonEmpty[Seq[Sequenced[BytesPayload]]]): Boolean
Prepends events to the buffer up to the memory limit.
Prepends events to the buffer up to the memory limit. May not buffer all provided events to stay within the memory limits.
- returns
true if the buffer is at the memory limit or some events had to be dropped again to stay within the memory limit.
- final def snapshot(): Vector[Sequenced[BytesPayload]]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])