com.digitalasset.canton.participant.protocol.conflictdetection
NaiveRequestTracker
Companion object NaiveRequestTracker
class NaiveRequestTracker extends RequestTracker with NamedLogging with FlagCloseableAsync
The naive request tracker performs all its tasks (activeness check/timeout/finalization) sequentially.
It accumulates all pending tasks in a priority queue and executes them as soon as the request tracker can
progress to their associated timestamp. The execution happens asynchronously in the execution context ecForConflictDetection
.
Requests are kept in memory from the call to NaiveRequestTracker!.addRequest until the finalization time or the timeout.
- Alphabetic
- By Inheritance
- NaiveRequestTracker
- FlagCloseableAsync
- FlagCloseable
- RequestTracker
- NamedLogging
- AutoCloseable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new NaiveRequestTracker(initSc: SequencerCounter, initTimestamp: CantonTimestamp, conflictDetector: ConflictDetector, taskSchedulerMetrics: TaskSchedulerMetrics, timeouts: ProcessingTimeout, loggerFactory: NamedLoggerFactory)(implicit executionContext: ExecutionContext)
- initSc
The first sequencer counter to be processed
- initTimestamp
Only timestamps after this timestamp are allowed
Type Members
- case class ReaderState(count: Int, readers: MultiSet[String]) extends Product with Serializable
- Definition Classes
- FlagCloseable
Value Members
- object ReaderState extends Serializable
- Definition Classes
- FlagCloseable
- 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
- def addCommitSet(rc: RequestCounter, commitSet: Try[CommitSet])(implicit traceContext: TraceContext): Either[CommitSetError, EitherT[Future, NonEmptyChain[RequestTrackerStoreError], Unit]]
Informs the request tracker of the effect of a request that is to be committed.
Informs the request tracker of the effect of a request that is to be committed. The effect is described by a CommitSet, namely which contracts should be deactivated and which ones activated.
This method may be called only after an addResult call for the same request.
- commitSet
The commit set to describe the committed effect of the request A scala.util.Failure$ indicates that result processing failed and no commit set can be provided.
- returns
A future to indicate whether the request was successfully finalized. When this future completes, the request's effect is persisted to the store.ActiveContractStore and the store.TransferStore. The future fails with an exception if the commit set tries to activate or deactivate a contract that was not locked during the activeness check. Otherwise, activeness irregularities are reported as scala.Left$.
- Definition Classes
- NaiveRequestTracker → RequestTracker
- See also
ConflictDetector.finalizeRequest
- def addEmptyCommitSet(rc: RequestCounter)(implicit traceContext: TraceContext): Either[CommitSetError, Future[Unit]]
Shorthand for
addCommitSet(rc, CommitSet.empty)
Shorthand for
addCommitSet(rc, CommitSet.empty)
- Definition Classes
- RequestTracker
- def addRequest(rc: RequestCounter, sc: SequencerCounter, requestTimestamp: CantonTimestamp, activenessTimestamp: CantonTimestamp, decisionTime: CantonTimestamp, activenessSet: ActivenessSet)(implicit traceContext: TraceContext): Either[RequestAlreadyExists, Future[RequestFutures]]
Adds the confirmation request to the request tracker.
Adds the confirmation request to the request tracker. It schedules the activeness check for the
activenessTime
and the timeout of the request for thedecisionTime
, whereby a result exactly at thedecisionTime
is considered to be in time. If a scala.Right$ is returned, it also signals the arrival of the message withsequencerCounter
and timestamprequestTimestamp
, like the RequestTracker!.tick operation.The activeness check request is expressed as an activeness set comprising all the contracts that must be active and those that may be created or transferred-in. This operation returns a pair of futures indicating the outcome of the activeness check and the timeout state of the request, described below.
If a request with
requestCounter
andsequencerCounter
is added, the request tracker expects that eventually every request prior torequestCounter
will be added, and that every sequencer counter prior tosequencerCounter
will be signaled.If the request has been added before with the same parameters, but it is not yet finalized nor has it timed out, the method ignores the second call and returns the same futures as in the first call.
- requestTimestamp
The timestamp on the request.
- decisionTime
The timeout for the request. Must be after the
activenessTime
.- activenessSet
The activeness set that determines the checks at the
activenessTime
.- returns
scala.Right$ if the request was added successfully or this is a duplicate call for the request. One future for the result of the activeness check and one for signalling the timeout state of a request. These futures complete only when their result is determined: The result of the activeness check when the request tracker has progressed to the
activenessTime
. The timeout state when the request tracker has progressed to thedecisionTime
or a transaction result was added for the request. scala.Left$ if a request with the samerequestCounter
is in flight with different parameters.
- Definition Classes
- NaiveRequestTracker → RequestTracker
- Exceptions thrown
- If the
requestTimestamp
orsequencerCounter
isLong.MaxValue
. - If the
requestTimestamp
is earlier than to where the request tracking has already progressed - If the
activenessTimestamp
is not between therequestTimestamp
(inclusive) and thedecisionTime
(exclusive).
- If the
- def addResult(rc: RequestCounter, sc: SequencerCounter, resultTimestamp: CantonTimestamp, commitTime: CantonTimestamp)(implicit traceContext: TraceContext): Either[ResultError, Unit]
Informs the request tracker that a result message has arrived for the given request.
Informs the request tracker that a result message has arrived for the given request. This marks the request as not having timed out. The actual effect of the result must be supplied via a subsequent call to RequestTracker!.addCommitSet. The request tracker may not progress beyond the
commitTime
until the commit set is provided.This method may be called only after a RequestTracker!.addRequest call for the same request.
- resultTimestamp
The timestamp of the result message. Must be after the request's timestamp and at most the decision time.
- commitTime
The commit time, i.e., when the result takes effect Must be no earlier than the result timestamp.
- returns
scala.Right$ if the result was added successfully or this is a duplicate call for the request. The timeout future returned by the corresponding call to RequestTracker!.addRequest completes with RequestTracker$.NoTimeout. scala.Left$ if the result could not be added (see the RequestTracker$.ResultErrors for the possible cases). The timestamp is nevertheless considered as observed.
- Definition Classes
- NaiveRequestTracker → RequestTracker
- Exceptions thrown
java.lang.IllegalArgumentException
if thecommitTime
is before theresultTimestamp
, or if the request is in flight and theresultTimestamp
is after its decision time. The timestamp is not observed in this case.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def awaitTimestamp(timestamp: CantonTimestamp): Option[Future[Unit]]
Returns a future that completes after the request has progressed to the given timestamp.
Returns a future that completes after the request has progressed to the given timestamp. If the request tracker has already progressed to the timestamp, scala.None is returned.
- Definition Classes
- NaiveRequestTracker → RequestTracker
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def close(): Unit
Blocks until all earlier tasks have completed and then prevents further tasks from being run.
Blocks until all earlier tasks have completed and then prevents further tasks from being run.
- Definition Classes
- FlagCloseable → AutoCloseable
- Annotations
- @SuppressWarnings()
- def closeAsync(): Seq[AsyncOrSyncCloseable]
closeAsync asynchronously releases resources held by a future
closeAsync asynchronously releases resources held by a future
- returns
an ordered sequence of async and sync closeables with async closeables made up of future and timeout
- Definition Classes
- NaiveRequestTracker → FlagCloseableAsync
- def closingTimeout: FiniteDuration
- Attributes
- protected
- Definition Classes
- FlagCloseable
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def getApproximateState(coid: LfContractId)(implicit traceContext: TraceContext): OptionT[Future, ContractState]
Returns a possibly outdated state of the contract.
Returns a possibly outdated state of the contract.
- Definition Classes
- NaiveRequestTracker → RequestTracker
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def internalPerformUnlessClosingF[A](name: String)(f: => Future[A])(implicit ec: ExecutionContext, traceContext: TraceContext): UnlessShutdown[Future[A]]
- Attributes
- protected
- Definition Classes
- FlagCloseable
- def isClosing: Boolean
Check whether we're closing.
Check whether we're closing. Susceptible to race conditions; unless you're using using this as a flag to the retry lib or you really know what you're doing, prefer performUnlessClosing and friends.
- Definition Classes
- FlagCloseable
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def keepTrackOfOpenFutures: Boolean
track running futures on shutdown
track running futures on shutdown
set to true to get detailed information about all futures that did not complete during shutdown. if set to false, we don't do anything.
- Attributes
- protected
- Definition Classes
- FlagCloseable
- def logger: TracedLogger
- Attributes
- protected
- Definition Classes
- NamedLogging
- val loggerFactory: NamedLoggerFactory
- Attributes
- protected
- Definition Classes
- NaiveRequestTracker → NamedLogging
- implicit def loggingContext(implicit traceContext: TraceContext): ErrorLoggingContext
- Attributes
- protected
- Definition Classes
- NamedLogging
- def maxSleepMillis: Long
- Attributes
- protected
- Definition Classes
- FlagCloseable
- 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
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def onClosed(): Unit
- Definition Classes
- FlagCloseableAsync → FlagCloseable
- def performUnlessClosing[A](name: String)(f: => A)(implicit traceContext: TraceContext): UnlessShutdown[A]
Performs the task given by
f
unless a shutdown has been initiated.Performs the task given by
f
unless a shutdown has been initiated. The shutdown will only begin afterf
completes, but other tasks may execute concurrently withf
, if started using this function, or one of the other variants (performUnlessClosingF and performUnlessClosingEitherT). The tasks are assumed to take less than closingTimeout to complete.DO NOT CALL
this.close
as part off
, because it will result in a deadlock.- f
The task to perform
- returns
scala.None$ if a shutdown has been initiated. Otherwise the result of the task.
- Definition Classes
- FlagCloseable
- def performUnlessClosingEitherT[E, R](name: String, onClosing: => E)(etf: => EitherT[Future, E, R])(implicit ec: ExecutionContext, traceContext: TraceContext): EitherT[Future, E, R]
Performs the EitherT[Future] given by
etf
unless a shutdown has been initiated, in which case the provided error is returned instead.Performs the EitherT[Future] given by
etf
unless a shutdown has been initiated, in which case the provided error is returned instead. Bothetf
and the error are lazy;etf
is only evaluated if there is no shutdown, the error only if we're shutting down. The shutdown will only begin afteretf
completes, but other tasks may execute concurrently withetf
, if started using this function, or one of the other variants (performUnlessClosing and performUnlessClosingF). The tasks are assumed to take less than closingTimeout to complete.DO NOT CALL
this.close
as part ofetf
, because it will result in a deadlock.- etf
The task to perform
- Definition Classes
- FlagCloseable
- def performUnlessClosingEitherTF[E, R](name: String, onClosing: => E)(etf: => EitherT[Future, E, Future[R]])(implicit ec: ExecutionContext, traceContext: TraceContext): EitherT[Future, E, Future[R]]
- Definition Classes
- FlagCloseable
- def performUnlessClosingF[A](name: String)(f: => Future[A])(implicit ec: ExecutionContext, traceContext: TraceContext): FutureUnlessShutdown[A]
Performs the Future given by
f
unless a shutdown has been initiated.Performs the Future given by
f
unless a shutdown has been initiated. The future is lazy and not evaluated during shutdown. The shutdown will only begin afterf
completes, but other tasks may execute concurrently withf
, if started using this function, or one of the other variants (performUnlessClosing and performUnlessClosingEitherT). The tasks are assumed to take less than closingTimeout to complete.DO NOT CALL
this.close
as part off
, because it will result in a deadlock.- f
The task to perform
- returns
The future completes with com.digitalasset.canton.lifecycle.UnlessShutdown.AbortedDueToShutdown if a shutdown has been initiated. Otherwise the result of the task wrapped in com.digitalasset.canton.lifecycle.UnlessShutdown.Outcome.
- Definition Classes
- FlagCloseable
- def requestInFlight(rc: RequestCounter): Boolean
Returns whether the request is in flight, i.e., in the requests map.
Returns whether the request is in flight, i.e., in the requests map.
- Annotations
- @VisibleForTesting()
- def runOnShutdown[T](task: RunOnShutdown)(implicit traceContext: TraceContext): Unit
Register a task that will run onClose after all "performUnlessShutdown" tasks have finished
Register a task that will run onClose after all "performUnlessShutdown" tasks have finished
- Definition Classes
- FlagCloseable
- def runStateChanged(waitingState: Boolean = false): Unit
- Attributes
- protected
- Definition Classes
- FlagCloseable
- Annotations
- @VisibleForTesting()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def tick(sc: SequencerCounter, timestamp: CantonTimestamp)(implicit traceContext: TraceContext): Unit
Tells the request tracker that a message with the given sequencer counter and timestamp has been received.
Tells the request tracker that a message with the given sequencer counter and timestamp has been received.
If RequestTracker!.addRequest or RequestTracker!.addResult shall be called for the same message, RequestTracker!.tick may only be called after those methods as they may schedule tasks at the timestamp or later and task scheduling for a timestamp must be done before the time is observed.
A given sequencer counter may be signalled several times provided that all calls signal the same timestamp. Only the first such call is taken into account. Since RequestTracker!.addRequest and RequestTracker!.addResult implicitly signal the sequencer counter and timestamp to the request tracker (unless specified otherwise), it is safe to call this method after calling these methods.
The timestamps must increase with the sequencer counters.
- timestamp
The timestamp on the message.
- Definition Classes
- NaiveRequestTracker → RequestTracker
- Exceptions thrown
If one of the following conditions hold:
- If
sequencerCounter
isLong.MaxValue
. - If not all sequencer counters below
sequencerCounter
have been signalled and thetimestamp
does not increase with sequencer counters. - If all sequencer counters below
sequencerCounter
have been signalled and the timestamp is at most the timestamp of an earlier sequencer counter. - If
sequencerCounter
has been signalled before with a differenttimestamp
and not all sequencer counters belowsequencerCounter
have been signalled.
- If
- val timeouts: ProcessingTimeout
- Attributes
- protected
- Definition Classes
- NaiveRequestTracker → FlagCloseable
- 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])