2 Replies Latest reply on Aug 25, 2011 10:34 AM by javart1

    Question on configuration

    viniciuscarvalho

      Hi, I'm trying to use the fluent api to start a new cache:

       

      return new Configuration().fluent()

                                                .clustering()

                                                  .mode(Configuration.CacheMode.DIST_SYNC)

                                                  .sync()

                                                  .l1().lifespan(25000L)

                                                  .hash().numOwners(3)

                                                .build();

       

      But, the moment I try to run this, I get an error:

      Caused by: org.infinispan.config.ConfigurationException: Cache cannot use a clustered mode (DIST_SYNC) mode and not define a transport!

       

      I could not find a way to configure the transport on the API. I'm not using GlobalConfiguration cause I'm trying to use the cdi extension and my code actually looks like this:

       

      @Infinispan("clustered-cache")

                @Produces

                @ClusteredCache

                public Configuration getDefaultConfig(){

                          return new Configuration().fluent()

                                                .clustering()

                                                  .mode(Configuration.CacheMode.DIST_SYNC)

                                                  .sync()

                                                  .l1().lifespan(25000L)

                                                  .hash().numOwners(3)

                                                .build();

                }

       

      Any ideas?

       

      Regards

        • 1. Re: Question on configuration
          kevinpollet

          Hi,

           

          The GlobalConfiguration has to be defined at the CacheManager level.

          Here you have different ways to achieve this.

           

          • Override the default cache manager initialized with the GlobalConfiguration
          • Create a specific cache manager for your cache  initialized with the GlobalConfiguration

           

          For example something like that will work (in this example a specific cache manager is used):

           

           

          public class Config {
          
             @Clustered
             @Infinispan("clustered")
             @Produces
             public Configuration clusteredConfiguration() {
                return new Configuration().fluent()
                      .clustering().mode(Configuration.CacheMode.REPL_ASYNC)
                      .build();
             }
          
             @Clustered
             @Produces
             @ApplicationScoped
             public EmbeddedCacheManager specificCacheManager() {
                return new DefaultCacheManager(GlobalConfiguration.getClusteredDefault().fluent()
                      .transport().clusterName("shared-cache-cluster").addProperty("configurationFile", "jgroups-tcp.xml")
                      .build());
             }
          }
          

           

           

          For further details look at the documentation: https://docs.jboss.org/author/display/ISPN/CDI+Support

           

          Hope this help.

           

          --Kevin

          • 2. Re: Question on configuration
            javart1

            Add the following to your imports:

             

            import org.infinispan.remoting.transport.jgroups.JGroupsTransport;

             

             

            Then add the following to your configuration:

             

            globalcfg.fluent().transport().clusterName("cluster1")

                    .addProperty("configurationFile", "jgroups-udp.xml")

                    .transportClass(JGroupsTransport.class)

             

            Be sure to use a cluster name that is appropriate for your enviroment.  Also select the jgroups configuration file that works on your network.