Update to a working version of Scalariform
This commit is contained in:
parent
cae070bd93
commit
c66ce62d63
616 changed files with 5966 additions and 5436 deletions
|
|
@ -86,9 +86,9 @@ object ClusterSingletonManagerSettings {
|
|||
* (+ `removalMargin`).
|
||||
*/
|
||||
final class ClusterSingletonManagerSettings(
|
||||
val singletonName: String,
|
||||
val role: Option[String],
|
||||
val removalMargin: FiniteDuration,
|
||||
val singletonName: String,
|
||||
val role: Option[String],
|
||||
val removalMargin: FiniteDuration,
|
||||
val handOverRetryInterval: FiniteDuration) extends NoSerializationVerificationNeeded {
|
||||
|
||||
def withSingletonName(name: String): ClusterSingletonManagerSettings = copy(singletonName = name)
|
||||
|
|
@ -103,10 +103,11 @@ final class ClusterSingletonManagerSettings(
|
|||
def withHandOverRetryInterval(retryInterval: FiniteDuration): ClusterSingletonManagerSettings =
|
||||
copy(handOverRetryInterval = retryInterval)
|
||||
|
||||
private def copy(singletonName: String = singletonName,
|
||||
role: Option[String] = role,
|
||||
removalMargin: FiniteDuration = removalMargin,
|
||||
handOverRetryInterval: FiniteDuration = handOverRetryInterval): ClusterSingletonManagerSettings =
|
||||
private def copy(
|
||||
singletonName: String = singletonName,
|
||||
role: Option[String] = role,
|
||||
removalMargin: FiniteDuration = removalMargin,
|
||||
handOverRetryInterval: FiniteDuration = handOverRetryInterval): ClusterSingletonManagerSettings =
|
||||
new ClusterSingletonManagerSettings(singletonName, role, removalMargin, handOverRetryInterval)
|
||||
}
|
||||
|
||||
|
|
@ -121,9 +122,9 @@ object ClusterSingletonManager {
|
|||
* Scala API: Factory method for `ClusterSingletonManager` [[akka.actor.Props]].
|
||||
*/
|
||||
def props(
|
||||
singletonProps: Props,
|
||||
singletonProps: Props,
|
||||
terminationMessage: Any,
|
||||
settings: ClusterSingletonManagerSettings): Props =
|
||||
settings: ClusterSingletonManagerSettings): Props =
|
||||
Props(new ClusterSingletonManager(singletonProps, terminationMessage, settings)).withDeploy(Deploy.local)
|
||||
|
||||
/**
|
||||
|
|
@ -364,20 +365,22 @@ class ClusterSingletonManagerIsStuck(message: String) extends AkkaException(mess
|
|||
* @param settings see [[ClusterSingletonManagerSettings]]
|
||||
*/
|
||||
class ClusterSingletonManager(
|
||||
singletonProps: Props,
|
||||
singletonProps: Props,
|
||||
terminationMessage: Any,
|
||||
settings: ClusterSingletonManagerSettings)
|
||||
settings: ClusterSingletonManagerSettings)
|
||||
extends Actor with FSM[ClusterSingletonManager.State, ClusterSingletonManager.Data] {
|
||||
|
||||
import ClusterSingletonManager.Internal._
|
||||
import ClusterSingletonManager.Internal.OldestChangedBuffer._
|
||||
import settings._
|
||||
import FSM.`→`
|
||||
|
||||
val cluster = Cluster(context.system)
|
||||
val selfAddressOption = Some(cluster.selfAddress)
|
||||
import cluster.settings.LogInfo
|
||||
|
||||
require(role.forall(cluster.selfRoles.contains),
|
||||
require(
|
||||
role.forall(cluster.selfRoles.contains),
|
||||
s"This cluster member [${cluster.selfAddress}] doesn't have the role [$role]")
|
||||
|
||||
val removalMargin =
|
||||
|
|
@ -406,7 +409,7 @@ class ClusterSingletonManager(
|
|||
var removed = Map.empty[Address, Deadline]
|
||||
|
||||
def addRemoved(address: Address): Unit =
|
||||
removed += address -> (Deadline.now + 15.minutes)
|
||||
removed += address → (Deadline.now + 15.minutes)
|
||||
|
||||
def cleanupOverdueNotMemberAnyMore(): Unit = {
|
||||
removed = removed filter { case (address, deadline) ⇒ deadline.hasTimeLeft }
|
||||
|
|
@ -514,7 +517,8 @@ class ClusterSingletonManager(
|
|||
if (sender().path.address == previousOldest)
|
||||
gotoOldest()
|
||||
else {
|
||||
logInfo("Ignoring HandOverDone in BecomingOldest from [{}]. Expected previous oldest [{}]",
|
||||
logInfo(
|
||||
"Ignoring HandOverDone in BecomingOldest from [{}]. Expected previous oldest [{}]",
|
||||
sender().path.address, previousOldest)
|
||||
stay
|
||||
}
|
||||
|
|
@ -538,7 +542,8 @@ class ClusterSingletonManager(
|
|||
|
||||
case Event(TakeOverFromMe, BecomingOldestData(Some(previousOldest))) ⇒
|
||||
if (previousOldest == sender().path.address) sender() ! HandOverToMe
|
||||
else logInfo("Ignoring TakeOver request in BecomingOldest from [{}]. Expected previous oldest [{}]",
|
||||
else logInfo(
|
||||
"Ignoring TakeOver request in BecomingOldest from [{}]. Expected previous oldest [{}]",
|
||||
sender().path.address, previousOldest)
|
||||
stay
|
||||
|
||||
|
|
@ -698,24 +703,24 @@ class ClusterSingletonManager(
|
|||
}
|
||||
|
||||
onTransition {
|
||||
case from -> to ⇒ logInfo("ClusterSingletonManager state change [{} -> {}]", from, to)
|
||||
case from → to ⇒ logInfo("ClusterSingletonManager state change [{} -> {}]", from, to)
|
||||
}
|
||||
|
||||
onTransition {
|
||||
case _ -> BecomingOldest ⇒ setTimer(HandOverRetryTimer, HandOverRetry(1), handOverRetryInterval, repeat = false)
|
||||
case _ → BecomingOldest ⇒ setTimer(HandOverRetryTimer, HandOverRetry(1), handOverRetryInterval, repeat = false)
|
||||
}
|
||||
|
||||
onTransition {
|
||||
case BecomingOldest -> _ ⇒ cancelTimer(HandOverRetryTimer)
|
||||
case WasOldest -> _ ⇒ cancelTimer(TakeOverRetryTimer)
|
||||
case BecomingOldest → _ ⇒ cancelTimer(HandOverRetryTimer)
|
||||
case WasOldest → _ ⇒ cancelTimer(TakeOverRetryTimer)
|
||||
}
|
||||
|
||||
onTransition {
|
||||
case _ -> (Younger | Oldest) ⇒ getNextOldestChanged()
|
||||
case _ → (Younger | Oldest) ⇒ getNextOldestChanged()
|
||||
}
|
||||
|
||||
onTransition {
|
||||
case _ -> (Younger | End) if removed.contains(cluster.selfAddress) ⇒
|
||||
case _ → (Younger | End) if removed.contains(cluster.selfAddress) ⇒
|
||||
logInfo("Self removed, stopping ClusterSingletonManager")
|
||||
// note that FSM.stop() can't be used in onTransition
|
||||
context.stop(self)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue