Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Public Attributes
arcom.store.zodbstore.ZODBStore Class Reference
Inheritance diagram for arcom.store.zodbstore.ZODBStore:
Inheritance graph
[legend]
Collaboration diagram for arcom.store.zodbstore.ZODBStore:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def packingThread
def list
def get
def set
def lock
def unlock

Public Attributes

 dbfile
 db
 metadata
 period
 datadir
 non_existent_object
 llock

Detailed Description

Definition at line 32 of file zodbstore.py.


Constructor & Destructor Documentation

def arcom.store.zodbstore.ZODBStore.__init__ (   self,
  storecfg,
  non_existent_object = {} 
)
Constructor of ZODBStore.

ZODBStore(storecfg)

'storecfg' is an XMLNode with a 'DataDir'
'non_existent_object' will be returned if an object not found

Reimplemented from arcom.store.basestore.BaseStore.

Definition at line 34 of file zodbstore.py.

00034 
00035     def __init__(self, storecfg, non_existent_object = {}):
00036         """ Constructor of ZODBStore.
00037 
00038         ZODBStore(storecfg)
00039 
00040         'storecfg' is an XMLNode with a 'DataDir'
00041         'non_existent_object' will be returned if an object not found
00042         """
00043         BaseStore.__init__(self, storecfg, non_existent_object)
00044         log.msg(arc.VERBOSE, "ZODBStore constructor called")
00045         log.msg(arc.VERBOSE, "datadir:", self.datadir)
00046         self.dbfile = os.path.join(self.datadir,'metadata.fs')
00047         if os.path.isfile(self.dbfile):
00048             self.db = DB(FileStorage.FileStorage(self.dbfile))
00049             self.db.setCacheSize(4000)
00050             # decrease db file size in case of previous deletions 
00051             # (should maybe do this in a separate script?)
00052             #db.pack()
00053             self.metadata = self.db.open().root()['meta']
00054         else:
00055             self.db = DB(FileStorage.FileStorage(self.dbfile))
00056             root = self.db.open().root()
00057             root['meta'] = Metadata()
00058             get_transaction().commit()
00059             self.metadata = root['meta']
00060         self.period = 60
00061         threading.Thread(target = self.packingThread, args = [self.period]).start()


Member Function Documentation

def arcom.store.zodbstore.ZODBStore.get (   self,
  ID 
)
Returns the object with the given ID.

get(ID)

'ID' is the ID of the requested object.
If there is no object with this ID, returns the given non_existent_object value.

Definition at line 79 of file zodbstore.py.

00079 
00080     def get(self, ID):
00081         """ Returns the object with the given ID.
00082 
00083         get(ID)
00084 
00085         'ID' is the ID of the requested object.
00086         If there is no object with this ID, returns the given non_existent_object value.
00087         """
00088         try:
00089             #get_transaction().commit()
00090             return self.metadata[ID]
00091         except KeyError:
00092             # don't print 'KeyError' if there is no such ID
00093             pass
00094         except:
00095             # print whatever exception happened
00096             log.msg()
00097             log.msg(arc.ERROR, "ID", ID)
00098         # if there was an exception, return the given non_existent_object
00099         return copy.deepcopy(self.non_existent_object)

Here is the caller graph for this function:

List the IDs of the existing entries.

list()

Returns a list of IDs.
Only relevant for shepherd

Definition at line 68 of file zodbstore.py.

00068 
00069     def list(self):
00070         """ List the IDs of the existing entries.
00071         
00072         list()
00073         
00074         Returns a list of IDs.
00075         Only relevant for shepherd
00076         """
00077         #get_transaction().commit()
00078         return self.metadata.list()

def arcom.store.basestore.BaseStore.lock (   self,
  blocking = True 
) [inherited]
Acquire the lock.

lock(blocking = True)

'blocking': if blocking is True, then this only returns when the lock is acquired.
If it is False, then it returns immediately with False if the lock is not available,
or with True if it could be acquired.

Reimplemented in storage.ahash.replicatedahash.ReplicationStore.

Definition at line 27 of file basestore.py.

00027 
00028     def lock(self, blocking = True):
00029         """ Acquire the lock.
00030 
00031         lock(blocking = True)
00032 
00033         'blocking': if blocking is True, then this only returns when the lock is acquired.
00034         If it is False, then it returns immediately with False if the lock is not available,
00035         or with True if it could be acquired.
00036         """
00037         return self.llock.acquire(blocking)

Here is the caller graph for this function:

def arcom.store.zodbstore.ZODBStore.packingThread (   self,
  period 
)

Definition at line 62 of file zodbstore.py.

00062 
00063     def packingThread(self,period):
00064         time.sleep(7)
00065         while True:
00066             self.db.pack()
00067             time.sleep(period)
            
def arcom.store.zodbstore.ZODBStore.set (   self,
  ID,
  object 
)
Stores an object with the given ID..

set(ID, object)

'ID' is the ID of the object
'object' is the object itself
If there is already an object with this ID it will be overwritten completely.

Definition at line 100 of file zodbstore.py.

00100 
00101     def set(self, ID, object):
00102         """ Stores an object with the given ID..
00103 
00104         set(ID, object)
00105 
00106         'ID' is the ID of the object
00107         'object' is the object itself
00108         If there is already an object with this ID it will be overwritten completely.
00109         """
00110         if not ID:
00111             raise Exception, 'ID is empty'
00112         try:
00113             if object == None:
00114                 self.metadata.delMeta(ID)
00115             else:
00116                 self.metadata.addMeta(ID, object)
00117             get_transaction().commit()
00118         except:
00119             log.msg()
def arcom.store.basestore.BaseStore.unlock (   self) [inherited]
Release the lock.

unlock()

Reimplemented in storage.ahash.replicatedahash.ReplicationStore.

Definition at line 38 of file basestore.py.

00038 
00039     def unlock(self):
00040         """ Release the lock.
00041 
00042         unlock()
00043         """
00044         self.llock.release()
        

Here is the caller graph for this function:


Member Data Documentation

Definition at line 18 of file basestore.py.

Definition at line 47 of file zodbstore.py.

Definition at line 45 of file zodbstore.py.

Definition at line 25 of file basestore.py.

Definition at line 52 of file zodbstore.py.

Definition at line 20 of file basestore.py.

Definition at line 59 of file zodbstore.py.


The documentation for this class was generated from the following file: