pekko/akka-cluster-metrics/src/main/scala/akka/cluster/metrics/ClusterMetricsStrategy.scala
Andrei Pozolotin 7b9f77a073 + akka-cluster-metrics: new akka module
* new akka module split from akka-cluster
* provide sigar provisioning
* fix ewma usage
* resolve #16121
* see #16354
2015-01-19 10:23:54 -06:00

37 lines
1.1 KiB
Scala

/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.cluster.metrics
import com.typesafe.config.Config
import akka.actor.OneForOneStrategy
import akka.util.Helpers.ConfigOps
/**
* Default [[ClusterMetricsSupervisor]] strategy:
* A configurable [[OneForOneStrategy]] with restart-on-throwable decider.
*/
class ClusterMetricsStrategy(config: Config) extends OneForOneStrategy(
maxNrOfRetries = config.getInt("maxNrOfRetries"),
withinTimeRange = config.getMillisDuration("withinTimeRange"),
loggingEnabled = config.getBoolean("loggingEnabled"))(ClusterMetricsStrategy.metricsDecider)
/**
* Provide custom metrics strategy resources.
*/
object ClusterMetricsStrategy {
import akka.actor._
import akka.actor.SupervisorStrategy._
/**
* [[SupervisorStrategy.Decider]] which allows to survive intermittent Sigar native method calls failures.
*/
val metricsDecider: SupervisorStrategy.Decider = {
case _: ActorInitializationException Stop
case _: ActorKilledException Stop
case _: DeathPactException Stop
case _: Throwable Restart
}
}