internal static PollResult PollSignal(this IHDInsightManagementPocoClient client, ClusterDetails cluster, params ClusterState[] states) { if (cluster == null) { client.LogMessage("Polling for cluster returned null. Returning null to polling function for retry logic.", Severity.Informational, Verbosity.Diagnostic); return(PollResult.Null); } PollResult retval = PollResult.Continue; client.RaiseClusterProvisioningEvent(client, new ClusterProvisioningStatusEventArgs(cluster, cluster.State)); var msg = string.Format(CultureInfo.CurrentCulture, "Current State {0} -> waiting for one state of {1}", cluster.State, string.Join(",", states.Select(s => s.ToString()))); client.LogMessage(msg, Severity.Informational, Verbosity.Diagnostic); if (cluster.State == ClusterState.Error) { client.LogMessage("Stopping Poll because cluster state was in Error", Severity.Error, Verbosity.Normal); retval = PollResult.Stop; } else if (cluster.Error != null) { msg = string.Format(CultureInfo.CurrentCulture, "Stopping Poll because cluster returned an error message. The message was: {0}", cluster.Error); client.LogMessage(msg, Severity.Error, Verbosity.Normal); retval = PollResult.Stop; } else if (states.Contains(cluster.State)) { msg = string.Format(CultureInfo.CurrentCulture, "Stopping Poll because cluster returned in a final state. The message was: {0}", cluster.State); client.LogMessage(msg, Severity.Informational, Verbosity.Diagnostic); retval = PollResult.Stop; } else if (cluster.State == ClusterState.Unknown) { retval = PollResult.Unknown; } msg = string.Format(CultureInfo.CurrentCulture, "Continue function determined a poll result of: {0}", retval); client.LogMessage(msg, Severity.Informational, Verbosity.Diagnostic); return(retval); }