Class LockValidatingDirectoryWrapper

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public final class LockValidatingDirectoryWrapper
    extends FilterDirectory
    This class makes a best-effort check that a provided Lock is valid before any destructive filesystem operation.
    • Field Detail

      • writeLock

        private final Lock writeLock
    • Constructor Detail

      • LockValidatingDirectoryWrapper

        public LockValidatingDirectoryWrapper​(Directory in,
                                              Lock writeLock)
    • Method Detail

      • deleteFile

        public void deleteFile​(java.lang.String name)
                        throws java.io.IOException
        Description copied from class: Directory
        Removes an existing file in the directory.

        This method must throw either NoSuchFileException or FileNotFoundException if name points to a non-existing file.

        Overrides:
        deleteFile in class FilterDirectory
        Parameters:
        name - the name of an existing file.
        Throws:
        java.io.IOException - in case of I/O error
      • createOutput

        public IndexOutput createOutput​(java.lang.String name,
                                        IOContext context)
                                 throws java.io.IOException
        Description copied from class: Directory
        Creates a new, empty file in the directory and returns an IndexOutput instance for appending data to this file.

        This method must throw FileAlreadyExistsException if the file already exists.

        Overrides:
        createOutput in class FilterDirectory
        Parameters:
        name - the name of the file to create.
        Throws:
        java.io.IOException - in case of I/O error
      • copyFrom

        public void copyFrom​(Directory from,
                             java.lang.String src,
                             java.lang.String dest,
                             IOContext context)
                      throws java.io.IOException
        Description copied from class: Directory
        Copies an existing src file from directory from to a non-existent file dest in this directory.
        Overrides:
        copyFrom in class Directory
        Throws:
        java.io.IOException
      • rename

        public void rename​(java.lang.String source,
                           java.lang.String dest)
                    throws java.io.IOException
        Description copied from class: Directory
        Renames source file to dest file where dest must not already exist in the directory.

        It is permitted for this operation to not be truly atomic, for example both source and dest can be visible temporarily in Directory.listAll(). However, the implementation of this method must ensure the content of dest appears as the entire source atomically. So once dest is visible for readers, the entire content of previous source is visible.

        This method is used by IndexWriter to publish commits.

        Overrides:
        rename in class FilterDirectory
        Throws:
        java.io.IOException
      • syncMetaData

        public void syncMetaData()
                          throws java.io.IOException
        Description copied from class: Directory
        Ensures that directory metadata, such as recent file renames, are moved to stable storage.
        Overrides:
        syncMetaData in class FilterDirectory
        Throws:
        java.io.IOException
        See Also:
        Directory.sync(Collection)
      • sync

        public void sync​(java.util.Collection<java.lang.String> names)
                  throws java.io.IOException
        Description copied from class: Directory
        Ensures that any writes to these files are moved to stable storage (made durable).

        Lucene uses this to properly commit changes to the index, to prevent a machine/OS crash from corrupting the index.

        Overrides:
        sync in class FilterDirectory
        Throws:
        java.io.IOException
        See Also:
        Directory.syncMetaData()