Beispiel #1
0
        public override void MachineAction()
        {
            BidLock      = -1;
            EvacuateMode = false;
            //inital sleep before push or pull
            //Thread.Sleep(10*Global.Second);
            while (Started)
            {
                //change to time based on backoff algorithm
                var bft = GetBackOffTime();
                Thread.Sleep(bft);
                lock (_hostLock)
                {
                    var s = LoadManager.CheckSystemState(true, MinUtilization, MaxUtilization); //can this be up
                    if (BidLock == -1 && !EvacuateMode)
                    {
                        TryToChangeSystemState(s);
                    }
                    else if (EvacuateMode && BidLock == -1)
                    {
                        if (!SendPushRequest())
                        {
                            break;
                        }
                    }
                }
            }
            var message = new EvacuationDone(0, this.MachineId);

            CommunicationModule.SendMessage(message);
            //Console.WriteLine("Hahahahha");
        }
Beispiel #2
0
        private void HandleEvacuationDone(EvacuationDone message)
        {
            if (DataHolder.GetUtilization(message.SenderId) != UtilizationStates.Evacuating)
            {
                throw new NotImplementedException("Home come");
            }

            PowerController.PowerOffHost(message.SenderId);

            //EvacuatingHost = 0;
            //EvacuatingHosts.Remove(message.SenderId);
        }
        public override void MachineAction()
        {
            _hostState.CurrentAction  = HostCurrentAction.None;
            _hostState.EvacuationMode = false;
            _hostState.AuctionId      = 0;
            while (Started)
            {
                //change to time based on backoff algorithm
                var bft = GetBackOffTime();
                Thread.Sleep(bft);
                lock (_hostLock)
                {
                    var s = LoadManager.CheckSystemState(true, MinUtilization, MaxUtilization); //can this be up
                    if (_hostState.CurrentAction == HostCurrentAction.None && !_hostState.EvacuationMode)
                    {
                        TryToChangeSystemState(s);
                    }
                    else if (_hostState.EvacuationMode && _hostState.CurrentAction == HostCurrentAction.None)
                    {
                        if (!SendPushRequest())
                        {
                            break;
                        }
                    }
                }
            }
            var message = new EvacuationDone(0, this.MachineId);

            CommunicationModule.SendMessage(message);

            //lock (_hostLock)
            //{

            //    if (Started)
            //    {
            //        if (ContainerTable.GetContainersCount() > 0)
            //        {

            //        }
            //        var message = new EvacuationDone(0, this.MachineId);
            //        CommunicationModule.SendMessage(message);
            //    }
            //}
        }
 private void HandleEvacuationDone(EvacuationDone message)
 {
     PowerController.PowerOffHost(message.SenderId);
     //EvacuatingHost = 0;
     EvacuatingHosts.Remove(message.SenderId);
 }