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->new( 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.
agent_id
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, lock_name and timeout, which are passed on to Lock's constructor.
lock_name
timeout
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, lock_name and timeout, which are passed on to SharedLock's constructor.
Copyright 2007 Marvin Humphrey
See KinoSearch version 0.20.
To install KinoSearch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm KinoSearch
CPAN shell
perl -MCPAN -e shell install KinoSearch
For more information on module installation, please visit the detailed CPAN module installation guide.