[jboss-user] [Beginners Corner] - JBossCache, PojoCache & Serialization
IT2Be
do-not-reply at jboss.com
Tue Jun 12 11:08:00 EDT 2007
Hi,
I have started implementing JBossCache/PojoCache and stumble to the following:
I (basically) use the config files as provided through the samples. I also play with PojoCache 2.0. Java 1.5
The Config files are below and I use the annotations as described.
The issue is the following: I have an application that is very memory consuming so I try to cache the overflow of objects to disk.
As you can see I set the cache mode to be LOCAL, cacheloader is JdbmCacheLoader is and marshallNonSerializable = true.
1. After closing the app I expect the table to be cleared but somehow this does not happen.
2. From what I understand my objects don't need to be serialized but when I don't do this jboss complains: Jun 12, 2007 4:40:42 PM org.jboss.cache.eviction.BaseEvictionAlgorithm evictCacheNode
| SEVERE: Eviction of /__JBossInternal__/9e13ccf9-0908-4234-bd1f-cf0f1deea048/1426servoy_sample_auto_pdf-1/_ID_/5c4o16-rj0vpp-f2uhehnn-1-f2uhehq1-3 failed
| java.lang.RuntimeException: java.io.NotSerializableException: com.it2be.analyzer.repository.Style
| at org.jboss.cache.CacheImpl.invokeMethod(CacheImpl.java:3860)
| .....
3. Serializing then is not the solution either. After a while (I guess when caching to disk really takes place) I see the following error:Jun 12, 2007 5:01:42 PM org.jboss.cache.eviction.BaseEvictionAlgorithm evictCacheNode
| WARNING: Eviction of /e9737027-7423-45ad-b3d7-87a5f5be2174 timed out, retrying laterand ultimately, out of the blue, I receive the next error where the class is exactly the same as the ones before:Jun 12, 2007 5:02:46 PM org.jboss.cache.pojo.interceptors.PojoTxInterceptor invoke
| WARNING: attach: exception occurred: java.lang.RuntimeException: java.io.InvalidClassException: com.it2be.analyzer.repository.Method; no valid constructor
I am new to caching so I hope you forgive me my ignorance and hope you can help me to solve these issues.
Thanks,
Marcel
--- cluster
<?xml version="1.0" encoding="UTF-8"?>
|
| <server>
| <mbean code="org.jboss.cache.aop.PojoCache"
| name="jboss.cache:service=PojoCache">
| <depends>jboss:service=TransactionManager</depends>
|
| <!-- Configure the TransactionManager -->
| <attribute name="TransactionManagerLookupClass">
| org.jboss.cache.transaction.DummyTransactionManagerLookup</attribute>
|
| <!-- Isolation level : SERIALIZABLE
| REPEATABLE_READ (default)
| READ_COMMITTED
| READ_UNCOMMITTED
| NONE
| -->
| <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
|
| <!-- Valid modes are LOCAL, REPL_ASYNC and REPL_SYNC -->
| <attribute name="CacheMode">LOCAL</attribute>
|
| <!-- Just used for async repl: use a replication queue -->
| <attribute name="UseReplQueue">false</attribute>
|
| <!-- Replication interval for replication queue (in ms) -->
| <attribute name="ReplQueueInterval">0</attribute>
|
| <!-- Max number of elements which trigger replication -->
| <attribute name="ReplQueueMaxElements">0</attribute>
|
| <!-- Name of cluster. Needs to be the same for all clusters, in order
| to find each other
| -->
| <attribute name="ClusterName">Analyzer</attribute>
|
| <!-- Whether or not to fetch state on joining a cluster -->
| <attribute name="FetchStateOnStartup">true</attribute>
|
| <!-- The max amount of time (in milliseconds) we wait until the
| initial state (ie. the contents of the cache) are retrieved from
| existing members in a clustered environment
|
| -->
| <attribute name="InitialStateRetrievalTimeout">5000</attribute>
|
| <!-- Number of milliseconds to wait until all responses for a
| synchronous call have been received.
| -->
| <attribute name="SyncReplTimeout">15000</attribute>
|
| <!-- Max number of milliseconds to wait for a lock acquisition -->
| <attribute name="LockAcquisitionTimeout">10000</attribute>
|
| <!-- Name of the eviction policy class. -->
| <attribute name="EvictionPolicyClass"/>
|
| <attribute name="EvictionPolicyConfig">
| <config>
| <attribute name="wakeUpIntervalSeconds">1</attribute>
|
| <!-- This defaults to 200000 if not specified -->
| <attribute name="eventQueueSize">200000</attribute>
|
| <!-- Name of the DEFAULT eviction policy class. -->
| <attribute name="policyClass">org.jboss.cache.eviction.LFUPolicy</attribute>
| <attribute name="timeToLiveSeconds">60</attribute>
|
| <!-- Cache wide default -->
| <region name="/_default_">
| <attribute name="maxNodes">10</attribute>
| </region>
| </config>
| </attribute>
|
| <!-- New 1.3.x cache loader config block -->
| <attribute name="CacheLoaderConfig">
| <config>
|
| <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
| <passivation>true</passivation>
| <preload>/</preload>
| <shared>false</shared>
|
| <!-- we can now have multiple cache loaders, which get chained -->
| <cacheloader>
| <class>org.jboss.cache.loader.jdbm.JdbmCacheLoader</class>
| <!-- same as the old CacheLoaderConfig attribute
| location=/tmp this can be part of the properties.
| location=/tmp/JBossCacheFileCacheLoader
| -->
| <properties>location=/Users/marceltrapman/Desktop/cache</properties>
| <!-- whether the cache loader writes are asynchronous -->
| <async>false</async>
| <!-- only one cache loader in the chain may set fetchPersistentState to true.
|
| An exception is thrown if more than one cache loader sets this to true. -->
| <fetchPersistentState>true</fetchPersistentState>
|
| <!-- determines whether this cache loader ignores writes - defaults to false. -->
| <ignoreModifications>false</ignoreModifications>
| </cacheloader>
|
| </config>
| </attribute>
|
| </mbean>
|
| </server>
--- cluster pojo
<?xml version="1.0" encoding="UTF-8"?>
|
| <!--
| This is the PojoCache configuration file that specifies:
| 1. Interceptor stack for API
| 2. Annotation binding for POJO (via "prepare" element)
|
| Basically, this is a variant of jboss-aop.xml. Note that
| except for the customization of interceptor stack, you should
| not need to modify this file.
|
| To run PojoCache, you will need to define a system property:
| jboss.aop.path that contains the path to this file such that JBoss Aop
| can locate it.
| -->
| <aop>
|
| <!--
| This defines the PojoCache 2.0 interceptor stack. Unless necessary, don't modify the stack here!
| -->
|
| <!-- Check id range validity -->
| <interceptor name="CheckId"
| class="org.jboss.cache.pojo.interceptors.CheckIdInterceptor"
| scope="PER_INSTANCE"/>
|
| <!-- Track Tx undo operation -->
| <interceptor name="Undo"
| class="org.jboss.cache.pojo.interceptors.PojoTxUndoInterceptor"
| scope="PER_INSTANCE"/>
|
| <!-- Begining of interceptor chain -->
| <interceptor name="Start"
| class="org.jboss.cache.pojo.interceptors.PojoBeginInterceptor"
| scope="PER_INSTANCE"/>
|
| <!-- Check if we need a local tx for batch processing -->
| <interceptor name="Tx"
| class="org.jboss.cache.pojo.interceptors.PojoTxInterceptor"
| scope="PER_INSTANCE"/>
|
| <!--
| Mockup failed tx for testing. You will need to set PojoFailedTxMockupInterceptor.setRollback(true)
| to activate it.
| -->
| <interceptor name="MockupTx"
| class="org.jboss.cache.pojo.interceptors.PojoFailedTxMockupInterceptor"
| scope="PER_INSTANCE"/>
|
| <!-- Perform parent level node locking -->
| <interceptor name="TxLock"
| class="org.jboss.cache.pojo.interceptors.PojoTxLockInterceptor"
| scope="PER_INSTANCE"/>
|
| <!-- Interceptor to perform Pojo level rollback -->
| <interceptor name="TxUndo"
| class="org.jboss.cache.pojo.interceptors.PojoTxUndoSynchronizationInterceptor"
| scope="PER_INSTANCE"/>
|
| <!-- Interceptor to used to check recursive field interception. -->
| <interceptor name="Reentrant"
| class="org.jboss.cache.pojo.interceptors.MethodReentrancyStopperInterceptor"
| scope="PER_INSTANCE"/>
|
| <!-- Whether to allow non-serializable pojo. Default is false. -->
| <interceptor name="MarshallNonSerializable"
| class="org.jboss.cache.pojo.interceptors.CheckNonSerializableInterceptor"
| scope="PER_INSTANCE">
| <attribute name="marshallNonSerializable">true</attribute>
| </interceptor>
|
| <!-- This defines the stack macro -->
| <stack name="Attach">
| <interceptor-ref name="Start"/>
| <interceptor-ref name="CheckId"/>
| <interceptor-ref name="MarshallNonSerializable"/>
| <interceptor-ref name="Tx"/>
|
|
| <!-- NOTE: You can comment this out during production although leaving it here is OK. -->
| <interceptor-ref name="MockupTx"/>
| <interceptor-ref name="TxLock"/>
| <interceptor-ref name="TxUndo"/>
| </stack>
|
| <stack name="Detach">
| <interceptor-ref name="Start"/>
| <interceptor-ref name="CheckId"/>
| <interceptor-ref name="Tx"/>
|
|
| <!-- NOTE: You can comment this out during production although leaving it here is OK. -->
| <interceptor-ref name="MockupTx"/>
| <interceptor-ref name="TxLock"/>
| <interceptor-ref name="TxUndo"/>
| </stack>
|
| <stack name="Find">
| <interceptor-ref name="Start"/>
| <interceptor-ref name="CheckId"/>
| </stack>
|
| <!--
| The following section should be READ-ONLY!! It defines the annotation binding to the stack.
| -->
|
|
| <!-- This binds the jointpoint to specific in-memory operations. Currently in PojoUtil. -->
| <bind
| pointcut="execution(*
| @org.jboss.cache.pojo.annotation.Reentrant->toString())">
| <interceptor-ref name="Reentrant"/>
| </bind>
|
| <bind
| pointcut="execution(*
| org.jboss.cache.pojo.PojoUtil->@org.jboss.cache.pojo.annotation.TxUndo(..))">
| <interceptor-ref name="Undo"/>
| </bind>
|
| <bind
| pointcut="execution(* org.jboss.cache.pojo.impl.PojoCacheImpl->@org.jboss.cache.pojo.annotation.Attach(..))">
| <stack-ref name="Attach"/>
| </bind>
|
| <bind
| pointcut="execution(* org.jboss.cache.pojo.impl.PojoCacheImpl->@org.jboss.cache.pojo.annotation.Detach(..))">
| <stack-ref name="Detach"/>
| </bind>
|
| <bind
| pointcut="execution(* org.jboss.cache.pojo.impl.PojoCacheImpl->@org.jboss.cache.pojo.annotation.Find(..))">
| <stack-ref name="Find"/>
| </bind>
|
| <!--
| Following is declaration for JDK50 annotation. You use the specific annotation on your
| POJO such that it can be instrumented. Idea is user will then need only to annotate like:
| @org.jboss.cache.pojo.annotation.Replicable
| in his POJO. There will be no need of jboss-aop.xml from user's side.
| -->
|
| <!-- If a POJO has PojoCachable annotation, it will be asepctized. -->
| <prepare
| expr="field(* $instanceof{@org.jboss.cache.pojo.annotation.Replicable}->*)"/>
|
| <!-- Observer and Observable to monitor field modification -->
| <bind
| pointcut="
| set(* $instanceof{@org.jboss.cache.pojo.annotation.Replicable}->*)
| ">
| <interceptor
| class="org.jboss.cache.pojo.observable.SubjectInterceptor"/>
| </bind>
|
| <introduction
| class="$instanceof{@org.jboss.cache.pojo.annotation.Replicable}">
| <mixin>
| <interfaces>org.jboss.cache.pojo.observable.Subject</interfaces>
| <class>org.jboss.cache.pojo.observable.SubjectImpl</class>
| <construction>new
| org.jboss.cache.pojo.observable.SubjectImpl(this)</construction>
| </mixin>
| </introduction>
| </aop>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4053609#4053609
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4053609
More information about the jboss-user
mailing list