protected void handlePurchaseTicket(PurchaseTicket purchaseTicket) { //If we are having a pending purchase, refuse the request if (this.pendingPurchaseQuantity > 0) { log.Info(string.Concat(Self.Path.Name, " is processing a purchase. Not available to process another purchase.")); return; } //If the purchase quantity < the reserved count, record the sale if (purchaseTicket.purchaseQuantity <= this.reservedTicketCount) { this.sellTicketFromReserved(purchaseTicket.purchaseQuantity); //If we are out of reserved tickets, request some more if (this.reservedTicketCount == 0) { this.currentServer.Tell(new ReserveTicket(NUM_TICKET_RESERVED_PER_REQUEST)); } } else { //This is going to be a lengthy process, cache the quantity and the sender this.pendingPurchaseQuantity = purchaseTicket.purchaseQuantity; //Do a inconsistent read to see whether we still have tickets for sale this.currentServer.Tell(new QueryTicket()); } }
public void processPurchaseTicketRequest(PurchaseTicket purchaseTicket, IActorRef sender) { //Make sure the purchase quantity does not exceed the quantity reserved for this front-end, this case should never happen //Add a log entry for the purchase this.logEntries.append(this.currentTerm, purchaseTicket.purchaseQuantity, ENTRY_COMMAND.SELL, sender.Path.ToString(), false, string.Empty); this.updatePersistentStorage(); //Update the tentative state this.stateMachine.sellTicket(sender.Path.ToString(), purchaseTicket.purchaseQuantity, true); this.log.Info(string.Concat(Self.Path.Name, " received purchase request of ", purchaseTicket.purchaseQuantity, " tickets from ", sender.Path.Name)); }
public void handlePurchaseTicket(PurchaseTicket purchaseTicket, IActorRef sender) { this.node.notifyClientOfLeaderAddress(purchaseTicket, sender); }
public void handlePurchaseTicket(PurchaseTicket purchaseTicket, IActorRef sender) { this.node.processPurchaseTicketRequest(purchaseTicket, sender); }