Commit 60d04a03 authored by Fred Drake's avatar Fred Drake

lots of cleanup; remove archaic BoboPOS 2 support

parent 537cb142
...@@ -10,104 +10,82 @@ ...@@ -10,104 +10,82 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
__doc__='''Cache management support '''Cache management support.
This class is mixed into the database manager in App.ApplicationManager.
$Id: CacheManager.py,v 1.28 2003/11/03 16:40:37 fdrake Exp $''' $Id: CacheManager.py,v 1.29 2003/11/03 19:08:44 fdrake Exp $'''
__version__='$Revision: 1.28 $'[11:-2] __version__='$Revision: 1.29 $'[11:-2]
import Globals, time, sys import time
import Globals
from DateTime import DateTime from DateTime import DateTime
class CacheManager: class CacheManager:
"""Cache management mix-in """Cache management mix-in
""" """
_cache_age=60 _cache_age = 60
_vcache_age=60 _vcache_age = 60
_history_length = 3600 # Seconds _history_length = 3600 # Seconds
manage_cacheParameters=Globals.DTMLFile('dtml/cacheParameters', globals()) manage_cacheParameters = Globals.DTMLFile('dtml/cacheParameters',
manage_cacheGC=Globals.DTMLFile('dtml/cacheGC', globals()) globals())
manage_cacheGC = Globals.DTMLFile('dtml/cacheGC', globals())
transparent_bar = Globals.ImageFile('www/transparent_bar.gif', globals()) transparent_bar = Globals.ImageFile('www/transparent_bar.gif', globals())
store_bar = Globals.ImageFile('www/store_bar.gif', globals()) store_bar = Globals.ImageFile('www/store_bar.gif', globals())
load_bar = Globals.ImageFile('www/load_bar.gif', globals()) load_bar = Globals.ImageFile('www/load_bar.gif', globals())
def _getDB(self):
return self._p_jar.db()
def _inVersion(self):
return self._p_jar.getVersion() and True or False
def cache_length(self): def cache_length(self):
try: db=self._p_jar.db() return self._getDB().cacheSize()
except:
# BoboPOS2
return len(Globals.Bobobase._jar.cache)
else: return db.cacheSize()
def cache_detail_length(self): def cache_detail_length(self):
try: db=self._p_jar.db() return self._getDB().cacheDetailSize()
except:
return ()
else: return db.cacheDetailSize()
def database_size(self): def database_size(self):
try: db=self._p_jar.db() return self._getDB().objectCount()
except:
# BoboPOS2
return len(Globals.Bobobase._jar.db.index)*4
else: return db.objectCount()
def cache_age(self): def cache_age(self):
try: if self._inVersion():
if self._p_jar.getVersion(): return self._vcache_age
return self._vcache_age else:
except: pass return self._cache_age
return self._cache_age
def manage_cache_age(self,value,REQUEST): def manage_cache_age(self,value,REQUEST):
"set cache age" "set cache age"
try: db = self._getDB()
v=self._p_jar.getVersion() if self._inVersion():
except: self._vcache_age = value
# BoboPOS2: db.setVersionCacheDeactivateAfter(value)
if self._p_jar.db is not Globals.Bobobase._jar.db:
raise 'Version Error', (
'''You may not change the database cache age
while working in a <em>version</em>''')
self._cache_age=Globals.Bobobase._jar.cache.cache_age=value
else: else:
if v: self._cache_age = value
self._vcache_age=value db.setCacheDeactivateAfter(value)
self._p_jar.db().setVersionCacheDeactivateAfter(value)
else:
self._cache_age=value
self._p_jar.db().setCacheDeactivateAfter(value)
if REQUEST is not None: if REQUEST is not None:
response=REQUEST['RESPONSE'] response=REQUEST['RESPONSE']
response.redirect(REQUEST['URL1']+'/manage_cacheParameters') response.redirect(REQUEST['URL1']+'/manage_cacheParameters')
def cache_size(self): def cache_size(self):
try: db = self._getDB()
if self._p_jar.getVersion(): if self._inVersion():
return self._p_jar.db().getVersionCacheSize() return db.getVersionCacheSize()
except: pass else:
return self._p_jar.db().getCacheSize() return db.getCacheSize()
def manage_cache_size(self,value,REQUEST): def manage_cache_size(self,value,REQUEST):
"set cache size" "set cache size"
try: db = self._getDB()
v=self._p_jar.getVersion() if self._inVersion():
except: db.setVersionCacheSize(value)
# BoboPOS2:
if self._p_jar.db is not Globals.Bobobase._jar.db:
raise 'Version Error', (
'''You may not change the database cache size
while working in a <em>version</em>''')
Globals.Bobobase._jar.cache.cache_size = value
else: else:
db = self._p_jar.db() db.setCacheSize(value)
if v:
db.setVersionCacheSize(value)
else:
db.setCacheSize(value)
if REQUEST is not None: if REQUEST is not None:
response=REQUEST['RESPONSE'] response=REQUEST['RESPONSE']
...@@ -115,24 +93,7 @@ class CacheManager: ...@@ -115,24 +93,7 @@ class CacheManager:
def cacheStatistics(self): def cacheStatistics(self):
try: return self._p_jar.db().cacheStatistics() return self._getDB().cacheStatistics()
except: pass
# BoboPOS 2
return (
('Mean time since last access (minutes)',
"%.4g" % (Globals.Bobobase._jar.cache.cache_mean_age/60.0)),
('Deallocation rate (objects/minute)',
"%.4g" % (Globals.Bobobase._jar.cache.cache_mean_deal*60)),
('Deactivation rate (objects/minute)',
"%.4g" % (Globals.Bobobase._jar.cache.cache_mean_deac*60)),
('Time of last cache garbage collection',
time.asctime(time.localtime(
Globals.Bobobase._jar.cache.cache_last_gc_time
))
),
)
# BoboPOS 2 # BoboPOS 2
def cache_mean_age(self): def cache_mean_age(self):
...@@ -153,11 +114,8 @@ class CacheManager: ...@@ -153,11 +114,8 @@ class CacheManager:
def manage_full_sweep(self,value,REQUEST): def manage_full_sweep(self,value,REQUEST):
"Perform a full sweep through the cache" "Perform a full sweep through the cache"
try: db=self._p_jar.db() db = self._getDB()
except: db.cacheFullSweep(value)
# BoboPOS2
Globals.Bobobase._jar.cache.full_sweep(value)
else: db.cacheFullSweep(value)
if REQUEST is not None: if REQUEST is not None:
response=REQUEST['RESPONSE'] response=REQUEST['RESPONSE']
...@@ -165,11 +123,7 @@ class CacheManager: ...@@ -165,11 +123,7 @@ class CacheManager:
def manage_minimize(self,value=1,REQUEST=None): def manage_minimize(self,value=1,REQUEST=None):
"Perform a full sweep through the cache" "Perform a full sweep through the cache"
try: db=self._p_jar.db() self._getDB().cacheMinimize(value)
except:
# BoboPOS2
Globals.Bobobase._jar.cache.minimize(value)
else: db.cacheMinimize(value)
if REQUEST is not None: if REQUEST is not None:
response=REQUEST['RESPONSE'] response=REQUEST['RESPONSE']
...@@ -184,8 +138,7 @@ class CacheManager: ...@@ -184,8 +138,7 @@ class CacheManager:
Returns the name of the classes of the objects in the cache Returns the name of the classes of the objects in the cache
and the number of objects in the cache for each class. and the number of objects in the cache for each class.
""" """
db=self._p_jar.db() detail = self._getDB().cacheDetail()
detail = db.cacheDetail()
if REQUEST is not None: if REQUEST is not None:
# format as text # format as text
REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain') REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain')
...@@ -199,8 +152,7 @@ class CacheManager: ...@@ -199,8 +152,7 @@ class CacheManager:
""" """
Returns information about each object in the cache. Returns information about each object in the cache.
""" """
db=self._p_jar.db() detail = self._getDB().cacheExtremeDetail()
detail = db.cacheExtremeDetail()
if REQUEST is not None: if REQUEST is not None:
# sort the list. # sort the list.
lst = map(lambda dict: ((dict['conn_no'], dict['oid']), dict), lst = map(lambda dict: ((dict['conn_no'], dict['oid']), dict),
...@@ -233,7 +185,7 @@ class CacheManager: ...@@ -233,7 +185,7 @@ class CacheManager:
return detail return detail
def _getActivityMonitor(self): def _getActivityMonitor(self):
db = self._p_jar.db() db = self._getDB()
if not hasattr(db, 'getActivityMonitor'): if not hasattr(db, 'getActivityMonitor'):
return None return None
am = db.getActivityMonitor() am = db.getActivityMonitor()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment