private void ComponentDeploymentStarted(ComponentVertexDeploymentProgress value)
 {
     Console.Out.WriteLine(_logMessages.DeploymentStarted(value.Vertex));
 }
예제 #2
0
        /// <summary>
        /// Deploy component
        /// </summary>
        /// <param name="componentDeploymentVertex"></param>
        /// <param name="cancellationToken"></param>
        private ComponentVertexDeploymentResult DeployComponent(ComponentDeploymentVertex componentDeploymentVertex, CancellationToken cancellationToken)
        {
            try
            {
                _throttler.Wait(cancellationToken);
                try
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return(new ComponentVertexDeploymentResult
                        {
                            Status = ComponentVertexDeploymentStatus.Cancelled,
                            Description = _logMessages.DeploymentCancelled(componentDeploymentVertex)
                        });
                    }

                    //Start progress
                    if (_progress != null)
                    {
                        var componentVertexDeploymentProgress = new ComponentVertexDeploymentProgress
                        {
                            Vertex       = componentDeploymentVertex,
                            Status       = ComponentVertexDeploymentStatus.Started,
                            MinimumValue = 0,
                            MaximumValue =
                                componentDeploymentVertex.DeploymentDuration.HasValue
                                    ? componentDeploymentVertex.DeploymentDuration.Value.Ticks
                                    : 0,
                            Value = 0,
                            Text  = _logMessages.DeploymentStarted(componentDeploymentVertex)
                        };
                        _progress.Report(componentVertexDeploymentProgress);
                    }

                    var result = new ComponentVertexDeploymentResult();

                    try
                    {
                        foreach (var deployer in _deployers)
                        {
                            result = deployer.Deploy(componentDeploymentVertex, cancellationToken, _logMessages, _progress);
                        }
                    }
                    catch (Exception ex)
                    {
                        var stringBuilder = new StringBuilder();
                        WriteExceptionDetails(ex, stringBuilder, 1);

                        result = new ComponentVertexDeploymentResult
                        {
                            Status      = ComponentVertexDeploymentStatus.Failure,
                            Description = _logMessages.DeploymentFailed(componentDeploymentVertex, stringBuilder.ToString())
                        };
                    }

                    //Finish progress
                    if (_progress != null)
                    {
                        var componentVertexDeploymentProgress = new ComponentVertexDeploymentProgress
                        {
                            Vertex       = componentDeploymentVertex,
                            Status       = result.Status,
                            MinimumValue = 0,
                            MaximumValue =
                                componentDeploymentVertex.DeploymentDuration.HasValue
                                    ? componentDeploymentVertex.DeploymentDuration.Value.Ticks
                                    : 0,
                            Value =
                                componentDeploymentVertex.DeploymentDuration.HasValue
                                    ? componentDeploymentVertex.DeploymentDuration.Value.Ticks
                                    : 0,
                            Text = result.Description
                        };
                        _progress.Report(componentVertexDeploymentProgress);
                    }

                    return(result);
                }
                finally
                {
                    _throttler.Release();
                }
            }
            catch (OperationCanceledException)
            {
                return(new ComponentVertexDeploymentResult
                {
                    Status = ComponentVertexDeploymentStatus.Cancelled,
                    Description = _logMessages.DeploymentCancelled(componentDeploymentVertex)
                });
            }
        }
        private void ComponentDeploymentStarted(ComponentVertexDeploymentProgress value)
        {
            var name      = GetName(value);
            var flowId    = GetFlowId(value);
            var timeStamp = GetJavaTimeStamp();

            var progressMessage = _serviceMessageFormatter.FormatMessage("progressMessage", _logMessages.DeploymentStarted(value.Vertex));

            var testStartedMessage = _serviceMessageFormatter.FormatMessage("testStarted", new
            {
                name      = name,
                flowId    = flowId,
                timeStamp = timeStamp
            });

            Console.Out.WriteLine(progressMessage);
            Console.Out.WriteLine(testStartedMessage);
        }