Exemple #1
0
        protected override void SendPullRequest()
        {
            int total = (int)SimulationSize - 1;
            var load  = LoadManager.GetPredictedHostLoadInfo();

            _currentAuction = new ForsmanPullAuction(load, total);
            BidLock         = 0;
            ForsmanPullRequest m = new ForsmanPullRequest(-1, this.MachineId, load, this.MachineId);

            CommunicationModule.SendMessage(m);
        }
Exemple #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;
            }
        }
Exemple #3
0
        protected override bool SendPushRequest()
        {
            var list = ContainerTable.GetAllContainersLoadInfo();
            //.Where(x=>
            //_loadManager.GetHostLoadInfoAWithoutContainer(x)
            //.CalculateTotalUtilizationState(MinUtilization,MaxUtilization)!= UtilizationStates.UnderUtilization )
            //.ToList();
            int total = (int)SimulationSize - 1;
            var load  = LoadManager.GetPredictedHostLoadInfo();

            _currentAuction = new ForsmanPushAuction(load, list, total);
            BidLock         = 0;
            ForsmanPushRequest m = new ForsmanPushRequest(-1, this.MachineId, load, this.MachineId, list);

            CommunicationModule.SendMessage(m);
            Console.WriteLine($"Host No{MachineId} send Push Request");
            return(false);
        }