Package sudoku
Class TimerManager
- java.lang.Object
-
- akka.actor.typed.Behavior<T>
-
- akka.actor.typed.ExtensibleBehavior<T>
-
- akka.actor.typed.javadsl.AbstractBehavior<TimerManager.Protocol>
-
- sudoku.TimerManager
-
public class TimerManager extends akka.actor.typed.javadsl.AbstractBehavior<TimerManager.Protocol>
Agent that manages Timers (in parallel), responding to the Teacher.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TimerManager.CreateMsg
Message creating the agent.static class
TimerManager.NewIterationStartedMsg
Message from the Teacher announcing new big iteration.static interface
TimerManager.Protocol
Protocol interface for input messages.static class
TimerManager.RemindToCheckTablesMsg
Message from the Teacher waking him up after passing given time to check if its Tables are still alive.static class
TimerManager.TimePassedMsg
Message from the Timer announcing that given time has passed.-
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 int
_lastIterationId
private int
_lastTimerId
Timers counter - it also represents the latest timerId.private int[]
_latelyRequestedTableIds
Table Ids requested to be checked on the last message.private akka.actor.typed.ActorRef<Teacher.Protocol>
_parent
Parent - the only agent TimeManager replies to.
-
Constructor Summary
Constructors Modifier Constructor Description private
TimerManager(akka.actor.typed.javadsl.ActorContext<TimerManager.Protocol> context, TimerManager.CreateMsg msg)
Private constructor called only by CreateMsg.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static akka.actor.typed.Behavior<TimerManager.Protocol>
create(TimerManager.CreateMsg msg)
Public method that calls private constructor.akka.actor.typed.javadsl.Receive<TimerManager.Protocol>
createReceive()
Main method controlling incoming messages.private akka.actor.typed.Behavior<TimerManager.Protocol>
onNewIterationStarted(TimerManager.NewIterationStartedMsg msg)
TimerManager when asked by the Teacher, creates an agent - Timer to measure some time.private akka.actor.typed.Behavior<TimerManager.Protocol>
onRemindToCheckTables(TimerManager.RemindToCheckTablesMsg msg)
TimerManager when asked by the Teacher, creates an agent - Timer to measure some time.private akka.actor.typed.Behavior<TimerManager.Protocol>
onTimePassed(TimerManager.TimePassedMsg msg)
TimerManager is informed that certain time has passed.-
Methods inherited from class akka.actor.typed.javadsl.AbstractBehavior
getContext, newReceiveBuilder, receive, receiveSignal
-
-
-
-
Field Detail
-
_parent
private final akka.actor.typed.ActorRef<Teacher.Protocol> _parent
Parent - the only agent TimeManager replies to.
-
_lastTimerId
private int _lastTimerId
Timers counter - it also represents the latest timerId. First timerId = 1.
-
_lastIterationId
private int _lastIterationId
-
_latelyRequestedTableIds
private int[] _latelyRequestedTableIds
Table Ids requested to be checked on the last message.
-
-
Constructor Detail
-
TimerManager
private TimerManager(akka.actor.typed.javadsl.ActorContext<TimerManager.Protocol> context, TimerManager.CreateMsg msg)
Private constructor called only by CreateMsg.
-
-
Method Detail
-
create
public static akka.actor.typed.Behavior<TimerManager.Protocol> create(TimerManager.CreateMsg msg)
Public method that calls private constructor. Existence required by Akka.- Returns:
- wrapped Behavior
-
createReceive
public akka.actor.typed.javadsl.Receive<TimerManager.Protocol> createReceive()
Main method controlling incoming messages. Existence required by Akka.- Specified by:
createReceive
in classakka.actor.typed.javadsl.AbstractBehavior<TimerManager.Protocol>
- Returns:
- wrapped Behavior
-
onRemindToCheckTables
private akka.actor.typed.Behavior<TimerManager.Protocol> onRemindToCheckTables(TimerManager.RemindToCheckTablesMsg msg)
TimerManager when asked by the Teacher, creates an agent - Timer to measure some time. If the Teacher does not send another RemindToCheckTablesMsg until Timer ends clicking, it means that its Tables are not responding. Note that Teacher can send _tableIds == null, meaning that it last Table had finished.- Parameters:
msg
- request from the Teacher- Returns:
- wrapped Behavior
-
onNewIterationStarted
private akka.actor.typed.Behavior<TimerManager.Protocol> onNewIterationStarted(TimerManager.NewIterationStartedMsg msg)
TimerManager when asked by the Teacher, creates an agent - Timer to measure some time. If the Teacher does not send another NewIterationStartedMsg until Timer ends clicking, it means that there is some timeout.- Parameters:
msg
- request from the Teacher- Returns:
- wrapped Behavior
-
onTimePassed
private akka.actor.typed.Behavior<TimerManager.Protocol> onTimePassed(TimerManager.TimePassedMsg msg)
TimerManager is informed that certain time has passed. If in this very moment TimerManager did not received new reminder, it should reply with warning that Teacher's Tables are not responding. Timer, who sent this msg, is no longer needed - can be removed.- Parameters:
msg
- ping from the Timer- Returns:
- wrapped Behavior
-
-