internal RateLimitedIndexOutput(RateLimiter rateLimiter, IndexOutput @delegate) { // TODO should we make buffer size configurable if (@delegate is BufferedIndexOutput) { bufferedDelegate = (BufferedIndexOutput)@delegate; this.@delegate = @delegate; } else { this.@delegate = @delegate; bufferedDelegate = null; } this.rateLimiter = rateLimiter; }
/// <summary> /// Sets the rate limiter to be used to limit (approx) MB/sec allowed by all IO /// performed with the given <seealso cref="IOContext.Context context"/>. Pass <code>null</code> to /// have no limit. /// /// <p> /// Passing an instance of rate limiter compared to setting it using /// <seealso cref="#setMaxWriteMBPerSec(Double, IOContext.Context)"/> /// allows to use the same limiter instance across several directories globally /// limiting IO across them. /// </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 SetRateLimiter(RateLimiter mergeWriteRateLimiter, IOContext.Context_e context) { EnsureOpen(); if (context == null) { throw new System.ArgumentException("Context must not be null"); } ContextRateLimiters[context] = mergeWriteRateLimiter; }
/// <summary> /// Sets the rate limiter to be used to limit (approx) MB/sec allowed by all IO /// performed with the given context (<see cref="IOContext.UsageContext"/>). Pass <c>null</c> to /// have no limit. /// /// <para/> /// Passing an instance of rate limiter compared to setting it using /// <see cref="SetMaxWriteMBPerSec(double?, IOContext.UsageContext)"/> /// allows to use the same limiter instance across several directories globally /// limiting IO across them. /// <para/> /// @lucene.experimental /// </summary> /// <exception cref="ObjectDisposedException"> if the <see cref="Directory"/> is already disposed /// </exception> public void SetRateLimiter(RateLimiter mergeWriteRateLimiter, IOContext.UsageContext context) { EnsureOpen(); _contextRateLimiters[context] = mergeWriteRateLimiter; }
/// <summary> /// Sets the rate limiter to be used to limit (approx) MB/sec allowed by all IO /// performed with the given <seealso cref="IOContext.Context context"/>. Pass <code>null</code> to /// have no limit. /// /// <p> /// Passing an instance of rate limiter compared to setting it using /// <seealso cref="#setMaxWriteMBPerSec(Double, IOContext.Context)"/> /// allows to use the same limiter instance across several directories globally /// limiting IO across them. /// </summary> /// <exception cref="ArgumentException"> /// if context is <code>null</code> </exception> /// <exception cref="AlreadyClosedException"> if the <seealso cref="Directory"/> is already closed /// @lucene.experimental </exception> public void SetRateLimiter(RateLimiter mergeWriteRateLimiter, IOContext.UsageContext context) { EnsureOpen(); _contextRateLimiters[context] = mergeWriteRateLimiter; }