shuber      2005/09/30 18:32:33 CEST

  Added files:
    core/src/java/org/jahia/services/cache/oscache 
                                                   
UpdatingJavaGroupsListener.java 
  Log:
  Updates to improve clustering support. Seems there are still some sync 
problems.
  - Using patched OSCache to include support for cache update notification 
through cluster
  - Modified all model objects that used generator-class="increment" to now use 
a MultipleHiLoPerTableGenerator that uses a new hibernate_sequences table to 
store the last used IDs for each table.
  - Updated Jahia installation DB population scripts to include values for the 
new table
  - Updated IDEA projects to include all the new versions of libraries.
  
  Revision  Changes    Path
  1.1       +61 -0     
jahia/core/src/java/org/jahia/services/cache/oscache/UpdatingJavaGroupsListener.java
 (new)
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/cache/oscache/UpdatingJavaGroupsListener.java?rev=1.1&content-type=text/plain
  
  
  
  Index: UpdatingJavaGroupsListener.java
  ====================================================================
  package org.jahia.services.cache.oscache;
  
  import java.util.Date;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import com.opensymphony.oscache.base.Cache;
  import com.opensymphony.oscache.base.events.CacheEntryEvent;
  import com.opensymphony.oscache.base.events.CacheEntryEventListener;
  import com.opensymphony.oscache.plugins.clustersupport.ClusterNotification;
  import 
com.opensymphony.oscache.plugins.clustersupport.JavaGroupsBroadcastingListener;
  
  public class UpdatingJavaGroupsListener extends 
JavaGroupsBroadcastingListener implements CacheEntryEventListener{
  
        private final static Log        log     = LogFactory.getLog( 
UpdatingJavaGroupsListener.class );
  
      public static final int REMOVE_KEY = 1555;
        
        public void cacheEntryUpdated( CacheEntryEvent event ) {
                if( !Cache.NESTED_EVENT.equals( event.getOrigin() )
                                && !CLUSTER_ORIGIN.equals( event.getOrigin() ) 
) {
                        if( log.isDebugEnabled() ) {
                                log.debug( "cacheEntryUpdated called (" + event 
+ ")" );
                        }
                        sendNotification( new ClusterNotification( REMOVE_KEY, 
event.getKey() ) );
                }
        }
  
      public void handleClusterNotification(ClusterNotification message) {
          if (cache == null) {
              log.warn("A cluster notification (" + message + ") was received, 
but no cache is registered on this machine. Notification ignored.");
  
              return;
          }
  
          if (log.isInfoEnabled()) {
              log.info("Cluster notification (" + message + ") was received.");
          }
  
          switch (message.getType()) {
              case ClusterNotification.FLUSH_KEY:
                  cache.flushEntry((String) message.getData(), CLUSTER_ORIGIN);
                  break;
              case ClusterNotification.FLUSH_GROUP:
                  cache.flushGroup((String) message.getData(), CLUSTER_ORIGIN);
                  break;
              case ClusterNotification.FLUSH_PATTERN:
                  cache.flushPattern((String) message.getData(), 
CLUSTER_ORIGIN);
                  break;
              case ClusterNotification.FLUSH_CACHE:
                  cache.flushAll((Date) message.getData(), CLUSTER_ORIGIN);
                  break;
              case REMOVE_KEY:
                                String key = (String) message.getData();
                                log.debug("Removing key "+key);
                                cache.removeEntry(((String) 
message.getData()),CLUSTER_ORIGIN );
                  break;
              default:
                  log.error("The cluster notification (" + message + ") is of 
an unknown type. Notification ignored.");
          }
      }
  }

Reply via email to