Ce contenu n'est pas disponible dans la langue sélectionnée.

3.9. LockFactory configuration


Lucene Directories have default locking strategies which work well for most cases, but it's possible to specify for each index managed by Hibernate Search which LockingFactory you want to use.
Some of these locking strategies require a file system level lock and may be used even on RAM based indexes, but this is not recommended and of no practical use.
To select a locking factory, set the hibernate.search.<index>.locking_strategy option to one of simple, native, single or none, or set it to the fully qualified name of an implementation of org.hibernate.search.store.LockFactoryFactory; Implementing this interface you can provide a custom org.apache.lucene.store.LockFactory.
Expand
Table 3.4. List of available LockFactory implementations
name Class Description
simple org.apache.lucene.store.SimpleFSLockFactory
Safe implementation based on Java's File API, it marks the usage of the index by creating a marker file.
If for some reason you had to kill your application, you will need to remove this file before restarting it.
This is the default implementation for FSDirectoryProvider,FSMasterDirectoryProvider and FSSlaveDirectoryProvider.
native org.apache.lucene.store.NativeFSLockFactory
As does simple this also marks the usage of the index by creating a marker file, but this one is using native OS file locks so that even if your application crashes the locks will be cleaned up.
This implementation has known problems on NFS.
single org.apache.lucene.store.SingleInstanceLockFactory
This LockFactory does not use a file marker but is a Java object lock held in memory; therefore it is possible to use it only when you are sure the index is not going to be shared by any other process.
This is the default implementation for RAMDirectoryProvider.
none org.apache.lucene.store.NoLockFactory
All changes to this index are not coordinated by any lock; test your application carefully and make sure you know what it means.
Configuration example:
hibernate.search.default.locking_strategy simple
hibernate.search.Animals.locking_strategy native
hibernate.search.Books.locking_strategy org.custom.components.MyLockingFactory
Copy to Clipboard Toggle word wrap
Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat