1 2 Previous Next 28 Replies Latest reply on Aug 29, 2008 5:52 AM by galder.zamarreno Go to original post
      • 15. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
        galder.zamarreno

        The integration part is done now. I've got a source patch of Portal 2.7.x that can be applied to generate jboss-portal-ha.sar/ that uses the new cache provider.

        I've generated a hibernate-jbc-cacheprovider.jar v1.0.0.Beta1 as well.

        Brian, WDYT?

        • 16. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
          prabhat.jha

          Galder, can you please also mention what changed you ended up doing on portal side?

          • 17. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
            galder.zamarreno

             

            "prabhat.jha@jboss.com" wrote:
            Galder, can you please also mention what changed you ended up doing on portal side?


            It's just configuration changes to use the new provider and a bit of cleanup in the jboss-service.xml. I'll attach the patch and jar to the JIRA once we're happy with the code.

            • 18. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
              brian.stansberry

              Looked through your changes. I like the CacheProperties class. :)

              Only thing I see is we need to override localPutsOnly if the we are caching timestamps. Following patch does that:

              Index: /home/bes/dev/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/JBCCache.java
              ===================================================================
              --- /home/bes/dev/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/JBCCache.java (revision 76762)
              +++ /home/bes/dev/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/JBCCache.java (working copy)
              @@ -33,6 +33,7 @@
               import org.hibernate.cache.Cache;
              
               import org.hibernate.cache.CacheException;
              
               import org.hibernate.cache.StandardQueryCache;
              
              +import org.hibernate.cache.UpdateTimestampsCache;
              
               import org.jboss.cache.Fqn;
              
               import org.jboss.cache.config.Option;
              
               import org.jboss.cache.lock.TimeoutException;
              
              @@ -57,6 +58,7 @@
               private final Fqn regionFqn;
              
               private final TransactionManager transactionManager;
              
               private boolean queryCacheLocalWritesOnly;
              
              + private boolean localPutsOnly;
              
              
              
               private final CacheProperties cacheProperties;
              
              
              
              @@ -95,6 +97,8 @@
               {
              
               log.debug("TreeCache is not configured for region based marshalling");
              
               }
              
              +
              
              + this.localPutsOnly = this.cacheProperties.isLocalPutsOnly() && (regionName.contains(UpdateTimestampsCache.class.getName()) == false);
              
               }
              
              
              
               public Object get(Object key) throws CacheException {
              
              @@ -135,7 +139,7 @@
               public void put(Object key, Object value) throws CacheException {
              
               Transaction tx = suspend();
              
               try {
              
              - if (queryCacheLocalWritesOnly || cacheProperties.isLocalPutsOnly()) {
              
              + if (queryCacheLocalWritesOnly || localPutsOnly) {
              
               Option option = new Option();
              
               option.setCacheModeLocal(true);
              
               // Overloaded method isn't available, so have to use InvocationContext
              
              Index: /home/bes/dev/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticJBCCache.java
              ===================================================================
              --- /home/bes/dev/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticJBCCache.java (revision 76762)
              +++ /home/bes/dev/cluster/hibernate-jbc-cacheprovider/trunk/src/main/java/org/jboss/hibernate/jbc/cacheprovider/OptimisticJBCCache.java (working copy)
              @@ -31,6 +31,7 @@
               import org.hibernate.cache.OptimisticCache;
               import org.hibernate.cache.OptimisticCacheSource;
               import org.hibernate.cache.StandardQueryCache;
              +import org.hibernate.cache.UpdateTimestampsCache;
               import org.jboss.cache.Fqn;
               import org.jboss.cache.optimistic.DataVersion;
               import org.jboss.cache.config.Option;
              @@ -59,6 +60,7 @@
               private final Fqn regionFqn;
               private OptimisticCacheSource source;
               private boolean queryCacheLocalWritesOnly;
              + private boolean localPutsOnly;
              
               private final CacheProperties cacheProperties;
              
              @@ -95,6 +97,8 @@
               {
               log.debug("TreeCache is not configured for region based marshalling");
               }
              +
              + this.localPutsOnly = this.cacheProperties.isLocalPutsOnly() && (regionName.contains(UpdateTimestampsCache.class.getName()) == false);
               }
              
              
              @@ -128,7 +132,7 @@
               Option option = new Option();
               option.setFailSilently( true );
               option.setDataVersion( NonLockingDataVersion.INSTANCE );
              - option.setCacheModeLocal(queryCacheLocalWritesOnly);
              + option.setCacheModeLocal(queryCacheLocalWritesOnly || localPutsOnly);
               cache.remove( new Fqn( regionFqn, key ), "ITEM", option );
              
               option = new Option();
              @@ -137,7 +141,7 @@
               ? new DataVersionAdapter( currentVersion, currentVersion, source.getVersionComparator(), source.toString() )
               : NonLockingDataVersion.INSTANCE;
               option.setDataVersion( dv );
              - option.setCacheModeLocal(queryCacheLocalWritesOnly);
              + option.setCacheModeLocal(queryCacheLocalWritesOnly || localPutsOnly);
               cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
               }
               catch (Exception e) {
              @@ -188,7 +192,7 @@
               Option option = new Option();
               option.setFailSilently( true );
               option.setDataVersion( NonLockingDataVersion.INSTANCE );
              - option.setCacheModeLocal(queryCacheLocalWritesOnly);
              + option.setCacheModeLocal(queryCacheLocalWritesOnly || localPutsOnly);
               cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
               }
               catch (TimeoutException te) {


              I can check that in if it won't step on you.

              • 19. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
                brian.stansberry

                Only other comment is on the hibernate.treecache.querycache.local.writes.only, which only affects things if the cache region is StandardQueryCache. (Correctly so, as the use of that class in the region name is what lets us know its a query region.) Function of the property is basically to turn off the local-writes behavior if the user knows it's safe.

                Perhaps the property name should be hibernate.treecache.stdquerycache.local.writes.only or hibernate.treecache.standardquerycache.local.writes.only to reflect the fact that the property has a very limited scope.

                • 20. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
                  brian.stansberry

                  Further to the last post:

                  Since it's now configurable, this:

                  queryCacheLocalWritesOnly = StandardQueryCache.class.getName().equals(regionName) && this.cacheProperties.isQueryCacheLocalWritesOnly();


                  Can now become this:

                  queryCacheLocalWritesOnly = regionName.contains(StandardQueryCache.class.getName()) && this.cacheProperties.isQueryCacheLocalWritesOnly();


                  This will handle the case where the user provided a region prefix for the SessionFactory but the StandardQueryCache is still used, i.e. the passed in regionName becomes:

                  regionprefix.org.hibernate.cache.StandardQueryCache


                  I didn't do it that way in the EJB3 code because localWritesOnly was a last minute workaround that couldn't be disabled, so I wanted to limit it to the one case I knew we couldn't handle. The hibernate.treecache.standardquerycache.local.writes.only property gives us more freedom to do it right.

                  Further, I think
                  queryCacheLocalWritesOnly = regionName.contains(StandardQueryCache.class.getName()) && this.cacheProperties.isQueryCacheLocalWritesOnly();
                  should move above the
                  if (cache.getUseRegionBasedMarshalling())
                  code block. This functionality is no longer so closely related to marshalling issues; it's also a (configurable) performance optimization.

                  • 21. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
                    brian.stansberry

                    I know you're unavailable soon, so if you don't have time to do this stuff, let me know. If you have limited time, would prefer you spend it getting the config changes you mentioned to Prabhat; I can get him the binary.

                    • 22. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
                      galder.zamarreno

                      Prabhat, you can find a patch with the config changes in https://jira.jboss.org/jira/browse/JBCLUSTER-206

                      • 23. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
                        brian.stansberry

                        A first cut on the binary is attached as well.

                        • 24. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
                          brian.stansberry

                          Prabhat,

                          I can release this today as a CR1. Could even call it a GA if necessary, although I'd prefer to wait in do that in another 1.5 weeks after I come back from vacation next week. I'd like to blog about it and have no time this week.

                          One thing I'd like to change before cutting the release would be the name of the provider classes: from "org.jboss.hibernate.jbc.cacheprovider.(Optimistic)TreeCacheProvider" to "org.jboss.hibernate.jbc.cacheprovider.(Optimistic)JmxBoundTreeCacheProvider". Will that mess you guys up too much?

                          Reason for this is to conform to the naming pattern of the providers shipped (in a different package) in Hibernate:

                          TreeCacheProvider (which instantiates a JBC instance itself)
                          JndiBoundTreeCacheProvider (which looks for a JBC instance in JNDI)

                          JmxBoundTreeCacheProvider would then mean one that looks for a JBC instance in JMX. I could then easily enough create a TreeCacheProvider and a JndiBoundTreeCacheProvider that work like the standard hibernate equivalents.

                          • 25. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
                            prabhat.jha

                             

                            "bstansberry@jboss.com" wrote:
                            Prabhat,

                            One thing I'd like to change before cutting the release would be the name of the provider classes: from "org.jboss.hibernate.jbc.cacheprovider.(Optimistic)TreeCacheProvider" to "org.jboss.hibernate.jbc.cacheprovider.(Optimistic)JmxBoundTreeCacheProvider". Will that mess you guys up too much?


                            I think it should be okay.Only reference of this class I have in portal is in few hibernate configuration files

                             <property name="cache.provider_class">org.jboss.hibernate.jbc.cacheprovider.TreeCacheProvider</property>
                             <property name="treecache.mbean.object_name">portal:service=TreeCache,type=hibernate</property>
                            


                            So it will be simply changing value of cache.provider_class. Once you have the new jar, please let me know and I can do a quick sanity check before you leave so that you have more pleasant vacation. :-)



                            • 26. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
                              brian.stansberry

                              I renamed the JMX-based provider classes as described above and added the JNDI-based providers and the default versions that instantiate a cache from a config file.

                              This has been released as 1.0.0.GA. I decided not to do CR1; Prabhat if you see issues we can do a 1.0.1.

                              I can blog about it when I get back, or, Galder if you feel like blogging, go for it; you did most of the work and can rightly take the glory if you wish.

                              • 27. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
                                prabhat.jha

                                I tested the GA version with portal and my basic testing (start up, some simple deployment) does not show any problem.

                                • 28. Re: JBCLUSTER-206 - Extract HB/JBC integration layer from EJ
                                  galder.zamarreno

                                   

                                  "bstansberry@jboss.com" wrote:
                                  I can blog about it when I get back, or, Galder if you feel like blogging, go for it; you did most of the work and can rightly take the glory if you wish.


                                  I can look into this next week and send you a draft. I'd like to publish on my newly created blog in which i was planning to create a jboss category, so this would be a good way to kick off that category :)

                                  1 2 Previous Next