public override string ToString() { if (id == NodeType.HostComputer) { return(hs.ToString()); } if (id == NodeType.VirtualMachines) { return(vs.ToString()); } return(""); }
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(); }
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); }
// 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); }