Ejemplo n.º 1
0
 public override string ToString()
 {
     if (id == NodeType.HostComputer)
     {
         return(hs.ToString());
     }
     if (id == NodeType.VirtualMachines)
     {
         return(vs.ToString());
     }
     return("");
 }
Ejemplo n.º 2
0
        private void GetState()
        {
            this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Getting Host Instance: {0} state on: {1}", this.HostName, this.MachineName));

            if (!this.GetHostInstanceByHostName())
            {
                return;
            }

            HostState s = (HostState)Convert.ToInt32(this.hostInstance["ServiceState"], CultureInfo.InvariantCulture);

            this.State = s.ToString();
        }
Ejemplo n.º 3
0
        private bool CheckExists()
        {
            this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Checking whether Host Instance exists: {0}", this.HostName));
            this.GetHostInstanceByHostName();
            if (this.hostInstance != null)
            {
                this.Exists = true;
                HostState s = (HostState)Convert.ToInt32(this.hostInstance["ServiceState"], CultureInfo.InvariantCulture);
                this.State = s.ToString();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
        // stops component and message publisher
        public async Task <IComponentHostServiceResponse> StopAsync()
        {
            var response = new ComponentHostServiceResponse();

            using (_logger.BeginScope("{Correlation}", HostInstanceId))
            {
                if (HostState == HostState.Started)
                {
                    try
                    {
                        // component is not null
                        // stop component first then message publisher
                        // this way we publish any remaining messages
                        if (!(Component is null))
                        {
                            await Component.StopAsync(CancellationToken.None);
                        }

                        // message publisher is not null
                        // stop message publisher after component
                        // this way if message publishers have
                        // any items in queue they can push them through
                        // in their stop method
                        if (!(MessagePublisher is null))
                        {
                            await MessagePublisher.StopAsync(CancellationToken.None);
                        }



                        HostState = HostState.Stopped;
                    }
                    catch (Exception e)
                    {
                        string message = "Failed to Stop members";
                        _logger.LogError(e, "{Message} {@ObjectProperties}", message, ComponentConfiguration);
                        HostState = HostState.Errored;
                        response.Set(MemberState.Error, message);
                    }
                }
                else if (HostState != HostState.Stopped)
                {
                    response.Set(MemberState.Error, $"Cannont Stop host when in {HostState.ToString()} state");
                }

                _logger.LogInformation("{Message} {@ObjectProperties}", $"Stop request processed -- response: {response.State}", response);
            }
            return(response);
        }