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();
 }
Exemple #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);
        }
        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);
        }
Exemple #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;
            }
        }
Exemple #5
0
        private void HandleMigrateContainerRequest(MigrateContainerRequest message)
        {
            Task t = new Task(() =>
            {
                ContainerTable.AddContainer(message.MigratedContainer.ContainerId, message.MigratedContainer);
                message.MigratedContainer.Restore(this.MachineId);
                var responce =
                    new MigrateContainerResponse(message.SenderId, this.MachineId, message.MigratedContainer.ContainerId,
                                                 true);
                CommunicationModule.SendMessage(responce);
                BidLock = -1;
                ResetBackOff();
            });

            t.Start();
        }
        private void HandleMigrateContainerRequest(MigrateContainerRequest message)
        {
            message.MigratedContainer.Restore(this.MachineId);
            if (message.MigratedContainer.ContainerType == ContainersType.D)
            {
                var table     = ContainerTable as DockerContainerTable;
                var container = message.MigratedContainer as DockerContainer;
                var t         = table.LoadImage(container.ImageId);
                t.Wait();
            }
            ContainerTable.AddContainer(message.MigratedContainer.ContainerId, message.MigratedContainer);
            var responce =
                new MigrateContainerResponse(message.SenderId, this.MachineId, message.MigratedContainer.ContainerId,
                                             true);

            CommunicationModule.SendMessage(responce);
        }
        private void HandleMigrateContainerRequest(MigrateContainerRequest message)
        {
            Task t = new Task(() =>
            {
                ContainerTable.AddContainer(message.MigratedContainer.ContainerId, message.MigratedContainer);
                //var nd = Global.GetNetworkDelay(message.MessageSize);
                //await Task.Delay(nd*Global.Second);
                message.MigratedContainer.Restore(this.MachineId);
                var responce =
                    new MigrateContainerResponse(message.SenderId, this.MachineId, message.MigratedContainer.ContainerId,
                                                 true);
                CommunicationModule.SendMessage(responce);
                _hostState.CurrentAction = HostCurrentAction.None;
                ResetBackOff();
            });

            t.Start();
        }
Exemple #8
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();
        }
 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();
 }