Define a SupervisorStrategyConfigurator

56 views
Skip to first unread message

Kilic Ali-Firat

unread,
Jan 17, 2017, 10:35:07 AM1/17/17
to Akka User List
Hi guys,

After reading more the documentation about the fault tolerance in Akka, I'm trying to a define a new guardian supervisor strategy like below :

package foo


import akka.actor.{OneForOneStrategy, SupervisorStrategy, SupervisorStrategyConfigurator}
import akka.actor.SupervisorStrategy.{Decider, Resume}


/**
  * Created by alifirat on 17/01/17.
  */

object Foo {


   
final val resumeDecider: Decider = {
     
case _: Exception => Resume
   
}


   
final val resumeStrategy: SupervisorStrategy =  OneForOneStrategy()(resumeDecider)


   
final class ResumeSupervisorStrategy extends SupervisorStrategyConfigurator {
     
override def create() = resumeStrategy
   
}
}

And in one my test, I try to set this new supervisor strategy like this :

class TEST_DEVICES_ROUTER_RECEIVE_DEVICES_DATA_AND_EXCEPTIONS
 
extends TestKit(ActorSystem("TEST_DEVICES_ROUTER_RECEIVE_DEVICES_DATA", ConfigFactory.parseString("""
  akka.actor.guardian-supervisor-strategy = "
foo.Foo.ResumeSupervisorStrategy"
  """
)))
   
with FlatSpecLike
   
with Matchers
   
with BeforeAndAfterAll
   
with MockitoSugar
   
with LazyLogging {


But when I run the test, I got the following exception :

info] TEST_DEVICES_ROUTER_RECEIVE_DEVICES_DATA_AND_EXCEPTIONS *** ABORTED ***
[info]   java.lang.ClassNotFoundException: foo.Foo.ResumeSupervisorStrategy
[info]   at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
[info]   at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[info]   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
[info]   at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[info]   at java.lang.Class.forName0(Native Method)
[info]   at java.lang.Class.forName(Class.java:348)
[info]   at akka.actor.ReflectiveDynamicAccess$$anonfun$getClassFor$1.apply(ReflectiveDynamicAccess.scala:21)
[info]   at akka.actor.ReflectiveDynamicAccess$$anonfun$getClassFor$1.apply(ReflectiveDynamicAccess.scala:20)
[info]   at scala.util.Try$.apply(Try.scala:192)
[info]   at akka.actor.ReflectiveDynamicAccess.getClassFor(ReflectiveDynamicAccess.scala:20)
[info]   ...


The path of the class ResumeSupervisorStrategy seems to be good but it seems that I didn't an another thing which I cannot fix. Any help will be appreciate !

Rafał Krzewski

unread,
Jan 17, 2017, 1:12:48 PM1/17/17
to Akka User List
foo.Foo.ResumeSupervisorStrategy is an inner class, so I would expect a mangled name, like foo.Foo$ResumeSupervisorStrategy but it would be the best if you checked the actual classes folder to make sure.

cheers,
Rafał

Kilic Ali-Firat

unread,
Jan 17, 2017, 4:25:42 PM1/17/17
to Akka User List
Yes thanks for the fix !
Reply all
Reply to author
Forward
0 new messages