You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (JIRA)" <ji...@apache.org> on 2014/11/08 17:43:33 UTC

[jira] [Updated] (LUCENE-5953) Make LockFactory final on Directory

     [ https://issues.apache.org/jira/browse/LUCENE-5953?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Uwe Schindler updated LUCENE-5953:
----------------------------------
    Attachment: LUCENE-5953.patch

Sorry that it took a while, I was very busy.

Attached is a patch that refactors LockFactory handling. In addition to the discussion before, this one makes handling of locks much simplier:
- LockFactory is no longer used or exposed by the Directory implementation it is just some factory class, that can be used by a directory to implement makeLock(name). BaseDirectory is the only place where the lockFactory is actually used, its not part of Directory interface.
- IndexWriter and all other components solely use Directory.makeLock(name), which returns a Lock instance
- FSDirectory subclasses are no longer allowed to take "null" as LockFactory instance. You have to pass one explicit (or use a constructor that is documented to take default).
- FSLockFactory.getDefault() can be used to get a default instance for the platform used. Currently this always returns NativeFSLockFactory.INSTANCE.
- Most lock factories are now singletons: NativeFSLockFactory.INSTANCE, SimpleFSLockFactory.INSTANCE, NoLockFactory.INSTANCE.

I also rewrote the broken SnapShooter (the way how it locks) in Solr (but not fix it). As it is documented as "deprecated" and no longer used, we should remove it in Solr 5.0. I will open another issue about that.

I would like to commit this asap, because the patch may get out of sync very fast. I will now run all test in a loop with explicit -Dtests.directory=... to check all combinations, because disallowing "null" as LockFactory may cause hidden bugs. So we should run this patch for a while on Jenkins :-)

> Make LockFactory final on Directory
> -----------------------------------
>
>                 Key: LUCENE-5953
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5953
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: core/store
>            Reporter: Uwe Schindler
>            Assignee: Uwe Schindler
>             Fix For: Trunk
>
>         Attachments: LUCENE-5953.patch
>
>
> We should remove the setters for the LockFactory from Directory and make the field final. It is a bug to change the LockFactory after creating a directory, because you may break locking (if locks are currently held).
> The LockFactory should be passed on ctor only.
> The other suggestion: Should LockFactory have a directory at all? We moved away from having the lock separately from the index directory. This is no longer a supported configuration (since approx Lucene 2.9 or 3.0). I would like to remove the directory from LockFactory and make it part of the Directory only.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org