クラス org.objectweb.cjdbc.controller.cache.result.ResultCache.RelaxedCacheThread

すべてのメンバ一覧

説明

Allows to remove dirty entries from the cache

ResultCache.java966 行で定義されています。

Public メソッド

 RelaxedCacheThread ()
 RelaxedCacheThread (int refreshCacheRate)
void run ()

変数

int refreshCacheRate = 60
int refreshCacheTime = 60 / refreshCacheRate

Private 変数

Trace logger
boolean isKilled = false


コンストラクタとデストラクタ

org.objectweb.cjdbc.controller.cache.result.ResultCache.RelaxedCacheThread.RelaxedCacheThread  ) 
 

Creates a new RelaxedCacheThread object ResultCache.java978 行で定義されています。

00979 { 00980 super("RelaxedCacheThread"); 00981 }

org.objectweb.cjdbc.controller.cache.result.ResultCache.RelaxedCacheThread.RelaxedCacheThread int  refreshCacheRate  ) 
 

Creates a new RelaxedCacheThread object

引数:
refreshCacheRate cache refresh rate in seconds
ResultCache.java988 行で定義されています。
00989 { 00990 this(); 00991 this.refreshCacheRate = refreshCacheRate; 00992 }


メソッド

void org.objectweb.cjdbc.controller.cache.result.ResultCache.RelaxedCacheThread.run  ) 
 

参照:
java.lang.Runnable#run()
ResultCache.java997 行で定義されています。

参照先 org.objectweb.cjdbc.controller.cache.result.entries.ResultCacheEntryRelaxed.getDeadline(), org.objectweb.cjdbc.controller.cache.result.entries.ResultCacheEntryRelaxed.getKeepIfNotDirty(), org.objectweb.cjdbc.controller.cache.result.entries.ResultCacheEntry.getRequest(), org.objectweb.cjdbc.common.sql.AbstractRequest.getSQL(), org.objectweb.cjdbc.controller.cache.result.entries.ResultCacheEntryRelaxed.getTimeout(), org.objectweb.cjdbc.controller.cache.result.entries.ResultCacheEntry.isDirty(), と org.objectweb.cjdbc.controller.cache.result.entries.ResultCacheEntryRelaxed.setDeadline().

00998 { 00999 ResultCacheEntryRelaxed entry; 01000 long now; 01001 long sleep; 01002 // Keep trace of relaxed cache entries to delete 01003 ArrayList toRemoveFromRelaxedCache = new ArrayList(); 01004 while (!isKilled) 01005 { 01006 synchronized (this) 01007 { 01008 try 01009 { 01010 threadWakeUpTime = 0; 01011 if (relaxedCache.isEmpty()) 01012 { // Nothing in the cache, just sleep! 01013 if (logger.isDebugEnabled()) 01014 logger.debug(Translate 01015 .get("relaxedcachethread.cache.empty.sleeping")); 01016 wait(); 01017 } 01018 else 01019 { // Look for first deadline 01020 now = System.currentTimeMillis(); 01021 clean : for (Iterator iter = relaxedCache.iterator(); iter 01022 .hasNext();) 01023 { 01024 entry = (ResultCacheEntryRelaxed) iter.next(); 01025 if (entry.getDeadline() < now) 01026 { 01027 if (entry.isDirty() || !entry.getKeepIfNotDirty()) 01028 { 01029 { 01030 toRemoveFromRelaxedCache.add(entry); 01031 } 01032 continue clean; 01033 } 01034 else 01035 entry.setDeadline(now + entry.getTimeout()); 01036 } 01037 if (threadWakeUpTime == 0 01038 || (entry.getDeadline() < threadWakeUpTime)) 01039 threadWakeUpTime = entry.getDeadline(); 01040 } 01041 01042 // Clean up all the entries from the relaxed cache 01043 for (int i = 0; i < toRemoveFromRelaxedCache.size(); i++) 01044 { 01045 entry = (ResultCacheEntryRelaxed) toRemoveFromRelaxedCache 01046 .get(i); 01047 if (logger.isDebugEnabled()) 01048 logger.debug(Translate.get( 01049 "relaxedcachethread.remove.entry.from.cache", entry 01050 .getRequest().getSQL())); 01051 removeFromCache(entry.getRequest()); 01052 relaxedCache.remove(toRemoveFromRelaxedCache.get(i)); 01053 toRemoveFromRelaxedCache.remove(i); 01054 } 01055 if (threadWakeUpTime == 0) 01056 { // All entries were dirty and not kept in the cache, therefore 01057 // there is no next deadline. (and no cache entry to wait for) 01058 continue; 01059 } 01060 else 01061 { // Sleep until the next deadline 01062 sleep = (threadWakeUpTime - now) / 1000 + refreshCacheTime; 01063 if (logger.isDebugEnabled()) 01064 { 01065 logger.debug(Translate.get("relaxedcachethread.sleeping", 01066 sleep)); 01067 } 01068 sleep = (sleep) * 1000; 01069 wait(sleep); 01070 } 01071 } 01072 } 01073 catch (Exception e) 01074 { 01075 logger.warn(e.getMessage(), e); 01076 } 01077 } 01078 } 01079 }


変数

boolean org.objectweb.cjdbc.controller.cache.result.ResultCache.RelaxedCacheThread.isKilled = false [private]
 

ResultCache.java973 行で定義されています。

Trace org.objectweb.cjdbc.controller.cache.result.ResultCache.RelaxedCacheThread.logger [private]
 

初期値:

Trace .getLogger("org.objectweb.cjdbc.controller.cache.cache.RelaxedThread")
ResultCache.java970 行で定義されています。

int org.objectweb.cjdbc.controller.cache.result.ResultCache.RelaxedCacheThread.refreshCacheRate = 60 [package]
 

ResultCache.java968 行で定義されています。

int org.objectweb.cjdbc.controller.cache.result.ResultCache.RelaxedCacheThread.refreshCacheTime = 60 / refreshCacheRate [package]
 

ResultCache.java969 行で定義されています。


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0.4に対してTue Oct 12 15:16:37 2004に生成されました。 doxygen 1.3.8