Ejemplo n.º 1
0
 public ForsmanBid(int host, bool valid, HostLoadInfo load, int targetAuction,
                   int containerId, BidReasons reason,
                   ContainerLoadInfo containerLoadInfo = null)
     : base(host, valid, load, targetAuction, containerId, reason)
 {
     ContainerLoadInfo = containerLoadInfo;
 }
Ejemplo n.º 2
0
        public HostLoadInfo GetHostLoadInfoAWithoutContainer(ContainerLoadInfo containerLoadInfo)
        {
            var totalLoad = CalculatePredictedTotalLoad();

            totalLoad -= containerLoadInfo.CurrentLoad;
            var load = CarveHostLoadInfo(totalLoad);

            return(load);
        }
        public PushLoadAvailabilityRequest(int target, int sender, ContainerLoadInfo containerLoadInfo, int auctionId, int requestOwner)
            : base(target, sender, MessageTypes.PushLoadAvailabilityRequest)
        {
            //Console.WriteLine($"LoadAvailabilityRequest for {auctionId} Created to host #{target}");

            NewContainerLoadInfo = containerLoadInfo;
            AuctionId            = auctionId;
            RequestOwner         = requestOwner;
        }
Ejemplo n.º 4
0
        public InOrderProping(int auctionId, int owner, List <int> candidates, StrategyActionType actionType, ContainerLoadInfo loadInfo)
            : base(auctionId, owner, candidates, actionType)
        {
            if (actionType == StrategyActionType.PullAction && ContainerLoadInfo != null)
            {
                throw new NotImplementedException();
            }

            ContainerLoadInfo = loadInfo;
        }
Ejemplo n.º 5
0
        private void HandlePullLoadAvailabilityRequest(PullLoadAvailabilityRequest message)
        {
            Console.WriteLine($"Pull : I'm Host #{MachineId}: I've got message from # {message.SenderId}" +
                              $" for auction # {message.AuctionId}");

            Bid bid;

            if (BidLock == -1 && !EvacuateMode)
            {
                ContainerLoadInfo selectedContainerload = GetToBeRemovedContainerLoadInfo();
                if (selectedContainerload != null)
                {
                    var oldstate = LoadManager.GetPredictedHostLoadInfo().CalculateTotalUtilizationState(MinUtilization, MaxUtilization);
                    var load     = LoadManager.GetHostLoadInfoAWithoutContainer(selectedContainerload);
                    var newState = load.CalculateTotalUtilizationState(MinUtilization, MaxUtilization);
                    if (oldstate == UtilizationStates.Normal && newState == UtilizationStates.UnderUtilization)
                    {
                        bid = new Bid(MachineId, false, load, message.AuctionId, selectedContainerload.ContainerId, BidReasons.MinimumLoad);
                    }
                    else
                    {
                        var breason = BidReasons.ValidBid;
                        if (oldstate == UtilizationStates.UnderUtilization)
                        {
                            EvacuateMode = true;
                            breason      = BidReasons.Evacuate;
                        }

                        bid     = new Bid(MachineId, true, load, message.AuctionId, selectedContainerload.ContainerId, breason);
                        BidLock = bid.AuctionId;
                    }

                    Console.WriteLine($"I am Host #{MachineId} I am bidding for AuctionId {bid.AuctionId}");
                }
                else
                {
                    bid = new Bid(MachineId, false, null, message.AuctionId, -1, BidReasons.Empty);
                }
            }
            else
            {
                Console.WriteLine($"I am Host #{MachineId} I am Not I'm not Bidlocked {BidLock}");

                bid = new Bid(MachineId, false, null, message.AuctionId, -1, BidReasons.CantBid);
            }

            Console.WriteLine($"I am Host #{MachineId} for Pull Auction {message.AuctionId} with {bid.Valid}");

            LoadAvailabilityResponce availabilityResponce =
                new LoadAvailabilityResponce(message.SenderId, this.MachineId, message.AuctionId, bid);

            // var responce = new GetHostLoadInfoResponce(this.HostId, load);
            CommunicationModule.SendMessage(availabilityResponce);
        }
Ejemplo n.º 6
0
        public HostLoadInfo GetHostLoadInfoByHostIdAfterContainer(int hostId, ContainerLoadInfo info)
        {
            lock (_lock)
            {
                _accountingModule.RequestCreated(MessageTypes.CommonLoadManager, 0);
                var item         = _currentHostLoadInfos[hostId];
                var nload        = item.CurrentLoad + info.CurrentLoad;
                var machinePower = Global.DataCenterHostConfiguration;
                var cpu          = nload.CpuLoad / machinePower.CpuLoad;
                var mem          = nload.MemorySize / machinePower.MemorySize;
                var io           = nload.IoSecond / machinePower.IoSecond;

                return(new HostLoadInfo(hostId, nload, item.ContainersCount + 1, cpu, mem, io, item.DataSizeOut, item.DataSizeIn));
            }
        }
        private void HandlePullLoadAvailabilityRequest(PullLoadAvailabilityRequest message)
        {
            Bid bid;

            if (_hostState.CurrentAction == HostCurrentAction.None && !_hostState.EvacuationMode)
            {
                ContainerLoadInfo selectedContainerload = GetToBeRemovedContainerLoadInfo();
                if (selectedContainerload != null)
                {
                    var oldstate = LoadManager.GetPredictedHostLoadInfo().CalculateTotalUtilizationState(MinUtilization, MaxUtilization);
                    var load     = LoadManager.GetHostLoadInfoAWithoutContainer(selectedContainerload);
                    var newState = load.CalculateTotalUtilizationState(MinUtilization, MaxUtilization);

                    //Comment this condition
                    if (oldstate == UtilizationStates.Normal && newState == UtilizationStates.UnderUtilization)
                    {
                        bid = new AuctionBid(MachineId, false, load, message.AuctionId, -1, BidReasons.MinimumLoad, 0);
                    }
                    else
                    {
                        //try to find how many pulls the target will need !!!
                        var pullsCountRequest = new PullsCountRequest(message.RequestOwner, this.MachineId, selectedContainerload.ImageId);
                        var t = CommunicationModule.RequestData(pullsCountRequest);
                        t.Wait();
                        var pullsCountResponce = t.Result as PullsCountResponce;
                        bid = new AuctionBid(MachineId, true, load, message.AuctionId, selectedContainerload.ContainerId, BidReasons.ValidBid, pullsCountResponce.PullsCount);
                        _hostState.CurrentAction = HostCurrentAction.Bidding;
                        _hostState.AuctionId     = message.AuctionId;
                    }
                }
                else
                {
                    bid = new AuctionBid(MachineId, false, null, message.AuctionId, -1, BidReasons.Empty, 0);
                }
            }
            else
            {
                bid = new AuctionBid(MachineId, false, null, message.AuctionId, -1, BidReasons.CantBid, 0);
            }


            LoadAvailabilityResponce availabilityResponce =
                new LoadAvailabilityResponce(message.SenderId, this.MachineId, message.AuctionId, bid);

            CommunicationModule.SendMessage(availabilityResponce);
        }
Ejemplo n.º 8
0
 public CanHaveContainerRequest(int target, int sender, int auctionId, ContainerLoadInfo container) :
     base(target, sender, MessageTypes.CanHaveContainerRequest)
 {
     AuctionId            = auctionId;
     NewContainerLoadInfo = container;
 }
Ejemplo n.º 9
0
        public bool CanITakeLoad(ContainerLoadInfo containerLoadInfo)
        {
            var totalLoad = CalculatePredictedTotalLoad();

            return(totalLoad.MemorySize < _maxLoad.MemorySize);
        }
Ejemplo n.º 10
0
 public PushRequest(int target, int sender, HostLoadInfo hostLoad, ContainerLoadInfo containerLoad) :
     base(target, sender, hostLoad, MessageTypes.PushRequest)
 {
     SelectedContainerLoadInfo = containerLoad;
 }