27 Oct 2007 19:46:10 UTC
- Development release
- Distribution: KinoSearch
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (5)
- Testers (21 / 5 / 2)
- KwaliteeBus factor: 0
- License: perl_5
- Activity24 month
- Download (460.82KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionCREAMYG Marvin Humphreyand 1 contributors
- Marvin Humphrey <marvin at rectangular dot com>
- LICENSE, DISCLAIMER, BUGS, etc.
KinoSearch::Store::LockFactory - Create Locks.
use Sys::Hostname; my $hostname = hostname(); die "Can't get unique hostname" unless $hostname; my $invindex = MySchema->open('/path/to/invindex/on/nfs/volume'); my $lock_factory = KinoSearch::Store::LockFactory->new( folder => $invindex->get_folder, agent_id => $hostname, ); my $index_reader = KinoSearch::Index::IndexReader->open( invindex => $invindex, lock_factory => $lock_factory, );
Normally, LockFactory is an internal class, quietly doing its work behind the scenes. On shared volumes, however, the locking mechanism fails, and manual intervention becomes necessary.
Both reading and writing applications accessing an index on a shared volume need to identify themselves with an
agent_id, typically the hostname. Knowing the hostname makes it possible to tell which lockfiles belong to other machines and therefore must not be zapped when their pid can't be found.
LockFactory spins off Lock and SharedLock objects at the request of other KinoSearch classes. If the behavior of Lock and SharedLock do not suit your needs, you may substitute a custom subclass of LockFactory which spins off your own Lock subclasses.
my $lock_factory = KinoSearch::Store::LockFactory->new( folder => $folder, # required agent_id => $hostname, # required );
Create a LockFactory. Takes named parameters.
folder - A KinoSearch::Store::Folder.
agent_id - An identifying string -- typically, the hostname.
my $exclusive_lock = $lock_factory->make_lock( lock_name => 'foo', timeout => 5000, );
Returns an exclusive lock on a resource. Called with two hash-style parameters,
timeout, which are passed on to Lock's constructor.
my $shared_lock = $lock_factory->make_lock( lock_name => 'foo', timeout => 5000, );
Returns a shared lock on a resource. Called with two hash-style parameters,
timeout, which are passed on to SharedLock's constructor.
Copyright 2007 Marvin Humphrey
See KinoSearch version 0.20.