Exemplo n.º 1
0
 private void HandleWinnerAnnouncementMessage(WinnerAnnouncementMessage message)
 {
     if (message.WinnerHostId == this.MachineId)//I am the winner
     {
         //throw new NotImplementedException();
     }
     else // I am not the winner
     {
         if (BidLock == message.SenderId)
         {
             BidLock = -1;
         }
     }
 }
Exemplo n.º 2
0
        private void HandleLoadAvailabilityResponse(ForsmanLoadAvailabilityResponce message)
        {
            _currentAuction.EndWaitFor(message.SenderId, message.OldLoadInfo);
            if (message.Valid)
            {
                foreach (var bid in message.Bids)
                {
                    _currentAuction.AddBid(bid, MinUtilization, MaxUtilization);
                }
            }

            if (!_currentAuction.OpenSession)
            {
                var winner = _currentAuction.GetWinnerBid();
                if (winner != null)
                {
                    WinnerAnnouncementMessage responce = new WinnerAnnouncementMessage(-1, this.MachineId, winner.BiddingHost);
                    CommunicationModule.SendMessage(responce);
                    if (_currentActionType == StrategyActionType.PushAction)
                    {
                        var con  = ContainerTable.GetContainerById(winner.ContainerId);
                        var size = (int)con.GetContainerNeededLoadInfo().CurrentLoad.MemorySize;
                        ContainerTable.LockContainer(con.ContainerId);
                        con.Checkpoint(this.MachineId);
                        MigrateContainerRequest request =
                            new MigrateContainerRequest(winner.BiddingHost, this.MachineId, con, size);
                        CommunicationModule.SendMessage(request);
                    }
                    else
                    {
                        InitiateMigration request = new InitiateMigration(this.MachineId, winner.BiddingHost, winner.BiddingHost, winner.ContainerId);
                        CommunicationModule.SendMessage(request);
                    }
                    ResetBackOff();
                    //_lastDelay = 5;
                }
                else //No winner
                {
                    WinnerAnnouncementMessage responce = new WinnerAnnouncementMessage(-1, this.MachineId, 0);
                    CommunicationModule.SendMessage(responce);
                    MaxUtilization = Global.OtherMaxUtilization;
                    MinUtilization = Global.OtherMinUtilization;
                    IncreaseBackOffTime();
                    BidLock = -1;
                    //_lastDelay = 5;
                }
                _currentAuction = null;
            }
        }