11 Replies Latest reply on Jun 22, 2016 4:45 PM by pferraro

    WildFly10: What is the right way to get preconfigured Infinispan cache instance?

    maxoid

      Dear forum,

       

      Does someone managed to get access to the preconfigured Infinispan cache instance in the WildFly 10? Because, I can't to do it (at least the same way as in WildFly9)

       

      Here was my way:

       

      I just uses a cache with a custom store configuration. Cache configured through the jboss-cli like this:

       

      /profile=full-ha/subsystem=infinispan/cache-container=cacheContainer:add()
      /profile=full-ha/subsystem=infinispan/cache-container=cacheContainer/transport=TRANSPORT:add(lock-timeout=60000)
      /profile=full-ha/subsystem=infinispan/cache-container=cacheContainer/replicated-cache=test:add(mode=ASYNC)
      /profile=full-ha/subsystem=infinispan/cache-container=cacheContainer/replicated-cache=test/store=STORE:add(class=org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder,passivation=false,preload=false,purge=false,properties={dataLocation=${jboss.server.data.dir}/infinispan/container/testData,indexLocation=${jboss.server.data.dir}/infinispan/container/testIndex})
      

      I want to use a custom persistance implementation (corresponded modules added to the WildFly).

      Ok, I found, that the WF10 uses different configuration model (WFLY-4452 Use Flag.RESTART_RESOURCE_SERVICES for child resources of cache by pferraro · Pull Request #7407 · wildfly/wil…) and changed scripts accordingly.

      /profile=full-ha/subsystem=infinispan/cache-container=cacheContainer:add()
      /profile=full-ha/subsystem=infinispan/cache-container=acheContainer/transport=jgroups:add(lock-timeout=60000)
      /profile=full-ha/subsystem=infinispan/cache-container=cacheContainer/replicated-cache=test:add(mode=ASYNC)
      /profile=full-ha/subsystem=infinispan/cache-container=cacheContainer/replicated-cache=test/store=custom:add(class=org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder,passivation=false,preload=false,purge=false,properties={dataLocation=${jboss.server.data.dir}/infinispan/container/testData,indexLocation=${jboss.server.data.dir}/infinispan/container/testIndex})
      

       

      But it doesn't help.

       

      I know, that to start my Infinispan container in WF9 I need to inject a CacheContainer instance inside the EJB container and after that, I can use CacheContainer.getCache("test") to get access to a properly configured cache instance.

       

      @Singleton
      @Startup
      public class CacheAccessBean {
      
      @Resource(lookup = "java:jboss/infinispan/container/cacheContainer")
      private CacheContainer cc;
      
      @PostConstruct
      public void init() {
          Cache cache = cc.getCache("test");
      ...
      }
      

       

      This is not work in WilfFly10. As I can see, the CacheContainer which is injected into the EJB container doesn't have any named configurations. So the invocation of the CacheContainer.getCache("test") returns a default cache (without any specific configurations).

       

      I was told by Paul Ferraro, that I should use a direct injection of the Cache instance:

      @Resource(lookup="java:jboss/infinispan/cache/cacheContainer/test") Cache<K, V> cache;
      

       

      But such trick does not work. It didn't work in WF9 too. I just get a deploy time exception, that the resource reference "java:jboss/infinispan/cache/cacheContainer/test" cannot be populated (it just doesn't binded at all).

       

      What did I wrong? Is there any special trick to start Cache service with the predefined configuration in WildFly10?

       

      Thanks for any advice!

        • 1. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
          pferraro

          Please post your jgroups subsystem configuration, as well as any relevant stack traces.

          • 2. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
            maxoid

            Here is the full set of files: https://www.dropbox.com/sh/qq5u9cqxzjcm4ty/AAAiBsjogEzsID1z3BBjvTZ5a?dl=0

            (sources, binaries, logs)

            jgroups configuration was not changed after WildFly installation:

            <subsystem xmlns="urn:jboss:domain:jgroups:4.0">
                <channels default="ee">
                    <channel name="ee" stack="udp"/>
                </channels>
                <stacks>
                    <stack name="udp">
                        <transport type="UDP" socket-binding="jgroups-udp"/>
                        <protocol type="PING"/>
                        <protocol type="MERGE3"/>
                        <protocol type="FD_SOCK" socket-binding="jgroups-udp-fd"/>
                        <protocol type="FD_ALL"/>
                        <protocol type="VERIFY_SUSPECT"/>
                        <protocol type="pbcast.NAKACK2"/>
                        <protocol type="UNICAST3"/>
                        <protocol type="pbcast.STABLE"/>
                        <protocol type="pbcast.GMS"/>
                        <protocol type="UFC"/>
                        <protocol type="MFC"/>
                        <protocol type="FRAG2"/>
                    </stack>
                    <stack name="tcp">
                        <transport type="TCP" socket-binding="jgroups-tcp"/>
                        <protocol type="MPING" socket-binding="jgroups-mping"/>
                        <protocol type="MERGE3"/>
                        <protocol type="FD_SOCK" socket-binding="jgroups-tcp-fd"/>
                        <protocol type="FD"/>
                        <protocol type="VERIFY_SUSPECT"/>
                        <protocol type="pbcast.NAKACK2"/>
                        <protocol type="UNICAST3"/>
                        <protocol type="pbcast.STABLE"/>
                        <protocol type="pbcast.GMS"/>
                        <protocol type="MFC"/>
                        <protocol type="FRAG2"/>
                    </stack>
                </stacks>
            </subsystem>
            
            

             

            Log doesn't contains any stacktrace. Just an error:

            2016-04-06 06:14:28,817 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 78) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "infinispan-test-1.0-SNAPSHOT.war")]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"infinispan-test-1.0-SNAPSHOT\".\"infinispan-test-1.0-SNAPSHOT\".env.\"foo.InfinispanAccessBean\".testCache is missing [jboss.naming.context.java.jboss.infinispan.container.cacheContainer.test]"]}
            2016-04-06 06:14:28,817 ERROR [org.jboss.as.server] (ServerService Thread Pool -- 78) WFLYSRV0021: Deploy of deployment "infinispan-test-1.0-SNAPSHOT.war" was rolled back with the following failure message: {"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"infinispan-test-1.0-SNAPSHOT\".\"infinispan-test-1.0-SNAPSHOT\".env.\"foo.InfinispanAccessBean\".testCache is missing [jboss.naming.context.java.jboss.infinispan.container.cacheContainer.test]"]}
            
            
            • 3. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
              pferraro

              Did you perform a "reload" after adding your cache container and cache via the CLI?

              • 4. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
                pferraro

                Out of curiosity, does your CacheAccessBean use any CDI injections?

                • 5. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
                  pferraro

                  Also, does your /store=custom:add(...) operation complete successfully?  This would require a modification to the org.infinispan module to be able to use the soft-index file cache store - as it is not packaged in the default infinispan bundle.

                  • 6. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
                    maxoid

                    Did you perform a "reload" after adding your cache container and cache via the CLI?

                    Yes, sure.

                    Out of curiosity, does your CacheAccessBean use any CDI injections?

                    Not at all. You can check it in the sources.

                    Also, does your /store=custom:add(...) operation complete successfully?  This would require a modification to the org.infinispan module to be able to use the soft-index file cache store - as it is not packaged in the default infinispan bundle.

                    Yes, of course. As I said, the same code works perfectly in WF9. BTW, custom store module doesn't make any sense here. The problem is that I can use any standard configuration and it will not work too.

                    • 7. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
                      pferraro

                      I just checked your source code.

                      The problem resides on lines 23/24:

                          @Resource(lookup = "java:jboss/infinispan/container/cacheContainer/test")
                          private Cache<String,String> testCache;
                      
                      

                      Lines 23/24 should be:

                          @Resource(lookup = "java:jboss/infinispan/cache/cacheContainer/test")
                          private Cache<String,String> testCache;
                      
                      

                       

                      You can remove the injected CacheContainer completely.

                      1 of 1 people found this helpful
                      • 8. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
                        pferraro

                        Maxim Karavaev wrote:

                        BTW, custom store module doesn't make any sense here.

                        Agreed.

                        https://issues.jboss.org/browse/WFLY-6499

                        • 9. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
                          maxoid

                          Thank you Paul!

                           

                          Now I managed to start right configuration of the cache, but I can't make it replicable in cluster. But, this will be another story, ohh

                          • 10. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
                            monarch7680

                            I'm in the process of doing this now--cache is getting injected properly but is not replicating across the nodes in my cluster.  Do you have to adjust the default transport stack for the cluster to enable this?

                            • 11. Re: WildFly10: What is the right way to get preconfigured Infinispan cache instance?
                              pferraro

                              The default transport (I'm assuming you are using the ha or full-ha profile) uses the default channel (as defined by the JGroups subsystem), which uses the udp stack (which requires UDP multicast).  If multicasting is not enabled on your network, you should switch to the tcp-based stack. However, to fully diagnose the problem - you'll need to post your configuration, cache usage, and logs.