protected override void AddContainer(Container container)
        {
            if (CurrentContainer != null)
            {
                throw new NotImplementedException("How come");
            }
            List <int> candidates = new List <int>(Holder.GetCandidateHosts(UtilizationStates.Normal, 0));
            var        under      = Holder.GetCandidateHosts(UtilizationStates.UnderUtilization, 0);

            candidates.AddRange(under);

            if (candidates.Count > 0)
            {
                CurrentContainer = container;
                AuctionFactory(candidates);
                foreach (var id in candidates)
                {
                    Message m = new CanHaveContainerRequest(id, 0, auction.InstanceId, CurrentContainer.GetContainerPredictedLoadInfo());
                    CommunicationModule.SendMessage(m);
                }
            }
            else
            {
                FailedScheduling();
            }
        }
Beispiel #2
0
        private void TestHostForAContainer()
        {
            var     id = inOrderProping.GetNextCandidate();
            Message m  = new CanHaveContainerRequest(id, 0, inOrderProping.InstanceId, CurrentContainer.GetContainerPredictedLoadInfo());

            CommunicationModule.SendMessage(m);
        }
        private void HandlaCanHaveContainerRequest(CanHaveContainerRequest message)
        {
            //ContainerTable.AddContainer(message.ScheduledContainer.ContainerId, message.ScheduledContainer);
            var load     = LoadManager.GetHostLoadInfoAfterContainer(message.NewContainerLoadInfo);
            var newState = load.CalculateTotalUtilizationState(MinUtilization, MaxUtilization);
            Bid bid      = null;

            if (!_hostState.EvacuationMode &&
                LoadManager.CanITakeLoad(message.NewContainerLoadInfo) && newState != UtilizationStates.OverUtilization)
            {
                var pulls = CalculatePullsCount(message.NewContainerLoadInfo.ImageId);
                bid = new AuctionBid(this.MachineId, true, load, message.AuctionId, message.NewContainerLoadInfo.ContainerId, BidReasons.ValidBid, pulls);
            }
            else
            {
                bid = new AuctionBid(this.MachineId, false, null, message.AuctionId, message.NewContainerLoadInfo.ContainerId, BidReasons.CantBid, 0);
            }
            CanHaveContainerResponce responce = new CanHaveContainerResponce(0, MachineId, bid);

            CommunicationModule.SendMessage(responce);
        }