Package Ganga :: Package Core :: Package GangaRepository :: Module SessionLock :: Class SessionLockManager
[hide private]
[frames] | no frames]

Class SessionLockManager

source code

object --+
         |
        SessionLockManager

Class with thread that keeps a global lock file that synchronizes
ID and counter access across Ganga sessions.
DEVELOPER WARNING: On NFS, files that are not locked with lockf (NOT flock) will 
NOT be synchronized across clients, even if a global lock file is used!
Interface:
    * startup() starts the session, automatically called on init
    * shutdown() stops the thread, FREES ALL LOCKS
    * make_new_ids(n) returns n new (locked) ids
    * lock_ids(ids) returns the ids that were successfully locked
    * release_ids(ids) returns the ids that were successfully released (now: all)
All access to an instance of this class MUST be synchronized!
Should ONLY raise RepositoryError (if possibly-corrupting errors are found)

Instance Methods [hide private]
 
mkdir(self, dn)
Make sure the given directory exists
source code
 
__init__(self, repo, root, name, minimum_count=0)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
startup(self) source code
 
shutdown(self)
Shutdown the thread and locking system (on ganga shutdown or repo error)
source code
 
global_lock_setup(self) source code
 
global_lock_acquire(self) source code
 
global_lock_release(self) source code
 
session_read(self, fn)
Reads a session file and returns a set of IDs locked by that session.
source code
 
session_write(self)
Writes the locked set to the session file.
source code
 
cnt_read(self)
Tries to read the counter file.
source code
 
cnt_write(self)
Writes the counter to the counter file.
source code
 
make_new_ids(self, n)
Locks the next n available ids and returns them as a list Raise RepositoryError on fatal error
source code
 
lock_ids(self, ids) source code
 
release_ids(self, ids) source code
 
check(self) source code
 
get_lock_session(id)
Tries to determine the session that holds the lock on id for information purposes, and return an informative string.
source code
 
get_other_sessions()
Tries to determine the other sessions that are active and returns an informative string for each of them.
source code
 
reap_locks(self)
reap_locks() --> True/False Remotely clear all foreign locks from the session.
source code
 
session_to_info(self, session) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, repo, root, name, minimum_count=0)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

session_read(self, fn)

source code 

Reads a session file and returns a set of IDs locked by that session. The global lock MUST be held for this function to work, although on NFS additional locking is done Raises RepositoryError if severe access problems occur (corruption otherwise!)

session_write(self)

source code 

Writes the locked set to the session file. The global lock MUST be held for this function to work, although on NFS additional locking is done Raises RepositoryError if session file is inaccessible

cnt_read(self)

source code 

Tries to read the counter file. Raises ValueError (invalid contents) Raises OSError (no access/does not exist) Raises RepositoryError (fatal)

cnt_write(self)

source code 

Writes the counter to the counter file. The global lock MUST be held for this function to work correctly Raises OSError if count file is inaccessible

get_lock_session(id)

source code 

Tries to determine the session that holds the lock on id for information purposes, and return an informative string. Returns None on failure

reap_locks(self)

source code 

reap_locks() --> True/False Remotely clear all foreign locks from the session. WARNING: This is not nice. Returns True on success, False on error.