Exemplo n.º 1
0
 public void setState(IRaftNodeState targetState)
 {
     //Change to the target state
     this.currentState = targetState;
     //Restart the target state
     this.currentState.init();
     if (targetState.Equals(this.leaderState))
     {
         this.leaderRef = Self;
     }
 }
Exemplo n.º 2
0
 public RaftServer(int nodeId, List <IActorRef> allNodes, IActorRef storageActor, ActorSystem actorSystem)
 {
     this.nodeId                = nodeId;
     this.logEntries            = new Log();
     this.followerState         = new FollowerState(this);
     this.candidateState        = new CandidateState(this);
     this.leaderState           = new LeaderState(this);
     this.stateMachine          = new TicketStateMachine(TOTAL_AVAILABLE_TICKETS, Self.Path.Name, storageActor);
     this.allNodes              = allNodes;
     this.storageActor          = storageActor;
     this.currentState          = this.followerState;
     this.actorSystem           = actorSystem;
     this.randomNumberGenerator = new Random();
     this.resetElectionTimer();
 }