Пример #1
0
        // Checks for discrepencies between Running+Starting deployments and the requested minimum number.
        private IEnumerable <DeploymentAction> GetCreationActions(IEnumerable <Deployment> existingDeployments)
        {
            List <DeploymentAction> creationActions = new List <DeploymentAction>();
            var readyDeployments    = existingDeployments.Count(d => d.Tag.Contains(ReadyTag));
            var startingDeployments = existingDeployments.Count(d => d.Tag.Contains(StartingTag));

            Reporter.ReportDeploymentsInReadyState(matchType, readyDeployments);
            Reporter.ReportDeploymentsInStartingState(matchType, startingDeployments);
            var availableDeployments = readyDeployments + startingDeployments;

            Log.Logger.Information(
                $"{readyDeployments}/{minimumReadyDeployments} deployments ready for use; {startingDeployments} starting up.");

            if (availableDeployments < minimumReadyDeployments)
            {
                var diff = minimumReadyDeployments - availableDeployments;
                Log.Logger.Information($"Missing {diff} deployments");

                for (int i = 0; i < diff; i++)
                {
                    creationActions.Add(DeploymentAction.NewCreationAction());
                }
            }

            return(creationActions);
        }
Пример #2
0
        public void StopAll()
        {
            // Basic views do not include player information
            var stopActions = ListDeployments().Select(dpl =>
            {
                dpl.Tag.Add(StoppingTag);
                dpl.Tag.Remove(ReadyTag);
                return(DeploymentAction.NewStopAction(dpl));
            }).ToList();

            Log.Logger.Warning("Stopping all running {} deployments", matchType);
            platformInvoker.InvokeActions(stopActions);
            Log.Logger.Information("All deployments have been stopped.");
        }
        // Checks if any deployments have finished, and shuts them down.
        private IEnumerable <DeploymentAction> GetStopActions(IEnumerable <Deployment> existingDeployments)
        {
            var completedDeployments = existingDeployments.Where(d => d.Tag.Contains(CompletedTag) && !d.Tag.Contains(StoppingTag));
            var stoppingDeployments  = existingDeployments.Where(d => d.Tag.Contains(StoppingTag));

            if (completedDeployments.Any() || stoppingDeployments.Any())
            {
                Log.Logger.Information($"{completedDeployments.Count()} deployments to shut down. {stoppingDeployments.Count()} in progress.");
            }

            return(completedDeployments.Select(completedDeployment =>
            {
                var newDeployment = completedDeployment.Clone();
                newDeployment.Tag.Remove(ReadyTag);
                newDeployment.Tag.Add(StoppingTag);
                return DeploymentAction.NewStopAction(newDeployment);
            }));
        }
Пример #4
0
        // Checks that previously started deployments have finished starting up, transfer them into the Ready state
        private IEnumerable <DeploymentAction> GetUpdateActions(IEnumerable <Deployment> existingDeployments)
        {
            return(existingDeployments
                   .Where(d => d.Tag.Contains(StartingTag))
                   .Where(dpl => dpl.Status == Deployment.Types.Status.Running || dpl.Status == Deployment.Types.Status.Error)
                   .Select(startingDeployment =>
            {
                var newDeployment = startingDeployment.Clone();
                if (startingDeployment.Status == Deployment.Types.Status.Error)
                {
                    newDeployment.Tag.Add(CompletedTag);
                }
                else if (startingDeployment.Status == Deployment.Types.Status.Running)
                {
                    newDeployment.Tag.Add(ReadyTag);
                }

                newDeployment.Tag.Remove(StartingTag);

                return DeploymentAction.NewUpdateAction(newDeployment);
            }).ToList());
        }
Пример #5
0
        // Checks if any deployments have finished, and shuts them down.
        private IEnumerable <DeploymentAction> GetStopActions(IEnumerable <Deployment> existingDeployments)
        {
            var completedDeployments = existingDeployments.Where(d => d.Tag.Contains(CompletedTag) && !d.Tag.Contains(StoppingTag));
            var stoppingDeployments  = existingDeployments.Where(d => d.Tag.Contains(StoppingTag));

            if (completedDeployments.Any() || stoppingDeployments.Any())
            {
                Log.Logger.Information($"{completedDeployments.Count()} deployments to shut down. {stoppingDeployments.Count()} in progress.");
            }

            return(completedDeployments.Select(completedDeployment =>
            {
                var newDeployment = completedDeployment.Clone();
                newDeployment.Tag.Remove(ReadyTag);
                newDeployment.Tag.Add(StoppingTag);
                _analytics.Send("deployment_completed", new Dictionary <string, string>
                {
                    { "spatialProjectId", completedDeployment.ProjectName },
                    { "deploymentName", completedDeployment.Name },
                    { "deploymentId", completedDeployment.Id }
                });
                return DeploymentAction.NewStopAction(newDeployment);
            }));
        }