Author: nzamosenchuk
Date: 2010-12-17 03:42:48 -0500 (Fri, 17 Dec 2010)
New Revision: 3673
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/pom.xml
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingletonTokenStream.java
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jcr-config.xml
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-1080 : First "quick and dirty" POC implementation of Indexer, where
documents are created on client side and then sent to coordinator.
Modified: jcr/branches/1.14-IMPR/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.14-IMPR/exo.jcr.component.core/pom.xml 2010-12-17 07:53:15 UTC (rev
3672)
+++ jcr/branches/1.14-IMPR/exo.jcr.component.core/pom.xml 2010-12-17 08:42:48 UTC (rev
3673)
@@ -380,7 +380,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>${env.MAVEN_OPTS}
-Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager
-Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
<systemProperties>
<property>
<name>jcr.test.configuration.file</name>
@@ -433,7 +432,8 @@
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLinkedWorkspaceStorageCacheMetrics.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/SQLBenchmarkTest.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLockPerstistentDataManager.java</exclude>
-
<exclude>org/exoplatform/services/jcr/**/impl/**/TestCleanableFileStreamValueData.java</exclude>
+
<exclude>org/exoplatform/services/jcr/**/impl/**/TestCleanableFileStreamValueData.java</exclude>
+
<exclude>org/exoplatform/services/jcr/**/impl/**/TestSecurityRepositoryManagment.java</exclude>
</excludes>
</configuration>
</plugin>
@@ -580,7 +580,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- TAKE CARE TO UPDATE ALSO run-all PROFILE -->
- <argLine>${env.MAVEN_OPTS}
-Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager
-Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
<systemProperties>
<property>
<name>jcr.test.configuration.file</name>
@@ -657,7 +656,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- TAKE CARE TO UPDATE ALSO run-tck PROFILE -->
- <argLine>${env.MAVEN_OPTS}
-Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager
-Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
<systemProperties>
<property>
<name>jcr.test.configuration.file</name>
@@ -738,6 +736,7 @@
<exclude>org/exoplatform/services/jcr/**/impl/**/SQLBenchmarkTest.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestCleanableFileStreamValueData.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLockPerstistentDataManager.java</exclude>
+
<exclude>org/exoplatform/services/jcr/**/impl/**/TestSecurityRepositoryManagment.java</exclude>
<!-- From TCK -->
<exclude>org/apache/jackrabbit/test/api/TestAll.java</exclude>
<exclude>org/apache/jackrabbit/test/api/**/Abstract*.java</exclude>
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2010-12-17
07:53:15 UTC (rev 3672)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2010-12-17
08:42:48 UTC (rev 3673)
@@ -35,6 +35,7 @@
import org.exoplatform.services.jcr.impl.core.SessionRegistry;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rpc.RPCService;
import org.picocontainer.Startable;
import java.io.InputStream;
@@ -90,13 +91,22 @@
currentRepositoryName.set(config.getDefaultRepositoryName());
managerStartChanges = new ManagerStartChanges();
}
+
+ public RepositoryServiceImpl(RepositoryServiceConfiguration configuration,
ExoContainerContext context, RPCService rpcService)
+ {
+ this(configuration, context);
+ }
public void addPlugin(ComponentPlugin plugin)
{
if (plugin instanceof AddNodeTypePlugin)
+ {
addNodeTypePlugins.add(plugin);
+ }
else if (plugin instanceof AddNamespacesPlugin)
+ {
addNamespacesPlugins.add(plugin);
+ }
else if (plugin instanceof RepositoryChangesListenerRegisterPlugin)
{
managerStartChanges.addPlugin((RepositoryChangesListenerRegisterPlugin)plugin);
@@ -167,7 +177,9 @@
public ManageableRepository getCurrentRepository() throws RepositoryException
{
if (currentRepositoryName.get() == null)
+ {
return getDefaultRepository();
+ }
return getRepository(currentRepositoryName.get());
}
@@ -192,7 +204,9 @@
RepositoryContainer repositoryContainer = repositoryContainers.get(name);
log.debug("RepositoryServiceimpl() getRepository " + name);
if (repositoryContainer == null)
+ {
throw new RepositoryException("Repository '" + name + "'
not found.");
+ }
return
(ManageableRepository)repositoryContainer.getComponentInstanceOfType(ManageableRepository.class);
}
@@ -208,7 +222,9 @@
public void setCurrentRepositoryName(String repositoryName) throws
RepositoryConfigurationException
{
if (!repositoryContainers.containsKey(repositoryName))
+ {
throw new RepositoryConfigurationException("Repository is not configured.
Name " + repositoryName);
+ }
currentRepositoryName.set(repositoryName);
}
@@ -352,8 +368,10 @@
private void removeRepository(String name, boolean allowRemoveDefaultRepository)
throws RepositoryException
{
if (!canRemoveRepository(name, allowRemoveDefaultRepository))
+ {
throw new RepositoryException("Repository " + name + " in use. If
you want to "
+ " remove repository close all open sessions");
+ }
try
{
@@ -407,14 +425,18 @@
{
// Check non system workspaces
if (!repo.getSystemWorkspaceName().equals(wsEntry.getName()) &&
!repo.canRemoveWorkspace(wsEntry.getName()))
+ {
return false;
+ }
}
// check system workspace
RepositoryContainer repositoryContainer = repositoryContainers.get(name);
SessionRegistry sessionRegistry =
(SessionRegistry)repositoryContainer.getComponentInstance(SessionRegistry.class);
if (sessionRegistry == null ||
sessionRegistry.isInUse(repo.getSystemWorkspaceName()))
+ {
return false;
+ }
}
catch (RepositoryConfigurationException e)
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2010-12-17
07:53:15 UTC (rev 3672)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2010-12-17
08:42:48 UTC (rev 3673)
@@ -54,6 +54,7 @@
import
org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rpc.RPCService;
import org.jboss.cache.factories.annotations.NonVolatile;
import org.picocontainer.Startable;
@@ -140,7 +141,9 @@
* The unique name of the related workspace
*/
protected final String wsId;
-
+
+ protected final RPCService rpcService;
+
/**
* Creates a new <code>SearchManager</code>.
*
@@ -165,10 +168,11 @@
* @throws RepositoryConfigurationException
*/
- public SearchManager(WorkspaceEntry wsConfig, QueryHandlerEntry config,
NamespaceRegistryImpl nsReg, NodeTypeDataManager ntReg,
- WorkspacePersistentDataManager itemMgr, SystemSearchManagerHolder
parentSearchManager,
- DocumentReaderService extractor, ConfigurationManager cfm, final
RepositoryIndexSearcherHolder indexSearcherHolder)
- throws RepositoryException, RepositoryConfigurationException
+ public SearchManager(WorkspaceEntry wsConfig, QueryHandlerEntry config,
NamespaceRegistryImpl nsReg,
+ NodeTypeDataManager ntReg, WorkspacePersistentDataManager itemMgr,
SystemSearchManagerHolder parentSearchManager,
+ DocumentReaderService extractor, ConfigurationManager cfm,
+ final RepositoryIndexSearcherHolder indexSearcherHolder, RPCService rpcService)
throws RepositoryException,
+ RepositoryConfigurationException
{
this.wsId = wsConfig.getUniqueName();
this.extractor = extractor;
@@ -180,6 +184,7 @@
this.cfm = cfm;
this.virtualTableResolver = new LuceneVirtualTableResolver(nodeTypeDataManager,
nsReg);
this.parentSearchManager = parentSearchManager != null ? parentSearchManager.get()
: null;
+ this.rpcService = rpcService;
if (parentSearchManager != null)
{
((WorkspacePersistentDataManager)this.itemMgr).addItemPersistenceListener(this);
@@ -277,7 +282,9 @@
try
{
if (reader != null)
+ {
reader.close();
+ }
}
catch (IOException e)
{
@@ -390,7 +397,9 @@
{
if (log.isDebugEnabled())
+ {
log.debug("start");
+ }
try
{
if (indexingTree == null)
@@ -412,7 +421,9 @@
{
ItemData excludeData =
itemMgr.getItemData(stringTokenizer.nextToken());
if (excludeData != null)
+ {
excludedPath.add(excludeData.getQPath());
+ }
}
catch (RepositoryException e)
{
@@ -429,7 +440,9 @@
{
ItemData indexingRootDataItem =
itemMgr.getItemData(rootNodeIdentifer);
if (indexingRootDataItem != null &&
indexingRootDataItem.isNode())
+ {
indexingRootData = (NodeData)indexingRootDataItem;
+ }
}
catch (RepositoryException e)
{
@@ -510,14 +523,20 @@
if (item.isNode())
{
if (!indexingTree.isExcluded(item))
+ {
return (NodeData)item;
+ }
}
else
+ {
log.warn("Node not found, but property " + id +
", " + item.getQPath().getAsString()
+ " found. ");
+ }
}
else
+ {
log.warn("Unable to index node with id " + id + ",
node does not exist.");
+ }
}
catch (RepositoryException e)
@@ -708,14 +727,19 @@
// initialize query handler
String className = config.getType();
if (className == null)
+ {
throw new RepositoryConfigurationException("Content hanler
configuration fail");
+ }
try
{
Class qHandlerClass = Class.forName(className, true,
this.getClass().getClassLoader());
- Constructor constuctor = qHandlerClass.getConstructor(QueryHandlerEntry.class,
ConfigurationManager.class);
- handler = (QueryHandler)constuctor.newInstance(config, cfm);
+ Constructor constuctor =
+ qHandlerClass.getConstructor(QueryHandlerEntry.class,
ConfigurationManager.class, RPCService.class,
+ String.class);
QueryHandler parentHandler = (this.parentSearchManager != null) ?
parentSearchManager.getHandler() : null;
+ handler =
+ (QueryHandler)constuctor.newInstance(config, cfm, rpcService, wsId +
(parentHandler != null ? "" : "-sys"));
QueryHandlerContext context = createQueryHandlerContext(parentHandler);
handler.setContext(context);
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2010-12-17
07:53:15 UTC (rev 3672)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2010-12-17
08:42:48 UTC (rev 3673)
@@ -29,6 +29,7 @@
import
org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rpc.RPCService;
import java.util.ArrayList;
import java.util.List;
@@ -57,11 +58,12 @@
public static final String INDEX_DIR_SUFFIX = "system";
- public SystemSearchManager(WorkspaceEntry wsConfig, QueryHandlerEntry config,
NamespaceRegistryImpl nsReg, NodeTypeDataManager ntReg,
- WorkspacePersistentDataManager itemMgr, DocumentReaderService service,
ConfigurationManager cfm,
- RepositoryIndexSearcherHolder indexSearcherHolder) throws RepositoryException,
RepositoryConfigurationException
+ public SystemSearchManager(WorkspaceEntry wsConfig, QueryHandlerEntry config,
NamespaceRegistryImpl nsReg,
+ NodeTypeDataManager ntReg, WorkspacePersistentDataManager itemMgr,
DocumentReaderService service,
+ ConfigurationManager cfm, RepositoryIndexSearcherHolder indexSearcherHolder,
RPCService rpcService)
+ throws RepositoryException, RepositoryConfigurationException
{
- super(wsConfig, config, nsReg, ntReg, itemMgr, null, service, cfm,
indexSearcherHolder);
+ super(wsConfig, config, nsReg, ntReg, itemMgr, null, service, cfm,
indexSearcherHolder, rpcService);
}
@Override
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java 2010-12-17
07:53:15 UTC (rev 3672)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java 2010-12-17
08:42:48 UTC (rev 3673)
@@ -189,18 +189,66 @@
protected void doUpdateIndex(Set<String> removedNodes, Set<String>
addedNodes, Set<String> parentRemovedNodes,
Set<String> parentAddedNodes)
{
- String id = IdGenerator.generate();
+
+
try
{
- PrivilegedCacheHelper.put(cache, Fqn.fromRelativeElements(rootFqn, id),
LISTWRAPPER,
- new ChangesFilterListsWrapper(addedNodes, removedNodes, parentAddedNodes,
parentRemovedNodes));
+ searchManager.updateIndex(removedNodes, addedNodes);
}
- catch (CacheException e)
+ catch (RepositoryException e)
{
- log.error(e.getLocalizedMessage(), e);
- logErrorChanges(handler, removedNodes, addedNodes);
- logErrorChanges(parentHandler, parentRemovedNodes, parentAddedNodes);
+ 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);
+ }
+ }
+
+ 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(removedNodes, addedNodes);
+ }
+ catch (IOException ioe)
+ {
+ log.warn("Exception occure when errorLog writed. Error log is not
complete. " + ioe, ioe);
+ }
+ }
+
+
+
+
+
+// String id = IdGenerator.generate();
+// try
+// {
+// PrivilegedCacheHelper.put(cache, Fqn.fromRelativeElements(rootFqn, id),
LISTWRAPPER,
+// new ChangesFilterListsWrapper(addedNodes, removedNodes, parentAddedNodes,
parentRemovedNodes));
+// }
+// catch (CacheException e)
+// {
+// log.error(e.getLocalizedMessage(), e);
+// logErrorChanges(handler, removedNodes, addedNodes);
+// logErrorChanges(parentHandler, parentRemovedNodes, parentAddedNodes);
+// }
}
/**
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2010-12-17
07:53:15 UTC (rev 3672)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2010-12-17
08:42:48 UTC (rev 3673)
@@ -878,15 +878,48 @@
* @param value the reader value.
* @return a lucene field.
*/
- protected Fieldable createFulltextField(Reader value)
+ protected Fieldable createFulltextField(Reader reader)
{
+
+ StringBuffer textExtract = new StringBuffer();
+ char[] buffer = new char[1024];
+ int len;
+ try
+ {
+ while ((len = reader.read(buffer)) > -1)
+ {
+ textExtract.append(buffer, 0, len);
+ }
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception reading value for field: " + e.getMessage());
+ log.debug("Dump:", e);
+ }
+ finally
+ {
+ //IOUtils.closeQuietly(reader);
+ try
+ {
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ }
+ String valueString = textExtract.toString();
+
if (supportHighlighting)
{
- return new LazyTextExtractorField(FieldNames.FULLTEXT, value, true, true);
+ //return new LazyTextExtractorField(FieldNames.FULLTEXT, value, true, true);
+ return new Field(FieldNames.FULLTEXT, valueString, Field.Store.YES,
Field.Index.ANALYZED,
+ Field.TermVector.WITH_OFFSETS);
}
else
{
- return new LazyTextExtractorField(FieldNames.FULLTEXT, value, false, false);
+ //return new LazyTextExtractorField(FieldNames.FULLTEXT, value, false, false);
+ return new Field(FieldNames.FULLTEXT, valueString, Field.Store.NO,
Field.Index.ANALYZED, Field.TermVector.NO);
}
}
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2010-12-17
07:53:15 UTC (rev 3672)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2010-12-17
08:42:48 UTC (rev 3673)
@@ -16,6 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+
import org.apache.commons.collections.IteratorUtils;
import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.collection.TransformedCollection;
@@ -62,6 +64,13 @@
import org.exoplatform.services.jcr.impl.util.SecurityHelper;
import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.impl.util.io.PrivilegedSystemHelper;
+import org.exoplatform.services.jcr.util.IdGenerator;
+import org.exoplatform.services.rpc.RPCException;
+import org.exoplatform.services.rpc.RPCService;
+import org.exoplatform.services.rpc.RemoteCommand;
+import org.exoplatform.services.rpc.TopologyChangeEvent;
+import org.exoplatform.services.rpc.TopologyChangeListener;
+import org.exoplatform.services.rpc.impl.RPCServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
@@ -71,6 +80,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.Serializable;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
@@ -81,7 +91,9 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Random;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.jcr.RepositoryException;
import javax.jcr.query.InvalidQueryException;
@@ -452,19 +464,27 @@
private final ConfigurationManager cfm;
+ private final RPCService rpcService;
+
+ private final String wsId;
+
+ private RemoteCommand sendDocs;
+
/**
* Working constructor.
*
* @throws RepositoryConfigurationException
* @throws IOException
*/
- public SearchIndex(QueryHandlerEntry queryHandlerConfig, ConfigurationManager cfm)
throws IOException,
- RepositoryConfigurationException
+ public SearchIndex(QueryHandlerEntry queryHandlerConfig, ConfigurationManager cfm,
RPCService rpcService, String wsId)
+ throws IOException, RepositoryConfigurationException
{
this.analyzer = new JcrStandartAnalyzer();
// this.queryHandlerConfig = new QueryHandlerEntryWrapper(
// queryHandlerConfig);
this.cfm = cfm;
+ this.rpcService = rpcService;
+ this.wsId = wsId;
SearchIndexConfigurationHelper searchIndexConfigurationHelper = new
SearchIndexConfigurationHelper(this);
searchIndexConfigurationHelper.init(queryHandlerConfig);
}
@@ -477,6 +497,8 @@
this.analyzer = new JcrStandartAnalyzer();
// this.queryHandlerConfig = null;
this.cfm = null;
+ this.rpcService = null;
+ this.wsId = null;
}
/**
@@ -627,6 +649,31 @@
}
modeHandler.addIndexerIoModeListener(this);
+
+ // register the command
+ sendDocs = rpcService.registerCommand(new RemoteCommand()
+ {
+ public String getId()
+ {
+ return "sendDocs-" + wsId;
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwable
+ {
+ // additional check! if to JCR nodes are launched on same machine,
+ // RPCService will call this task on both instances.
+ //if (rpcService.isCoordinator())
+ if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
+ {
+ ArrayList<String> remove = (ArrayList<String>)args[0];
+ ArrayList<Document> add = (ArrayList<Document>)args[1];
+ index.update(remove, add);
+ }
+ return null;
+ }
+ });
+ log.info("COMMAND '" + sendDocs.getId() + "'
REGISTERED!");
+
}
/**
@@ -699,7 +746,7 @@
final Set<String> removedNodeIds = new HashSet<String>();
final Set<String> addedNodeIds = new HashSet<String>();
- index.update(IteratorUtils.toList(new TransformIterator(remove, new Transformer()
+ updateInternal(IteratorUtils.toList(new TransformIterator(remove, new
Transformer()
{
public Object transform(Object input)
{
@@ -762,10 +809,39 @@
}
});
modified.addAll(aggregateRoots.values());
- index.update(aggregateRoots.keySet(), modified);
+ updateInternal(aggregateRoots.keySet(), modified);
}
}
+ private void updateInternal(final Collection<String> remove, final
Collection<Document> add) throws IOException
+ {
+ if (rpcService == null)
+ {
+ index.update(remove, add);
+ }
+ else
+ {
+ ArrayList<String> removeList = new ArrayList<String>(remove);
+ ArrayList<Document> addList = new ArrayList<Document>(add);
+ //log.info("sending docs to coordinator");
+ try
+ {
+ rpcService.executeCommandOnCoordinator(sendDocs, true, removeList, addList);
+ }
+ catch (SecurityException e)
+ {
+ e.printStackTrace();
+ throw new IOException(e.getMessage());
+ }
+ catch (RPCException e)
+ {
+ e.printStackTrace();
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ }
+
/**
* Creates a new query by specifying the query statement itself and the
* language in which the query is stated. If the query statement is
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingletonTokenStream.java
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingletonTokenStream.java 2010-12-17
07:53:15 UTC (rev 3672)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SingletonTokenStream.java 2010-12-17
08:42:48 UTC (rev 3673)
@@ -16,64 +16,78 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-
import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.index.Payload;
+import java.io.IOException;
+import java.io.Serializable;
+
/**
* <code>SingletonTokenStream</code> implements a token stream that wraps a
* single value with a given property type. The property type is stored as a
* payload on the single returned token.
*/
-public final class SingletonTokenStream extends TokenStream {
+public final class SingletonTokenStream extends TokenStream implements Serializable
+{
- /**
- * The string value of the token.
- */
- private String value;
+ /**
+ * The string value of the token.
+ */
+ private String value;
- /**
- * The payload of the token.
- */
- private final Payload payload;
+ /**
+ * The payload of the token.
+ */
+ private Payload payload;
- /**
- * Creates a new SingleTokenStream with the given value and a property
- * <code>type</code>.
- *
- * @param value the string value that will be returned with the token.
- * @param type the JCR property type.
- */
- public SingletonTokenStream(String value, int type) {
- this.value = value;
- this.payload = new Payload(new PropertyMetaData(type).toByteArray());
- }
+ /**
+ * for serialization
+ */
+ public SingletonTokenStream()
+ {
+ // TODO Auto-generated constructor stub
+ }
- /**
- * Creates a new SingleTokenStream with the given token.
- *
- * @param t the token.
- */
- public SingletonTokenStream(Token t) {
- this.value = t.term();
- this.payload = t.getPayload();
- }
+ /**
+ * Creates a new SingleTokenStream with the given value and a property
+ * <code>type</code>.
+ *
+ * @param value the string value that will be returned with the token.
+ * @param type the JCR property type.
+ */
+ public SingletonTokenStream(String value, int type)
+ {
+ this.value = value;
+ this.payload = new Payload(new PropertyMetaData(type).toByteArray());
+ }
- /**
- * {@inheritDoc}
- */
- public Token next(Token reusableToken) throws IOException {
- if (value == null) {
- return null;
- }
- reusableToken.clear();
- reusableToken.setTermBuffer(value);
- reusableToken.setPayload(payload);
- reusableToken.setStartOffset(0);
- reusableToken.setEndOffset(value.length());
- value = null;
- return reusableToken;
- }
+ /**
+ * Creates a new SingleTokenStream with the given token.
+ *
+ * @param t the token.
+ */
+ public SingletonTokenStream(Token t)
+ {
+ this.value = t.term();
+ this.payload = t.getPayload();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Token next(Token reusableToken) throws IOException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ reusableToken.clear();
+ reusableToken.setTermBuffer(value);
+ reusableToken.setPayload(payload);
+ reusableToken.setStartOffset(0);
+ reusableToken.setEndOffset(value.length());
+ value = null;
+ return reusableToken;
+ }
}
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml 2010-12-17
07:53:15 UTC (rev 3672)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml 2010-12-17
08:42:48 UTC (rev 3673)
@@ -101,6 +101,33 @@
</init-params>
</component>
+
+ <component>
+ <key>org.exoplatform.services.rpc.RPCService</key>
+ <type>org.exoplatform.services.rpc.impl.RPCServiceImpl</type>
+ <init-params>
+ <value-param>
+ <name>jgroups-configuration</name>
+ <value>classpath:/udp.xml</value>
+ </value-param>
+ <value-param>
+ <name>jgroups-cluster-name</name>
+ <value>RPCService-Cluster</value>
+ </value-param>
+ <value-param>
+ <name>jgroups-default-timeout</name>
+ <value>0</value>
+ </value-param>
+ <value-param>
+ <name>allow-failover</name>
+ <value>true</value>
+ </value-param>
+ <value-param>
+ <name>retry-timeout</name>
+ <value>20000</value>
+ </value-param>
+ </init-params>
+ </component>
<component>
<key>org.exoplatform.services.jcr.RepositoryService</key>
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jcr-config.xml
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jcr-config.xml 2010-12-17
07:53:15 UTC (rev 3672)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jcr-config.xml 2010-12-17
08:42:48 UTC (rev 3673)
@@ -55,7 +55,7 @@
<property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
</properties>
</cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.CRTSearchIndex">
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
<property name="index-dir"
value="target/temp/index/db1/ws" />
<property name="changesfilter-class"
@@ -119,7 +119,7 @@
<property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
</properties>
</cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.CRTSearchIndex">
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
<property name="index-dir"
value="target/temp/index/db1/ws1" />
<property name="changesfilter-class"
@@ -193,7 +193,7 @@
<property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
</properties>
</cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.CRTSearchIndex">
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
<property name="index-dir"
value="target/temp/index/db1/ws2" />
<property name="changesfilter-class"
@@ -281,7 +281,7 @@
<property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
</properties>
</cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.CRTSearchIndex">
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
<property name="index-dir"
value="target/temp/index/db1/ws3" />
<property name="changesfilter-class"
@@ -374,7 +374,7 @@
<property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
</properties>
</cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.CRTSearchIndex">
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
<property name="index-dir"
value="target/temp/index/db1tck/ws" />
<property name="changesfilter-class"
@@ -455,7 +455,7 @@
<property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
</properties>
</cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.CRTSearchIndex">
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
<property name="index-dir"
value="target/temp/index/db1tck/ws1" />
<property name="changesfilter-class"
@@ -534,7 +534,7 @@
<property name="jbosscache-shareable"
value="${jbosscache-shareable}" />
</properties>
</cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.CRTSearchIndex">
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
<property name="index-dir"
value="target/temp/index/db1tck/ws2" />
<property name="changesfilter-class"
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2010-12-17
07:53:15 UTC (rev 3672)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2010-12-17
08:42:48 UTC (rev 3673)
@@ -102,6 +102,34 @@
</init-params>
</component>
+
+ <component>
+ <key>org.exoplatform.services.rpc.RPCService</key>
+ <type>org.exoplatform.services.rpc.impl.RPCServiceImpl</type>
+ <init-params>
+ <value-param>
+ <name>jgroups-configuration</name>
+ <value>classpath:/udp.xml</value>
+ </value-param>
+ <value-param>
+ <name>jgroups-cluster-name</name>
+ <value>RPCService-Cluster</value>
+ </value-param>
+ <value-param>
+ <name>jgroups-default-timeout</name>
+ <value>0</value>
+ </value-param>
+ <value-param>
+ <name>allow-failover</name>
+ <value>true</value>
+ </value-param>
+ <value-param>
+ <name>retry-timeout</name>
+ <value>20000</value>
+ </value-param>
+ </init-params>
+ </component>
+
<component>
<key>org.exoplatform.services.jcr.RepositoryService</key>
<type>org.exoplatform.services.jcr.impl.RepositoryServiceImpl</type>