12 Replies Latest reply on Mar 28, 2011 5:59 AM by Dan Berindei

    How put, replace and remove methods are implemented in infinispan

    venkatesha k c Newbie

      Hi,

       

      I'm working on infinispan from the past 1 month.

      Its performance is really outstanding.

      I'm keen interested to know how put, replace and remove methods are implemented.

       

      Please reply ASAP.

       

      thanks

      --Venkatesha.k.c

        • 2. How put, replace and remove methods are implemented in infinispan
          venkatesha k c Newbie

          hi ,

           

          thanks for the useful answer.

           

          I'm trying to store a cache in another cache, but its throwing errors.

          Please help me to get out of these errors.

          thanks in advance.

           

          SEVERE: Execution error:

          org.infinispan.CacheException: java.lang.RuntimeException: Failure to marshal argument(s)

                    at org.infinispan.util.Util.rewrapAsCacheException(Util.java:477)

                    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.invokeRemoteCommands(CommandAwareRpcDispatcher.java:127)

                    at org.infinispan.remoting.transport.jgroups.JGroupsTransport.invokeRemotely(JGroupsTransport.java:399)

                    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:101)

                    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:125)

                    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:230)

                    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:217)

                    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:213)

                    at org.infinispan.interceptors.DistributionInterceptor.handleWriteCommand(DistributionInterceptor.java:353)

                    at org.infinispan.interceptors.DistributionInterceptor.visitPutKeyValueCommand(DistributionInterceptor.java:185)

                    at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)

                    at org.infinispan.interceptors.LockingInterceptor.visitPutKeyValueCommand(LockingInterceptor.java:297)

                    at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                    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.visitPutKeyValueCommand(AbstractVisitor.java:58)

                    at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)

                    at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:184)

                    at org.infinispan.interceptors.TxInterceptor.visitPutKeyValueCommand(TxInterceptor.java:132)

                    at org.infinispan.interceptors.DistTxInterceptor.visitPutKeyValueCommand(DistTxInterceptor.java:76)

                    at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)

                    at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:87)

                    at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:58)

                    at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:58)

                    at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                    at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:273)

                    at org.infinispan.CacheDelegate.put(CacheDelegate.java:444)

                    at org.infinispan.CacheSupport.put(CacheSupport.java:80)

                    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                    at java.lang.Thread.run(Thread.java:662)

          Caused by: java.lang.RuntimeException: Failure to marshal argument(s)

                    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher$ReplicationTask.marshallCall(CommandAwareRpcDispatcher.java:244)

                    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher$ReplicationTask.call(CommandAwareRpcDispatcher.java:271)

                    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.invokeRemoteCommands(CommandAwareRpcDispatcher.java:125)

                    ... 35 more

          Caused by: org.infinispan.marshall.NotSerializableException: org.infinispan.CacheDelegate

          Caused by: an exception which occurred:

                    in object org.infinispan.CacheDelegate@1f7708

                    in object org.infinispan.commands.write.PutKeyValueCommand@4b9b5179

                    in object org.infinispan.commands.remote.SingleRpcCommand@7ebc8999

          org.infinispan.CacheException: java.lang.RuntimeException: Failure to marshal argument(s)

                    at org.infinispan.util.Util.rewrapAsCacheException(Util.java:477)

                    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.invokeRemoteCommands(CommandAwareRpcDispatcher.java:127)

                    at org.infinispan.remoting.transport.jgroups.JGroupsTransport.invokeRemotely(JGroupsTransport.java:399)

                    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:101)

                    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:125)

                    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:230)

                    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:217)

                    at org.infinispan.remoting.rpc.RpcManagerImpl.invokeRemotely(RpcManagerImpl.java:213)

                    at org.infinispan.interceptors.DistributionInterceptor.handleWriteCommand(DistributionInterceptor.java:353)

                    at org.infinispan.interceptors.DistributionInterceptor.visitPutKeyValueCommand(DistributionInterceptor.java:185)

                    at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)

                    at org.infinispan.interceptors.LockingInterceptor.visitPutKeyValueCommand(LockingInterceptor.java:297)

                    at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                    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.visitPutKeyValueCommand(AbstractVisitor.java:58)

                    at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)

                    at org.infinispan.interceptors.TxInterceptor.enlistWriteAndInvokeNext(TxInterceptor.java:184)

                    at org.infinispan.interceptors.TxInterceptor.visitPutKeyValueCommand(TxInterceptor.java:132)

                    at org.infinispan.interceptors.DistTxInterceptor.visitPutKeyValueCommand(DistTxInterceptor.java:76)

                    at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                    at org.infinispan.interceptors.base.CommandInterceptor.invokeNextInterceptor(CommandInterceptor.java:118)

                    at org.infinispan.interceptors.InvocationContextInterceptor.handleAll(InvocationContextInterceptor.java:87)

                    at org.infinispan.interceptors.InvocationContextInterceptor.handleDefault(InvocationContextInterceptor.java:58)

                    at org.infinispan.commands.AbstractVisitor.visitPutKeyValueCommand(AbstractVisitor.java:58)

                    at org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(PutKeyValueCommand.java:76)

                    at org.infinispan.interceptors.InterceptorChain.invoke(InterceptorChain.java:273)

                    at org.infinispan.CacheDelegate.put(CacheDelegate.java:444)

                    at org.infinispan.CacheSupport.put(CacheSupport.java:80)

                    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                    at java.lang.Thread.run(Thread.java:662)

          Caused by: java.lang.RuntimeException: Failure to marshal argument(s)

                    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher$ReplicationTask.marshallCall(CommandAwareRpcDispatcher.java:244)

                    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher$ReplicationTask.call(CommandAwareRpcDispatcher.java:271)

                    at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.invokeRemoteCommands(CommandAwareRpcDispatcher.java:125)

                    ... 35 more

          Caused by: org.infinispan.marshall.NotSerializableException: org.infinispan.CacheDelegate

          Caused by: an exception which occurred:

                    in object org.infinispan.CacheDelegate@1f7708

                    in object org.infinispan.commands.write.PutKeyValueCommand@4b9b5179

                    in object org.infinispan.commands.remote.SingleRpcCommand@7ebc8999

          • 3. Re: How put, replace and remove methods are implemented in infinispan
            Christian Kulenkampff Newbie

            Use the cache name or AtomicHashMap instead. Are you new to Java?

            • 4. Re: How put, replace and remove methods are implemented in infinispan
              venkatesha k c Newbie

              hi Chris,

               

              Thanks for the answer.

              Yes , just 6 months.

               

              It will be very useful if you provide some examples.

              Also, I'm interesting to know in Infinispan, how they are parsing the xml file which is given as an argument for DefaultCacheManager("conf.xml").

              Thanks

              --Venkatesha.k.c

              • 5. Re: How put, replace and remove methods are implemented in infinispan
                Christian Kulenkampff Newbie
                //node1
                configCache.put("cacheUsedForXY", cacheXY.getName());
                //node2
                Cache c=manager.getCache((String)configCache.get("cacheUsedForXY"));
                

                 

                http://docs.jboss.org/infinispan/5.0/apidocs/org/infinispan/atomic/AtomicHashMap.html

                 

                Maybe you should work on your java knowledge on a more basic level first.

                • 6. Re: How put, replace and remove methods are implemented in infinispan
                  venkatesha k c Newbie

                  hi Chris,

                   

                  Yes, I'm

                  I wanted to know how rpcDispatcher from JGroups is implemented in Infinispan.

                  It plays the major role in sharing data cache with another node.

                   

                  I tried with your snippet. I'm using JGroups tcp configuartion for clustering.

                  Its throwing errors while replicating to another node.

                   

                  Thanks in Advance

                   

                  Cheer....!

                  • 7. Re: How put, replace and remove methods are implemented in infinispan
                    Christian Kulenkampff Newbie

                    You can browse the entire sourcecode of infinispan.

                    https://github.com/infinispan/infinispan/blob/master/core/src/main/java/

                    Look for org.infinispan.remoting.transport.jgroups.JGroupsTransport

                     

                    The snippet works for me - REPL_SYNC for configCache. I am unsure if cache configs are synchronized automatically, you should ensure this.

                    • 8. Re: How put, replace and remove methods are implemented in infinispan
                      venkatesha k c Newbie

                      hi Chris,

                       

                      I'm browsing entire code.

                       

                      I'm keen interested to know that if SYNC_DIST mode is set, how this configuration is read and used within the code.

                      I need the flow from parsing to setting the above configuration.

                      Please guide me to know the flow ASAP.

                       

                      Thanks in advance

                       

                      Regards

                      --Venkatesha K.C.

                      • 9. Re: How put, replace and remove methods are implemented in infinispan
                        Christian Kulenkampff Newbie

                        Just load the code into an IDE like Netbeans or Eclipse and you can explore it by yourself via usage search etc. It should be no problem to understand everything by looking at the code and the wiki documents. Many design patterns like "Visitor" or "Command" are used which will make it easier for you.

                        • 10. How put, replace and remove methods are implemented in infinispan
                          Galder Zamarreño Master

                          Btw, it seems like you have a Cache stored in a cache which is not possible since it's not marshallable.

                          • 11. Re: How put, replace and remove methods are implemented in infinispan
                            venkatesha k c Newbie

                            hi Galder,

                             

                            yes you are rt.

                             

                            so, I started to use xstream to create a string to put in cache.

                             

                            i need some information about collections in java.

                             

                            i need a data structure to retrieve the data very quickly.

                            Please suggests the best one which has the best throughput with minimum latency in doing storing and retrieving data.

                             

                            thanks

                            venkatesha.k.c

                            • 12. Re: How put, replace and remove methods are implemented in infinispan
                              Dan Berindei Expert

                              There is no "best collection", each collection can be the best in some use cases.

                               

                              Do you know how you're going to store and retrieve the data? Are you going to need random access? Will you have multiple threads reading and writing?

                               

                              In general the best way to decide what the best collection works best in a particular use case is to write a prototype using different collections and profile it to see which collection actually performs better.