/// <summary> /// Sets the maximum (approx) MB/sec allowed by all write IO performed by /// <see cref="IndexOutput"/> created with the given <see cref="IOContext.UsageContext"/>. Pass /// <c>null</c> for <paramref name="mbPerSec"/> to have no limit. /// /// <para/> /// <b>NOTE</b>: For already created <see cref="IndexOutput"/> instances there is no /// guarantee this new rate will apply to them; it will only be guaranteed to /// apply for new created <see cref="IndexOutput"/> instances. /// <para/> /// <b>NOTE</b>: this is an optional operation and might not be respected by /// all <see cref="Directory"/> implementations. Currently only buffered (<see cref="FSDirectory"/>) /// <see cref="Directory"/> implementations use rate-limiting. /// <para/> /// @lucene.experimental /// </summary> /// <exception cref="ObjectDisposedException"> if the <see cref="Directory"/> is already disposed /// </exception> public void SetMaxWriteMBPerSec(double?mbPerSec, IOContext.UsageContext context) { EnsureOpen(); //if (context == null) // LUCENENET NOTE: enum values can never be null in .NET //{ // throw new ArgumentException("Context must not be null"); //} //int ord = context.ordinal(); RateLimiter limiter; _contextRateLimiters.TryGetValue(context, out limiter); if (mbPerSec == null) { if (limiter != null) { limiter.SetMbPerSec(double.MaxValue); _contextRateLimiters[context] = null; } } else if (limiter != null) { limiter.SetMbPerSec(mbPerSec.Value); _contextRateLimiters[context] = limiter; // cross the mem barrier again } else { _contextRateLimiters[context] = new RateLimiter.SimpleRateLimiter(mbPerSec.Value); } }
/// <summary> /// Sets the maximum (approx) MB/sec allowed by all write IO performed by /// <seealso cref="IndexOutput"/> created with the given <seealso cref="IOContext.Context"/>. Pass /// <code>null</code> to have no limit. /// /// <p> /// <b>NOTE</b>: For already created <seealso cref="IndexOutput"/> instances there is no /// guarantee this new rate will apply to them; it will only be guaranteed to /// apply for new created <seealso cref="IndexOutput"/> instances. /// <p> /// <b>NOTE</b>: this is an optional operation and might not be respected by /// all Directory implementations. Currently only <seealso cref="FSDirectory buffered"/> /// Directory implementations use rate-limiting. /// </summary> /// <exception cref="IllegalArgumentException"> /// if context is <code>null</code> </exception> /// <exception cref="AlreadyClosedException"> if the <seealso cref="Directory"/> is already closed /// @lucene.experimental </exception> public void SetMaxWriteMBPerSec(double mbPerSec, IOContext.Context_e?context) { EnsureOpen(); if (context == null) { throw new System.ArgumentException("Context must not be null"); } //int ord = context.ordinal(); RateLimiter limiter = ContextRateLimiters[context]; if (mbPerSec == null) { if (limiter != null) { limiter.MbPerSec = double.MaxValue; ContextRateLimiters[context] = null; } } else if (limiter != null) { limiter.MbPerSec = mbPerSec; ContextRateLimiters[context] = limiter; // cross the mem barrier again } else { ContextRateLimiters[context] = new RateLimiter.SimpleRateLimiter(mbPerSec); } }
/// <summary> /// Sets the maximum (approx) MB/sec allowed by all write IO performed by /// <seealso cref="IndexOutput"/> created with the given <seealso cref="IOContext.Context"/>. Pass /// <code>null</code> to have no limit. /// /// <p> /// <b>NOTE</b>: For already created <seealso cref="IndexOutput"/> instances there is no /// guarantee this new rate will apply to them; it will only be guaranteed to /// apply for new created <seealso cref="IndexOutput"/> instances. /// <p> /// <b>NOTE</b>: this is an optional operation and might not be respected by /// all Directory implementations. Currently only <seealso cref="FSDirectory buffered"/> /// Directory implementations use rate-limiting. /// </summary> /// <exception cref="IllegalArgumentException"> /// if context is <code>null</code> </exception> /// <exception cref="AlreadyClosedException"> if the <seealso cref="Directory"/> is already closed /// @lucene.experimental </exception> public void SetMaxWriteMBPerSec(double mbPerSec, IOContext.Context_e? context) { EnsureOpen(); if (context == null) { throw new System.ArgumentException("Context must not be null"); } //int ord = context.ordinal(); RateLimiter limiter = ContextRateLimiters[context]; if (mbPerSec == null) { if (limiter != null) { limiter.MbPerSec = double.MaxValue; ContextRateLimiters[context] = null; } } else if (limiter != null) { limiter.MbPerSec = mbPerSec; ContextRateLimiters[context] = limiter; // cross the mem barrier again } else { ContextRateLimiters[context] = new RateLimiter.SimpleRateLimiter(mbPerSec); } }