exo-jcr SVN: r934 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-07 09:27:08 -0500 (Mon, 07 Dec 2009)
New Revision: 934
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingleStoreCacheLoader.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
Log:
EXOJCR-291: Add new IndexerCacheLoader and IndexerSingleStoreCacheLoader
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-07 12:55:35 UTC (rev 933)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-07 14:27:08 UTC (rev 934)
@@ -16,217 +16,90 @@
*/
package org.exoplatform.services.jcr.impl.core.query.jbosscache;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.impl.core.query.SearchManager;
import org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader;
-import org.exoplatform.services.jcr.impl.storage.jbosscache.JBossCacheStorage;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
+import org.jboss.cache.Modification.ModificationType;
+import org.jboss.cache.factories.annotations.Inject;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: IndexerCacheLoader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
*
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: CacheIndexer.java 111 2008-11-11 11:11:11Z serg $
*/
-@Deprecated
public class IndexerCacheLoader extends AbstractWriteOnlyCacheLoader
{
+ private final Log log = ExoLogger.getLogger(this.getClass().getName());
- /**
- * Logger instance for this class
- */
- private static final Log log = ExoLogger.getLogger(IndexerCacheLoader.class);
+ public static String ADDED = "$add".intern();
- //IndexInterceptorHolder searchManagerHolder = null;
+ public static String REMOVED = "$remove".intern();
- public IndexerCacheLoader()
- {
- }
+ private SearchManager searchManager;
- // @Inject
- // public void injectDependencies(IndexInterceptorHolder holder)
- // {
- // searchManagerHolder = holder;
- // }
-
- private String parseUUID(Fqn<String> fqn)
+ @Inject
+ public void init(SearchManager searchManager) throws RepositoryConfigurationException
{
- if (fqn.size() > 1)
- {
-
- // get only uuid
- String uuid = (String)fqn.get(1);
- //remove slash
- return uuid;
- }
- else
- {
- return null;
- }
+ this.searchManager = searchManager;
}
- private boolean isNode(Fqn<String> fqn)
- {
- String items = (String)fqn.get(0);
- String s = items.toString();
- return s.equals(JBossCacheStorage.NODES);
- }
-
@Override
public void put(List<Modification> modifications) throws Exception
{
- // if (searchManagerHolder == null || searchManagerHolder.get() == null)
- // {
- // return;
- // }
-
- // nodes that need to be removed from the index.
+ if (log.isDebugEnabled())
+ {
+ log.info("Received list of modifications");
+ }
final Set<String> removedNodes = new HashSet<String>();
- // nodes that need to be added to the index.
final Set<String> addedNodes = new HashSet<String>();
-
- // node thst must be updated
- final Set<String> updateNodes = new HashSet<String>();
-
- //final Map<String, List<ItemState>> updatedNodes = new HashMap<String, List<ItemState>>();
-
for (Modification m : modifications)
{
- // check do we need skip modification
- // $NODES ,$PROPS cache-node modification and child cache-node (/$NODES/nodeUUID/[]childNodeName) are skipped
- // we process only modifications with Fqn like /[$NODES | $PROPS]/UUID
- if (m.getFqn().size() == 2)
+ if (m.getType() == ModificationType.PUT_KEY_VALUE && m.getFqn().size() == 1)
{
- String uuid = parseUUID(m.getFqn());
-
- switch (m.getType())
+ if (m.getKey().equals(ADDED) && m.getValue() instanceof Set<?>)
{
- case PUT_DATA :
- if (isNode(m.getFqn()))
- {
- // add node
- addedNodes.add(uuid);
- }
- else
- {
- // this is property - do nothing
- }
- break;
- case PUT_DATA_ERASE :
- // update node
- if (isNode(m.getFqn()))
- {
- removedNodes.add(uuid);
- addedNodes.add(uuid);
- }
- else
- {
- // this is property - do nothing
- }
- break;
- case PUT_KEY_VALUE :
-
- if (!isNode(m.getFqn()))
- {
- PropertyData property = (PropertyData)m.getValue();
- uuid = property.getParentIdentifier();
- }
-
- if (addedNodes.contains(uuid))
- {
- // do nothing - node by uuid will be indexed
- }
- else
- {
- // update document by this uuid
- updateNodes.add(uuid);
- }
- break;
- case REMOVE_DATA :
- // update node
- if (isNode(m.getFqn()))
- {
- removedNodes.add(uuid);
- }
- else
- {
- // this is a property - do nothing
- }
- break;
- case REMOVE_KEY_VALUE :
- // removed property - do update node
- if (isNode(m.getFqn()))
- {
- if (!removedNodes.contains(uuid))
- {
- updateNodes.add(uuid);
- }
- }
- else
- {
- // this is a property - do nothing
- }
-
- break;
- case REMOVE_NODE :
- // if node - remove it, otherwise ignore it
- if (isNode(m.getFqn()))
- {
- removedNodes.add(uuid);
- }
- else
- {
- // this is a property - do nothing
- }
-
- break;
- case MOVE :
- // involve moving all children too
- move(m.getFqn(), m.getFqn2());
- if (isNode(m.getFqn()))
- {
- //remove first
- removedNodes.add(parseUUID(m.getFqn()));
- //add second
- addedNodes.add(parseUUID(m.getFqn2()));
- }
- else
- {
- // must be never happen
- throw new UnsupportedOperationException("Moving of properties is unsupported.");
- }
- break;
- default :
- throw new CacheException("Unknown modification " + m.getType());
+ addedNodes.addAll((Set<String>)m.getValue());
}
+ else if (m.getKey().equals(REMOVED) && m.getValue() instanceof Set<?>)
+ {
+ removedNodes.addAll((Set<String>)m.getValue());
+ }
}
+ else
+ {
+ if (log.isDebugEnabled())
+ {
+ log.info("Received " + m.getType() + " modification, skipping...");
+ }
+ }
}
-
- for (String uuid : updateNodes)
+ new StubSearchManager().updateIndex(addedNodes, removedNodes);
+ if (searchManager!=null)
{
- removedNodes.add(uuid);
- addedNodes.add(uuid);
+ searchManager.updateIndex(removedNodes, addedNodes);
}
+ }
- try
+ class StubSearchManager
+ {
+ public void updateIndex(Set<String> added, Set<String> removed)
{
- //searchManagerHolder.get().updateIndex(removedNodes, addedNodes);
+ for (String uuid : added)
+ {
+ System.out.println("A\t" + uuid);
+ }
+ for (String uuid : removed)
+ {
+ System.out.println("D\t" + uuid);
+ }
}
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
}
}
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingleStoreCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingleStoreCacheLoader.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingleStoreCacheLoader.java 2009-12-07 14:27:08 UTC (rev 934)
@@ -0,0 +1,101 @@
+/*
+ * 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.jbosscache;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.loader.SingletonStoreCacheLoader;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: IndexerSingleStoraCacheLoader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class IndexerSingleStoreCacheLoader extends SingletonStoreCacheLoader
+{
+
+ private final Log log = ExoLogger.getLogger(this.getClass().getName());
+
+ @Override
+ protected void activeStatusChanged(boolean newActiveState) throws PushStateException
+ {
+ // at first change indexer mode
+ modeChanged(newActiveState);
+ // and them push states if needed
+ super.activeStatusChanged(newActiveState);
+
+ }
+
+ /**
+ * Changes indexer mode RO->RW, RW->RO
+ *
+ * @param enableWrite
+ * true when this node of cluster is coordinator, means that indexer is RW
+ * false means that indexer is read only, and this node of cluster is no a coordinator
+ */
+ protected void modeChanged(boolean enableWrite)
+ {
+ }
+
+ @Override
+ protected Callable<?> createPushStateTask()
+ {
+ return new Callable()
+ {
+ public Object call() throws Exception
+ {
+ final boolean debugEnabled = log.isDebugEnabled();
+
+ if (debugEnabled)
+ log.debug("start pushing in-memory state to cache cacheLoader collection");
+
+ final Set<String> removedNodes = new HashSet<String>();
+ final Set<String> addedNodes = new HashSet<String>();
+
+ // merging all lists stored in memory
+ Collection<NodeSPI> children = cache.getRoot().getChildrenDirect();
+ for (NodeSPI aChildren : children)
+ {
+ Fqn fqn = aChildren.getFqn();
+ Object value = cache.get(fqn, IndexerCacheLoader.ADDED);
+ if (value != null && value instanceof Set<?>)
+ {
+ addedNodes.addAll((Set<String>)value);
+ };
+ value = cache.get(fqn, IndexerCacheLoader.REMOVED);
+ if (value != null && value instanceof Set<?>)
+ {
+ removedNodes.addAll((Set<String>)value);
+ };
+ }
+ //TODO: recover logic is here, lists are: removedNodes and addedNodes
+ if (debugEnabled)
+ log.debug("in-memory state passed to cache cacheLoader successfully");
+ return null;
+ }
+ };
+ }
+}
16 years, 7 months
exo-jcr SVN: r933 - in jcr/branches/1.12.0-JBC/component/core/src: test/resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-07 07:55:35 -0500 (Mon, 07 Dec 2009)
New Revision: 933
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-indexer-config-exoloader_db1_ws.xml
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-283: Test configuration added
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-07 12:04:47 UTC (rev 932)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-07 12:55:35 UTC (rev 933)
@@ -19,10 +19,18 @@
package org.exoplatform.services.jcr.impl.core.query.jbosscache;
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.QueryHandlerParams;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.impl.core.query.IndexerChangesFilter;
import org.exoplatform.services.jcr.impl.core.query.IndexingTree;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.DefaultCacheFactory;
+import java.io.Serializable;
import java.util.Set;
/**
@@ -32,16 +40,30 @@
*/
public class JbossCacheIndexChangesFilter extends IndexerChangesFilter
{
+ /**
+ * Logger instance for this class
+ */
+ private final Log log = ExoLogger.getLogger(JbossCacheIndexChangesFilter.class);
+ private final Cache<Serializable, Object> cache;
+
/**
* @param searchManager
* @param config
* @param indexingTree
+ * @throws RepositoryConfigurationException
*/
public JbossCacheIndexChangesFilter(SearchManager searchManager, QueryHandlerEntry config, IndexingTree indexingTree)
+ throws RepositoryConfigurationException
{
super(searchManager, config, indexingTree);
- //TODO create cache;
+ String jbcConfig = config.getParameterValue(QueryHandlerParams.PARAM_CHANGES_FILTER_CONFIG_PATH);
+ CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
+ log.info("JBoss Cache configuration used: " + jbcConfig);
+ this.cache = factory.createCache(jbcConfig, false);
+ this.cache.create();
+ this.cache.start();
+
}
/**
Added: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-indexer-config-exoloader_db1_ws.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-indexer-config-exoloader_db1_ws.xml (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-indexer-config-exoloader_db1_ws.xml 2009-12-07 12:55:35 UTC (rev 933)
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <!-- Configure the TransactionManager -->
+ <transaction
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
+
+ <clustering mode="replication" clusterName="JBoss-Cache-Indexer-Cluster_db1_ws">
+
+ <jgroupsConfig>
+ <!--UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
+ loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10"
+ mcast_port="45588" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000"
+ oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4"
+ oob_thread_pool.min_threads="1" oob_thread_pool.queue_enabled="true" oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl" thread_pool.enabled="true"
+ thread_pool.keep_alive_time="30000" thread_pool.max_threads="25" thread_pool.min_threads="1"
+ thread_pool.queue_enabled="true" thread_pool.queue_max_size="10" thread_pool.rejection_policy="Run"
+ tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true"
+ use_incoming_packet_handler="true" />
+ <PING num_initial_members="3" timeout="2000" /-->
+
+ <TCP bind_addr="127.0.0.1" start_port="9800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true" use_send_queues="false" sock_conn_timeout="300"
+ skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
+
+ oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
+ <MPING timeout="2000" num_initial_members="3" mcast_port="34521" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+
+
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD max_tries="5" shun="true" timeout="10000"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
+ use_mcast_xmit="false"/>
+ <UNICAST timeout="300,600,1200,2400,3600"/>
+ <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/>
+ <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000"
+ view_bundling="true"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
+ <pbcast.FLUSH timeout="0"/>
+
+ </jgroupsConfig>
+
+ <sync />
+ <!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
+ <!-- <async /> -->
+ </clustering>
+
+ <loaders passivation="false" shared="false">
+ <loader class="org.jboss.cache.loader.FileCacheLoader" async="false"
+ fetchPersistentState="true" ignoreModifications="false"
+ purgeOnStartup="false">
+ <properties>
+ location=/tmp/test-jboss-cache/proxy
+ </properties>
+ </loader>
+
+ <!-- loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
+ async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ </properties>
+ </loader-->
+
+ <!-- loader class="org.exoplatform.services.jcr.impl.core.query.cacheloader.IndexerCacheLoader"
+ async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ </properties>
+ </loader-->
+
+ </loaders>
+
+ <!-- Enable batching -->
+ <invocationBatching enabled="true"/>
+</jbosscache>
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-indexer-config-exoloader_db1_ws.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-12-07 12:04:47 UTC (rev 932)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-12-07 12:55:35 UTC (rev 933)
@@ -63,6 +63,9 @@
<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" value="org.exoplatform.services.jcr.impl.core.query.jbosscache.JbossCacheIndexChangesFilter" />
+ <property name="changesfilter-config-path" value="conf/standalone/test-jbosscache-indexer-config-exoloader_db1_ws.xml" /-->
+
</properties>
</query-handler>
<!-- lock-manager>
16 years, 7 months
exo-jcr SVN: r932 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query: jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-07 07:04:47 -0500 (Mon, 07 Dec 2009)
New Revision: 932
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
Log:
EXOJCR-283: Added JbossCache Changes filter.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java 2009-12-07 10:56:37 UTC (rev 931)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java 2009-12-07 12:04:47 UTC (rev 932)
@@ -19,18 +19,10 @@
package org.exoplatform.services.jcr.impl.core.query;
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
-import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.jcr.RepositoryException;
@@ -43,6 +35,11 @@
public class DefaultChangesFilter extends IndexerChangesFilter
{
/**
+ * Logger instance for this class
+ */
+ private static final Log log = ExoLogger.getLogger(DefaultChangesFilter.class);
+
+ /**
* @param searchManager
* @param handler
* @param indexingTree
@@ -50,104 +47,17 @@
public DefaultChangesFilter(SearchManager searchManager, QueryHandlerEntry config, IndexingTree indexingTree)
{
super(searchManager, config, indexingTree);
- // TODO Auto-generated constructor stub
}
/**
- * Logger instance for this class
+ * @param removedNodes
+ * @param addedNodes
+ * @see org.exoplatform.services.jcr.impl.core.query.IndexerChangesFilter#doUpdateIndex()
*/
- private static final Log log = ExoLogger.getLogger(DefaultChangesFilter.class);
-
- /**
- * @see org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener#onSaveItems(org.exoplatform.services.jcr.dataflow.ItemStateChangesLog)
- */
- public void onSaveItems(ItemStateChangesLog itemStates)
+ @Override
+ protected void doUpdateIndex(Set<String> removedNodes, Set<String> addedNodes)
{
- long time = System.currentTimeMillis();
-
- // nodes that need to be removed from the index.
- final Set<String> removedNodes = new HashSet<String>();
- // nodes that need to be added to the index.
- final Set<String> addedNodes = new HashSet<String>();
-
- final Map<String, List<ItemState>> updatedNodes = new HashMap<String, List<ItemState>>();
-
- for (Iterator<ItemState> iter = itemStates.getAllStates().iterator(); iter.hasNext();)
- {
- ItemState itemState = iter.next();
-
- if (!indexingTree.isExcluded(itemState))
- {
- String uuid =
- itemState.isNode() ? itemState.getData().getIdentifier() : itemState.getData().getParentIdentifier();
-
- if (itemState.isAdded())
- {
- if (itemState.isNode())
- {
- addedNodes.add(uuid);
- }
- else
- {
- if (!addedNodes.contains(uuid))
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- }
- }
- else if (itemState.isRenamed())
- {
- if (itemState.isNode())
- {
- addedNodes.add(uuid);
- }
- else
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- }
- else if (itemState.isUpdated())
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- else if (itemState.isMixinChanged())
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- else if (itemState.isDeleted())
- {
- if (itemState.isNode())
- {
- if (addedNodes.contains(uuid))
- {
- addedNodes.remove(uuid);
- removedNodes.remove(uuid);
- }
- else
- {
- removedNodes.add(uuid);
- }
- // remove all changes after node remove
- updatedNodes.remove(uuid);
- }
- else
- {
- if (!removedNodes.contains(uuid) && !addedNodes.contains(uuid))
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- }
- }
- }
- }
- // TODO make quick changes
- for (String uuid : updatedNodes.keySet())
- {
- removedNodes.add(uuid);
- addedNodes.add(uuid);
- }
-
try
{
searchManager.updateIndex(removedNodes, addedNodes);
@@ -169,22 +79,6 @@
}
}
- if (log.isDebugEnabled())
- {
- log.debug("onEvent: indexing finished in " + String.valueOf(System.currentTimeMillis() - time) + " ms.");
- }
-
}
- public void createNewOrAdd(String key, ItemState state, Map<String, List<ItemState>> updatedNodes)
- {
- List<ItemState> list = updatedNodes.get(key);
- if (list == null)
- {
- list = new ArrayList<ItemState>();
- updatedNodes.put(key, list);
- }
- list.add(state);
-
- }
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2009-12-07 10:56:37 UTC (rev 931)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2009-12-07 12:04:47 UTC (rev 932)
@@ -19,8 +19,20 @@
package org.exoplatform.services.jcr.impl.core.query;
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
* @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
@@ -28,6 +40,11 @@
*/
public abstract class IndexerChangesFilter implements ItemsPersistenceListener
{
+ /**
+ * Logger instance for this class
+ */
+ private static final Log log = ExoLogger.getLogger(DefaultChangesFilter.class);
+
protected final SearchManager searchManager;
protected final QueryHandlerEntry config;
@@ -82,4 +99,116 @@
return indexingTree;
}
+ /**
+ * @see org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener#onSaveItems(org.exoplatform.services.jcr.dataflow.ItemStateChangesLog)
+ */
+ public void onSaveItems(ItemStateChangesLog itemStates)
+ {
+
+ long time = System.currentTimeMillis();
+
+ // nodes that need to be removed from the index.
+ final Set<String> removedNodes = new HashSet<String>();
+ // nodes that need to be added to the index.
+ final Set<String> addedNodes = new HashSet<String>();
+
+ final Map<String, List<ItemState>> updatedNodes = new HashMap<String, List<ItemState>>();
+
+ for (Iterator<ItemState> iter = itemStates.getAllStates().iterator(); iter.hasNext();)
+ {
+ ItemState itemState = iter.next();
+
+ if (!indexingTree.isExcluded(itemState))
+ {
+ String uuid =
+ itemState.isNode() ? itemState.getData().getIdentifier() : itemState.getData().getParentIdentifier();
+
+ if (itemState.isAdded())
+ {
+ if (itemState.isNode())
+ {
+ addedNodes.add(uuid);
+ }
+ else
+ {
+ if (!addedNodes.contains(uuid))
+ {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ }
+ }
+ else if (itemState.isRenamed())
+ {
+ if (itemState.isNode())
+ {
+ addedNodes.add(uuid);
+ }
+ else
+ {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ }
+ else if (itemState.isUpdated())
+ {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ else if (itemState.isMixinChanged())
+ {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ else if (itemState.isDeleted())
+ {
+ if (itemState.isNode())
+ {
+ if (addedNodes.contains(uuid))
+ {
+ addedNodes.remove(uuid);
+ removedNodes.remove(uuid);
+ }
+ else
+ {
+ removedNodes.add(uuid);
+ }
+ // remove all changes after node remove
+ updatedNodes.remove(uuid);
+ }
+ else
+ {
+ if (!removedNodes.contains(uuid) && !addedNodes.contains(uuid))
+ {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ }
+ }
+ }
+ }
+
+ for (String uuid : updatedNodes.keySet())
+ {
+ removedNodes.add(uuid);
+ addedNodes.add(uuid);
+ }
+
+ doUpdateIndex(removedNodes, addedNodes);
+ }
+
+ private void createNewOrAdd(String key, ItemState state, Map<String, List<ItemState>> updatedNodes)
+ {
+ List<ItemState> list = updatedNodes.get(key);
+ if (list == null)
+ {
+ list = new ArrayList<ItemState>();
+ updatedNodes.put(key, list);
+ }
+ list.add(state);
+
+ }
+
+ /**
+ * Update index.
+ * @param removedNodes
+ * @param addedNodes
+ */
+ protected abstract void doUpdateIndex(Set<String> removedNodes, Set<String> addedNodes);
+
}
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-07 12:04:47 UTC (rev 932)
@@ -0,0 +1,57 @@
+/*
+ * 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.jbosscache;
+
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.impl.core.query.IndexerChangesFilter;
+import org.exoplatform.services.jcr.impl.core.query.IndexingTree;
+import org.exoplatform.services.jcr.impl.core.query.SearchManager;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
+ *
+ */
+public class JbossCacheIndexChangesFilter extends IndexerChangesFilter
+{
+
+ /**
+ * @param searchManager
+ * @param config
+ * @param indexingTree
+ */
+ public JbossCacheIndexChangesFilter(SearchManager searchManager, QueryHandlerEntry config, IndexingTree indexingTree)
+ {
+ super(searchManager, config, indexingTree);
+ //TODO create cache;
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.impl.core.query.IndexerChangesFilter#doUpdateIndex(java.util.Set, java.util.Set)
+ */
+ @Override
+ protected void doUpdateIndex(Set<String> removedNodes, Set<String> addedNodes)
+ {
+ //write changes
+
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 7 months
exo-jcr SVN: r931 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr: impl/core/query and 1 other directory.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-07 05:56:37 -0500 (Mon, 07 Dec 2009)
New Revision: 931
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
Log:
EXOJCR-283: Added Changes filter
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java 2009-12-07 10:11:19 UTC (rev 930)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java 2009-12-07 10:56:37 UTC (rev 931)
@@ -99,4 +99,7 @@
public static final String PARAM_ANALYZER_CLASS = "analyzer";
+ public static final String PARAM_CHANGES_FILTER_CLASS = "changesfilter-class";
+
+ public static final String PARAM_CHANGES_FILTER_CONFIG_PATH = "changesfilter-config-path";
}
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java 2009-12-07 10:56:37 UTC (rev 931)
@@ -0,0 +1,190 @@
+/*
+ * 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;
+
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
+ *
+ */
+public class DefaultChangesFilter extends IndexerChangesFilter
+{
+ /**
+ * @param searchManager
+ * @param handler
+ * @param indexingTree
+ */
+ public DefaultChangesFilter(SearchManager searchManager, QueryHandlerEntry config, IndexingTree indexingTree)
+ {
+ super(searchManager, config, indexingTree);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * Logger instance for this class
+ */
+ private static final Log log = ExoLogger.getLogger(DefaultChangesFilter.class);
+
+ /**
+ * @see org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener#onSaveItems(org.exoplatform.services.jcr.dataflow.ItemStateChangesLog)
+ */
+ public void onSaveItems(ItemStateChangesLog itemStates)
+ {
+
+ long time = System.currentTimeMillis();
+
+ // nodes that need to be removed from the index.
+ final Set<String> removedNodes = new HashSet<String>();
+ // nodes that need to be added to the index.
+ final Set<String> addedNodes = new HashSet<String>();
+
+ final Map<String, List<ItemState>> updatedNodes = new HashMap<String, List<ItemState>>();
+
+ for (Iterator<ItemState> iter = itemStates.getAllStates().iterator(); iter.hasNext();)
+ {
+ ItemState itemState = iter.next();
+
+ if (!indexingTree.isExcluded(itemState))
+ {
+ String uuid =
+ itemState.isNode() ? itemState.getData().getIdentifier() : itemState.getData().getParentIdentifier();
+
+ if (itemState.isAdded())
+ {
+ if (itemState.isNode())
+ {
+ addedNodes.add(uuid);
+ }
+ else
+ {
+ if (!addedNodes.contains(uuid))
+ {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ }
+ }
+ else if (itemState.isRenamed())
+ {
+ if (itemState.isNode())
+ {
+ addedNodes.add(uuid);
+ }
+ else
+ {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ }
+ else if (itemState.isUpdated())
+ {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ else if (itemState.isMixinChanged())
+ {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ else if (itemState.isDeleted())
+ {
+ if (itemState.isNode())
+ {
+ if (addedNodes.contains(uuid))
+ {
+ addedNodes.remove(uuid);
+ removedNodes.remove(uuid);
+ }
+ else
+ {
+ removedNodes.add(uuid);
+ }
+ // remove all changes after node remove
+ updatedNodes.remove(uuid);
+ }
+ else
+ {
+ if (!removedNodes.contains(uuid) && !addedNodes.contains(uuid))
+ {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ }
+ }
+ }
+ }
+ // TODO make quick changes
+ for (String uuid : updatedNodes.keySet())
+ {
+ removedNodes.add(uuid);
+ addedNodes.add(uuid);
+ }
+
+ 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);
+ }
+ }
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("onEvent: indexing finished in " + String.valueOf(System.currentTimeMillis() - time) + " ms.");
+ }
+
+ }
+
+ public void createNewOrAdd(String key, ItemState state, Map<String, List<ItemState>> updatedNodes)
+ {
+ List<ItemState> list = updatedNodes.get(key);
+ if (list == null)
+ {
+ list = new ArrayList<ItemState>();
+ updatedNodes.put(key, list);
+ }
+ list.add(state);
+
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2009-12-07 10:56:37 UTC (rev 931)
@@ -0,0 +1,85 @@
+/*
+ * 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;
+
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
+
+/**
+ * @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
+ *
+ */
+public abstract class IndexerChangesFilter implements ItemsPersistenceListener
+{
+ protected final SearchManager searchManager;
+
+ protected final QueryHandlerEntry config;
+
+ protected QueryHandler handler;
+
+ protected final IndexingTree indexingTree;
+
+ /**
+ * @param searchManager
+ * @param handler
+ * @param indexingTree
+ */
+ public IndexerChangesFilter(SearchManager searchManager, QueryHandlerEntry config, IndexingTree indexingTree)
+ {
+ super();
+ this.searchManager = searchManager;
+ this.config = config;
+
+ this.indexingTree = indexingTree;
+ }
+
+ /**
+ * @return the handler
+ */
+ public QueryHandler getHandler()
+ {
+ return handler;
+ }
+
+ /**
+ * @param handler the handler to set
+ */
+ public void setHandler(QueryHandler handler)
+ {
+ this.handler = handler;
+ }
+
+ /**
+ * @return the searchManager
+ */
+ public SearchManager getSearchManager()
+ {
+ return searchManager;
+ }
+
+ /**
+ * @return the indexingTree
+ */
+ public IndexingTree getIndexingTree()
+ {
+ return indexingTree;
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-12-07 10:11:19 UTC (rev 930)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-12-07 10:56:37 UTC (rev 931)
@@ -64,7 +64,6 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -107,6 +106,7 @@
/**
* QueryHandler where query execution is delegated to
*/
+
protected QueryHandler handler;
/**
@@ -140,6 +140,8 @@
protected LuceneVirtualTableResolver virtualTableResolver;
+ private IndexerChangesFilter changesFilter;
+
/**
* Creates a new <code>SearchManager</code>.
*
@@ -183,6 +185,18 @@
((WorkspacePersistentDataManager)this.itemMgr).addItemPersistenceListener(this);
}
+ public void createNewOrAdd(String key, ItemState state, Map<String, List<ItemState>> updatedNodes)
+ {
+ List<ItemState> list = updatedNodes.get(key);
+ if (list == null)
+ {
+ list = new ArrayList<ItemState>();
+ updatedNodes.put(key, list);
+ }
+ list.add(state);
+
+ }
+
/**
* Creates a query object from a node that can be executed on the workspace.
*
@@ -236,6 +250,45 @@
}
/**
+ * {@inheritDoc}
+ */
+ public Set<String> getFieldNames() throws IndexException
+ {
+ final Set<String> fildsSet = new HashSet<String>();
+ if (handler instanceof SearchIndex)
+ {
+ IndexReader reader = null;
+ try
+ {
+ reader = ((SearchIndex)handler).getIndexReader();
+ final Collection fields = reader.getFieldNames(IndexReader.FieldOption.ALL);
+ for (final Object field : fields)
+ {
+ fildsSet.add((String)field);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new IndexException(e.getLocalizedMessage(), e);
+ }
+ finally
+ {
+ try
+ {
+ if (reader != null)
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ throw new IndexException(e.getLocalizedMessage(), e);
+ }
+ }
+
+ }
+ return fildsSet;
+ }
+
+ /**
* just for test use only
*/
public QueryHandler getHandler()
@@ -244,6 +297,90 @@
return handler;
}
+ public Set<String> getNodesByNodeType(final InternalQName nodeType) throws RepositoryException
+ {
+
+ return getNodes(virtualTableResolver.resolve(nodeType, true));
+ }
+
+ /**
+ * Return set of uuid of nodes. Contains in names prefixes maped to the
+ * given uri
+ *
+ * @param prefix
+ * @return
+ * @throws RepositoryException
+ */
+ public Set<String> getNodesByUri(final String uri) throws RepositoryException
+ {
+ Set<String> result;
+ final int defaultClauseCount = BooleanQuery.getMaxClauseCount();
+ try
+ {
+
+ // final LocationFactory locationFactory = new
+ // LocationFactory(this);
+ final ValueFactoryImpl valueFactory = new ValueFactoryImpl(new LocationFactory(nsReg));
+ BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);
+ BooleanQuery query = new BooleanQuery();
+
+ final String prefix = nsReg.getNamespacePrefixByURI(uri);
+ query.add(new WildcardQuery(new Term(FieldNames.LABEL, prefix + ":*")), Occur.SHOULD);
+ // name of the property
+ query.add(new WildcardQuery(new Term(FieldNames.PROPERTIES_SET, prefix + ":*")), Occur.SHOULD);
+
+ result = getNodes(query);
+
+ // value of the property
+
+ try
+ {
+ final Set<String> props = getFieldNames();
+
+ query = new BooleanQuery();
+ for (final String fieldName : props)
+ {
+ if (!FieldNames.PROPERTIES_SET.equals(fieldName))
+ {
+ query.add(new WildcardQuery(new Term(fieldName, "*" + prefix + ":*")), Occur.SHOULD);
+ }
+ }
+ }
+ catch (final IndexException e)
+ {
+ throw new RepositoryException(e.getLocalizedMessage(), e);
+ }
+
+ final Set<String> propSet = getNodes(query);
+ // Manually check property values;
+ for (final String uuid : propSet)
+ {
+ if (isPrefixMatch(valueFactory, uuid, prefix))
+ {
+ result.add(uuid);
+ }
+ }
+ }
+ finally
+ {
+ BooleanQuery.setMaxClauseCount(defaultClauseCount);
+ }
+
+ return result;
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener#onSaveItems(org.exoplatform.services.jcr.dataflow.ItemStateChangesLog)
+ */
+ public void onSaveItems(ItemStateChangesLog itemStates)
+ {
+ //Check if SearchManager started
+ if (changesFilter == null)
+ return;
+ changesFilter.onSaveItems(itemStates);
+
+ }
+
public void onSaveItems(List<WriteCommand> modifications) throws RepositoryException
{
try
@@ -279,124 +416,96 @@
}
}
- public void onSaveItems(ItemStateChangesLog changesLog)
+ public void start()
{
- // Exception es = new Exception();
- // es.printStackTrace();
- if (handler == null)
- return;
-
- long time = System.currentTimeMillis();
-
- // nodes that need to be removed from the index.
- final Set<String> removedNodes = new HashSet<String>();
- // nodes that need to be added to the index.
- final Set<String> addedNodes = new HashSet<String>();
-
- final Map<String, List<ItemState>> updatedNodes = new HashMap<String, List<ItemState>>();
-
- for (Iterator<ItemState> iter = changesLog.getAllStates().iterator(); iter.hasNext();)
+ if (log.isDebugEnabled())
+ log.debug("start");
+ try
{
- ItemState itemState = iter.next();
-
- if (!indexingTree.isExcluded(itemState))
+ if (indexingTree == null)
{
- String uuid =
- itemState.isNode() ? itemState.getData().getIdentifier() : itemState.getData().getParentIdentifier();
+ List<QPath> excludedPath = new ArrayList<QPath>();
+ // Calculating excluded node identifiers
+ excludedPath.add(Constants.JCR_SYSTEM_PATH);
- if (itemState.isAdded())
+ //if (config.getExcludedNodeIdentifers() != null)
+ String excludedNodeIdentifer =
+ config.getParameterValue(QueryHandlerParams.PARAM_EXCLUDED_NODE_IDENTIFERS, null);
+ if (excludedNodeIdentifer != null)
{
- if (itemState.isNode())
+ StringTokenizer stringTokenizer = new StringTokenizer(excludedNodeIdentifer);
+ while (stringTokenizer.hasMoreTokens())
{
- addedNodes.add(uuid);
- }
- else
- {
- if (!addedNodes.contains(uuid))
+
+ try
{
- createNewOrAdd(uuid, itemState, updatedNodes);
+ ItemData excludeData = itemMgr.getItemData(stringTokenizer.nextToken());
+ if (excludeData != null)
+ excludedPath.add(excludeData.getQPath());
}
+ catch (RepositoryException e)
+ {
+ log.warn(e.getLocalizedMessage());
+ }
}
}
- else if (itemState.isRenamed())
+
+ NodeData indexingRootData = null;
+ String rootNodeIdentifer = config.getParameterValue(QueryHandlerParams.PARAM_ROOT_NODE_ID, null);
+ if (rootNodeIdentifer != null)
{
- if (itemState.isNode())
+ try
{
- addedNodes.add(uuid);
+ ItemData indexingRootDataItem = itemMgr.getItemData(rootNodeIdentifer);
+ if (indexingRootDataItem != null && indexingRootDataItem.isNode())
+ indexingRootData = (NodeData)indexingRootDataItem;
}
- else
+ catch (RepositoryException e)
{
- createNewOrAdd(uuid, itemState, updatedNodes);
+ log.warn(e.getLocalizedMessage() + " Indexing root set to " + Constants.ROOT_PATH.getAsString());
+
}
+
}
- else if (itemState.isUpdated())
+ else
{
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- else if (itemState.isMixinChanged())
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- else if (itemState.isDeleted())
- {
- if (itemState.isNode())
+ try
{
- if (addedNodes.contains(uuid))
- {
- addedNodes.remove(uuid);
- removedNodes.remove(uuid);
- }
- else
- {
- removedNodes.add(uuid);
- }
- // remove all changes after node remove
- updatedNodes.remove(uuid);
+ indexingRootData = (NodeData)itemMgr.getItemData(Constants.ROOT_UUID);
+ // indexingRootData =
+ // new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ // new InternalQName[0], 0, null, new AccessControlList());
}
- else
+ catch (RepositoryException e)
{
- if (!removedNodes.contains(uuid) && !addedNodes.contains(uuid))
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
+ log.error("Fail to load root node data");
}
}
+
+ indexingTree = new IndexingTree(indexingRootData, excludedPath);
}
+ initializeChangesFilter();
+ initializeQueryHandler();
}
- // TODO make quick changes
- for (String uuid : updatedNodes.keySet())
- {
- removedNodes.add(uuid);
- addedNodes.add(uuid);
- }
-
- try
- {
- updateIndex(removedNodes, addedNodes);
- }
catch (RepositoryException e)
{
- log.error("Error indexing changes " + e, e);
+ log.error(e.getLocalizedMessage());
+ handler = null;
+ throw new RuntimeException(e.getLocalizedMessage(), e.getCause());
}
- catch (IOException e)
+ catch (RepositoryConfigurationException 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);
- }
+ log.error(e.getLocalizedMessage());
+ handler = null;
+ throw new RuntimeException(e.getLocalizedMessage(), e.getCause());
}
+ }
- if (log.isDebugEnabled())
- {
- log.debug("onEvent: indexing finished in " + String.valueOf(System.currentTimeMillis() - time) + " ms.");
- }
-
+ public void stop()
+ {
+ handler.close();
+ log.info("Search manager stopped");
}
/**
@@ -491,141 +600,46 @@
}
- public void createNewOrAdd(String key, ItemState state, Map<String, List<ItemState>> updatedNodes)
+ protected QueryHandlerContext createQueryHandlerContext(QueryHandler parentHandler)
+ throws RepositoryConfigurationException
{
- List<ItemState> list = updatedNodes.get(key);
- if (list == null)
- {
- list = new ArrayList<ItemState>();
- updatedNodes.put(key, list);
- }
- list.add(state);
+ QueryHandlerContext context =
+ new QueryHandlerContext(itemMgr, indexingTree, nodeTypeDataManager, nsReg, parentHandler, getIndexDir(),
+ extractor, true, virtualTableResolver);
+ return context;
}
- public void start()
+ /**
+ * Creates a new instance of an {@link AbstractQueryImpl} which is not
+ * initialized.
+ *
+ * @return an new query instance.
+ * @throws RepositoryException
+ * if an error occurs while creating a new query instance.
+ */
+ protected AbstractQueryImpl createQueryInstance() throws RepositoryException
{
-
- if (log.isDebugEnabled())
- log.debug("start");
try
{
- if (indexingTree == null)
+ String queryImplClassName = handler.getQueryClass();
+ Object obj = Class.forName(queryImplClassName).newInstance();
+ if (obj instanceof AbstractQueryImpl)
{
- List<QPath> excludedPath = new ArrayList<QPath>();
- // Calculating excluded node identifiers
- excludedPath.add(Constants.JCR_SYSTEM_PATH);
-
- //if (config.getExcludedNodeIdentifers() != null)
- String excludedNodeIdentifer =
- config.getParameterValue(QueryHandlerParams.PARAM_EXCLUDED_NODE_IDENTIFERS, null);
- if (excludedNodeIdentifer != null)
- {
- StringTokenizer stringTokenizer = new StringTokenizer(excludedNodeIdentifer);
- while (stringTokenizer.hasMoreTokens())
- {
-
- try
- {
- ItemData excludeData = itemMgr.getItemData(stringTokenizer.nextToken());
- if (excludeData != null)
- excludedPath.add(excludeData.getQPath());
- }
- catch (RepositoryException e)
- {
- log.warn(e.getLocalizedMessage());
- }
- }
- }
-
- NodeData indexingRootData = null;
- String rootNodeIdentifer = config.getParameterValue(QueryHandlerParams.PARAM_ROOT_NODE_ID, null);
- if (rootNodeIdentifer != null)
- {
- try
- {
- ItemData indexingRootDataItem = itemMgr.getItemData(rootNodeIdentifer);
- if (indexingRootDataItem != null && indexingRootDataItem.isNode())
- indexingRootData = (NodeData)indexingRootDataItem;
- }
- catch (RepositoryException e)
- {
- log.warn(e.getLocalizedMessage() + " Indexing root set to " + Constants.ROOT_PATH.getAsString());
-
- }
-
- }
- else
- {
- try
- {
- indexingRootData = (NodeData)itemMgr.getItemData(Constants.ROOT_UUID);
- // indexingRootData =
- // new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- // new InternalQName[0], 0, null, new AccessControlList());
- }
- catch (RepositoryException e)
- {
- log.error("Fail to load root node data");
- }
- }
-
- indexingTree = new IndexingTree(indexingRootData, excludedPath);
+ return (AbstractQueryImpl)obj;
}
-
- initializeQueryHandler();
+ else
+ {
+ throw new IllegalArgumentException(queryImplClassName + " is not of type "
+ + AbstractQueryImpl.class.getName());
+ }
}
- catch (RepositoryException e)
+ catch (Throwable t)
{
- log.error(e.getLocalizedMessage());
- handler = null;
- throw new RuntimeException(e.getLocalizedMessage(), e.getCause());
+ throw new RepositoryException("Unable to create query: " + t.toString(), t);
}
- catch (RepositoryConfigurationException e)
- {
- log.error(e.getLocalizedMessage());
- handler = null;
- throw new RuntimeException(e.getLocalizedMessage(), e.getCause());
- }
}
- public void stop()
- {
- handler.close();
- log.info("Search manager stopped");
- }
-
- // /**
- // * Checks if the given event should be excluded based on the
- // * {@link #excludePath} setting.
- // *
- // * @param event
- // * observation event
- // * @return <code>true</code> if the event should be excluded,
- // * <code>false</code> otherwise
- // */
- // protected boolean isExcluded(ItemState event) {
- //
- // for (QPath excludedPath : excludedPaths) {
- // if (event.getData().getQPath().isDescendantOf(excludedPath)
- // || event.getData().getQPath().equals(excludedPath))
- // return true;
- // }
- //
- // return !event.getData().getQPath().isDescendantOf(indexingRoot)
- // && !event.getData().getQPath().equals(indexingRoot);
- // }
-
- protected QueryHandlerContext createQueryHandlerContext(QueryHandler parentHandler)
- throws RepositoryConfigurationException
- {
-
- QueryHandlerContext context =
- new QueryHandlerContext(itemMgr, indexingTree, nodeTypeDataManager, nsReg, parentHandler, getIndexDir(),
- extractor, true, virtualTableResolver);
- return context;
- }
-
protected String getIndexDir() throws RepositoryConfigurationException
{
String dir = config.getParameterValue(QueryHandlerParams.PARAM_INDEX_DIR, null);
@@ -639,6 +653,61 @@
}
/**
+ * Initialize changes filter.
+ * @throws RepositoryException
+ * @throws RepositoryConfigurationException
+ * @throws ClassNotFoundException
+ * @throws NoSuchMethodException
+ * @throws SecurityException
+ */
+ protected void initializeChangesFilter() throws RepositoryException, RepositoryConfigurationException
+
+ {
+ Class<? extends IndexerChangesFilter> changesFilterClass = DefaultChangesFilter.class;
+ String changesFilterClassName = config.getParameterValue(QueryHandlerParams.PARAM_CHANGES_FILTER_CLASS, null);
+ try
+ {
+ if (changesFilterClassName != null)
+ {
+ changesFilterClass =
+ (Class<? extends IndexerChangesFilter>)Class.forName(changesFilterClassName, true, this.getClass()
+ .getClassLoader());
+ }
+ Constructor<? extends IndexerChangesFilter> constuctor =
+ changesFilterClass.getConstructor(SearchManager.class, QueryHandlerEntry.class, IndexingTree.class);
+ changesFilter = constuctor.newInstance(this, config, indexingTree);
+ }
+ catch (SecurityException e)
+ {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ }
+
+ /**
* Initializes the query handler.
*
* @throws RepositoryException
@@ -661,6 +730,7 @@
QueryHandler parentHandler = (this.parentSearchManager != null) ? parentSearchManager.getHandler() : null;
QueryHandlerContext context = createQueryHandlerContext(parentHandler);
handler.init(context);
+ changesFilter.setHandler(handler);
}
catch (SecurityException e)
{
@@ -697,143 +767,29 @@
}
/**
- * Creates a new instance of an {@link AbstractQueryImpl} which is not
- * initialized.
- *
- * @return an new query instance.
- * @throws RepositoryException
- * if an error occurs while creating a new query instance.
- */
- protected AbstractQueryImpl createQueryInstance() throws RepositoryException
- {
- try
- {
- String queryImplClassName = handler.getQueryClass();
- Object obj = Class.forName(queryImplClassName).newInstance();
- if (obj instanceof AbstractQueryImpl)
- {
- return (AbstractQueryImpl)obj;
- }
- else
- {
- throw new IllegalArgumentException(queryImplClassName + " is not of type "
- + AbstractQueryImpl.class.getName());
- }
- }
- catch (Throwable t)
- {
- throw new RepositoryException("Unable to create query: " + t.toString(), t);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Set<String> getFieldNames() throws IndexException
- {
- final Set<String> fildsSet = new HashSet<String>();
- if (handler instanceof SearchIndex)
- {
- IndexReader reader = null;
- try
- {
- reader = ((SearchIndex)handler).getIndexReader();
- final Collection fields = reader.getFieldNames(IndexReader.FieldOption.ALL);
- for (final Object field : fields)
- {
- fildsSet.add((String)field);
- }
- }
- catch (IOException e)
- {
- throw new IndexException(e.getLocalizedMessage(), e);
- }
- finally
- {
- try
- {
- if (reader != null)
- reader.close();
- }
- catch (IOException e)
- {
- throw new IndexException(e.getLocalizedMessage(), e);
- }
- }
-
- }
- return fildsSet;
- }
-
- public Set<String> getNodesByNodeType(final InternalQName nodeType) throws RepositoryException
- {
-
- return getNodes(virtualTableResolver.resolve(nodeType, true));
- }
-
- /**
- * Return set of uuid of nodes. Contains in names prefixes maped to the
- * given uri
- *
- * @param prefix
+ * @param query
* @return
* @throws RepositoryException
*/
- public Set<String> getNodesByUri(final String uri) throws RepositoryException
+ private Set<String> getNodes(final org.apache.lucene.search.Query query) throws RepositoryException
{
- Set<String> result;
- final int defaultClauseCount = BooleanQuery.getMaxClauseCount();
+ Set<String> result = new HashSet<String>();
try
{
+ QueryHits hits = handler.executeQuery(query);
- // final LocationFactory locationFactory = new
- // LocationFactory(this);
- final ValueFactoryImpl valueFactory = new ValueFactoryImpl(new LocationFactory(nsReg));
- BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);
- BooleanQuery query = new BooleanQuery();
+ ScoreNode sn;
- final String prefix = nsReg.getNamespacePrefixByURI(uri);
- query.add(new WildcardQuery(new Term(FieldNames.LABEL, prefix + ":*")), Occur.SHOULD);
- // name of the property
- query.add(new WildcardQuery(new Term(FieldNames.PROPERTIES_SET, prefix + ":*")), Occur.SHOULD);
-
- result = getNodes(query);
-
- // value of the property
-
- try
+ while ((sn = hits.nextScoreNode()) != null)
{
- final Set<String> props = getFieldNames();
-
- query = new BooleanQuery();
- for (final String fieldName : props)
- {
- if (!FieldNames.PROPERTIES_SET.equals(fieldName))
- {
- query.add(new WildcardQuery(new Term(fieldName, "*" + prefix + ":*")), Occur.SHOULD);
- }
- }
+ // Node node = session.getNodeById(sn.getNodeId());
+ result.add(sn.getNodeId());
}
- catch (final IndexException e)
- {
- throw new RepositoryException(e.getLocalizedMessage(), e);
- }
-
- final Set<String> propSet = getNodes(query);
- // Manually check property values;
- for (final String uuid : propSet)
- {
- if (isPrefixMatch(valueFactory, uuid, prefix))
- {
- result.add(uuid);
- }
- }
}
- finally
+ catch (IOException e)
{
- BooleanQuery.setMaxClauseCount(defaultClauseCount);
+ throw new RepositoryException(e.getLocalizedMessage(), e);
}
-
return result;
}
@@ -898,31 +854,4 @@
return false;
}
- /**
- * @param query
- * @return
- * @throws RepositoryException
- */
- private Set<String> getNodes(final org.apache.lucene.search.Query query) throws RepositoryException
- {
- Set<String> result = new HashSet<String>();
- try
- {
- QueryHits hits = handler.executeQuery(query);
-
- ScoreNode sn;
-
- while ((sn = hits.nextScoreNode()) != null)
- {
- // Node node = session.getNodeById(sn.getNodeId());
- result.add(sn.getNodeId());
- }
- }
- catch (IOException e)
- {
- throw new RepositoryException(e.getLocalizedMessage(), e);
- }
- return result;
- }
-
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2009-12-07 10:11:19 UTC (rev 930)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2009-12-07 10:56:37 UTC (rev 931)
@@ -103,6 +103,7 @@
indexingTree = new IndexingTree(indexingRootNodeData, excludedPaths);
}
+ initializeChangesFilter();
initializeQueryHandler();
}
16 years, 7 months
exo-jcr SVN: r930 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/impl/dataflow and 1 other directory.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2009-12-07 05:11:19 -0500 (Mon, 07 Dec 2009)
New Revision: 930
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestTransientValueDataSerialization.java
Log:
EXOJCR-264: absolute blob file path now serialized with TransientValueData
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2009-12-07 08:41:44 UTC (rev 929)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2009-12-07 10:11:19 UTC (rev 930)
@@ -950,6 +950,10 @@
*/
public void writeExternal(ObjectOutput out) throws IOException
{
+ //spool if needed
+ if (!spooled)
+ spoolInputStream();
+
if (this.isByteArray())
{
out.writeInt(1);
@@ -962,21 +966,24 @@
// write streams
out.writeInt(2);
//TODO Need optimization in backup service.
- byte[] buf = new byte[4 * 1024];
+ //byte[] buf = new byte[4 * 1024];
- if (!spooled)
- spoolInputStream();
- InputStream in = (spoolFile == null ? new ByteArrayInputStream(data) : new FileInputStream(spoolFile));
- long dataLength = (spoolFile == null ? data.length : spoolFile.length());
- int len;
+ // write path to spool file
+ String filePath = spoolFile.getAbsolutePath();
- //write length of spoolFile
- out.writeLong(dataLength);
+ out.writeUTF(filePath);
- while ((len = in.read(buf)) > 0)
- out.write(buf, 0, len);
+ // InputStream in = (spoolFile == null ? new ByteArrayInputStream(data) : new FileInputStream(spoolFile));
+ // long dataLength = (spoolFile == null ? data.length : spoolFile.length());
+ // int len;
- in.close();
+ // write length of spoolFile
+ // out.writeLong(dataLength);
+
+ // while ((len = in.read(buf)) > 0)
+ // out.write(buf, 0, len);
+ //
+ // in.close();
}
out.writeInt(orderNumber);
@@ -997,32 +1004,42 @@
}
else
{
- //read file form stream
- long lengthSpoolFile = in.readLong();
+ String path = in.readUTF();
- //TODO May be optimization.
- SpoolFile sf = SpoolFile.createTempFile("jcrvd", null, tempDirectory);
- sf.acquire(this);
- OutputStream outStream = new FileOutputStream(sf);
+ //TODO we do not know is there SpoolFile or TreeFile etc.
+ File sf = new File(path);
- byte[] buf = new byte[4 * 1024];
-
- while (lengthSpoolFile > 0)
+ if (!sf.exists())
{
- if (lengthSpoolFile - buf.length > 0)
- {
- in.readFully(buf);
- outStream.write(buf);
- }
- else
- {
- in.readFully(buf, 0, (int)lengthSpoolFile);
- outStream.write(buf, 0, (int)lengthSpoolFile);
- }
- lengthSpoolFile -= buf.length;
+ //TODO this exception must be never thrown
+ throw new IOException("SpoolFile [" + sf.getAbsolutePath() + "] not exist.");
}
- outStream.flush();
- outStream.close();
+ //read file form stream
+ // long lengthSpoolFile = in.readLong();
+ //
+ // //TODO May be optimization.
+ // SpoolFile sf = SpoolFile.createTempFile("jcrvd", null, tempDirectory);
+ // sf.acquire(this);
+ // OutputStream outStream = new FileOutputStream(sf);
+ //
+ // byte[] buf = new byte[4 * 1024];
+ //
+ // while (lengthSpoolFile > 0)
+ // {
+ // if (lengthSpoolFile - buf.length > 0)
+ // {
+ // in.readFully(buf);
+ // outStream.write(buf);
+ // }
+ // else
+ // {
+ // in.readFully(buf, 0, (int)lengthSpoolFile);
+ // outStream.write(buf, 0, (int)lengthSpoolFile);
+ // }
+ // lengthSpoolFile -= buf.length;
+ // }
+ // outStream.flush();
+ // outStream.close();
spoolFile = sf;
spooled = true;
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestTransientValueDataSerialization.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestTransientValueDataSerialization.java 2009-12-07 08:41:44 UTC (rev 929)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestTransientValueDataSerialization.java 2009-12-07 10:11:19 UTC (rev 930)
@@ -18,15 +18,15 @@
*/
package org.exoplatform.services.jcr.impl.dataflow;
+import org.exoplatform.services.jcr.JcrImplBaseTest;
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import org.exoplatform.services.jcr.JcrImplBaseTest;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-
/**
* Created by The eXo Platform SAS.
*
@@ -36,8 +36,7 @@
* @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
* @version $Id$
*/
-public class TestTransientValueDataSerialization
- extends JcrImplBaseTest
+public class TestTransientValueDataSerialization extends JcrImplBaseTest
{
public void testTVDSerialization() throws Exception
@@ -47,9 +46,8 @@
// Create TransientValueData instants
TransientValueData tvd = new TransientValueData(new FileInputStream(f), 10);
- tvd.setMaxBufferSize(200*1024);
+ tvd.setMaxBufferSize(200 * 1024);
tvd.setFileCleaner(new FileCleaner());
-
File out = File.createTempFile("test", ".data");
out.deleteOnExit();
@@ -62,7 +60,7 @@
//deserialize
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(out));
- TransientValueData deserializedTransientValueData = (TransientValueData) ois.readObject();
+ TransientValueData deserializedTransientValueData = (TransientValueData)ois.readObject();
//check
assertNotNull(deserializedTransientValueData);
@@ -70,15 +68,18 @@
assertEquals(tvd.getOrderNumber(), deserializedTransientValueData.getOrderNumber());
compareStream(tvd.getAsStream(), deserializedTransientValueData.getAsStream());
}
-
+
public void testTVDSerialization2M() throws Exception
{
File f = createBLOBTempFile(2145);
f.deleteOnExit();
// Create TransientValueData instants
- TransientValueData tvd = new TransientValueData(new FileInputStream(f), 10);
- tvd.setMaxBufferSize(200*1024);
+ TransientValueData tvd = //new TransientValueData(new FileInputStream(f), 10);
+ new TransientValueData(10, null, new FileInputStream(f), null, null, 1024, new File(System
+ .getProperty("java.io.tmpdir")), false);
+
+ tvd.setMaxBufferSize(200 * 1024);
tvd.setFileCleaner(new FileCleaner());
File out = File.createTempFile("test", ".data");
@@ -92,7 +93,7 @@
//deserialize
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(out));
- TransientValueData deserializedTransientValueData = (TransientValueData) ois.readObject();
+ TransientValueData deserializedTransientValueData = (TransientValueData)ois.readObject();
//check
assertNotNull(deserializedTransientValueData);
16 years, 7 months
exo-jcr SVN: r929 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl: core/query and 1 other directory.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-07 03:41:44 -0500 (Mon, 07 Dec 2009)
New Revision: 929
Removed:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSearchManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSystemSearchManager.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
Log:
EXOJCR-283: Removed separated classes due to error in container.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2009-12-04 16:45:41 UTC (rev 928)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2009-12-07 08:41:44 UTC (rev 929)
@@ -46,8 +46,6 @@
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
import org.exoplatform.services.jcr.impl.core.nodetype.registration.JcrNodeTypeDataPersister;
import org.exoplatform.services.jcr.impl.core.observation.ObservationManagerRegistry;
-import org.exoplatform.services.jcr.impl.core.query.JbossCacheSearchManager;
-import org.exoplatform.services.jcr.impl.core.query.JbossCacheSystemSearchManager;
import org.exoplatform.services.jcr.impl.core.query.QueryManagerFactory;
import org.exoplatform.services.jcr.impl.core.query.RepositoryIndexSearcherHolder;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
@@ -266,22 +264,12 @@
QueryHandlerEntry queryHandler = wsConfig.getQueryHandler();
if (queryHandler != null)
{
- if (queryHandler.getParameterValue(JbossCacheSearchManager.JBOSSCACHE_CONFIG, null) == null)
+ workspaceContainer.registerComponentImplementation(SearchManager.class);
+ if (isSystem)
{
- workspaceContainer.registerComponentImplementation(SearchManager.class);
- if (isSystem)
- {
- workspaceContainer.registerComponentImplementation(SystemSearchManager.class);
- }
+ workspaceContainer.registerComponentImplementation(SystemSearchManager.class);
}
- else
- {
- workspaceContainer.registerComponentImplementation(JbossCacheSearchManager.class);
- if (isSystem)
- {
- workspaceContainer.registerComponentImplementation(JbossCacheSystemSearchManager.class);
- }
- }
+
workspaceContainer.registerComponentImplementation(QueryManager.class);
workspaceContainer.registerComponentImplementation(QueryManagerFactory.class);
workspaceContainer.registerComponentInstance(queryHandler);
Deleted: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSearchManager.java 2009-12-04 16:45:41 UTC (rev 928)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSearchManager.java 2009-12-07 08:41:44 UTC (rev 929)
@@ -1,61 +0,0 @@
-/*
- * 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;
-
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.services.jcr.config.QueryHandlerEntry;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
-import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
-
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
- * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
- *
- */
-public class JbossCacheSearchManager extends SearchManager
-{
- /**
- * @param config
- * @param nsReg
- * @param ntReg
- * @param itemMgr
- * @param parentSearchManager
- * @param extractor
- * @param cfm
- * @param indexSearcherHolder
- * @throws RepositoryException
- * @throws RepositoryConfigurationException
- */
- public JbossCacheSearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg, NodeTypeDataManager ntReg,
- WorkspacePersistentDataManager itemMgr, SystemSearchManagerHolder parentSearchManager,
- DocumentReaderService extractor, ConfigurationManager cfm, RepositoryIndexSearcherHolder indexSearcherHolder)
- throws RepositoryException, RepositoryConfigurationException
- {
- super(config, nsReg, ntReg, itemMgr, parentSearchManager, extractor, cfm, indexSearcherHolder);
- // TODO Auto-generated constructor stub
- }
-
- public static final String JBOSSCACHE_CONFIG = "jbosscache-configuration";
-
-}
Deleted: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSystemSearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSystemSearchManager.java 2009-12-04 16:45:41 UTC (rev 928)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSystemSearchManager.java 2009-12-07 08:41:44 UTC (rev 929)
@@ -1,59 +0,0 @@
-/*
- * 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;
-
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.services.jcr.config.QueryHandlerEntry;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
-import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
-
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
- * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
- *
- */
-public class JbossCacheSystemSearchManager extends SystemSearchManager
-{
-
- /**
- * @param config
- * @param nsReg
- * @param ntReg
- * @param itemMgr
- * @param service
- * @param cfm
- * @param indexSearcherHolder
- * @throws RepositoryException
- * @throws RepositoryConfigurationException
- */
- public JbossCacheSystemSearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg,
- NodeTypeDataManager ntReg, WorkspacePersistentDataManager itemMgr, DocumentReaderService service,
- ConfigurationManager cfm, RepositoryIndexSearcherHolder indexSearcherHolder) throws RepositoryException,
- RepositoryConfigurationException
- {
- super(config, nsReg, ntReg, itemMgr, service, cfm, indexSearcherHolder);
- // TODO Auto-generated constructor stub
- }
-
-}
16 years, 7 months
exo-jcr SVN: r928 - in jcr/branches/1.12.0-JBC/component/core/src: main/java/org/exoplatform/services/jcr/impl/core/query/lucene and 2 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-12-04 11:45:41 -0500 (Fri, 04 Dec 2009)
New Revision: 928
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestItemAccess.java
Log:
EXOJCR-307: getItemData(String) returns only NodeData
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-12-04 16:15:15 UTC (rev 927)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-12-04 16:45:41 UTC (rev 928)
@@ -873,7 +873,9 @@
{
try
{
- PropertyData vhPropertyData = (PropertyData)getItemData(data.getIdentifier());
+ PropertyData vhPropertyData =
+ (PropertyData)getItemData((NodeData)getItemData(data.getParentIdentifier()), data.getQPath()
+ .getEntries()[data.getQPath().getEntries().length - 1]);
removeVersionHistory(new String(vhPropertyData.getValues().get(0).getAsByteArray()), null,
ancestorToSave);
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2009-12-04 16:15:15 UTC (rev 927)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2009-12-04 16:45:41 UTC (rev 928)
@@ -402,8 +402,9 @@
// WARN. DON'T USE access item BY PATH - it's may be a node in case of
// residual definitions in NT
List<ValueData> data =
- prop.getValues().size() > 0 ? prop.getValues() : ((PropertyData)stateProvider.getItemData(prop
- .getIdentifier())).getValues();
+ prop.getValues().size() > 0 ? prop.getValues() : ((PropertyData)stateProvider.getItemData(
+ (NodeData)stateProvider.getItemData(prop.getParentIdentifier()), prop.getQPath().getEntries()[prop
+ .getQPath().getEntries().length - 1])).getValues();
if (data == null)
log.warn("null value found at property " + prop.getQPath().getAsString());
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-04 16:15:15 UTC (rev 927)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-04 16:45:41 UTC (rev 928)
@@ -593,22 +593,24 @@
throw new RepositoryException("FATAL NodeData empty " + identifier);
}
}
- else
- {
- Node<Serializable, Object> prop = propsRoot.getChild(makePropFqn(identifier));
- if (prop != null)
- {
- Object itemData = prop.get(ITEM_DATA);
- if (itemData != null)
- {
- return (PropertyData)itemData;
- }
- else
- {
- throw new RepositoryException("FATAL PropertyData empty " + identifier);
- }
- }
- }
+
+ // only Nodes by Id
+// else
+// {
+// Node<Serializable, Object> prop = propsRoot.getChild(makePropFqn(identifier));
+// if (prop != null)
+// {
+// Object itemData = prop.get(ITEM_DATA);
+// if (itemData != null)
+// {
+// return (PropertyData)itemData;
+// }
+// else
+// {
+// throw new RepositoryException("FATAL PropertyData empty " + identifier);
+// }
+// }
+// }
return null;
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestItemAccess.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestItemAccess.java 2009-12-04 16:15:15 UTC (rev 927)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestItemAccess.java 2009-12-04 16:45:41 UTC (rev 928)
@@ -58,7 +58,7 @@
nGen.genereteTree();
validNames = NameTraversingVisitor.getValidNames(testGetItemNode, NameTraversingVisitor.SCOPE_ALL);
- validUuids = NameTraversingVisitor.getValidUuids(testGetItemNode, NameTraversingVisitor.SCOPE_ALL);
+ validUuids = NameTraversingVisitor.getValidUuids(testGetItemNode, NameTraversingVisitor.SCOPE_NODES);
}
public void testGetItemTest() throws RepositoryException
16 years, 7 months
exo-jcr SVN: r927 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-12-04 11:15:15 -0500 (Fri, 04 Dec 2009)
New Revision: 927
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-293 : The reuse tree algorithm for JbossCache nodes.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java 2009-12-04 14:08:54 UTC (rev 926)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java 2009-12-04 16:15:15 UTC (rev 927)
@@ -30,8 +30,10 @@
public class IdTreeHelper
{
- private final static int xLength = 8;
+ private final static int X_LENGTH = 8;
+ private final static int FQN_ID_LENGTH = X_LENGTH + 2;
+
/**
* Build path by UUID.
*
@@ -40,7 +42,7 @@
* @return String[]
* the tree id
*/
- public static String[] buildPath(String id)
+ /*public static String[] buildPath(String id)
{
String tree[] = new String[id.length()];
@@ -48,20 +50,20 @@
tree[i-1] = id.substring(i - 1, i);
return tree;
- }
+ }*/
- /*public static String[] buildPath(String id)
+ public static String[] buildPath(String id)
{
- String tree[] = new String[xLength +1];
+ String tree[] = new String[X_LENGTH +1];
char[] chs = id.toCharArray();
- for (int i = 0; i < xLength; i++)
+ for (int i = 0; i < X_LENGTH; i++)
tree[i] = String.valueOf(chs[i]);
- tree[xLength] = id.substring(xLength);
+ tree[X_LENGTH] = id.substring(X_LENGTH);
return tree;
- }*/
+ }
/**
* Create that transformation
@@ -78,7 +80,7 @@
* the tree Fqn
* @return Fqn
*/
- public static Fqn buildFqn(Fqn treeFqn)
+ /*public static Fqn buildFqn(Fqn treeFqn)
{
String id = treeFqn.getSubFqn(1, IdGenerator.IDENTIFIER_LENGTH + 1).toString();
@@ -97,27 +99,85 @@
}
return Fqn.fromElements(sArray);
- }
+ } */
/*public static Fqn buildFqn(Fqn treeFqn)
{
- String oldId = treeFqn.getSubFqn(1, xLength + 2).toString();
+ String id = "";
+
+ int index = 1;
+
+ for (;index < treeFqn.size(); index++)
+ {
+ if (((String) treeFqn.get(index)).length() == 1)
+ {
+ id += (String) treeFqn.get(index);
+ } else
+ {
+ break;
+ }
+ }
+
+ String[] sArray = new String[treeFqn.size() - (index - 2)];
+
+ sArray[0] = (String) treeFqn.get(0);
+ sArray[1] = id;
+
+ int sArrayIndex = 2;
+
+ for (int i=index; i < treeFqn.size(); i++)
+ {
+ sArray[sArrayIndex++] = (String) treeFqn.get(i);
+ }
+
+ return Fqn.fromElements(sArray);
+ }*/
+
+
+ public static Fqn buildFqn(Fqn treeFqn)
+ {
+ String oldId = treeFqn.getSubFqn(1, X_LENGTH + 2).toString();
String id = oldId.replaceAll(Fqn.SEPARATOR, "");
- String[] sArray = new String[treeFqn.size() - (xLength)];
+ String[] sArray = new String[treeFqn.size() - (X_LENGTH)];
sArray[0] = (String) treeFqn.get(0);
sArray[1] = id;
int sArrayIndex = 1;
- for (int i=(xLength + 2); i < treeFqn.size(); i++)
+ for (int i=(X_LENGTH + 2); i < treeFqn.size(); i++)
{
sArray[++sArrayIndex] = (String) treeFqn.get(i);
}
return Fqn.fromElements(sArray);
- }*/
+ }
+ /**
+ * Check the sub Fqn like /$LOCKs/2/5/6
+ * @return
+ */
+ public static boolean isSubFqn (Fqn fqn) {
+ if (FQN_ID_LENGTH - fqn.size() > 1)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+ public static void main(String[] args)
+ {
+ System.out.println(Fqn.fromElements(buildPath("00exo0jcr0root0uuid0000000000000")));
+ System.out.println(buildFqn(Fqn.fromString("/$NODES/0/0/e/x/o/0/j/c/r/0/r/o/o/t/0/u/u/i/d/0/0/0/0/0/0/0/0/0/0/0/0/0")));
+ System.out.println(buildFqn(Fqn.fromString("/$NODES/0/0/e/x/o/0/j/c/r/0/r/o/o/t/0/u/u/i/d/0/0/0/0/0/0/0/0/0/0/0/0/0/[]subNodeName:1")));
+ System.out.println(buildFqn(Fqn.fromString("/$NODES/f/a/l/s/e/[]dsds:1")));
+
+ }
+
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-04 14:08:54 UTC (rev 926)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-04 16:15:15 UTC (rev 927)
@@ -1311,7 +1311,7 @@
*/
public List<LockData> getLocksData() throws RepositoryException
{
- Set<Node<Serializable, Object>> lockSet = locksRoot.getChildren();
+ Set<Node<Serializable, Object>> lockSet = locksRoot.getChildren()/*getNodes(locksRoot)*/;
List<LockData> locksData = new ArrayList<LockData>();
for (Node<Serializable, Object> node : lockSet)
{
@@ -1326,8 +1326,39 @@
}
return locksData;
}
-
+
+
/**
+ * Traverse tree and getting all nodes without children.
+ *
+ * @param node
+ * @return
+ */
+ private Set<Node<Serializable, Object>> getNodes(Node<Serializable, Object> node) {
+ Set<Node<Serializable, Object>> lockSet = new HashSet<Node<Serializable,Object>>();
+
+ traverseTree(lockSet, node);
+
+ return lockSet;
+ }
+
+ private void traverseTree(Set<Node<Serializable, Object>> resultSet, Node<Serializable, Object> node) {
+ Set<Node<Serializable, Object>> childNodes = node.getChildren();
+
+ for (Node<Serializable, Object> childNode : childNodes)
+ {
+ if (childNode.getChildrenNames().size() == 0)
+ {
+ resultSet.add(childNode);
+ } else
+ {
+ traverseTree(resultSet, childNode);
+ }
+
+ }
+ }
+
+ /**
* @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#addLockData(org.exoplatform.services.jcr.impl.core.lock.LockData)
*/
public void addLockData(LockData lockData) throws RepositoryException
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-04 14:08:54 UTC (rev 926)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-04 16:15:15 UTC (rev 927)
@@ -595,6 +595,10 @@
{
// return child nodes names
+ //to sub Fqn (example /$LOCKS/5/4/3)
+ if (IdTreeHelper.isSubFqn(fqn))
+ return null;
+
Fqn name = ( fqn.size() >= 2 ? IdTreeHelper.buildFqn(fqn) : fqn);
JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
16 years, 7 months
exo-jcr SVN: r926 - in jcr/branches/1.12.0-JBC/component/core/src: main/java/org/exoplatform/services/jcr/impl/core/query and 2 other directories.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-04 09:08:54 -0500 (Fri, 04 Dec 2009)
New Revision: 926
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSearchManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSystemSearchManager.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
Log:
EXOJCR-283: initial implementation indexer on JBC
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2009-12-04 13:56:05 UTC (rev 925)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2009-12-04 14:08:54 UTC (rev 926)
@@ -26,6 +26,7 @@
import org.exoplatform.management.jmx.annotations.NamingContext;
import org.exoplatform.management.jmx.annotations.Property;
import org.exoplatform.services.jcr.access.AccessControlPolicy;
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
@@ -45,6 +46,8 @@
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
import org.exoplatform.services.jcr.impl.core.nodetype.registration.JcrNodeTypeDataPersister;
import org.exoplatform.services.jcr.impl.core.observation.ObservationManagerRegistry;
+import org.exoplatform.services.jcr.impl.core.query.JbossCacheSearchManager;
+import org.exoplatform.services.jcr.impl.core.query.JbossCacheSystemSearchManager;
import org.exoplatform.services.jcr.impl.core.query.QueryManagerFactory;
import org.exoplatform.services.jcr.impl.core.query.RepositoryIndexSearcherHolder;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
@@ -260,16 +263,29 @@
workspaceContainer.registerComponentImplementation(ObservationManagerRegistry.class);
// Query handler
- if (wsConfig.getQueryHandler() != null)
+ QueryHandlerEntry queryHandler = wsConfig.getQueryHandler();
+ if (queryHandler != null)
{
- workspaceContainer.registerComponentImplementation(SearchManager.class);
+ if (queryHandler.getParameterValue(JbossCacheSearchManager.JBOSSCACHE_CONFIG, null) == null)
+ {
+ workspaceContainer.registerComponentImplementation(SearchManager.class);
+ if (isSystem)
+ {
+ workspaceContainer.registerComponentImplementation(SystemSearchManager.class);
+ }
+ }
+ else
+ {
+ workspaceContainer.registerComponentImplementation(JbossCacheSearchManager.class);
+ if (isSystem)
+ {
+ workspaceContainer.registerComponentImplementation(JbossCacheSystemSearchManager.class);
+ }
+ }
workspaceContainer.registerComponentImplementation(QueryManager.class);
workspaceContainer.registerComponentImplementation(QueryManagerFactory.class);
- workspaceContainer.registerComponentInstance(wsConfig.getQueryHandler());
- if (isSystem)
- {
- workspaceContainer.registerComponentImplementation(SystemSearchManager.class);
- }
+ workspaceContainer.registerComponentInstance(queryHandler);
+
}
// access manager
@@ -422,8 +438,8 @@
{
initWorkspace(ws);
WorkspaceContainer workspaceContainer = getWorkspaceContainer(ws.getName());
- SearchManager searchManager =
- (SearchManager)workspaceContainer.getComponentInstanceOfType(SearchManager.class);
+ // SearchManager searchManager =
+ // (SearchManager)workspaceContainer.getComponentInstanceOfType(SearchManager.class);
// if (searchManager != null)
// {
// typeManager.addQueryHandler(searchManager.getHandler());
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSearchManager.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSearchManager.java 2009-12-04 14:08:54 UTC (rev 926)
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.document.DocumentReaderService;
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
+ *
+ */
+public class JbossCacheSearchManager extends SearchManager
+{
+ /**
+ * @param config
+ * @param nsReg
+ * @param ntReg
+ * @param itemMgr
+ * @param parentSearchManager
+ * @param extractor
+ * @param cfm
+ * @param indexSearcherHolder
+ * @throws RepositoryException
+ * @throws RepositoryConfigurationException
+ */
+ public JbossCacheSearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg, NodeTypeDataManager ntReg,
+ WorkspacePersistentDataManager itemMgr, SystemSearchManagerHolder parentSearchManager,
+ DocumentReaderService extractor, ConfigurationManager cfm, RepositoryIndexSearcherHolder indexSearcherHolder)
+ throws RepositoryException, RepositoryConfigurationException
+ {
+ super(config, nsReg, ntReg, itemMgr, parentSearchManager, extractor, cfm, indexSearcherHolder);
+ // TODO Auto-generated constructor stub
+ }
+
+ public static final String JBOSSCACHE_CONFIG = "jbosscache-configuration";
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSearchManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSystemSearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSystemSearchManager.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSystemSearchManager.java 2009-12-04 14:08:54 UTC (rev 926)
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.document.DocumentReaderService;
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
+ *
+ */
+public class JbossCacheSystemSearchManager extends SystemSearchManager
+{
+
+ /**
+ * @param config
+ * @param nsReg
+ * @param ntReg
+ * @param itemMgr
+ * @param service
+ * @param cfm
+ * @param indexSearcherHolder
+ * @throws RepositoryException
+ * @throws RepositoryConfigurationException
+ */
+ public JbossCacheSystemSearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg,
+ NodeTypeDataManager ntReg, WorkspacePersistentDataManager itemMgr, DocumentReaderService service,
+ ConfigurationManager cfm, RepositoryIndexSearcherHolder indexSearcherHolder) throws RepositoryException,
+ RepositoryConfigurationException
+ {
+ super(config, nsReg, ntReg, itemMgr, service, cfm, indexSearcherHolder);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/JbossCacheSystemSearchManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-12-04 13:56:05 UTC (rev 925)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-12-04 14:08:54 UTC (rev 926)
@@ -43,7 +43,6 @@
import org.exoplatform.services.jcr.impl.core.SessionDataManager;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.exoplatform.services.jcr.impl.core.query.jbosscache.IndexModificationsBuilder;
-import org.exoplatform.services.jcr.impl.core.query.jbosscache.IndexerInterceptor;
import org.exoplatform.services.jcr.impl.core.query.lucene.FieldNames;
import org.exoplatform.services.jcr.impl.core.query.lucene.LuceneVirtualTableResolver;
import org.exoplatform.services.jcr.impl.core.query.lucene.QueryHits;
@@ -167,8 +166,7 @@
public SearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg, NodeTypeDataManager ntReg,
WorkspacePersistentDataManager itemMgr, SystemSearchManagerHolder parentSearchManager,
- DocumentReaderService extractor, ConfigurationManager cfm,
- final RepositoryIndexSearcherHolder indexSearcherHolder, IndexerInterceptor indexInterceptor)
+ DocumentReaderService extractor, ConfigurationManager cfm, final RepositoryIndexSearcherHolder indexSearcherHolder)
throws RepositoryException, RepositoryConfigurationException
{
@@ -181,7 +179,8 @@
this.cfm = cfm;
this.virtualTableResolver = new LuceneVirtualTableResolver(nodeTypeDataManager, nsReg);
this.parentSearchManager = parentSearchManager != null ? parentSearchManager.get() : null;
- indexInterceptor.addIndexInterceptorListener(this);
+ //indexInterceptor.addIndexInterceptorListener(this);
+ ((WorkspacePersistentDataManager)this.itemMgr).addItemPersistenceListener(this);
}
/**
@@ -282,8 +281,8 @@
public void onSaveItems(ItemStateChangesLog changesLog)
{
- Exception es = new Exception();
- es.printStackTrace();
+ // Exception es = new Exception();
+ // es.printStackTrace();
if (handler == null)
return;
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2009-12-04 13:56:05 UTC (rev 925)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2009-12-04 14:08:54 UTC (rev 926)
@@ -26,7 +26,6 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
-import org.exoplatform.services.jcr.impl.core.query.jbosscache.IndexerInterceptor;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -71,10 +70,9 @@
public SystemSearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg, NodeTypeDataManager ntReg,
WorkspacePersistentDataManager itemMgr, DocumentReaderService service, ConfigurationManager cfm,
- RepositoryIndexSearcherHolder indexSearcherHolder, IndexerInterceptor indexInterceptor)
- throws RepositoryException, RepositoryConfigurationException
+ RepositoryIndexSearcherHolder indexSearcherHolder) throws RepositoryException, RepositoryConfigurationException
{
- super(config, nsReg, ntReg, itemMgr, null, service, cfm, indexSearcherHolder, indexInterceptor);
+ super(config, nsReg, ntReg, itemMgr, null, service, cfm, indexSearcherHolder);
}
@Override
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-12-04 13:56:05 UTC (rev 925)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-12-04 14:08:54 UTC (rev 926)
@@ -21,7 +21,6 @@
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.core.query.jbosscache.IndexerInterceptor;
import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
@@ -36,7 +35,6 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
-import org.jboss.cache.interceptors.CacheStoreInterceptor;
import org.picocontainer.Startable;
import java.io.IOException;
@@ -81,9 +79,8 @@
*
*/
public JBossCacheWorkspaceDataContainer(WorkspaceEntry wsConfig, RepositoryEntry repConfig,
- InitialContextInitializer contextInit, ValueStoragePluginProvider valueStorageProvider,
- IndexerInterceptor indexInterceptor) throws RepositoryConfigurationException, NamingException, RepositoryException,
- IOException
+ InitialContextInitializer contextInit, ValueStoragePluginProvider valueStorageProvider)
+ throws RepositoryConfigurationException, NamingException, RepositoryException, IOException
{
this.repositoryName = repConfig.getName();
this.containerName = wsConfig.getName();
@@ -122,7 +119,7 @@
// initializes configuration state, the root node, etc.
this.cache.create();
this.cache.start();
- this.cache.addInterceptor(indexInterceptor, CacheStoreInterceptor.class);
+ //this.cache.addInterceptor(indexInterceptor, CacheStoreInterceptor.class);
Node<Serializable, Object> cacheRoot = cache.getRoot();
@@ -143,7 +140,7 @@
{
this.cache.stop();
this.cache.destroy();
-
+
if (persistentContainer instanceof Startable)
{
((Startable)persistentContainer).stop();
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java 2009-12-04 13:56:05 UTC (rev 925)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java 2009-12-04 14:08:54 UTC (rev 926)
@@ -18,22 +18,29 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.document.DocumentReaderService;
import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
import org.exoplatform.services.jcr.impl.core.SessionDataManager;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.exoplatform.services.jcr.impl.core.query.IndexException;
import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
import org.exoplatform.services.jcr.impl.core.query.RepositoryIndexSearcherHolder;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
+import org.exoplatform.services.jcr.impl.core.query.SystemSearchManagerHolder;
import org.exoplatform.services.jcr.impl.core.query.jbosscache.IndexerCacheLoader;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.jboss.cache.Modification;
import java.io.IOException;
@@ -72,7 +79,7 @@
// holder = new IndexInterceptorHolder();
indexerCacheLoader = new IndexerCacheLoader();
//indexerCacheLoader.injectDependencies(holder);
- searchManager = new DummySearchManager();
+ //searchManager = new DummySearchManager();
}
@@ -263,15 +270,31 @@
private class DummySearchManager extends SearchManager
{
+ /**
+ * @param config
+ * @param nsReg
+ * @param ntReg
+ * @param itemMgr
+ * @param parentSearchManager
+ * @param extractor
+ * @param cfm
+ * @param indexSearcherHolder
+ * @throws RepositoryException
+ * @throws RepositoryConfigurationException
+ */
+ public DummySearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg, NodeTypeDataManager ntReg,
+ WorkspacePersistentDataManager itemMgr, SystemSearchManagerHolder parentSearchManager,
+ DocumentReaderService extractor, ConfigurationManager cfm, RepositoryIndexSearcherHolder indexSearcherHolder)
+ throws RepositoryException, RepositoryConfigurationException
+ {
+ super(config, nsReg, ntReg, itemMgr, parentSearchManager, extractor, cfm, indexSearcherHolder);
+ // TODO Auto-generated constructor stub
+ }
+
private Set<String> removedNodes;
private Set<String> addedNodes;
- public DummySearchManager() throws RepositoryException, RepositoryConfigurationException
- {
- super(null, null, null, null, null, null, null, new RepositoryIndexSearcherHolder(), null);
- }
-
/**
* @see org.exoplatform.services.jcr.impl.core.query.SearchManager#createQuery(org.exoplatform.services.jcr.impl.core.SessionImpl, org.exoplatform.services.jcr.impl.core.SessionDataManager, javax.jcr.Node)
*/
16 years, 7 months
exo-jcr SVN: r925 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-12-04 08:56:05 -0500 (Fri, 04 Dec 2009)
New Revision: 925
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-305: code format
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-04 12:13:59 UTC (rev 924)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-04 13:56:05 UTC (rev 925)
@@ -1279,11 +1279,15 @@
public boolean isLocked() throws RepositoryException
{
checkValid();
- if (dataManager.isNew(getInternalIdentifier())) {
- return false;
- } else {
- return session.getLockManager().isLocked((NodeData)this.getData());
+
+ if (dataManager.isNew(getInternalIdentifier()))
+ {
+ return false;
}
+ else
+ {
+ return session.getLockManager().isLocked((NodeData)this.getData());
+ }
}
/**
16 years, 7 months