Author: nzamosenchuk
Date: 2011-02-25 05:29:18 -0500 (Fri, 25 Feb 2011)
New Revision: 4017
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/Indexer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/AbstractInputCacheStore.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java
Modified:
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
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
Log:
EXOJCR-832 : Implementing IndexerCacheStore, extracting "Indexer" class from
indexerCacheLoader.
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/Indexer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/Indexer.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/Indexer.java 2011-02-25
10:29:18 UTC (rev 4017)
@@ -0,0 +1,155 @@
+package org.exoplatform.services.jcr.impl.core.query;
+
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.impl.core.query.lucene.ChangesHolder;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * This class will update the indexes of the related workspace
+ */
+public class Indexer
+{
+ private static final Log log =
ExoLogger.getLogger("exo.jcr.component.core.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
+ */
+ public 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.
+ */
+ public 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);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/Indexer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/AbstractInputCacheStore.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/AbstractInputCacheStore.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/AbstractInputCacheStore.java 2011-02-25
10:29:18 UTC (rev 4017)
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2011 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.infinispan.container.entries.InternalCacheEntry;
+import org.infinispan.loaders.AbstractCacheStore;
+import org.infinispan.loaders.AbstractCacheStoreConfig;
+import org.infinispan.loaders.CacheLoaderConfig;
+import org.infinispan.loaders.CacheLoaderException;
+
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay
Zamosenchuk</a>
+ * @version $Id: AbstractInputCacheStore.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public abstract class AbstractInputCacheStore extends AbstractCacheStore
+{
+
+ /**
+ *
+ */
+ public AbstractInputCacheStore()
+ {
+ super();
+ }
+
+ /**
+ * @see org.infinispan.loaders.CacheLoader#getConfigurationClass()
+ */
+ public Class<? extends CacheLoaderConfig> getConfigurationClass()
+ {
+ return AbstractCacheStoreConfig.class;
+ }
+
+ /**
+ * @see org.infinispan.loaders.CacheStore#fromStream(java.io.ObjectInput)
+ */
+ public void fromStream(ObjectInput inputStream) throws CacheLoaderException
+ {
+ throw new UnsupportedOperationException("This operation is not supported by
this component.");
+ }
+
+ /**
+ * @see org.infinispan.loaders.CacheStore#toStream(java.io.ObjectOutput)
+ */
+ public void toStream(ObjectOutput outputStream) throws CacheLoaderException
+ {
+ throw new UnsupportedOperationException("This operation is not supported by
this component.");
+ }
+
+ /**
+ * @see org.infinispan.loaders.AbstractCacheStore#purgeInternal()
+ */
+ @Override
+ protected void purgeInternal() throws CacheLoaderException
+ {
+ throw new UnsupportedOperationException("This operation is not supported by
this component.");
+ }
+
+ /**
+ * @see org.infinispan.loaders.CacheStore#clear()
+ */
+ public void clear() throws CacheLoaderException
+ {
+ throw new UnsupportedOperationException("This operation is not supported by
this component.");
+ }
+
+ /**
+ * @see org.infinispan.loaders.CacheStore#remove(java.lang.Object)
+ */
+ public boolean remove(Object key) throws CacheLoaderException
+ {
+ // This cacheStore only accepts data
+ return false;
+ }
+
+ /**
+ * @see org.infinispan.loaders.CacheLoader#load(java.lang.Object)
+ */
+ public InternalCacheEntry load(Object key) throws CacheLoaderException
+ {
+ // This cacheStore only accepts data
+ return null;
+ }
+
+ /**
+ * @see org.infinispan.loaders.CacheLoader#load(int)
+ */
+ public Set<InternalCacheEntry> load(int numEntries) throws CacheLoaderException
+ {
+ // This cacheStore only accepts data
+ return null;
+ }
+
+ /**
+ * @see org.infinispan.loaders.CacheLoader#loadAll()
+ */
+ public Set<InternalCacheEntry> loadAll() throws CacheLoaderException
+ {
+ // This cacheStore only accepts data
+ return null;
+ }
+
+ /**
+ * @see org.infinispan.loaders.CacheLoader#loadAllKeys(java.util.Set)
+ */
+ public Set<Object> loadAllKeys(Set<Object> keysToExclude) throws
CacheLoaderException
+ {
+ // This cacheStore only accepts data
+ return null;
+ }
+
+}
\ No newline at end of file
Property changes on:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/AbstractInputCacheStore.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
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 2011-02-25
08:27:21 UTC (rev 4016)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ChangesKey.java 2011-02-25
10:29:18 UTC (rev 4017)
@@ -30,6 +30,8 @@
*/
public class ChangesKey extends CacheKey
{
+ private static final long serialVersionUID = 8597037282459379392L;
+
private final int wsId;
ChangesKey(int wsId, String id)
Modified:
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 2011-02-25
08:27:21 UTC (rev 4016)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java 2011-02-25
10:29:18 UTC (rev 4017)
@@ -22,6 +22,7 @@
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;
@@ -34,6 +35,8 @@
import org.exoplatform.services.log.Log;
import org.infinispan.Cache;
import org.infinispan.CacheException;
+import org.infinispan.config.Configuration.CacheMode;
+import org.infinispan.loaders.CacheLoaderManager;
import java.io.IOException;
import java.io.Serializable;
@@ -78,55 +81,37 @@
this.wsId = searchManager.getWsId().hashCode();
- // initialize IndexerCacheLoader
- // IndexerCacheStore indexerCacheStore = new IndexerCacheStore();
- //
- // // try to get pushState parameters, since they are set programmatically
only
- // // Boolean pushState =
config.getParameterBoolean(PARAM_JBOSSCACHE_PUSHSTATE, false);
- // // Long pushStateTimeOut =
config.getParameterTime(PARAM_JBOSSCACHE_PUSHSTATE_TIMEOUT, 10000L);
- //
- // // insert CacheLoaderConfig
ISPNCacheFactory<Serializable, Object> factory = new
ISPNCacheFactory<Serializable, Object>(cfm);
this.cache = factory.createCache("Indexer-" + searchManager.getWsId(),
config);
- //
- // // Could have change of cache
- // CacheLoaderManager cacheLoaderManager =
- //
cache.getAdvancedCache().getComponentRegistry().getComponent(CacheLoaderManager.class);
- // IndexerCacheStore cacheStore =
(IndexerCacheStore)cacheLoaderManager.getCacheLoader();
- // 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
- // {
- // cacheStore.activeStatusChanged(true);
- // }
- // catch (PushStateException e)
- // {
- // // ignore me;
- // }
- // }
- // indexerCacheLoader = (IndexerCacheLoader)issCacheLoader.getCacheLoader();
- //
- // indexerCacheLoader.register(searchManager, parentSearchManager, handler,
parentHandler);
- // IndexerIoModeHandler modeHandler = indexerCacheLoader.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();
- // }
+ CacheLoaderManager cacheLoaderManager =
+
cache.getAdvancedCache().getComponentRegistry().getComponent(CacheLoaderManager.class);
+ IndexerCacheStore cacheStore =
(IndexerCacheStore)cacheLoaderManager.getCacheLoader();
+
+ // This code make it possible to use the ISPNIndexChangesFilter in a non-cluster
environment
+ if (cache.getConfiguration().getCacheMode() == CacheMode.LOCAL)
+ {
+ cacheStore.activeStatusChanged(true);
+ }
+
+ cacheStore.register(searchManager, parentSearchManager, handler, parentHandler);
+ IndexerIoModeHandler modeHandler = cacheStore.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();
+ }
}
/**
Modified:
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 2011-02-25
08:27:21 UTC (rev 4016)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/IndexerCacheStore.java 2011-02-25
10:29:18 UTC (rev 4017)
@@ -1,386 +1,326 @@
-/*
- * 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@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
-
- }
-}
+/*
+ * Copyright (C) 2011 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.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.impl.core.query.Indexer;
+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.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.infinispan.Cache;
+import org.infinispan.container.entries.InternalCacheEntry;
+import org.infinispan.lifecycle.ComponentStatus;
+import org.infinispan.loaders.CacheLoaderConfig;
+import org.infinispan.loaders.CacheLoaderException;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.marshall.StreamingMarshaller;
+import org.infinispan.notifications.Listener;
+import org.infinispan.notifications.cachemanagerlistener.annotation.CacheStarted;
+import org.infinispan.notifications.cachemanagerlistener.annotation.ViewChanged;
+import org.infinispan.notifications.cachemanagerlistener.event.Event;
+import org.infinispan.notifications.cachemanagerlistener.event.ViewChangedEvent;
+import org.infinispan.remoting.transport.Address;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay
Zamosenchuk</a>
+ * @version $Id: IndexCacheLoader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class IndexerCacheStore extends AbstractInputCacheStore
+{
+
+ protected CacheListener listener;
+
+ /**
+ * Address instance that allows SingletonStore to find out whether it became the
coordinator of the cluster, or
+ * whether it stopped being it. This dictates whether the SingletonStore is active or
not.
+ */
+ private Address localAddress;
+
+ /**
+ * Whether the the current cache is the coordinator and therefore SingletonStore is
active. Being active means
+ * delegating calls to the underlying cache loader.
+ */
+ private volatile boolean coordinator;
+
+ EmbeddedCacheManager cacheManager;
+
+ protected volatile IndexerIoModeHandler modeHandler;
+
+ /**
+ * A map of all the indexers that has been registered
+ */
+ private final Map<Integer, Indexer> indexers = new HashMap<Integer,
Indexer>();
+
+ private static final Log log =
ExoLogger.getLogger("exo.jcr.component.core.IndexerCacheLoader");
+
+ /**
+ * 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(searchManager.getWsId().hashCode(), new Indexer(searchManager,
parentSearchManager, handler,
+ parentHandler));
+ if (log.isDebugEnabled())
+ {
+ log.debug("Register " + searchManager.getWsId() + " " + this
+ " in " + indexers);
+ }
+ }
+
+ @Override
+ public void init(CacheLoaderConfig config, Cache<?, ?> cache,
StreamingMarshaller m) throws CacheLoaderException
+ {
+ super.init(config, cache, m);
+ this.cacheManager = cache == null ? null :
(EmbeddedCacheManager)cache.getCacheManager();
+ listener = new CacheListener();
+ cache.addListener(listener);
+ }
+
+ /**
+ * @see
org.infinispan.loaders.CacheStore#store(org.infinispan.container.entries.InternalCacheEntry)
+ */
+ public void store(InternalCacheEntry entry) throws CacheLoaderException
+ {
+ if (entry.getValue() instanceof ChangesFilterListsWrapper && entry.getKey()
instanceof ChangesKey)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.info("Received list wrapper, start indexing...");
+ }
+ // updating index
+ ChangesFilterListsWrapper wrapper =
(ChangesFilterListsWrapper)entry.getValue();
+ ChangesKey key = (ChangesKey)entry.getKey();
+ try
+ {
+ Indexer indexer = indexers.get(key.getWsId());
+ if (indexer == null)
+ {
+ log.warn("No indexer could be found for the cache entry " +
key.toString());
+ 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.remove(key);
+ }
+ }
+ }
+ }
+
+ /**
+ * Set the mode handler
+ * @param modeHandler
+ */
+ IndexerIoModeHandler getModeHandler()
+ {
+ if (modeHandler == null)
+ {
+
+ if (cache.getStatus() != ComponentStatus.RUNNING)
+ {
+ throw new IllegalStateException("The cache should be started
first");
+ }
+ synchronized (this)
+ {
+ if (modeHandler == null)
+ {
+ this.modeHandler =
+ new IndexerIoModeHandler(cacheManager.isCoordinator() ?
IndexerIoMode.READ_WRITE
+ : IndexerIoMode.READ_ONLY);
+ }
+ }
+ }
+ return modeHandler;
+ }
+
+ /**
+ * Indicates whether the current cache is the coordinator of the cluster. This
implementation assumes that the
+ * coordinator is the first member in the list.
+ *
+ * @param newView View instance containing the new view of the cluster
+ * @return whether the current cache is the coordinator or not.
+ */
+ private boolean isCoordinator(List<Address> newView, Address currentAddress)
+ {
+ if (!currentAddress.equals(localAddress))
+ {
+ localAddress = currentAddress;
+ }
+ if (localAddress != null)
+ {
+ return !newView.isEmpty() && localAddress.equals(newView.get(0));
+ }
+ else
+ {
+ /* Invalid new view, so previous value returned */
+ return coordinator;
+ }
+ }
+
+ /**
+ * Method called when the cache either becomes the coordinator or stops being the
coordinator. If it becomes the
+ * coordinator, it can optionally start the in-memory state transfer to the underlying
cache store.
+ *
+ * @param newActiveState true if the cache just became the coordinator, false if the
cache stopped being the
+ * coordinator.
+ */
+ protected void activeStatusChanged(boolean newActiveState)
+ {
+ coordinator = newActiveState;
+
+ if (modeHandler != null)
+ {
+ modeHandler.setMode(coordinator ? IndexerIoMode.READ_WRITE :
IndexerIoMode.READ_ONLY);
+ log.info("Set indexer io mode to:" + (coordinator ?
IndexerIoMode.READ_WRITE : IndexerIoMode.READ_ONLY));
+ }
+
+ if (coordinator)
+ {
+ doPushState();
+ }
+ }
+
+ protected void doPushState()
+ {
+ // final boolean debugEnabled = log.isDebugEnabled();
+ //
+ // if (debugEnabled)
+ // {
+ // log.debug("start pushing in-memory state to cache cacheLoader
collection");
+ // }
+ //
+ // // merging all lists stored in memory
+ // Collection<NodeSPI> children = cache.getRoot().getChildren();
+ // for (NodeSPI wsChildren : children)
+ // {
+ // final Set<String> removedNodes = new HashSet<String>();
+ // final Set<String> addedNodes = new HashSet<String>();
+ // final Set<String> parentRemovedNodes = new
HashSet<String>();
+ // final Set<String> parentAddedNodes = new HashSet<String>();
+ // Collection<NodeSPI> changes = wsChildren.getChildren();
+ // for (NodeSPI aChildren : changes)
+ // {
+ // Fqn<?> fqn = aChildren.getFqn();
+ // Object value = cache.get(fqn,
JBossCacheIndexChangesFilter.LISTWRAPPER);
+ // if (value instanceof ChangesFilterListsWrapper)
+ // {
+ // // get wrapper object
+ // ChangesFilterListsWrapper listsWrapper =
(ChangesFilterListsWrapper)value;
+ // if (listsWrapper.withChanges())
+ // {
+ // if (listsWrapper.getChanges() != null)
+ // {
+ // // get search manager lists
+ // addedNodes.addAll(listsWrapper.getChanges().getAddIds());
+ // removedNodes.addAll(listsWrapper.getChanges().getRemove());
+ // }
+ // if (listsWrapper.getParentChanges() != null)
+ // {
+ // // parent search manager lists
+ //
parentAddedNodes.addAll(listsWrapper.getParentChanges().getAddIds());
+ //
parentRemovedNodes.addAll(listsWrapper.getParentChanges().getRemove());
+ // }
+ // }
+ // else
+ // {
+ // // get search manager lists
+ // addedNodes.addAll(listsWrapper.getAddedNodes());
+ // removedNodes.addAll(listsWrapper.getRemovedNodes());
+ // // parent search manager lists
+ // parentAddedNodes.addAll(listsWrapper.getParentAddedNodes());
+ // parentRemovedNodes.addAll(listsWrapper.getParentAddedNodes());
+ // }
+ // }
+ // }
+ // String id = IdGenerator.generate();
+ // cache.put(Fqn.fromRelativeElements(wsChildren.getFqn(), id),
JBossCacheIndexChangesFilter.LISTWRAPPER,
+ // new ChangesFilterListsWrapper(addedNodes, removedNodes,
parentAddedNodes, parentRemovedNodes));
+ // // Once we put the merged changes into the cache we can remove other
changes from the cache
+ // for (NodeSPI aChildren : children)
+ // {
+ // // Remove the node from the cache and do it asynchronously
+ //
cache.getInvocationContext().getOptionOverrides().setForceAsynchronous(true);
+ // cache.removeNode(aChildren.getFqn());
+ // }
+ // }
+ // if (debugEnabled)
+ // {
+ // log.debug("in-memory state passed to cache cacheLoader
successfully");
+ // }
+ // return null;
+ }
+
+ @Listener
+ public class CacheListener
+ {
+ @CacheStarted
+ public void cacheStarted(Event e)
+ {
+ localAddress = cacheManager.getAddress();
+ coordinator = cacheManager.isCoordinator();
+ }
+
+ /**
+ * The cluster formation changed, so determine whether the current cache stopped
being the coordinator or became
+ * the coordinator. This method can lead to an optional in memory to cache loader
state push, if the current cache
+ * became the coordinator. This method will report any issues that could
potentially arise from this push.
+ */
+ @ViewChanged
+ public void viewChange(ViewChangedEvent event)
+ {
+ boolean tmp = isCoordinator(event.getNewMembers(), event.getLocalAddress());
+
+ if (coordinator != tmp)
+ {
+ activeStatusChanged(tmp);
+ }
+ }
+ }
+
+}
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java 2011-02-25
10:29:18 UTC (rev 4017)
@@ -0,0 +1,151 @@
+/*
+ * 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.loaders.CacheLoaderManager;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * This type of ChangeFilter offers an ability for each cluster instance to have own
+ * local index (stack of indexes, from persistent to volatile). It uses ISPN cache for
+ * Lucene Documents and UUIDs delivery. Each node works in ReadWrite mode, so manages
+ * it own volatile, merger, local list of persisted indexes and stand-alone
+ * UpdateInProgressMonitor implementation.
+ * This implementation is similar to ISPNIndexChangesFilter but does not use
+ * ISPNIndexInfoss and ISPNIndexUpdateMonitor classes.
+ *
+ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy
Bazko</a>
+ * @version $Id: LocalIndexChangesFilter.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class LocalIndexChangesFilter extends IndexerChangesFilter
+{
+ /**
+ * Logger instance for this class
+ */
+ private final Log log =
ExoLogger.getLogger("exo.jcr.component.core.LocalIndexChangesFilter");
+
+ private final Cache<Serializable, Object> cache;
+
+ private final int wsId;
+
+ /**
+ * LocalIndexChangesFilter constructor.
+ */
+ public LocalIndexChangesFilter(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);
+
+ this.wsId = searchManager.getWsId().hashCode();
+
+ ISPNCacheFactory<Serializable, Object> factory = new
ISPNCacheFactory<Serializable, Object>(cfm);
+ this.cache = factory.createCache("Indexer-" + searchManager.getWsId(),
config);
+
+ CacheLoaderManager cacheLoaderManager =
+
cache.getAdvancedCache().getComponentRegistry().getComponent(CacheLoaderManager.class);
+ IndexerCacheStore cacheStore =
(IndexerCacheStore)cacheLoaderManager.getCacheLoader();
+
+ cacheStore.register(searchManager, parentSearchManager, handler, parentHandler);
+ IndexerIoModeHandler modeHandler = cacheStore.getModeHandler();
+ handler.setIndexerIoModeHandler(modeHandler);
+ parentHandler.setIndexerIoModeHandler(modeHandler);
+
+ // using default updateMonitor and default
+ if (!parentHandler.isInitialized())
+ {
+ parentHandler.init();
+ }
+ if (!handler.isInitialized())
+ {
+ 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(wsId, 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);
+ }
+ }
+}
Property changes on:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2011-02-25
08:27:21 UTC (rev 4016)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2011-02-25
10:29:18 UTC (rev 4017)
@@ -17,11 +17,11 @@
package org.exoplatform.services.jcr.impl.core.query.jbosscache;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.impl.core.query.Indexer;
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.lucene.ChangesHolder;
import
org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -29,15 +29,10 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import java.io.IOException;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import javax.jcr.RepositoryException;
-
/**
* @author <a href="mailto:nikolazius@gmail.com">Nikolay
Zamosenchuk</a>
* @version $Id: IndexerCacheLoader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
@@ -191,146 +186,4 @@
}
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);
- }
- }
- }
- }
- }
}