diff --git a/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/HaCoordinator.scala b/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/HaCoordinator.scala index 1379924da98c..bb4ef4f2696c 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/HaCoordinator.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/HaCoordinator.scala @@ -132,7 +132,7 @@ object HaCoordinator { mainLockChecker <- go[PollingChecker]( new PollingChecker( periodMillis = haConfig.mainLockCheckerPeriodMillis, - check = acquireMainLock(mainConnection), + checkBody = acquireMainLock(mainConnection), killSwitch = handle.killSwitch, // meaning: this PollingChecker will shut down the main preemptableSequence ) diff --git a/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/KillSwitchCaptor.scala b/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/KillSwitchCaptor.scala index a2133d53f71b..ec7decb83cda 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/KillSwitchCaptor.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/KillSwitchCaptor.scala @@ -8,11 +8,14 @@ import java.util.concurrent.atomic.AtomicReference import akka.stream.KillSwitch import com.daml.logging.{ContextualizedLogger, LoggingContext} -/** A KillSwitch which captures it's usage - * - Shutdown always wins - * - From aborts, the last abort wins - * - With setDelegate() we can set a delegate KillSwitch, which to usage will be replayed - * - Captured state is available with state +/** This KillSwitch captures it's usage in it's internal state, which can be queried. + * Captured state is available with the 'state' method. + * + * Rules of state transitions: + * - Shutdown is always the final state + * - From multiple aborts, the last abort wins + * + * With setDelegate() we can set a delegate KillSwitch, which to usage will be replayed */ class KillSwitchCaptor(implicit loggingContext: LoggingContext) extends KillSwitch { import KillSwitchCaptor._ diff --git a/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/PollingChecker.scala b/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/PollingChecker.scala index d743d9647b8f..a793a59f9eb5 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/PollingChecker.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/indexer/ha/PollingChecker.scala @@ -18,12 +18,12 @@ import scala.util.{Failure, Success, Try} * - It is also an AutoCloseable to release internal resources * * @param periodMillis period of the checking, between each scheduled checks there will be so much delay - * @param check the check function, Exception signals failed check + * @param checkBody the check function, Exception signals failed check * @param killSwitch to abort if a check fails */ class PollingChecker( periodMillis: Long, - check: => Unit, + checkBody: => Unit, killSwitch: KillSwitch, )(implicit loggingContext: LoggingContext) extends AutoCloseable { @@ -49,7 +49,7 @@ class PollingChecker( // (the peak scenario) which should be enough, and which can leave this code very simple. def check(): Unit = synchronized { logger.debug(s"Checking...") - Try(check) match { + Try(checkBody) match { case Success(_) => logger.debug(s"Check successful.")