public ReservationLog clone() { ReservationLog result = new ReservationLog(); foreach (KeyValuePair <string, int> entry in this.log) { result.updateReservedCount(entry.Key, entry.Value); } return(result); }
public TicketStateMachine(int totalTicketCount, string nodeName, IActorRef storageActor) { this.totalTicketCount = totalTicketCount; //Main state this.availableTicketCount = totalTicketCount; this.reservationLog = new ReservationLog(); //Tentative state this.tentativeAvailableTicketCount = totalTicketCount; this.tentativeReservationLog = new ReservationLog(); this.nodeName = nodeName; this.storageActor = storageActor; // this.reservedAndSoldTickets = }
public void recomputeTentativeState(List <LogEntry> uncommitedEntries) { this.tentativeAvailableTicketCount = this.availableTicketCount; this.tentativeReservationLog = this.reservationLog.clone(); foreach (LogEntry entry in uncommitedEntries) { switch (entry.command) { case ENTRY_COMMAND.RESERVE: this.reserveTicket(entry.clientActorPath, entry.quantity, true); break; case ENTRY_COMMAND.SELL: this.sellTicket(entry.clientActorPath, entry.quantity, true); break; case ENTRY_COMMAND.GIVE_UP_RESERVATION: this.reserveTicket(entry.clientActorPath, -entry.quantity, true); break; } } }
public QueryTicketResponse(int availableTicketCount, ReservationLog reservedTicketLog) { this.availableTicketCount = availableTicketCount; this.reservedTicketLog = reservedTicketLog; }