Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class NativeFSLockFactory

    Implements LockFactory using native OS file locks. For NFS based access to an index, it's recommended that you try SimpleFSLockFactory first and work around the one limitation that a lock file could be left when the runtime exits abnormally.

    The primary benefit of NativeFSLockFactory is that locks (not the lock file itsself) will be properly removed (by the OS) if the runtime has an abnormal exit.

    Note that, unlike SimpleFSLockFactory, the existence of leftover lock files in the filesystem is fine because the OS will free the locks held against these files even though the files still remain. Lucene will never actively remove the lock files, so although you see them, the index may not be locked.

    Special care needs to be taken if you change the locking implementation: First be certain that no writer is in fact writing to the index otherwise you can easily corrupt your index. Be sure to do the LockFactory change on all Lucene instances and clean up all leftover lock files before starting the new configuration for the first time. Different implementations can not work together!

    If you suspect that this or any other LockFactory is not working properly in your environment, you can easily test it by using VerifyingLockFactory, LockVerifyServer and LockStressTest.

    Inheritance
    object
    LockFactory
    FSLockFactory
    NativeFSLockFactory
    Inherited Members
    FSLockFactory.m_lockDir
    FSLockFactory.SetLockDir(DirectoryInfo)
    FSLockFactory.LockDir
    FSLockFactory.ToString()
    LockFactory.m_lockPrefix
    LockFactory.LockPrefix
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Store
    Assembly: Lucene.Net.dll
    Syntax
    public class NativeFSLockFactory : FSLockFactory

    Constructors

    NativeFSLockFactory()

    Create a NativeFSLockFactory instance, with null (unset) lock directory. When you pass this factory to a FSDirectory subclass, the lock directory is automatically set to the directory itself. Be sure to create one instance for each directory your create!

    Declaration
    public NativeFSLockFactory()
    See Also
    LockFactory

    NativeFSLockFactory(DirectoryInfo)

    Create a NativeFSLockFactory instance, storing lock files into the specified lockDir

    Declaration
    public NativeFSLockFactory(DirectoryInfo lockDir)
    Parameters
    Type Name Description
    DirectoryInfo lockDir

    where lock files are created.

    See Also
    LockFactory

    NativeFSLockFactory(string)

    Create a NativeFSLockFactory instance, storing lock files into the specified lockDirName

    Declaration
    public NativeFSLockFactory(string lockDirName)
    Parameters
    Type Name Description
    string lockDirName

    where lock files are created.

    See Also
    LockFactory

    Methods

    ClearLock(string)

    Attempt to clear (forcefully unlock and remove) the specified lock. Only call this at a time when you are certain this lock is no longer in use.

    Declaration
    public override void ClearLock(string lockName)
    Parameters
    Type Name Description
    string lockName

    name of the lock to be cleared.

    Overrides
    LockFactory.ClearLock(string)
    See Also
    LockFactory

    MakeLock(string)

    Return a new Lock instance identified by lockName.

    Declaration
    public override Lock MakeLock(string lockName)
    Parameters
    Type Name Description
    string lockName

    name of the lock to be created.

    Returns
    Type Description
    Lock
    Overrides
    LockFactory.MakeLock(string)
    See Also
    LockFactory

    See Also

    LockFactory
    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.