コード例 #1
0
        /// <summary>
        /// Waits for the server to enter a specified state.
        /// </summary>
        /// <remarks>
        /// When the method returns, the current instance is updated to reflect the state
        /// of the server at the end of the operation.
        ///
        /// <note type="caller">
        /// This is a blocking operation and will not return until the server enters either an expected state, an error state, or the retry count is exceeded.
        /// </note>
        /// </remarks>
        /// <param name="expectedState">The expected state.</param>
        /// <param name="errorStates">The error state(s) in which to throw an exception if the server enters.</param>
        /// <param name="refreshCount">Number of times to poll the server's status.</param>
        /// <param name="refreshDelay">The time to wait between polling requests for the server status. If this value is <see langword="null"/>, the default is 2.4 seconds.</param>
        /// <param name="progressUpdatedCallback">A callback delegate to execute each time the <see cref="Server.Progress"/> value increases. If this value is <see langword="null"/>, progress updates are not reported.</param>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="expectedState"/> is <see langword="null"/>.
        /// <para>-or-</para>
        /// <para>If <paramref name="errorStates"/> is <see langword="null"/>.</para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// If <paramref name="refreshCount"/> is less than 0.
        /// <para>-or-</para>
        /// <para>If <paramref name="refreshDelay"/> is negative.</para>
        /// </exception>
        /// <exception cref="ServerEnteredErrorStateException">If the method returned due to the server entering one of the <paramref name="errorStates"/>.</exception>
        /// <exception cref="net.openstack.Core.Exceptions.Response.ResponseException">If the REST API request failed.</exception>
        public void WaitForState(ServerState expectedState, ServerState[] errorStates, int refreshCount = 600, TimeSpan?refreshDelay = null, Action <int> progressUpdatedCallback = null)
        {
            if (expectedState == null)
            {
                throw new ArgumentNullException("expectedState");
            }
            if (errorStates == null)
            {
                throw new ArgumentNullException("errorStates");
            }
            if (refreshCount < 0)
            {
                throw new ArgumentOutOfRangeException("refreshCount");
            }
            if (refreshDelay < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("refreshDelay");
            }

            var details = Provider.WaitForServerState(Id, expectedState, errorStates, refreshCount, refreshDelay ?? TimeSpan.FromMilliseconds(2400), progressUpdatedCallback, Region, Identity);

            UpdateThis(details);
        }
コード例 #2
0
ファイル: ServerState.cs プロジェクト: krowin24/backuptool
 /// <inheritdoc/>
 protected override ServerState FromName(string name)
 {
     return(ServerState.FromName(name));
 }