コード例 #1
0
 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();
 }
コード例 #2
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);
        }
コード例 #3
0
        private void MigrationContainer(ContainerToHost result)
        {
            var con  = ContainerTable.GetContainerById(result.ConId);
            var size = (int)con.GetContainerNeededLoadInfo().CurrentLoad.MemorySize;

            ContainerTable.LockContainer(con.ContainerId);
            con.Checkpoint(this.MachineId);

            MigrateContainerRequest request =
                new MigrateContainerRequest(result.HostId, this.MachineId, con, size);

            CommunicationModule.SendMessage(request);
        }
コード例 #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;
            }
        }
コード例 #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();
        }
コード例 #6
0
 private void HandleImageLoadResponce(ImageLoadResponce message)
 {
     if (message.State)
     {
         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.SenderId, this.MachineId, container, size);
             CommunicationModule.SendMessage(request);
             ResetBackOff();
         });
         t.Start();
     }
     else
     {
         throw new Exception("How Come its not loaded");
     }
     //GlobalEnviromentVariables.ResetCheckRate();
 }