Package sudoku
Class SudokuSupervisor
- java.lang.Object
-
- akka.actor.typed.Behavior<T>
-
- akka.actor.typed.ExtensibleBehavior<T>
-
- akka.actor.typed.javadsl.AbstractBehavior<SudokuSupervisor.Protocol>
-
- sudoku.SudokuSupervisor
-
public class SudokuSupervisor extends akka.actor.typed.javadsl.AbstractBehavior<SudokuSupervisor.Protocol>
Simple agent-guardian of the whole multi-agent-system solving Sudoku. Existence required by Akka. Parent of Teacher agent.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSudokuSupervisor.IterationFinishedMsgMessage received from the Teacher on every iteration's finish, containing new solution of the Sudoku riddle.static interfaceSudokuSupervisor.ProtocolAbstract interface for all commands (messages) passed to the Agent.static classSudokuSupervisor.SimulateTeacherCrashMsgMessage for making the Teacher crash.static classSudokuSupervisor.TeacherWillRestartMsgMessage when Teacher is going to be restarted.static classSudokuSupervisor.TerminateMsgMessage for controlled termination of the agent.-
Nested classes/interfaces inherited from class akka.actor.typed.Behavior
akka.actor.typed.Behavior.BehaviorDecorators<Inner extends Object>, akka.actor.typed.Behavior.BehaviorDecorators$
-
-
Field Summary
Fields Modifier and Type Field Description private akka.actor.typed.ActorRef<String>_simulationParentParent - agent for debugging when simulating Teacher's crash.private Sudoku_sudokuSudoku riddle to be solved by the app.private akka.actor.typed.ActorRef<Teacher.Protocol>_teacherChild Teacher agent.
-
Constructor Summary
Constructors Modifier Constructor Description privateSudokuSupervisor(akka.actor.typed.javadsl.ActorContext<SudokuSupervisor.Protocol> context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static akka.actor.typed.Behavior<SudokuSupervisor.Protocol>create()Public method that calls private constructor.akka.actor.typed.javadsl.Receive<SudokuSupervisor.Protocol>createReceive()Main method controlling incoming messages.private akka.actor.typed.Behavior<SudokuSupervisor.Protocol>onIterationFinished(SudokuSupervisor.IterationFinishedMsg msg)As every iteration finishes, SudokuSupervisor saves new (iterated) solution on the hard drive.private SudokuSupervisoronPostStop()Handler of PostStop signal.private akka.actor.typed.Behavior<SudokuSupervisor.Protocol>onSimulateTeacherCrash(SudokuSupervisor.SimulateTeacherCrashMsg msg)Behaviour towards SimulateTeacherCrashMsg message.private akka.actor.typed.Behavior<SudokuSupervisor.Protocol>onTeacherWillRestart(SudokuSupervisor.TeacherWillRestartMsg msg)Behaviour towards TeacherWillRestartMsg message.private akka.actor.typed.Behavior<SudokuSupervisor.Protocol>onTermination(SudokuSupervisor.TerminateMsg terminateMsg)Behaviour towards TerminateMsg message.private voidreadSudoku()Action of reading _sudoku from file.-
Methods inherited from class akka.actor.typed.javadsl.AbstractBehavior
getContext, newReceiveBuilder, receive, receiveSignal
-
-
-
-
Field Detail
-
_sudoku
private Sudoku _sudoku
Sudoku riddle to be solved by the app.
-
_teacher
private akka.actor.typed.ActorRef<Teacher.Protocol> _teacher
Child Teacher agent.
-
_simulationParent
private akka.actor.typed.ActorRef<String> _simulationParent
Parent - agent for debugging when simulating Teacher's crash.
-
-
Constructor Detail
-
SudokuSupervisor
private SudokuSupervisor(akka.actor.typed.javadsl.ActorContext<SudokuSupervisor.Protocol> context)
-
-
Method Detail
-
create
public static akka.actor.typed.Behavior<SudokuSupervisor.Protocol> create()
Public method that calls private constructor. Existence required by Akka.- Returns:
- wrapped Behavior
-
createReceive
public akka.actor.typed.javadsl.Receive<SudokuSupervisor.Protocol> createReceive()
Main method controlling incoming messages. Existence required by Akka.- Specified by:
createReceivein classakka.actor.typed.javadsl.AbstractBehavior<SudokuSupervisor.Protocol>- Returns:
- wrapped Behavior
-
onPostStop
private SudokuSupervisor onPostStop()
Handler of PostStop signal. Expected after stopping SudokuSupervisor agent.- Returns:
- wrapped Behavior
-
onTermination
private akka.actor.typed.Behavior<SudokuSupervisor.Protocol> onTermination(SudokuSupervisor.TerminateMsg terminateMsg)
Behaviour towards TerminateMsg message. Action performed on termination.- Parameters:
terminateMsg- termination message- Returns:
- wrapped Behavior
-
onSimulateTeacherCrash
private akka.actor.typed.Behavior<SudokuSupervisor.Protocol> onSimulateTeacherCrash(SudokuSupervisor.SimulateTeacherCrashMsg msg)
Behaviour towards SimulateTeacherCrashMsg message. Agent tells the Teacher to simulate crash.- Parameters:
msg- message simulating crash- Returns:
- wrapped Behavior
-
onTeacherWillRestart
private akka.actor.typed.Behavior<SudokuSupervisor.Protocol> onTeacherWillRestart(SudokuSupervisor.TeacherWillRestartMsg msg)
Behaviour towards TeacherWillRestartMsg message. The Teacher responds just before restart.- Parameters:
msg- respond just before restart- Returns:
- wrapped Behavior
-
onIterationFinished
private akka.actor.typed.Behavior<SudokuSupervisor.Protocol> onIterationFinished(SudokuSupervisor.IterationFinishedMsg msg)
As every iteration finishes, SudokuSupervisor saves new (iterated) solution on the hard drive.- Parameters:
msg- message containing new solution represented by Sudoku object- Returns:
- wrapped Behavior
-
readSudoku
private void readSudoku()
Action of reading _sudoku from file.
-
-