/// <summary>コピー中のアーカイブが利用可能になるまで待機します。 /// /// <param name="timeoutSec" /> /// <returns>成功時はtrue、タイムアウトやエラーによる失敗時はfalseを返します。</returns> /// </summary> public bool SleepWhileCopying(long timeoutSec = 3600) { long step = 3; while (0 < timeoutSec) { try { this.Reload(); } catch (HttpException ex) { } string a = this.Get_availability(); if (a == EAvailability.AVAILABLE) { return(true); } if (a != EAvailability.MIGRATING) { timeoutSec = 0; } timeoutSec -= step; if (0 < timeoutSec) { Util.Sleep(step); } } return(false); }
/// <summary>アプライアンスが指定のステータスに遷移するまで待機します。 /// /// /// <param name="status" /> /// <param name="timeoutSec" /> /// </summary> private bool SleepUntil(string status, long timeoutSec = 600) { long step = 10; while (0 < timeoutSec) { try { this.Reload(); } catch (HttpException ex) { } string s = this.Get_status(); if (s == null) { s = EServerInstanceStatus.DOWN; } if (s == status) { return(true); } timeoutSec -= step; if (0 < timeoutSec) { Util.Sleep(step); } } return(false); }
/// <summary>作成中のルータが利用可能になるまで待機します。 /// /// <param name="timeoutSec" /> /// <returns>成功時はtrue、タイムアウトやエラーによる失敗時はfalseを返します。</returns> /// </summary> public bool SleepWhileCreating(long timeoutSec = 120) { long step = 3; bool isOk = false; while (0 < timeoutSec) { try { if (this.Exists()) { this.Reload(); isOk = true; } } catch (HttpException ex) { } timeoutSec -= step; if (isOk) { timeoutSec = 0; } if (0 < timeoutSec) { Util.Sleep(step); } } return(isOk); }
/// <summary> /// <param name="method" /> /// <param name="path" /> /// <param name="query" /> /// <param name="retryCount" /> /// <param name="retrySleep" /> /// </summary> public object RequestRetry(string method, string path, object query = null, long retryCount = 5, long retrySleep = 5) { object ret = null; while (1 < retryCount) { bool isOk = false; try { ret = this._Client.Request(method, path, query); isOk = true; } catch (HttpException ex) { isOk = false; } if (isOk) { retryCount = -1; } else { retryCount -= 1; Util.Sleep(retrySleep); } } if (retryCount == 0) { ret = this._Client.Request(method, path, query); } return(ret); }