[exo-jcr-commits] exo-jcr SVN: r4008 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/infinispan and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Feb 23 07:40:22 EST 2011


Author: tolusha
Date: 2011-02-23 07:40:22 -0500 (Wed, 23 Feb 2011)
New Revision: 4008

Added:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ChangesKey.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java
Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexUpdateMonitor.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/PrivilegedISPNCacheHelper.java
   jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-config.xml
   jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-indexer.xml
   jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-lock.xml
Log:
EXOJCR-832: implementation

Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ChangesKey.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ChangesKey.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ChangesKey.java	2011-02-23 12:40:22 UTC (rev 4008)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.core.query.ispn;
+
+import org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.CacheKey;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * Date: 22.02.011
+ * 
+ * @author <a href="mailto:anatoliy.bazko at exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id: ChangesKey.java 34360 2010-11-11 11:11:11Z tolusha $
+ */
+public class ChangesKey extends CacheKey
+{
+
+   ChangesKey(String id)
+   {
+      super(id);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj instanceof ChangesKey)
+      {
+         ChangesKey key = (ChangesKey)obj;
+         return (key.hash == hash && key.id.equals(id));
+      }
+      else
+      {
+         return false;
+      }
+   }
+}

Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java	2011-02-23 12:40:22 UTC (rev 4008)
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.core.query.ispn;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.impl.core.query.IndexerChangesFilter;
+import org.exoplatform.services.jcr.impl.core.query.IndexerIoModeHandler;
+import org.exoplatform.services.jcr.impl.core.query.IndexingTree;
+import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
+import org.exoplatform.services.jcr.impl.core.query.SearchManager;
+import org.exoplatform.services.jcr.impl.core.query.jbosscache.ChangesFilterListsWrapper;
+import org.exoplatform.services.jcr.impl.core.query.lucene.ChangesHolder;
+import org.exoplatform.services.jcr.infinispan.ISPNCacheFactory;
+import org.exoplatform.services.jcr.infinispan.PrivilegedISPNCacheHelper;
+import org.exoplatform.services.jcr.util.IdGenerator;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.infinispan.Cache;
+import org.infinispan.CacheException;
+import org.infinispan.config.CacheLoaderManagerConfig;
+import org.infinispan.config.Configuration.CacheMode;
+import org.infinispan.loaders.AbstractCacheStoreConfig;
+import org.infinispan.loaders.decorators.AsyncStoreConfig;
+import org.infinispan.loaders.decorators.SingletonStoreConfig;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * Date: 23.02.2011
+ * 
+ * @author <a href="mailto:anatoliy.bazko at exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id: ISPNIndexChangesFilter.java 34360 2010-11-11 11:11:11Z tolusha $
+ */
+public class ISPNIndexChangesFilter extends IndexerChangesFilter
+{
+   /**
+    * Logger instance for this class
+    */
+   private final Log log = ExoLogger.getLogger("exo.jcr.component.core.ISPNIndexChangesFilter");
+
+   public static final String PARAM_INFINISPAN_CONFIGURATION = "infinispan-configuration";
+
+   public static final String PARAM_INFINISPAN_PUSHSTATE = "infinispan-sscl-push.state.enabled";
+
+   public static final String PARAM_INFINISPAN_PUSHSTATE_TIMEOUT = "infinispan-sscl-push.state.timeout";
+
+   // TODO eviction
+
+   /**
+    * ISPN cache.
+    */
+   private final Cache<Serializable, Object> cache;
+
+   /**
+    * ISPNIndexChangesFilter constructor.
+    */
+   public ISPNIndexChangesFilter(SearchManager searchManager, SearchManager parentSearchManager,
+      QueryHandlerEntry config, IndexingTree indexingTree, IndexingTree parentIndexingTree, QueryHandler handler,
+      QueryHandler parentHandler, ConfigurationManager cfm) throws IOException, RepositoryException,
+      RepositoryConfigurationException
+   {
+      super(searchManager, parentSearchManager, config, indexingTree, parentIndexingTree, handler, parentHandler, cfm);
+
+      // create cache using custom factory
+      ISPNCacheFactory<Serializable, Object> factory = new ISPNCacheFactory<Serializable, Object>(cfm);
+      cache = factory.createCache("Indexer-" + searchManager.getWsId(), config);
+
+      //      singletonStoreConfig.setSingletonStoreClass(IndexerSingletonStoreCacheLoader.class.getName());
+      // create SingletonStoreConfig
+      SingletonStoreConfig singletonStoreConfig = new SingletonStoreConfig();
+
+      Boolean pushState = config.getParameterBoolean(PARAM_INFINISPAN_PUSHSTATE, false);
+      Long pushStateTimeOut = config.getParameterTime(PARAM_INFINISPAN_PUSHSTATE_TIMEOUT, 10000L);
+
+      singletonStoreConfig.setPushStateWhenCoordinator(pushState);
+      singletonStoreConfig.setPushStateTimeout(pushStateTimeOut);
+      singletonStoreConfig.setSingletonStoreEnabled(true);
+
+      // initialize IndexerCacheLoader 
+      IndexerCacheStore indexerCacheStore = new IndexerCacheStore();
+
+      // create CacheLoaderConfig
+      AbstractCacheStoreConfig individualCacheStoreConfig = new AbstractCacheStoreConfig();
+      individualCacheStoreConfig.setSingletonStoreConfig(singletonStoreConfig);
+      individualCacheStoreConfig.setCacheLoaderClassName(IndexerCacheStore.class.getName());
+      individualCacheStoreConfig.setFetchPersistentState(false);
+      individualCacheStoreConfig.setIgnoreModifications(false);
+      individualCacheStoreConfig.setPurgeOnStartup(false);
+      
+      AsyncStoreConfig asyncStoreConfig = new AsyncStoreConfig();
+      asyncStoreConfig.setEnabled(false);
+      individualCacheStoreConfig.setAsyncStoreConfig(asyncStoreConfig);
+
+      // create CacheLoaderManagerConfig
+      CacheLoaderManagerConfig cacheLoaderManagerConfig = new CacheLoaderManagerConfig();
+      cacheLoaderManagerConfig.setShared(false);
+      cacheLoaderManagerConfig.setPassivation(false);
+      cacheLoaderManagerConfig.addCacheLoaderConfig(individualCacheStoreConfig);
+
+      // insert CacheLoaderManagerConfig
+      cache.getConfiguration().setCacheLoaderManagerConfig(cacheLoaderManagerConfig);
+
+      // Could have change of cache
+      //  IndexerSingletonStoreCacheLoader
+      //      IndexerCacheStore issCacheLoader =
+      //         (IndexerCacheStore)cache.getConfiguration().getCacheLoaderManagerConfig().getFirstCacheLoaderConfig().g;
+
+      // This code make it possible to use the JBossCacheIndexChangesFilter in
+      // a non-cluster environment
+      if (cache.getConfiguration().getCacheMode() == CacheMode.LOCAL)
+      {
+         // Activate the cache loader
+         //         try
+         //         {
+         //            //            issCacheLoader.activeStatusChanged(true);
+         //         }
+         //         catch (PushStateException e)
+         //         {
+         //            // ignore me;
+         //         }
+      }
+      //      indexerCacheStore = (IndexerCacheStore)issCacheLoader.getCacheLoader();
+
+      indexerCacheStore.register(searchManager, parentSearchManager, handler, parentHandler);
+      IndexerIoModeHandler modeHandler = indexerCacheStore.getModeHandler();
+      handler.setIndexerIoModeHandler(modeHandler);
+      parentHandler.setIndexerIoModeHandler(modeHandler);
+
+      if (!parentHandler.isInitialized())
+      {
+         parentHandler.setIndexInfos(new ISPNIndexInfos(searchManager.getWsId(), cache, true, modeHandler));
+         parentHandler.setIndexUpdateMonitor(new ISPNIndexUpdateMonitor(searchManager.getWsId(), cache, true,
+            modeHandler));
+         parentHandler.init();
+      }
+      if (!handler.isInitialized())
+      {
+         handler.setIndexInfos(new ISPNIndexInfos(searchManager.getWsId(), cache, false, modeHandler));
+         handler.setIndexUpdateMonitor(new ISPNIndexUpdateMonitor(searchManager.getWsId(), cache, false, modeHandler));
+         handler.init();
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   protected void doUpdateIndex(Set<String> removedNodes, Set<String> addedNodes, Set<String> parentRemovedNodes,
+      Set<String> parentAddedNodes)
+   {
+      ChangesHolder changes = searchManager.getChanges(removedNodes, addedNodes);
+      ChangesHolder parentChanges = parentSearchManager.getChanges(parentRemovedNodes, parentAddedNodes);
+
+      if (changes == null && parentChanges == null)
+      {
+         return;
+      }
+
+      ChangesKey changesKey = new ChangesKey(searchManager.getWsId() + IdGenerator.generate());
+      try
+      {
+         PrivilegedISPNCacheHelper.put(cache, changesKey, new ChangesFilterListsWrapper(changes, parentChanges));
+      }
+      catch (CacheException e)
+      {
+         log.error(e.getLocalizedMessage(), e);
+         logErrorChanges(handler, removedNodes, addedNodes);
+         logErrorChanges(parentHandler, parentRemovedNodes, parentAddedNodes);
+      }
+   }
+
+   /**
+    * Log errors.
+    * 
+    * @param logHandler
+    * @param removedNodes
+    * @param addedNodes
+    */
+   private void logErrorChanges(QueryHandler logHandler, Set<String> removedNodes, Set<String> addedNodes)
+   {
+      try
+      {
+         logHandler.logErrorChanges(addedNodes, removedNodes);
+      }
+      catch (IOException ioe)
+      {
+         log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
+      }
+   }
+}

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java	2011-02-22 15:03:27 UTC (rev 4007)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexInfos.java	2011-02-23 12:40:22 UTC (rev 4008)
@@ -34,6 +34,7 @@
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Created by The eXo Platform SAS.
@@ -167,7 +168,7 @@
          super.write();
 
          // write to cache
-         PrivilegedISPNCacheHelper.put(cache, namesKey, getNames());
+         PrivilegedISPNCacheHelper.put(cache, namesKey, getNames(), -1, TimeUnit.SECONDS);
       }
    }
 

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexUpdateMonitor.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexUpdateMonitor.java	2011-02-22 15:03:27 UTC (rev 4007)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexUpdateMonitor.java	2011-02-23 12:40:22 UTC (rev 4008)
@@ -35,6 +35,7 @@
 import java.io.Serializable;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Created by The eXo Platform SAS.
@@ -152,7 +153,7 @@
          localUpdateInProgress = updateInProgress;
          if (persitentUpdate)
          {
-            PrivilegedISPNCacheHelper.put(cache, updateKey, new Boolean(updateInProgress));
+            PrivilegedISPNCacheHelper.put(cache, updateKey, new Boolean(updateInProgress), -1, TimeUnit.SECONDS);
          }
          for (IndexUpdateMonitorListener listener : listeners)
          {

Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java	                        (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java	2011-02-23 12:40:22 UTC (rev 4008)
@@ -0,0 +1,386 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.core.query.ispn;
+
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.impl.core.query.IndexerIoMode;
+import org.exoplatform.services.jcr.impl.core.query.IndexerIoModeHandler;
+import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
+import org.exoplatform.services.jcr.impl.core.query.SearchManager;
+import org.exoplatform.services.jcr.impl.core.query.jbosscache.ChangesFilterListsWrapper;
+import org.exoplatform.services.jcr.impl.core.query.jbosscache.JBossCacheIndexChangesFilter;
+import org.exoplatform.services.jcr.impl.core.query.lucene.ChangesHolder;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.infinispan.container.entries.InternalCacheEntry;
+import org.infinispan.lifecycle.ComponentStatus;
+import org.infinispan.loaders.AbstractCacheStore;
+import org.infinispan.loaders.CacheLoaderConfig;
+import org.infinispan.loaders.CacheLoaderException;
+import org.jboss.cache.Fqn;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * Date: 23.02.2011
+ * 
+ * @author <a href="mailto:anatoliy.bazko at exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id: IndexerCacheStore.java 34360 2010-11-11 11:11:11Z tolusha $
+ */
+public class IndexerCacheStore extends AbstractCacheStore
+{
+   private static final Log log = ExoLogger.getLogger("exo.jcr.component.core.IndexerCacheStore");
+
+   /**
+    * A map of all the indexers that has been registered.
+    */
+   private final Map<Fqn<String>, Indexer> indexers = new HashMap<Fqn<String>, Indexer>();
+
+   protected volatile IndexerIoModeHandler modeHandler;
+
+   /**
+    * This method will register a new Indexer according to the given parameters. 
+    * 
+    * @param searchManager
+    * @param parentSearchManager
+    * @param handler
+    * @param parentHandler
+    * @throws RepositoryConfigurationException
+    */
+   public void register(SearchManager searchManager, SearchManager parentSearchManager, QueryHandler handler,
+      QueryHandler parentHandler) throws RepositoryConfigurationException
+   {
+      indexers.put(Fqn.fromElements(searchManager.getWsId()), new Indexer(searchManager, parentSearchManager, handler,
+         parentHandler));
+      if (log.isDebugEnabled())
+      {
+         log.debug("Register " + searchManager.getWsId() + " " + this + " in " + indexers);
+      }
+   }
+
+   /**
+    * @see org.jboss.cache.loader.CacheLoader#put(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
+    */
+   public Object put(Fqn name, Object key, Object value) throws Exception
+   {
+      if (key.equals(JBossCacheIndexChangesFilter.LISTWRAPPER) && value instanceof ChangesFilterListsWrapper)
+      {
+         if (log.isDebugEnabled())
+         {
+            log.info("Received list wrapper, start indexing...");
+         }
+         // updating index
+         ChangesFilterListsWrapper wrapper = (ChangesFilterListsWrapper)value;
+         try
+         {
+            Indexer indexer = indexers.get(name.getParent());
+            if (indexer == null)
+            {
+               log.warn("No indexer could be found for the fqn " + name.getParent());
+               if (log.isDebugEnabled())
+               {
+                  log.debug("The current content of the map of indexers is " + indexers);
+               }
+            }
+            else if (wrapper.withChanges())
+            {
+               indexer.updateIndex(wrapper.getChanges(), wrapper.getParentChanges());
+            }
+            else
+            {
+               indexer.updateIndex(wrapper.getAddedNodes(), wrapper.getRemovedNodes(), wrapper.getParentAddedNodes(),
+                  wrapper.getParentRemovedNodes());
+            }
+         }
+         finally
+         {
+            if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
+            {
+               // remove the data from the cache
+               //               cache.removeNode(name);
+            }
+         }
+      }
+      return null;
+   }
+
+   /**
+    * Switches Indexer mode from RO to RW, or from RW to RO
+    * 
+    * @param ioMode
+    */
+   void setMode(IndexerIoMode ioMode)
+   {
+      if (modeHandler != null)
+      {
+         modeHandler.setMode(ioMode);
+      }
+   }
+
+   /**
+    * Get the mode handler.
+    */
+   IndexerIoModeHandler getModeHandler()
+   {
+      if (modeHandler == null)
+      {
+         if (cache.getStatus() != ComponentStatus.RUNNING)
+         {
+            throw new IllegalStateException("The cache should be started first");
+         }
+         synchronized (this)
+         {
+            if (modeHandler == null)
+            {
+               boolean isCoordinator = cache.getAdvancedCache().getRpcManager().getTransport().isCoordinator();
+               this.modeHandler =
+                  new IndexerIoModeHandler(isCoordinator ? IndexerIoMode.READ_WRITE : IndexerIoMode.READ_ONLY);
+            }
+         }
+      }
+      return modeHandler;
+   }
+
+   /**
+    * This class will update the indexes of the related workspace 
+    */
+   private static class Indexer
+   {
+
+      private final SearchManager searchManager;
+
+      private final SearchManager parentSearchManager;
+
+      private final QueryHandler handler;
+
+      private final QueryHandler parentHandler;
+
+      public Indexer(SearchManager searchManager, SearchManager parentSearchManager, QueryHandler handler,
+         QueryHandler parentHandler) throws RepositoryConfigurationException
+      {
+         this.searchManager = searchManager;
+         this.parentSearchManager = parentSearchManager;
+         this.handler = handler;
+         this.parentHandler = parentHandler;
+      }
+
+      /**
+       * Flushes lists of added/removed nodes to SearchManagers, starting indexing.
+       * 
+       * @param addedNodes
+       * @param removedNodes
+       * @param parentAddedNodes
+       * @param parentRemovedNodes
+       */
+      protected void updateIndex(Set<String> addedNodes, Set<String> removedNodes, Set<String> parentAddedNodes,
+         Set<String> parentRemovedNodes)
+      {
+         // pass lists to search manager 
+         if (searchManager != null && (addedNodes.size() > 0 || removedNodes.size() > 0))
+         {
+            try
+            {
+               searchManager.updateIndex(removedNodes, addedNodes);
+            }
+            catch (RepositoryException e)
+            {
+               log.error("Error indexing changes " + e, e);
+            }
+            catch (IOException e)
+            {
+               log.error("Error indexing changes " + e, e);
+               try
+               {
+                  handler.logErrorChanges(removedNodes, addedNodes);
+               }
+               catch (IOException ioe)
+               {
+                  log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
+               }
+            }
+         }
+         // pass lists to parent search manager 
+         if (parentSearchManager != null && (parentAddedNodes.size() > 0 || parentRemovedNodes.size() > 0))
+         {
+            try
+            {
+               parentSearchManager.updateIndex(parentRemovedNodes, parentAddedNodes);
+            }
+            catch (RepositoryException e)
+            {
+               log.error("Error indexing changes " + e, e);
+            }
+            catch (IOException e)
+            {
+               log.error("Error indexing changes " + e, e);
+               try
+               {
+                  parentHandler.logErrorChanges(parentRemovedNodes, parentAddedNodes);
+               }
+               catch (IOException ioe)
+               {
+                  log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
+               }
+            }
+         }
+      }
+
+      /**
+       * Flushes lists of added/removed nodes to SearchManagers, starting indexing.
+       */
+      protected void updateIndex(ChangesHolder changes, ChangesHolder parentChanges)
+      {
+         // pass lists to search manager 
+         if (searchManager != null && changes != null)
+         {
+            try
+            {
+               searchManager.apply(changes);
+            }
+            catch (RepositoryException e)
+            {
+               log.error("Error indexing changes " + e, e);
+            }
+            catch (IOException e)
+            {
+               log.error("Error indexing changes " + e, e);
+               try
+               {
+                  handler.logErrorChanges(new HashSet<String>(changes.getRemove()), new HashSet<String>(changes
+                     .getAddIds()));
+               }
+               catch (IOException ioe)
+               {
+                  log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
+               }
+            }
+         }
+         // pass lists to parent search manager 
+         if (parentSearchManager != null && parentChanges != null)
+         {
+            try
+            {
+               parentSearchManager.apply(parentChanges);
+            }
+            catch (RepositoryException e)
+            {
+               log.error("Error indexing changes " + e, e);
+            }
+            catch (IOException e)
+            {
+               log.error("Error indexing changes " + e, e);
+               try
+               {
+                  parentHandler.logErrorChanges(new HashSet<String>(parentChanges.getRemove()), new HashSet<String>(
+                     parentChanges.getAddIds()));
+               }
+               catch (IOException ioe)
+               {
+                  log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
+               }
+            }
+         }
+      }
+   }
+
+   @Override
+   public void store(InternalCacheEntry entry) throws CacheLoaderException
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   @Override
+   public void fromStream(ObjectInput inputStream) throws CacheLoaderException
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   @Override
+   public void toStream(ObjectOutput outputStream) throws CacheLoaderException
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   @Override
+   public void clear() throws CacheLoaderException
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   @Override
+   public boolean remove(Object key) throws CacheLoaderException
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   @Override
+   public InternalCacheEntry load(Object key) throws CacheLoaderException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Set<InternalCacheEntry> loadAll() throws CacheLoaderException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Set<InternalCacheEntry> load(int numEntries) throws CacheLoaderException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Set<Object> loadAllKeys(Set<Object> keysToExclude) throws CacheLoaderException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   public Class<? extends CacheLoaderConfig> getConfigurationClass()
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   @Override
+   protected void purgeInternal() throws CacheLoaderException
+   {
+      // TODO Auto-generated method stub
+
+   }
+}

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/PrivilegedISPNCacheHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/PrivilegedISPNCacheHelper.java	2011-02-22 15:03:27 UTC (rev 4007)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/PrivilegedISPNCacheHelper.java	2011-02-23 12:40:22 UTC (rev 4008)
@@ -23,6 +23,7 @@
 import java.io.Serializable;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @author <a href="anatoliy.bazko at exoplatform.org">Anatoliy Bazko</a>
@@ -37,7 +38,7 @@
     * 
     * @param cache
     */
-   public static void start(final org.infinispan.Cache<Serializable, Object> cache)
+   public static void start(final Cache<Serializable, Object> cache)
    {
       PrivilegedAction<Object> action = new PrivilegedAction<Object>()
       {
@@ -102,4 +103,21 @@
       return AccessController.doPrivileged(action);
    }
 
+   /**
+    * Put in Infinispan cache in privileged mode.
+    * 
+    * @param cache
+    */
+   public static Object put(final Cache<Serializable, Object> cache, final Serializable key, final Object value,
+      final long lifespan, final TimeUnit unit)
+   {
+      PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+      {
+         public Object run()
+         {
+            return cache.put(key, value, lifespan, unit);
+         }
+      };
+      return AccessController.doPrivileged(action);
+   }
 }

Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-config.xml	2011-02-22 15:03:27 UTC (rev 4007)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-config.xml	2011-02-23 12:40:22 UTC (rev 4008)
@@ -41,10 +41,15 @@
     </global>
 
     <default>
+      <clustering mode="replication">
+        <stateRetrieval timeout="20000" fetchInMemoryState="false" />
+        <sync />
+      </clustering>
+
       <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500"/>
       <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="false" syncCommitPhase="false"/>
       <jmxStatistics enabled="true"/>
       <deadlockDetection enabled="true" spinDuration="100"/>
-      <eviction strategy="LRU" wakeUpInterval="5000" threadPolicy="DEFAULT" maxEntries="5000"/>
+      <eviction strategy="LRU" wakeUpInterval="5000" threadPolicy="DEFAULT" maxEntries="1000000"/>
    </default>
 </infinispan>

Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-indexer.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-indexer.xml	2011-02-22 15:03:27 UTC (rev 4007)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-indexer.xml	2011-02-23 12:40:22 UTC (rev 4008)
@@ -25,6 +25,12 @@
       xmlns="urn:infinispan:config:4.0">
 
     <global>
+      <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+        <properties>
+          <property name="threadNamePrefix" value="EvictionThread"/>
+        </properties>
+      </evictionScheduledExecutor>
+
       <globalJmxStatistics jmxDomain="infinispan" enabled="true" allowDuplicateDomains="true"/>
 
       <transport transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport" clusterName="${infinispan-cluster-name}" distributedSyncTimeout="20000">
@@ -35,9 +41,15 @@
     </global>
 
     <default>
+      <clustering mode="replication">
+        <stateRetrieval timeout="20000" fetchInMemoryState="false" />
+        <sync />
+      </clustering>
+
       <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500"/>
       <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="false" syncCommitPhase="false"/>
       <jmxStatistics enabled="true"/>
       <deadlockDetection enabled="true" spinDuration="100"/>
+      <eviction strategy="LRU" wakeUpInterval="5000" threadPolicy="DEFAULT" maxEntries="10000"/>
    </default>
 </infinispan>

Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-lock.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-lock.xml	2011-02-22 15:03:27 UTC (rev 4007)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-infinispan-lock.xml	2011-02-23 12:40:22 UTC (rev 4008)
@@ -35,6 +35,11 @@
     </global>
 
     <default>
+      <clustering mode="replication">
+        <stateRetrieval timeout="20000" fetchInMemoryState="false" />
+        <sync />
+      </clustering>
+
       <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="20000" writeSkewCheck="false" concurrencyLevel="500"/>
       <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup" syncRollbackPhase="false" syncCommitPhase="false"/>
       <jmxStatistics enabled="true"/>



More information about the exo-jcr-commits mailing list