Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class RateLimitedDirectoryWrapper

    A Directory wrapper that allows IndexOutput rate limiting using IO context (IOContext.UsageContext) specific rate limiters (RateLimiter).

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Inheritance
    object
    Directory
    FilterDirectory
    RateLimitedDirectoryWrapper
    Implements
    IDisposable
    Inherited Members
    FilterDirectory.Delegate
    FilterDirectory.ListAll()
    FilterDirectory.FileExists(string)
    FilterDirectory.DeleteFile(string)
    FilterDirectory.FileLength(string)
    FilterDirectory.Sync(ICollection<string>)
    FilterDirectory.OpenInput(string, IOContext)
    FilterDirectory.MakeLock(string)
    FilterDirectory.ClearLock(string)
    FilterDirectory.SetLockFactory(LockFactory)
    FilterDirectory.GetLockID()
    FilterDirectory.LockFactory
    FilterDirectory.ToString()
    Directory.OpenChecksumInput(string, IOContext)
    Directory.Dispose()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Store
    Assembly: Lucene.Net.dll
    Syntax
    public sealed class RateLimitedDirectoryWrapper : FilterDirectory, IDisposable

    Constructors

    RateLimitedDirectoryWrapper(Directory)

    A Directory wrapper that allows IndexOutput rate limiting using IO context (IOContext.UsageContext) specific rate limiters (RateLimiter).

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Declaration
    public RateLimitedDirectoryWrapper(Directory wrapped)
    Parameters
    Type Name Description
    Directory wrapped
    See Also
    SetRateLimiter(RateLimiter, UsageContext)

    Methods

    Copy(Directory, string, string, IOContext)

    Copies the file src to Directoryto under the new file name dest.

    If you want to copy the entire source directory to the destination one, you can do so like this:
    Directory to; // the directory to copy to
    foreach (string file in dir.ListAll()) {
        dir.Copy(to, file, newFile, IOContext.DEFAULT); // newFile can be either file, or a new name
    }

    NOTE: this method does not check whether dest exist and will

    overwrite it if it does.

    Declaration
    public override void Copy(Directory to, string src, string dest, IOContext context)
    Parameters
    Type Name Description
    Directory to
    string src
    string dest
    IOContext context
    Overrides
    Directory.Copy(Directory, string, string, IOContext)
    See Also
    SetRateLimiter(RateLimiter, UsageContext)

    CreateOutput(string, IOContext)

    Creates a new, empty file in the directory with the given name. Returns a stream writing this file.

    Declaration
    public override IndexOutput CreateOutput(string name, IOContext context)
    Parameters
    Type Name Description
    string name
    IOContext context
    Returns
    Type Description
    IndexOutput
    Overrides
    FilterDirectory.CreateOutput(string, IOContext)
    See Also
    SetRateLimiter(RateLimiter, UsageContext)

    CreateSlicer(string, IOContext)

    Creates an Directory.IndexInputSlicer for the given file name. Directory.IndexInputSlicer allows other Directory implementations to efficiently open one or more sliced IndexInput instances from a single file handle. The underlying file handle is kept open until the Directory.IndexInputSlicer is closed.

    Throws FileNotFoundException if the file does not exist.

    Note

    This API is for internal purposes only and might change in incompatible ways in the next release.

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Declaration
    public override Directory.IndexInputSlicer CreateSlicer(string name, IOContext context)
    Parameters
    Type Name Description
    string name
    IOContext context
    Returns
    Type Description
    Directory.IndexInputSlicer
    Overrides
    Directory.CreateSlicer(string, IOContext)
    Exceptions
    Type Condition
    IOException

    if an IOException occurs

    See Also
    SetRateLimiter(RateLimiter, UsageContext)

    GetMaxWriteMBPerSec(UsageContext)

    See SetMaxWriteMBPerSec(double?, UsageContext).

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Declaration
    public double GetMaxWriteMBPerSec(IOContext.UsageContext context)
    Parameters
    Type Name Description
    IOContext.UsageContext context
    Returns
    Type Description
    double
    Exceptions
    Type Condition
    ObjectDisposedException

    if the Directory is already disposed

    See Also
    SetRateLimiter(RateLimiter, UsageContext)

    SetMaxWriteMBPerSec(double?, UsageContext)

    Sets the maximum (approx) MB/sec allowed by all write IO performed by IndexOutput created with the given IOContext.UsageContext. Pass null for mbPerSec to have no limit.

    NOTE: For already created IndexOutput instances there is no guarantee this new rate will apply to them; it will only be guaranteed to apply for new created IndexOutput instances.

    NOTE: this is an optional operation and might not be respected by all Directory implementations. Currently only buffered (FSDirectory) Directory implementations use rate-limiting.

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Declaration
    public void SetMaxWriteMBPerSec(double? mbPerSec, IOContext.UsageContext context)
    Parameters
    Type Name Description
    double? mbPerSec
    IOContext.UsageContext context
    Exceptions
    Type Condition
    ObjectDisposedException

    if the Directory is already disposed

    See Also
    SetRateLimiter(RateLimiter, UsageContext)

    SetRateLimiter(RateLimiter, UsageContext)

    Sets the rate limiter to be used to limit (approx) MB/sec allowed by all IO performed with the given context (IOContext.UsageContext). Pass null to have no limit.

    Passing an instance of rate limiter compared to setting it using SetMaxWriteMBPerSec(double?, UsageContext) allows to use the same limiter instance across several directories globally limiting IO across them.

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Declaration
    public void SetRateLimiter(RateLimiter mergeWriteRateLimiter, IOContext.UsageContext context)
    Parameters
    Type Name Description
    RateLimiter mergeWriteRateLimiter
    IOContext.UsageContext context
    Exceptions
    Type Condition
    ObjectDisposedException

    if the Directory is already disposed

    See Also
    SetRateLimiter(RateLimiter, UsageContext)

    Implements

    IDisposable

    See Also

    SetRateLimiter(RateLimiter, UsageContext)
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.