Manual eviction not working
dmary Feb 12, 2008 12:54 PMHi all,
I'm trying to evict manualy all nodes from memory cache to cache loader (mysql datastore).
I'm doing this as I want to keep data from cache even if I shutdown JBoss server, so I want to store physicaly datas , and when I start Jboss another time, it will bring up all datas from cacheloader.
This is the code :
public void backupAllCache() { this.log.info("launching backup cache"); Fqn fqn = Fqn.fromString("/root/"); try { Node root = this.cache.get(new Fqn(fqn, "smu")); Map childs = root.getChildren(); Set keys = childs.keySet(); for (Iterator iterator = keys.iterator(); iterator.hasNext();) { Object object = (Object) iterator.next(); String k = (String)object; Node child = (Node)childs.get(k); this.cache.evict(child.getFqn()); } } catch (CacheException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
The nodes are deleted from memory but doesn't go to cache loader.
Here is my config cache :
<?xml version="1.0" encoding="UTF-8" ?> <server> <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar" /> <mbean code="org.jboss.cache.aop.PojoCache" name="jboss.cache:service=PojoCache"> <depends>jboss:service=Naming</depends> <depends>jboss:service=TransactionManager</depends> <depends>jboss.jca:service=DataSourceBinding,name=my-ds</depends> <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute> <attribute name="NodeLockingScheme">PESSIMISTIC</attribute> <attribute name="IsolationLevel">REPEATABLE_READ</attribute> <attribute name="CacheMode">LOCAL</attribute> <attribute name="LockAcquisitionTimeout">15000</attribute> <attribute name="EvictionPolicyClass">org.jboss.cache.aop.eviction.AopLRUPolicy</attribute> <attribute name="EvictionPolicyConfig"> <config> <attribute name="wakeUpIntervalSeconds">2</attribute> <!-- Cache wide default --> <region name="/_default_"> <attribute name="maxNodes">100000</attribute> <attribute name="timeToLiveSeconds">0</attribute> </region> <region name="/root/smu"> <attribute name="maxNodes">100000</attribute> <attribute name="timeToLiveSeconds">0</attribute> </region> </config> </attribute> <attribute name="CacheLoaderConfiguration"> <config> <passivation>true</passivation> <shared>false</shared> <preload></preload> <cacheloader> <class>org.jboss.cache.loader.JDBCCacheLoader</class> <properties> cache.jdbc.datasource=java:/my-ds cache.jdbc.table.drop=false </properties> <async>false</async> <fetchPersistentState>true</fetchPersistentState> <ignoreModifications>false</ignoreModifications> </cacheloader> </config> </attribute> </mbean> </server>
So, to conclude, if anybody knows why this manual evicting is not working ??
Otherelse, If somebody knows also a simpliest way to evict automaticly all nodes from memory to cacheloader when Jboss shutdown ????
Thanks all!
ps : I use Jboss 4.05GA and JbossCache 1.4.1 SP3.