private void HandleInitiateMigration(InitiateMigration message)
 {
     //Case Docker
     if (ContainerTable.ContainerType == ContainersType.D)
     {
         var container = ContainerTable.GetContainerById(message.ContainerId) as DockerContainer;
         var imageId   = container.ImageId;
         var request   = new ImageLoadRequest(message.TargetHost, this.MachineId, imageId, message.ContainerId);
         CommunicationModule.SendMessage(request);
     }
     //Case Normal
     else
     {
         Task t = new Task(() =>
         {
             var container = ContainerTable.GetContainerById(message.ContainerId);
             ContainerTable.LockContainer(message.ContainerId);
             container.Checkpoint(this.MachineId);
             var size = (int)container.GetContainerNeededLoadInfo().CurrentLoad.MemorySize;
             MigrateContainerRequest request =
                 new MigrateContainerRequest(message.TargetHost, this.MachineId, container, size);
             CommunicationModule.SendMessage(request);
             ResetBackOff();
         });
         t.Start();
     }
     //GlobalEnviromentVariables.ResetCheckRate();
 }
        protected void InitiateMigration(int source, int target, int containerId)
        {
            //Console.WriteLine($"\n\n ------------------- Initiate Push from {source} to {target} on contianer {containerId} in auction Id = {auctionId}");
            //migratedIds.Add(containerId,source);

            var initMigration = new InitiateMigration(this.MachineId, source, target, containerId);

            CommunicationModule.SendMessage(initMigration);
            //Should Release All Locks
        }
Beispiel #3
0
        private void HandleInitiateMigrationRequest(InitiateMigration message)
        {
            var con  = ContainerTable.GetContainerById(message.ContainerId);
            var size = (int)con.GetContainerNeededLoadInfo().CurrentLoad.MemorySize;

            ContainerTable.LockContainer(con.ContainerId);
            con.Checkpoint(this.MachineId);
            MigrateContainerRequest request =
                new MigrateContainerRequest(message.SenderId, this.MachineId, con, size);

            CommunicationModule.SendMessage(request);
        }
Beispiel #4
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;
            }
        }
Beispiel #5
0
        private void HandleInitiateMigration(InitiateMigration message)
        {
            //Console.WriteLine($" \n\n\n\n \t\t\t From Push with Love{message.ContainerId}");
            Task t = new Task(() =>
            {
                var container = ContainerTable.GetContainerById(message.ContainerId);
                ContainerTable.LockContainer(message.ContainerId);
                container.Checkpoint(this.MachineId);
                var size = (int)container.GetContainerNeededLoadInfo().CurrentLoad.MemorySize;
                MigrateContainerRequest request = new MigrateContainerRequest(message.TargetHost, this.MachineId,
                                                                              container, size);
                CommunicationModule.SendMessage(request);
                ResetBackOff();
            });

            t.Start();
            //GlobalEnviromentVariables.ResetCheckRate();
        }
Beispiel #6
0
        private void InitiateMigration(int source, int target, int containerId)
        {
            var initMigration = new InitiateMigration(this.MachineId, source, target, containerId);

            CommunicationModule.SendMessage(initMigration);
        }