1 2 Previous Next 16 Replies Latest reply on Oct 6, 2009 8:20 AM by araz

    Sync cache store data on a defined intervals

      How is the cache store data updated? I assume the store process is triggered by data change in cache. Is that right? Is it possible to sync cache store data with cache on defined intervals?

        • 1. Re: Sync cache store data on a defined intervals
          manik

          By default the cache stores are updated in the same process thread that updates the cache. To do this periodically (for performance reasons) look at the async attribute of the cache store. Also see the javadocs:

          http://docs.jboss.org/infinispan/4.0/apidocs/org/infinispan/loaders/decorators/AsyncStore.html

          • 2. Re: Sync cache store data on a defined intervals

            thanks manik. but I came across another problem on creating a cluster. here is my cache config:

            <infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:infinispan:config:4.0">
             <global>
             <transport clusterName="myCluster"/>
             </global>
            
             <default>
             <clustering mode="distribution">
             <l1 enabled="true" lifespan="60000"/>
             <hash numOwners="2" rehashRpcTimeout="60000"/>
             <sync/>
             </clustering>
             </default>
            
             <namedCache name="accounts">
             <eviction wakeUpInterval="5000" maxEntries="1000" strategy="FIFO"/>
             <expiration lifespan="600" maxIdle="1000"/>
             <loaders passivation="false" shared="false" preload="true">
             <loader class="com.magfa.gateway.dao.infinispan.jdbcstore.AccountJdbcCacheStore" fetchPersistentState="true"
             ignoreModifications="false" purgeOnStartup="true">
             <properties/>
             <singletonStore enabled="true" pushStateWhenCoordinator="true" pushStateTimeout="20000"/>
             <async enabled="true" threadPoolSize="5"/>
             </loader>
             </loaders>
             </namedCache>
            </infinispan>
            


            when I try to update the cache I get this exception:
            2009-09-29 13:41:34,883 ERROR [infinispan.remoting.rpc.RpcManagerImpl:99] - unexpected error while replicating
            java.lang.ClassCastException: java.lang.OutOfMemoryError cannot be cast to org.infinispan.remoting.responses.Response
            at org.infinispan.remoting.transport.jgroups.JGroupsTransport.invokeRemotely(JGroupsTransport.java:330)
            at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:88)
            at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:107)
            at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:214)
            at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:201)
            at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:197)
            at org.infinispan.interceptors.DistributionInterceptor.handleWriteCommand(DistributionInterceptor.java:291)
            at org.infinispan.interceptors.DistributionInterceptor.visitReplaceCommand(DistributionInterceptor.java:168)
            at org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:59)
            at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
            at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)
            at org.infinispan.commands.AbstractVisitor.visitReplaceCommand(AbstractVisitor.java:65)
            at org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:59)
            at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
            at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:179)
            at org.infinispan.interceptors.TxInterceptor.visitReplaceCommand(TxInterceptor.java:136)
            at org.infinispan.interceptors.DistTxInterceptor.visitReplaceCommand(DistTxInterceptor.java:90)
            at org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:59)
            at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
            at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:48)
            at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:34)
            at org.infinispan.commands.AbstractVisitor.visitReplaceCommand(AbstractVisitor.java:65)
            at org.infinispan.commands.write.ReplaceCommand.acceptVisitor(ReplaceCommand.java:59)
            at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:237)
            at org.infinispan.CacheDelegate.replace(CacheDelegate.java:395)
            at org.infinispan.CacheDelegate.replace(CacheDelegate.java:561)
            at org.infinispan.CacheDelegate.replace(CacheDelegate.java:150)
            at com.magfa.gateway.dao.infinispan.InfinispanBillingDao.decreseCredit(InfinispanBillingDao.java:143)
            ...

            and this is how I try to update cache on InfinispanBillingDao.decreseCredit: 143 :

            cache.getAdvancedCache().replace(accountId, oldAccount, newAccount);

            anyone knows what the problem might be?

            • 3. Re: Sync cache store data on a defined intervals
              manik

              Tune your eviction to be more aggressive? Or use a larger heap size?

              • 4. Re: Sync cache store data on a defined intervals

                It doesn't solve the problem. There must be something wrong with jgroups I assume. Changed accounts update to this:

                cache.remove(accountId);
                cache.put(accountId, newAccount);

                and the exception changed to TimeoutException:

                2009-09-29 14:51:32,462 ERROR [org.infinispan.interceptors.InvocationContextInterceptor:55] - Execution error:
                org.infinispan.util.concurrent.TimeoutException: Replication timeout for araz-desktop-20981
                at org.infinispan.remoting.transport.jgroups.JGroupsTransport.invokeRemotely(JGroupsTransport.java:325)
                at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:88)
                at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:107)
                at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:214)
                at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:201)
                at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:197)
                at org.infinispan.interceptors.DistributionInterceptor.handleWriteCommand(DistributionInterceptor.java:291)
                at org.infinispan.interceptors.DistributionInterceptor.visitRemoveCommand(DistributionInterceptor.java:157)
                at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:70)
                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
                at org.infinispan.interceptors.base.CommandInterceptor.handleDefault(CommandInterceptor.java:132)
                at org.infinispan.commands.AbstractVisitor.visitRemoveCommand(AbstractVisitor.java:61)
                at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:70)
                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
                at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:179)
                at org.infinispan.interceptors.TxInterceptor.visitRemoveCommand(TxInterceptor.java:131)
                at org.infinispan.interceptors.DistTxInterceptor.visitRemoveCommand(DistTxInterceptor.java:83)
                at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:70)
                at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)
                at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:48)
                at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:34)
                at org.infinispan.commands.AbstractVisitor.visitRemoveCommand(AbstractVisitor.java:61)
                at org.infinispan.commands.write.RemoveCommand.acceptVisitor(RemoveCommand.java:70)
                at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:237)
                at org.infinispan.CacheDelegate.remove(CacheDelegate.java:358)
                at org.infinispan.CacheDelegate.remove(CacheDelegate.java:183)
                at com.magfa.gateway.dao.infinispan.InfinispanBillingDao.decreseCredit(InfinispanBillingDao.java:144)
                ...

                • 5. Re: Sync cache store data on a defined intervals

                  enabled infinispan logs and this is The OutOfMemoryError stack trace I get:

                  2009-09-30 14:41:52,023 TRACE [VersionAwareMarshaller] (Incoming-2,SmppGatewayCluster,araz-desktop-18051) Read version 400
                  2009-09-30 14:41:52,416 TRACE [CommandAwareRpcDispatcher] (Incoming-2,SmppGatewayCluster,araz-desktop-18051) Problems invoking command.
                  java.lang.OutOfMemoryError: Java heap space
                  at org.jboss.marshalling.UTFUtils.readUTFBytes(UTFUtils.java:146)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:247)
                  at org.jboss.marshalling.river.BlockUnmarshaller.readToEndBlockData(BlockUnmarshaller.java:111)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1455)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1431)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1119)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:221)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:158)
                  at org.jboss.marshalling.AbstractUnmarshaller.readObject(AbstractUnmarshaller.java:81)
                  at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1562)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1471)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1119)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:221)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:158)
                  at org.jboss.marshalling.AbstractUnmarshaller.readObject(AbstractUnmarshaller.java:81)
                  at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1562)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1471)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1119)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:221)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:158)
                  at org.jboss.marshalling.AbstractUnmarshaller.readObject(AbstractUnmarshaller.java:81)
                  at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readObject(ReplicableCommandExternalizer.java:64)
                  at org.infinispan.marshall.jboss.ConstantObjectTable$ExternalizerAdapter.readObject(ConstantObjectTable.java:255)
                  at org.infinispan.marshall.jboss.ConstantObjectTable.readObject(ConstantObjectTable.java:242)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:307)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:158)
                  at org.jboss.marshalling.AbstractUnmarshaller.readObject(AbstractUnmarshaller.java:81)
                  at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readObject(ReplicableCommandExternalizer.java:64)
                  at org.infinispan.marshall.jboss.ConstantObjectTable$ExternalizerAdapter.readObject(ConstantObjectTable.java:255)
                  at org.infinispan.marshall.jboss.ConstantObjectTable.readObject(ConstantObjectTable.java:242)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:307)
                  at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:158)

                  • 6. Re: Sync cache store data on a defined intervals
                    manik

                    What version of Infinispan are you using?

                    • 7. Re: Sync cache store data on a defined intervals

                      4.0.0.BETA1

                      • 8. Re: Sync cache store data on a defined intervals

                        With BETA1 OutOfMemory error happens on cache sync process. if an item is removed or replaced in the cache. Trying with ALPHA6 the error occures when a cache node starts and tries to join the cluster.
                        here is the stack trace using ALPHA6 if it helps:

                        java.lang.OutOfMemoryError: Java heap space
                        at org.jboss.marshalling.UTFUtils.readUTFBytes(UTFUtils.java:146)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:247)
                        at org.jboss.marshalling.river.BlockUnmarshaller.readToEndBlockData(BlockUnmarshaller.java:111)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1455)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1431)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1119)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:221)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:158)
                        at org.jboss.marshalling.AbstractUnmarshaller.readObject(AbstractUnmarshaller.java:81)
                        at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1562)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1471)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1119)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:221)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:158)
                        at org.jboss.marshalling.AbstractUnmarshaller.readObject(AbstractUnmarshaller.java:81)
                        at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1562)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1471)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1119)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:221)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:158)
                        at org.jboss.marshalling.AbstractUnmarshaller.readObject(AbstractUnmarshaller.java:81)
                        at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readObject(ReplicableCommandExternalizer.java:62)
                        at org.infinispan.marshall.jboss.ConstantObjectTable$ExternalizerAdapter.readObject(ConstantObjectTable.java:261)
                        at org.infinispan.marshall.jboss.ConstantObjectTable.readObject(ConstantObjectTable.java:232)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:307)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:158)
                        at org.jboss.marshalling.AbstractUnmarshaller.readObject(AbstractUnmarshaller.java:81)
                        at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readObject(ReplicableCommandExternalizer.java:62)
                        at org.infinispan.marshall.jboss.ConstantObjectTable$ExternalizerAdapter.readObject(ConstantObjectTable.java:261)
                        at org.infinispan.marshall.jboss.ConstantObjectTable.readObject(ConstantObjectTable.java:232)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:307)
                        at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:158)

                        • 9. Re: Sync cache store data on a defined intervals
                          manik

                          What actually is in your newAccount instance? Can you describe the object a bit?

                          • 10. Re: Sync cache store data on a defined intervals

                            It's an instance of Account that it's credit is reduced. The Account class is:

                            public class Account implements Comparable, Serializable {
                             private final long id;
                             private final int hashCode;
                             private final String name;
                             private volatile double credit;
                             private final AtomicLong sent;
                             private final AtomicLong received;
                             private final AtomicLong rejectedSent;
                             private final AtomicLong rejectedReceived;
                             private final double outgoingCost;
                             private final double incomingCost;
                             private final boolean postpaid;
                             private final boolean prepaid;
                            ...
                            getters and setters
                            


                            • 11. Re: Sync cache store data on a defined intervals

                              It is an instance of Account class. The Account class is:

                              public class Account implements Comparable, Serializable {
                              private final long id;
                              private final int hashCode;
                              private final String name;
                              private volatile double credit;
                              private final AtomicLong sent;
                              private final AtomicLong received;
                              private final AtomicLong rejectedSent;
                              private final AtomicLong rejectedReceived;
                              private final double cost;
                              private final boolean postpaid;
                              private final boolean prepaid;
                              ...
                              with getters and setters

                              • 12. Re: Sync cache store data on a defined intervals
                                dmlloyd

                                Also is there any way you can post the ENTIRE stack trace with the object trace at the bottom?

                                • 13. Re: Sync cache store data on a defined intervals
                                  galder.zamarreno

                                  On top of what Manik is requesting, what JDK are you running?

                                  • 14. Re: Sync cache store data on a defined intervals
                                    galder.zamarreno

                                    As well as providing the JDK information, in order to get object trace information that David is refering to (this trace info is explained in http://www.jboss.org/community/wiki/infinispantechnicalfaqs#How_do_I_get_more_information_on_marshallingunmarshalling_exceptions, please build infinispan trunk calling 'mvn install' (svn trunk is located in http://anonsvn.jboss.org/repos/infinispan/trunk/) and try again.

                                    1 2 Previous Next