private void HandlePullRequest(ForsmanPullRequest message) { ForsmanLoadAvailabilityResponce responce; if (BidLock == -1) { BidLock = message.SenderId; List <ForsmanBid> bids = new List <ForsmanBid>(); var load = LoadManager.GetPredictedHostLoadInfo(); foreach (var cont in ContainerTable.GetAllContainers()) { var conload = cont.GetContainerPredictedLoadInfo(); var nload = LoadManager.GetHostLoadInfoAWithoutContainer(conload); if (LoadManager.CanITakeLoad(conload)) //&& nload.CalculateTotalUtilizationState(MinUtilization, MaxUtilization) != UtilizationStates.UnderUtilization) { ForsmanBid bid = new ForsmanBid(MachineId, true, nload, message.AuctionId, conload.ContainerId, BidReasons.ValidBid, conload); bids.Add(bid); } } responce = new ForsmanLoadAvailabilityResponce(message.SenderId, this.MachineId, load, true, bids); } else { responce = new ForsmanLoadAvailabilityResponce(message.SenderId, this.MachineId, null, false, null); //Resources are locked in the first place } CommunicationModule.SendMessage(responce); }
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); }