exo-jcr SVN: r4607 - jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-06 10:14:54 -0400 (Wed, 06 Jul 2011)
New Revision: 4607
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml
Log:
EXOJCR-1417: Doc updated
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml 2011-07-06 14:09:04 UTC (rev 4606)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml 2011-07-06 14:14:54 UTC (rev 4607)
@@ -140,11 +140,24 @@
<type>
org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl
</type>
+ <init-params>
+ <value-param>
+ <name>factory-class-name</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ </init-params>
</component></programlisting>
+
+ <itemizedlist>
+ <listitem>
+ <para>factory-class-name - is not mandatory parameter, indicates what
+ the factory need to use to create DataSource objects</para>
+ </listitem>
+ </itemizedlist>
</section>
<section>
- <title>Repsitory Interface</title>
+ <title>RepositoryCreationService Interface</title>
<programlisting language="java">public interface RepositoryCreationService
{
14 years, 10 months
exo-jcr SVN: r4606 - in jcr/trunk/exo.jcr.component.ext/src: test/resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-06 10:09:04 -0400 (Wed, 06 Jul 2011)
New Revision: 4606
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-1417: Make the code fully independent of DBCP
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-06 10:09:58 UTC (rev 4605)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-06 14:09:04 UTC (rev 4606)
@@ -20,6 +20,7 @@
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.container.configuration.ConfigurationException;
import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.container.xml.InitParams;
import org.exoplatform.services.database.creator.DBConnectionInfo;
import org.exoplatform.services.database.creator.DBCreator;
import org.exoplatform.services.database.creator.DBCreatorException;
@@ -86,6 +87,21 @@
private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.RepositoryCreationService");
/**
+ * The parameter name in service's configuration.
+ */
+ private final static String FACTORY_CLASSS_NAME_PARAM = "factory-class-name";
+
+ /**
+ * The default factory class name.
+ */
+ private static final String BASIC_DATA_SOURCE_FACTORY = "org.apache.commons.dbcp.BasicDataSourceFactory";
+
+ /**
+ * The factory class name to create object.
+ */
+ private String factoryClassName = BASIC_DATA_SOURCE_FACTORY;
+
+ /**
* The Repository service.
*/
private final RepositoryService repositoryService;
@@ -129,18 +145,25 @@
/**
* Constructor RepositoryCreationServiceImpl.
*/
- public RepositoryCreationServiceImpl(RepositoryService repositoryService, BackupManager backupManager,
- ExoContainerContext context, InitialContextInitializer initialContextInitializer)
+ public RepositoryCreationServiceImpl(InitParams initParams, RepositoryService repositoryService,
+ BackupManager backupManager, ExoContainerContext context, InitialContextInitializer initialContextInitializer)
{
- this(repositoryService, backupManager, context, initialContextInitializer, null);
+ this(initParams, repositoryService, backupManager, context, initialContextInitializer, null);
}
/**
* Constructor RepositoryCreationServiceImpl.
*/
- public RepositoryCreationServiceImpl(final RepositoryService repositoryService, BackupManager backupManager,
- ExoContainerContext context, InitialContextInitializer initialContextInitializer, final RPCService rpcService)
+ public RepositoryCreationServiceImpl(InitParams initParams, final RepositoryService repositoryService,
+ BackupManager backupManager, ExoContainerContext context, InitialContextInitializer initialContextInitializer,
+ final RPCService rpcService)
{
+ if (initParams != null)
+ {
+ // set reference class name for datasource binding from initialization parameters
+ factoryClassName = initParams.getValueParam(FACTORY_CLASSS_NAME_PARAM).getValue();
+ }
+
this.repositoryService = repositoryService;
this.backupManager = backupManager;
this.rpcService = rpcService;
@@ -535,7 +558,7 @@
try
{
initialContextInitializer.getInitialContextBinder().bind(dataSource, "javax.sql.DataSource",
- "org.apache.commons.dbcp.BasicDataSourceFactory", null, refAddr);
+ factoryClassName, null, refAddr);
}
catch (NamingException e)
{
@@ -634,7 +657,7 @@
try
{
initialContextInitializer.getInitialContextBinder().bind(dataSource, "javax.sql.DataSource",
- "org.apache.commons.dbcp.BasicDataSourceFactory", null, refAddr);
+ factoryClassName, null, refAddr);
}
catch (NamingException e)
{
@@ -860,10 +883,10 @@
repositoryService.removeRepository(repositoryName);
repositoryService.getConfig().retain();
- // unbind datasource
- for (String ds : datasources)
+ // unbind datasource and close connections
+ for (String dsName : datasources)
{
- initialContextInitializer.getInitialContextBinder().unbind(ds);
+ initialContextInitializer.getInitialContextBinder().unbind(dsName);
}
}
catch (RepositoryException e)
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2011-07-06 10:09:58 UTC (rev 4605)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2011-07-06 14:09:04 UTC (rev 4606)
@@ -382,6 +382,12 @@
<component>
<key>org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationService</key>
<type>org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl</type>
+ <!--init-params>
+ <value-param>
+ <name>factory-class-name</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ </init-params-->
</component>
<component>
14 years, 10 months
exo-jcr SVN: r4605 - kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2011-07-06 06:09:58 -0400 (Wed, 06 Jul 2011)
New Revision: 4605
Modified:
kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
Log:
EXOJCR-1418: Changed the import of InvalidationExoCache
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2011-07-06 09:34:01 UTC (rev 4604)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2011-07-06 10:09:58 UTC (rev 4605)
@@ -31,8 +31,8 @@
import org.exoplatform.services.cache.ExoCacheFactory;
import org.exoplatform.services.cache.ExoCacheInitException;
import org.exoplatform.services.cache.ObjectCacheInfo;
-import org.exoplatform.services.cache.impl.InvalidationExoCache;
import org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheCreator;
+import org.exoplatform.services.cache.invalidation.InvalidationExoCache;
import org.exoplatform.test.BasicTestCase;
import java.io.Serializable;
14 years, 10 months
exo-jcr SVN: r4604 - kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache and 2 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2011-07-06 05:34:01 -0400 (Wed, 06 Jul 2011)
New Revision: 4604
Added:
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/invalidation/
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/invalidation/InvalidationExoCache.java
Removed:
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/InvalidationExoCache.java
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java
Log:
EXOJCR-1418: Moved InvalidationExoCache in a dedicated package, auto wrap the eXo cache instance into an InvalidationExoCache only if the cache is replicated or distributed and set a better default concurrency level.
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml 2011-07-05 15:21:53 UTC (rev 4603)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml 2011-07-06 09:34:01 UTC (rev 4604)
@@ -209,12 +209,13 @@
parameter <emphasis>avoidValueReplication</emphasis> to
<emphasis>true</emphasis> in your eXo cache configuration, this will
indicate the CacheService to wrap your eXo cache instance into an
- <emphasis>InvalidationExoCache</emphasis>.</para>
+ <emphasis>InvalidationExoCache</emphasis> in case the cache is
+ defined as replicated or distributed.</para>
</listitem>
<listitem>
<para>Programmatically; You can wrap your eXo cache instance into an
- <emphasis>org.exoplatform.services.cache.impl.InvalidationExoCache</emphasis>
+ <emphasis>org.exoplatform.services.cache.invalidation.InvalidationExoCache</emphasis>
yourself using the public constructors that are available. Please
note that if you use <emphasis>CacheListeners</emphasis> add them to
the InvalidationExoCache instance instead of the nested eXo Cache
@@ -227,7 +228,7 @@
<note>
<para>The invalidation will be efficient if and only if the hash code
method is properly implemented, in other words 2 value objects
- representing the same data will return the same hash code otherwise
+ representing the same data need to return the same hash code otherwise
the infinite loop described above will still be effective.</para>
</note>
</section>
Modified: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java 2011-07-05 15:21:53 UTC (rev 4603)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/CacheServiceImpl.java 2011-07-06 09:34:01 UTC (rev 4604)
@@ -28,6 +28,7 @@
import org.exoplatform.services.cache.ExoCacheFactory;
import org.exoplatform.services.cache.ExoCacheInitException;
import org.exoplatform.services.cache.SimpleExoCache;
+import org.exoplatform.services.cache.invalidation.InvalidationExoCache;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -199,9 +200,11 @@
{
managed.registerCache(simple);
}
- // If the flag avoid value replication is enabled we wrap the eXo cache instance
- // into an InvalidationExoCache to enable the invalidation
- return safeConfig.avoidValueReplication() ? new InvalidationExoCache(simple) : simple;
+ // If the flag avoid value replication is enabled and the cache is replicated
+ // or distributed we wrap the eXo cache instance into an InvalidationExoCache
+ // to enable the invalidation
+ return safeConfig.avoidValueReplication() && (safeConfig.isRepicated() || safeConfig.isDistributed())
+ ? new InvalidationExoCache(simple) : simple;
}
public Collection<ExoCache<? extends Serializable, ?>> getAllCacheInstances()
Deleted: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/InvalidationExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/InvalidationExoCache.java 2011-07-05 15:21:53 UTC (rev 4603)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/InvalidationExoCache.java 2011-07-06 09:34:01 UTC (rev 4604)
@@ -1,561 +0,0 @@
-/*
- * Copyright (C) 2011 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.cache.impl;
-
-import org.exoplatform.services.cache.CacheListener;
-import org.exoplatform.services.cache.CacheListenerContext;
-import org.exoplatform.services.cache.CachedObjectSelector;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.cache.ObjectCacheInfo;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * This eXo cache type is a decorator allowing ExoCache instances that have
- * big values or non serializable values to be replicated thanks to an invalidation
- * mechanism. To prevent infinite loop described below, we replicate the hash code of
- * the value such that if the hash code is the same, we don't invalidate the value locally
- * <ul>
- * <li>Cluster node #1 puts (key1, value1) into the cache</li>
- * <li>On cluster node #2 key1 is invalidated by the put call in node #1</li>
- * <li>Node #2 re-loads key1 and puts (key1, value1) into the cache</li>
- * <li>On cluster node #1 key1 is invalidated, so we get back to step #1</li>
- * </ul>
- *
- * @author <a href="mailto:nfilotto@exoplatform.com">Nicolas Filotto</a>
- * @version $Id$
- *
- */
-public class InvalidationExoCache<K extends Serializable, V> implements ExoCache<K, V>,
- CacheListener<K, InvalidationExoCache.HashCode<V>>
-{
- /**
- * Logger.
- */
- private static final Log LOG = ExoLogger.getLogger("exo.kernel.component.cache.InvalidationExoCache");
-
- /**
- * The eXo cache instance that we would like to replicate using the invalidation
- * mechanism
- */
- private final ExoCache<K, HashCode<V>> delegate;
-
- /**
- * The listeners of the cache
- */
- private final CopyOnWriteArrayList<CacheListener<? super K, ? super V>> listeners;
-
- /**
- * The local cache that contains the real values
- */
- private final ConcurrentMap<K, V> localCache;
-
- /**
- * @param delegate the underneath eXo cache instance, we assume that the eXo cache
- * implementation behind is fully functional.
- */
- public InvalidationExoCache(ExoCache<K, V> delegate)
- {
- this(delegate, 16);
- }
-
- /**
- * @param delegate the underneath eXo cache instance, we assume that the eXo cache
- * implementation behind is fully functional.
- * @concurrencyLevel the estimated number of concurrently
- * updating threads. The implementation performs internal sizing
- * to try to accommodate this many threads.
- */
- @SuppressWarnings("unchecked")
- public InvalidationExoCache(ExoCache<K, V> delegate, int concurrencyLevel)
- {
- this.delegate = (ExoCache<K, HashCode<V>>)delegate;
- // We listen to the cache in order to get a callbacks in case of internal puts for example
- this.delegate.addCacheListener(this);
- this.listeners = new CopyOnWriteArrayList<CacheListener<? super K, ? super V>>();
- this.localCache = new ConcurrentHashMap<K, V>(concurrencyLevel, 0.75f, concurrencyLevel);
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#getName()
- */
- public String getName()
- {
- return delegate.getName();
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#setName(java.lang.String)
- */
- public void setName(String name)
- {
- delegate.setName(name);
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#getLabel()
- */
- public String getLabel()
- {
- return delegate.getLabel();
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#setLabel(java.lang.String)
- */
- public void setLabel(String s)
- {
- delegate.setLabel(s);
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#get(java.io.Serializable)
- */
- public V get(Serializable name)
- {
- HashCode<V> result = delegate.get(name);
- return result == null ? null : localCache.get(name);
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#remove(java.io.Serializable)
- */
- public V remove(Serializable key) throws NullPointerException
- {
- V value = localCache.get(key);
- delegate.remove(key);
- return value;
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#put(java.io.Serializable, java.lang.Object)
- */
- public void put(K key, V value) throws NullPointerException
- {
- delegate.put(key, new HashCode<V>(value));
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#putMap(java.util.Map)
- */
- public void putMap(Map<? extends K, ? extends V> objs) throws NullPointerException, IllegalArgumentException
- {
- if (objs == null)
- {
- throw new NullPointerException("No null map accepted");
- }
- Map<K, HashCode<V>> map = new LinkedHashMap<K, HashCode<V>>();
- for (Entry<? extends K, ? extends V> entry : objs.entrySet())
- {
- if (entry.getKey() == null)
- {
- throw new IllegalArgumentException("No null cache key accepted");
- }
- else if (entry.getValue() == null)
- {
- throw new IllegalArgumentException("No null cache value accepted");
- }
- map.put(entry.getKey(), new HashCode<V>(entry.getValue()));
- }
- delegate.putMap(map);
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#clearCache()
- */
- public void clearCache()
- {
- delegate.clearCache();
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#select(org.exoplatform.services.cache.CachedObjectSelector)
- */
- public void select(CachedObjectSelector<? super K, ? super V> selector) throws Exception
- {
- if (selector == null)
- {
- throw new IllegalArgumentException("No null selector");
- }
- for (Entry<K, V> entry : localCache.entrySet())
- {
- final K key = entry.getKey();
- final V value = entry.getValue();
- ObjectCacheInfo<V> info = new ObjectCacheInfo<V>()
- {
- public V get()
- {
- return value;
- }
-
- public long getExpireTime()
- {
- // Cannot know: The expire time is managed by JBoss Cache itself
- return -1;
- }
- };
- if (selector.select(key, info))
- {
- selector.onSelect(this, key, info);
- }
- }
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#getCacheSize()
- */
- public int getCacheSize()
- {
- return localCache.size();
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#getMaxSize()
- */
- public int getMaxSize()
- {
- return delegate.getMaxSize();
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#setMaxSize(int)
- */
- public void setMaxSize(int max)
- {
- delegate.setMaxSize(max);
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#getLiveTime()
- */
- public long getLiveTime()
- {
- return delegate.getLiveTime();
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#setLiveTime(long)
- */
- public void setLiveTime(long period)
- {
- delegate.setLiveTime(period);
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#getCacheHit()
- */
- public int getCacheHit()
- {
- return delegate.getCacheHit();
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#getCacheMiss()
- */
- public int getCacheMiss()
- {
- return delegate.getCacheMiss();
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#getCachedObjects()
- */
- public List<? extends V> getCachedObjects()
- {
- return new ArrayList<V>(localCache.values());
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#removeCachedObjects()
- */
- public List<? extends V> removeCachedObjects()
- {
- final List<? extends V> list = getCachedObjects();
- clearCache();
- return list;
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#addCacheListener(org.exoplatform.services.cache.CacheListener)
- */
- public void addCacheListener(CacheListener<? super K, ? super V> listener) throws NullPointerException
- {
- if (listener == null)
- {
- throw new NullPointerException();
- }
- listeners.add(listener);
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#isLogEnabled()
- */
- public boolean isLogEnabled()
- {
- return delegate.isLogEnabled();
- }
-
- /**
- * @see org.exoplatform.services.cache.ExoCache#setLogEnabled(boolean)
- */
- public void setLogEnabled(boolean b)
- {
- delegate.setLogEnabled(b);
- }
-
- /**
- * {@inheritDoc}
- */
- public void onExpire(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
- {
- V value = localCache.remove(key);
- if (listeners.isEmpty())
- {
- return;
- }
- for (CacheListener<? super K, ? super V> listener : listeners)
- {
- try
- {
- listener.onExpire(context, key, value);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void onRemove(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
- {
- V value = localCache.remove(key);
- if (listeners.isEmpty())
- {
- return;
- }
- for (CacheListener<? super K, ? super V> listener : listeners)
- {
- try
- {
- listener.onRemove(context, key, value);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void onPut(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
- {
- V value = obj.getValue();
- if (value != null)
- {
- // we assume that it is a local put since the value is inside the HashCode object
- localCache.put(key, value);
- }
- else
- {
- // we assume that it is a remote put since the value is not inside the HashCode object
- V currentValue = localCache.get(key);
- if (currentValue != null && obj != null && currentValue.hashCode() == obj.hashCode())
- {
- // We assume that it is the same value so we don't change the value in the cache
- value = currentValue;
- }
- else
- {
- // A new value has been added to the cache so we invalidate the local one
- value = null;
- localCache.remove(key);
- }
- }
- if (listeners.isEmpty())
- {
- return;
- }
- for (CacheListener<? super K, ? super V> listener : listeners)
- try
- {
- listener.onPut(context, key, value);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void onGet(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
- {
- if (listeners.isEmpty())
- {
- return;
- }
- V value = obj == null ? null : localCache.get(key);
- for (CacheListener<? super K, ? super V> listener : listeners)
- try
- {
- listener.onGet(context, key, value);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
-
- /**
- * @see org.exoplatform.services.cache.CacheListener#onClearCache(org.exoplatform.services.cache.CacheListenerContext)
- */
- public void onClearCache(CacheListenerContext context) throws Exception
- {
- localCache.clear();
- if (listeners.isEmpty())
- {
- return;
- }
- for (CacheListener<? super K, ? super V> listener : listeners)
- {
- try
- {
- listener.onClearCache(context);
- }
- catch (Exception e)
- {
- if (LOG.isWarnEnabled())
- LOG.warn("Cannot execute the CacheListener properly", e);
- }
- }
- }
-
- /**
- * We use this class to propagate the hash code of the value efficiently over the network
- */
- public static class HashCode<V> implements Externalizable
- {
- /**
- * The hash code of the value
- */
- private int hashCode;
-
- /**
- * The corresponding value
- */
- private V value;
-
- public HashCode() {}
-
- public HashCode(V value)
- {
- this.hashCode = value.hashCode();
- this.value = value;
- }
-
- /**
- * @return the value
- */
- public V getValue()
- {
- return value;
- }
-
- /**
- * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
- */
- public void writeExternal(ObjectOutput out) throws IOException
- {
- out.writeInt(hashCode);
- }
-
- /**
- * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
- */
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- this.hashCode = in.readInt();
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode()
- {
- return hashCode;
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- @SuppressWarnings("rawtypes")
- HashCode other = (HashCode)obj;
- if (hashCode != other.hashCode)
- return false;
- if (value != null && other.value != null)
- {
- return value.equals(other.value);
- }
- return true;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString()
- {
- return "HashCode [hashCode=" + hashCode + ", value=" + value + "]";
- }
- }
-}
Copied: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/invalidation/InvalidationExoCache.java (from rev 4603, kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl/InvalidationExoCache.java)
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/invalidation/InvalidationExoCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/invalidation/InvalidationExoCache.java 2011-07-06 09:34:01 UTC (rev 4604)
@@ -0,0 +1,561 @@
+/*
+ * Copyright (C) 2011 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.invalidation;
+
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CacheListenerContext;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ObjectCacheInfo;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * This eXo cache type is a decorator allowing ExoCache instances that have
+ * big values or non serializable values to be replicated thanks to an invalidation
+ * mechanism. To prevent infinite loop described below, we replicate the hash code of
+ * the value such that if the hash code is the same, we don't invalidate the value locally
+ * <ul>
+ * <li>Cluster node #1 puts (key1, value1) into the cache</li>
+ * <li>On cluster node #2 key1 is invalidated by the put call in node #1</li>
+ * <li>Node #2 re-loads key1 and puts (key1, value1) into the cache</li>
+ * <li>On cluster node #1 key1 is invalidated, so we get back to step #1</li>
+ * </ul>
+ *
+ * @author <a href="mailto:nfilotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class InvalidationExoCache<K extends Serializable, V> implements ExoCache<K, V>,
+ CacheListener<K, InvalidationExoCache.HashCode<V>>
+{
+ /**
+ * Logger.
+ */
+ private static final Log LOG = ExoLogger.getLogger("exo.kernel.component.cache.InvalidationExoCache");
+
+ /**
+ * The eXo cache instance that we would like to replicate using the invalidation
+ * mechanism
+ */
+ private final ExoCache<K, HashCode<V>> delegate;
+
+ /**
+ * The listeners of the cache
+ */
+ private final CopyOnWriteArrayList<CacheListener<? super K, ? super V>> listeners;
+
+ /**
+ * The local cache that contains the real values
+ */
+ private final ConcurrentMap<K, V> localCache;
+
+ /**
+ * @param delegate the underneath eXo cache instance, we assume that the eXo cache
+ * implementation behind is fully functional.
+ */
+ public InvalidationExoCache(ExoCache<K, V> delegate)
+ {
+ this(delegate, delegate.getMaxSize() > 0 && delegate.getMaxSize() < 512 ? delegate.getMaxSize() : 512);
+ }
+
+ /**
+ * @param delegate the underneath eXo cache instance, we assume that the eXo cache
+ * implementation behind is fully functional.
+ * @concurrencyLevel the estimated number of concurrently
+ * updating threads. The implementation performs internal sizing
+ * to try to accommodate this many threads.
+ */
+ @SuppressWarnings("unchecked")
+ public InvalidationExoCache(ExoCache<K, V> delegate, int concurrencyLevel)
+ {
+ this.delegate = (ExoCache<K, HashCode<V>>)delegate;
+ // We listen to the cache in order to get a callbacks in case of internal puts for example
+ this.delegate.addCacheListener(this);
+ this.listeners = new CopyOnWriteArrayList<CacheListener<? super K, ? super V>>();
+ this.localCache = new ConcurrentHashMap<K, V>(concurrencyLevel, 0.75f, concurrencyLevel);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#getName()
+ */
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#setName(java.lang.String)
+ */
+ public void setName(String name)
+ {
+ delegate.setName(name);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#getLabel()
+ */
+ public String getLabel()
+ {
+ return delegate.getLabel();
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#setLabel(java.lang.String)
+ */
+ public void setLabel(String s)
+ {
+ delegate.setLabel(s);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#get(java.io.Serializable)
+ */
+ public V get(Serializable name)
+ {
+ HashCode<V> result = delegate.get(name);
+ return result == null ? null : localCache.get(name);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#remove(java.io.Serializable)
+ */
+ public V remove(Serializable key) throws NullPointerException
+ {
+ V value = localCache.get(key);
+ delegate.remove(key);
+ return value;
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#put(java.io.Serializable, java.lang.Object)
+ */
+ public void put(K key, V value) throws NullPointerException
+ {
+ delegate.put(key, new HashCode<V>(value));
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#putMap(java.util.Map)
+ */
+ public void putMap(Map<? extends K, ? extends V> objs) throws NullPointerException, IllegalArgumentException
+ {
+ if (objs == null)
+ {
+ throw new NullPointerException("No null map accepted");
+ }
+ Map<K, HashCode<V>> map = new LinkedHashMap<K, HashCode<V>>();
+ for (Entry<? extends K, ? extends V> entry : objs.entrySet())
+ {
+ if (entry.getKey() == null)
+ {
+ throw new IllegalArgumentException("No null cache key accepted");
+ }
+ else if (entry.getValue() == null)
+ {
+ throw new IllegalArgumentException("No null cache value accepted");
+ }
+ map.put(entry.getKey(), new HashCode<V>(entry.getValue()));
+ }
+ delegate.putMap(map);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#clearCache()
+ */
+ public void clearCache()
+ {
+ delegate.clearCache();
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#select(org.exoplatform.services.cache.CachedObjectSelector)
+ */
+ public void select(CachedObjectSelector<? super K, ? super V> selector) throws Exception
+ {
+ if (selector == null)
+ {
+ throw new IllegalArgumentException("No null selector");
+ }
+ for (Entry<K, V> entry : localCache.entrySet())
+ {
+ final K key = entry.getKey();
+ final V value = entry.getValue();
+ ObjectCacheInfo<V> info = new ObjectCacheInfo<V>()
+ {
+ public V get()
+ {
+ return value;
+ }
+
+ public long getExpireTime()
+ {
+ // Cannot know: The expire time is managed by JBoss Cache itself
+ return -1;
+ }
+ };
+ if (selector.select(key, info))
+ {
+ selector.onSelect(this, key, info);
+ }
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#getCacheSize()
+ */
+ public int getCacheSize()
+ {
+ return localCache.size();
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#getMaxSize()
+ */
+ public int getMaxSize()
+ {
+ return delegate.getMaxSize();
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#setMaxSize(int)
+ */
+ public void setMaxSize(int max)
+ {
+ delegate.setMaxSize(max);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#getLiveTime()
+ */
+ public long getLiveTime()
+ {
+ return delegate.getLiveTime();
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#setLiveTime(long)
+ */
+ public void setLiveTime(long period)
+ {
+ delegate.setLiveTime(period);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#getCacheHit()
+ */
+ public int getCacheHit()
+ {
+ return delegate.getCacheHit();
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#getCacheMiss()
+ */
+ public int getCacheMiss()
+ {
+ return delegate.getCacheMiss();
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#getCachedObjects()
+ */
+ public List<? extends V> getCachedObjects()
+ {
+ return new ArrayList<V>(localCache.values());
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#removeCachedObjects()
+ */
+ public List<? extends V> removeCachedObjects()
+ {
+ final List<? extends V> list = getCachedObjects();
+ clearCache();
+ return list;
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#addCacheListener(org.exoplatform.services.cache.CacheListener)
+ */
+ public void addCacheListener(CacheListener<? super K, ? super V> listener) throws NullPointerException
+ {
+ if (listener == null)
+ {
+ throw new NullPointerException();
+ }
+ listeners.add(listener);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#isLogEnabled()
+ */
+ public boolean isLogEnabled()
+ {
+ return delegate.isLogEnabled();
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#setLogEnabled(boolean)
+ */
+ public void setLogEnabled(boolean b)
+ {
+ delegate.setLogEnabled(b);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onExpire(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
+ {
+ V value = localCache.remove(key);
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener<? super K, ? super V> listener : listeners)
+ {
+ try
+ {
+ listener.onExpire(context, key, value);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onRemove(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
+ {
+ V value = localCache.remove(key);
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener<? super K, ? super V> listener : listeners)
+ {
+ try
+ {
+ listener.onRemove(context, key, value);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onPut(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
+ {
+ V value = obj.getValue();
+ if (value != null)
+ {
+ // we assume that it is a local put since the value is inside the HashCode object
+ localCache.put(key, value);
+ }
+ else
+ {
+ // we assume that it is a remote put since the value is not inside the HashCode object
+ V currentValue = localCache.get(key);
+ if (currentValue != null && obj != null && currentValue.hashCode() == obj.hashCode())
+ {
+ // We assume that it is the same value so we don't change the value in the cache
+ value = currentValue;
+ }
+ else
+ {
+ // A new value has been added to the cache so we invalidate the local one
+ value = null;
+ localCache.remove(key);
+ }
+ }
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener<? super K, ? super V> listener : listeners)
+ try
+ {
+ listener.onPut(context, key, value);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onGet(CacheListenerContext context, K key, HashCode<V> obj) throws Exception
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ V value = obj == null ? null : localCache.get(key);
+ for (CacheListener<? super K, ? super V> listener : listeners)
+ try
+ {
+ listener.onGet(context, key, value);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.CacheListener#onClearCache(org.exoplatform.services.cache.CacheListenerContext)
+ */
+ public void onClearCache(CacheListenerContext context) throws Exception
+ {
+ localCache.clear();
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener<? super K, ? super V> listener : listeners)
+ {
+ try
+ {
+ listener.onClearCache(context);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ /**
+ * We use this class to propagate the hash code of the value efficiently over the network
+ */
+ public static class HashCode<V> implements Externalizable
+ {
+ /**
+ * The hash code of the value
+ */
+ private int hashCode;
+
+ /**
+ * The corresponding value
+ */
+ private V value;
+
+ public HashCode() {}
+
+ public HashCode(V value)
+ {
+ this.hashCode = value.hashCode();
+ this.value = value;
+ }
+
+ /**
+ * @return the value
+ */
+ public V getValue()
+ {
+ return value;
+ }
+
+ /**
+ * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeInt(hashCode);
+ }
+
+ /**
+ * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ this.hashCode = in.readInt();
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode()
+ {
+ return hashCode;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ @SuppressWarnings("rawtypes")
+ HashCode other = (HashCode)obj;
+ if (hashCode != other.hashCode)
+ return false;
+ if (value != null && other.value != null)
+ {
+ return value.equals(other.value);
+ }
+ return true;
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "HashCode [hashCode=" + hashCode + ", value=" + value + "]";
+ }
+ }
+}
14 years, 10 months
exo-jcr SVN: r4603 - jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2011-07-05 11:21:53 -0400 (Tue, 05 Jul 2011)
New Revision: 4603
Modified:
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java
Log:
EXOJCR-1405 : Unit test was fixed (for working on macos X )
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java 2011-07-05 15:13:59 UTC (rev 4602)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java 2011-07-05 15:21:53 UTC (rev 4603)
@@ -1224,7 +1224,7 @@
String newBackupDir =
"\\${java.io.tmpdir}"
+ bch.getBackupConfig().getBackupDir().getCanonicalPath()
- .replaceAll(backupDitEnv, "");
+ .replace(backupDitEnv, "");
File dest = new File(repositoryBackupChainLogPath + ".xml");
dest.createNewFile();
14 years, 10 months
exo-jcr SVN: r4602 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: core/nodetype/registration and 4 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2011-07-05 11:13:59 -0400 (Tue, 05 Jul 2011)
New Revision: 4602
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/CachingIndexReader.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocOrderScoreNodeIterator.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RowIteratorImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/indexing/JdbcNodeDataIndexingIterator.java
Log:
EXOJCR-1426: Cleanup the code to get rid of useless System.currentTimeMillis() calls
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -1037,9 +1037,10 @@
public NodeIterator getNodes() throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (LOG.isDebugEnabled())
{
+ start = System.currentTimeMillis();
LOG.debug("getNodes() >>>>>");
}
@@ -1086,9 +1087,10 @@
public NodeIterator getNodes(String namePattern) throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (LOG.isDebugEnabled())
{
+ start = System.currentTimeMillis();
LOG.debug("getNodes(String) >>>>>");
}
@@ -1197,9 +1199,10 @@
public PropertyIterator getProperties() throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (LOG.isDebugEnabled())
{
+ start = System.currentTimeMillis();
LOG.debug("getProperties() >>>>>");
}
@@ -1252,9 +1255,10 @@
*/
public PropertyIterator getProperties(String namePattern) throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (LOG.isDebugEnabled())
{
+ start = System.currentTimeMillis();
LOG.debug("getProperties(String) >>>>>");
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -364,9 +364,10 @@
public ItemImpl getItem(NodeData parent, QPathEntry name, boolean pool, ItemType itemType, boolean apiRead)
throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
log.debug("getItem(" + parent.getQPath().getAsString() + " + " + name.getAsString() + " ) >>>>>");
}
@@ -426,9 +427,10 @@
public ItemImpl getItem(NodeData parent, QPathEntry name, boolean pool, boolean skipCheckInPersistence,
ItemType itemType) throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
log.debug("getItem(" + parent.getQPath().getAsString() + " + " + name.getAsString() + " ) >>>>>");
}
@@ -485,9 +487,10 @@
public ItemImpl getItem(NodeData parent, QPathEntry[] relPath, boolean pool, ItemType itemType)
throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
String debugPath = "";
for (QPathEntry rp : relPath)
{
@@ -529,9 +532,10 @@
*/
public ItemImpl getItem(QPath path, boolean pool) throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
log.debug("getItem(" + path.getAsString() + " ) >>>>>");
}
@@ -649,9 +653,10 @@
*/
public ItemImpl getItemByIdentifier(String identifier, boolean pool, boolean apiRead) throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
log.debug("getItemByIdentifier(" + identifier + " ) >>>>>");
}
@@ -850,9 +855,10 @@
public List<NodeImpl> getChildNodes(NodeData parent, boolean pool) throws RepositoryException, AccessDeniedException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
log.debug("getChildNodes(" + parent.getQPath().getAsString() + ") >>>>>");
}
@@ -903,9 +909,10 @@
AccessDeniedException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
log.debug("getChildProperties(" + parent.getQPath().getAsString() + ") >>>>>");
}
@@ -941,9 +948,10 @@
*/
public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
log.debug("getChildNodesData(" + parent.getQPath().getAsString() + ") >>>>>");
}
@@ -967,9 +975,10 @@
public List<NodeData> getChildNodesData(NodeData parent, List<QPathEntryFilter> patternFilters)
throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
log.debug("getChildNodesData(" + parent.getQPath().getAsString() + " , itemDataFilter) >>>>>");
}
@@ -1113,9 +1122,10 @@
*/
public AccessControlList getACL(QPath path) throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
log.debug("getACL(" + path.getAsString() + " ) >>>>>");
}
@@ -1178,9 +1188,10 @@
public AccessControlList getACL(NodeData parent, QPathEntry name) throws RepositoryException
{
- long start = System.currentTimeMillis();
+ long start = 0;
if (log.isDebugEnabled())
{
+ start = System.currentTimeMillis();
log.debug("getACL(" + parent.getQPath().getAsString() + " + " + name.getAsString() + " ) >>>>>");
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -151,8 +151,12 @@
PlainChangesLog changesLog = new PlainChangesLogImpl();
TransientNodeData jcrNodetypes;
- long start = System.currentTimeMillis();
-
+ long start = 0;
+ if (log.isDebugEnabled())
+ {
+ start = System.currentTimeMillis();
+ }
+
if (addACL)
{
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -182,7 +182,11 @@
public QueryResult execute() throws RepositoryException
{
checkInitialized();
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
QueryResult result = query.execute(offset, limit);
if (log.isDebugEnabled())
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/CachingIndexReader.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/CachingIndexReader.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/CachingIndexReader.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -448,7 +448,11 @@
*/
private void initializeParents(IndexReader reader) throws IOException
{
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
final Map docs = new HashMap();
// read UUIDs
collectTermDocs(reader, new Term(FieldNames.UUID, ""), new TermDocsCollector()
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -716,10 +716,17 @@
//NodeId id = new NodeId(UUID.fromString(uuid));
try
{
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
NodeData state = (NodeData)itemMgr.getItemData(uuid);
- time = System.currentTimeMillis() - time;
- log.debug("got NodeState with id {} in {} ms.", uuid, new Long(time));
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis() - time;
+ log.debug("got NodeState with id {} in {} ms.", uuid, new Long(time));
+ }
Iterator<NodeData> entries;
if (nameTest != null)
{
@@ -813,7 +820,11 @@
@Override
public Hits getHits() throws IOException
{
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
Hits childrenHits = new AdaptingHits();
Hits nameHits = new ScorerHits(nameTestScorer);
int[] docs = new int[1];
@@ -839,9 +850,11 @@
}
}
}
- time = System.currentTimeMillis() - time;
-
- log.debug("Filtered hits in {} ms.", new Long(time));
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis() - time;
+ log.debug("Filtered hits in {} ms.", new Long(time));
+ }
return childrenHits;
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -587,7 +587,11 @@
{
if (!contextHitsCalculated)
{
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
contextScorer.score(new AbstractHitCollector()
{
@Override
@@ -597,9 +601,9 @@
}
}); // find all
contextHitsCalculated = true;
- time = System.currentTimeMillis() - time;
if (log.isDebugEnabled())
{
+ time = System.currentTimeMillis() - time;
log.debug("Collected {} context hits in {} ms for {}", new Object[]{
new Integer(contextHits.cardinality()), new Long(time), DescendantSelfAxisQuery.this});
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocOrderScoreNodeIterator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocOrderScoreNodeIterator.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocOrderScoreNodeIterator.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -172,7 +172,11 @@
{
return;
}
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
ScoreNode[][] nodes = (ScoreNode[][])scoreNodes.toArray(new ScoreNode[scoreNodes.size()][]);
final Set<String> invalidIDs = new HashSet<String>(2);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -56,11 +56,11 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
-import java.util.Map.Entry;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
@@ -1153,7 +1153,11 @@
if (handler.isInitializeHierarchyCache())
{
// force initializing of caches
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
{
public Object run() throws Exception
@@ -1162,8 +1166,11 @@
return null;
}
});
- time = System.currentTimeMillis() - time;
- log.debug("hierarchy cache initialized in {} ms", new Long(time));
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis() - time;
+ log.debug("hierarchy cache initialized in {} ms", new Long(time));
+ }
}
synchronized (this)
@@ -1754,7 +1761,11 @@
if (volatileIndex.getNumDocuments() > 0)
{
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
// create index
CreateIndex create = new CreateIndex(getTransactionId(), null);
executeAndLog(create);
@@ -1769,8 +1780,11 @@
// create new volatile index
resetVolatileIndex();
- time = System.currentTimeMillis() - time;
- log.debug("Committed in-memory index in " + time + "ms.");
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis() - time;
+ log.debug("Committed in-memory index in " + time + "ms.");
+ }
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -308,9 +308,16 @@
MultiColumnQueryHits result = null;
try
{
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
result = executeQuery(maxResultSize);
- log.debug("query executed in {} ms", new Long(System.currentTimeMillis() - time));
+ if (log.isDebugEnabled())
+ {
+ log.debug("query executed in {} ms", new Long(System.currentTimeMillis() - time));
+ }
// set selector names
selectorNames = result.getSelectorNames();
@@ -325,9 +332,15 @@
result.skip(start);
}
- time = System.currentTimeMillis();
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
collectScoreNodes(result, resultNodes, maxResultSize);
- log.debug("retrieved ScoreNodes in {} ms", new Long(System.currentTimeMillis() - time));
+ if (log.isDebugEnabled())
+ {
+ log.debug("retrieved ScoreNodes in {} ms", new Long(System.currentTimeMillis() - time));
+ }
// update numResults
numResults = result.getSize();
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RowIteratorImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RowIteratorImpl.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RowIteratorImpl.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -781,11 +781,18 @@
}
try
{
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
String excerpt = excerptProvider.getExcerpt(id, 3, 150);
-
- time = System.currentTimeMillis() - time;
- log.debug("Created excerpt in {} ms.", new Long(time));
+
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis() - time;
+ log.debug("Created excerpt in {} ms.", new Long(time));
+ }
if (excerpt != null)
{
return valueFactory.createValue(excerpt);
@@ -815,10 +822,17 @@
HighlightingExcerptProvider hep = (HighlightingExcerptProvider)excerptProvider;
try
{
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
text = hep.highlight(text);
- time = System.currentTimeMillis() - time;
- log.debug("Highlighted text in {} ms.", new Long(time));
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis() - time;
+ log.debug("Highlighted text in {} ms.", new Long(time));
+ }
return valueFactory.createValue(text);
}
catch (IOException e)
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -1881,7 +1881,11 @@
{
return;
}
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis();
+ }
int found = SecurityHelper.doPrivilegedAction(new PrivilegedAction<Integer>()
{
public Integer run()
@@ -1937,8 +1941,11 @@
return found;
}
});
- time = System.currentTimeMillis() - time;
- log.debug("Retrieved {} aggregate roots in {} ms.", new Integer(found), new Long(time));
+ if (log.isDebugEnabled())
+ {
+ time = System.currentTimeMillis() - time;
+ log.debug("Retrieved {} aggregate roots in {} ms.", new Integer(found), new Long(time));
+ }
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -517,8 +517,11 @@
// save state
if (itemState.isPersisted())
{
- long start = System.currentTimeMillis();
-
+ long start = 0;
+ if (LOG.isDebugEnabled())
+ {
+ start = System.currentTimeMillis();
+ }
ItemData data = itemState.getData();
WorkspaceStorageConnection conn;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/indexing/JdbcNodeDataIndexingIterator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/indexing/JdbcNodeDataIndexingIterator.java 2011-07-05 14:46:12 UTC (rev 4601)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/indexing/JdbcNodeDataIndexingIterator.java 2011-07-05 15:13:59 UTC (rev 4602)
@@ -115,7 +115,11 @@
currentLastNodeId = lastNodeId.get();
currentPage = page.incrementAndGet();
}
- long time = System.currentTimeMillis();
+ long time = 0;
+ if (PropertyManager.isDevelopping())
+ {
+ time = System.currentTimeMillis();
+ }
List<NodeDataIndexing> result = conn.getNodesAndProperties(currentLastNodeId, currentOffset, pageSize);
if (PropertyManager.isDevelopping())
{
14 years, 10 months
exo-jcr SVN: r4601 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2011-07-05 10:46:12 -0400 (Tue, 05 Jul 2011)
New Revision: 4601
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
Log:
EXOJCR-1191 : Set serialVersionUId in StreamPersistedValueData for JCR 1.14.x as in JCR 1.12.x.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java 2011-07-05 13:52:30 UTC (rev 4600)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java 2011-07-05 14:46:12 UTC (rev 4601)
@@ -40,6 +40,8 @@
public class StreamPersistedValueData extends FilePersistedValueData
{
+ private static final long serialVersionUID = -5831609242005946202L;
+
protected InputStream stream;
protected SpoolFile tempFile;
14 years, 10 months
exo-jcr SVN: r4600 - in jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation: cluster and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-05 09:52:30 -0400 (Tue, 05 Jul 2011)
New Revision: 4600
Modified:
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java
Log:
EXOJCR-1396: tests updated
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-07-05 13:49:29 UTC (rev 4599)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-07-05 13:52:30 UTC (rev 4600)
@@ -97,6 +97,17 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(tenantName));
// remove repository
+ try
+ {
+ creatorService.removeRepository(tenantName, false);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryCreationException e)
+ {
+ // repository in use
+ }
+
+ // remove repository
creatorService.removeRepository(tenantName, true);
try
@@ -163,6 +174,17 @@
RepositoryService repoService = (RepositoryService)this.container.getComponentInstance(RepositoryService.class);
assertNotNull(repoService.getConfig().getRepositoryConfiguration(tenantName));
+ // remove repository
+ try
+ {
+ creatorService.removeRepository(tenantName, false);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryCreationException e)
+ {
+ // repository in use
+ }
+
// remove repository
creatorService.removeRepository(tenantName, true);
@@ -240,6 +262,17 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(tenantName));
// remove repository
+ try
+ {
+ creatorService.removeRepository(tenantName, false);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryCreationException e)
+ {
+ // repository in use
+ }
+
+ // remove repository
creatorService.removeRepository(tenantName, true);
try
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java 2011-07-05 13:49:29 UTC (rev 4599)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java 2011-07-05 13:52:30 UTC (rev 4600)
@@ -26,6 +26,7 @@
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChain;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupConfig;
import org.exoplatform.services.jcr.ext.repository.creation.DBCreationProperties;
+import org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationException;
import org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationService;
import java.io.File;
@@ -111,6 +112,17 @@
Thread.sleep(60000);
// remove repository
+ try
+ {
+ creatorService.removeRepository(tenantName, false);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryCreationException e)
+ {
+ // repository in use
+ }
+
+ // remove repository
creatorService.removeRepository(tenantName, true);
try
14 years, 10 months
exo-jcr SVN: r4599 - in jcr/trunk: exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-05 09:49:29 -0400 (Tue, 05 Jul 2011)
New Revision: 4599
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml
Log:
EXOJCR-1396: check is repository in use on all cluster nodes before removing
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java 2011-07-05 12:42:16 UTC (rev 4598)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationService.java 2011-07-05 13:49:29 UTC (rev 4599)
@@ -101,10 +101,9 @@
* Remove previously created repository.
*
* @param repositoryName - the repository name to delete
- * @param forceCloseSessions - indicates if need to close sessions before repository removing, if
- * sessions are opened is it not possbile to remove repository and exception will be thrown
+ * @param forceRemove - force close all opened sessions
* @throws RepositoryCreationServiceException
* if some exception occurred during repository removing occurred
*/
- void removeRepository(String repositoryName, boolean forceCloseSessions) throws RepositoryCreationException;
+ void removeRepository(String repositoryName, boolean forceRemove) throws RepositoryCreationException;
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 12:42:16 UTC (rev 4598)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 13:49:29 UTC (rev 4599)
@@ -124,6 +124,8 @@
private RemoteCommand removeRepository;
+ private RemoteCommand canRemoveRepository;
+
/**
* Constructor RepositoryCreationServiceImpl.
*/
@@ -136,7 +138,7 @@
/**
* Constructor RepositoryCreationServiceImpl.
*/
- public RepositoryCreationServiceImpl(RepositoryService repositoryService, BackupManager backupManager,
+ public RepositoryCreationServiceImpl(final RepositoryService repositoryService, BackupManager backupManager,
ExoContainerContext context, InitialContextInitializer initialContextInitializer, final RPCService rpcService)
{
this.repositoryService = repositoryService;
@@ -231,13 +233,27 @@
public Serializable execute(Serializable[] args) throws Throwable
{
String repositoryName = (String)args[0];
- boolean forceCloseSessions = (Boolean)args[1];
- removeRepositoryLocally(repositoryName, forceCloseSessions);
+ removeRepositoryLocally(repositoryName);
return null;
}
});
+
+ canRemoveRepository = rpcService.registerCommand(new RemoteCommand()
+ {
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.ext.repository.creation.RepositoryCreationServiceImpl-checkRepositoryInUse";
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwable
+ {
+ String repositoryName = (String)args[0];
+
+ return new Boolean(repositoryService.canRemoveRepository(repositoryName));
+ }
+ });
}
else
{
@@ -729,21 +745,49 @@
this.rpcService.unregisterCommand(createRepository);
this.rpcService.unregisterCommand(startRepository);
this.rpcService.unregisterCommand(removeRepository);
+ this.rpcService.unregisterCommand(canRemoveRepository);
}
}
/**
* {@inheritDoc}
*/
- public void removeRepository(String repositoryName, boolean forceCloseSessions) throws RepositoryCreationException
+ public void removeRepository(String repositoryName, boolean forceRemove) throws RepositoryCreationException
{
if (rpcService != null)
{
try
{
- List<Object> results =
- rpcService.executeCommandOnAllNodes(removeRepository, true, repositoryName, forceCloseSessions);
+ if (!forceRemove)
+ {
+ List<Object> results = rpcService.executeCommandOnAllNodes(canRemoveRepository, true, repositoryName);
+ for (Object result : results)
+ {
+ if (result != null)
+ {
+ if (result instanceof Throwable)
+ {
+ throw new RepositoryCreationException("It is not possible to check is repository "
+ + repositoryName + " in usage or not", (Throwable)result);
+ }
+ else if (result instanceof Boolean)
+ {
+ if (!(Boolean)result)
+ {
+ throw new RepositoryCreationException("Can't remove repository " + repositoryName
+ + ". The repository in use.");
+ }
+ }
+ else
+ {
+ throw new RepositoryCreationException(
+ "checkRepositoryInUse command returned uknown result type");
+ }
+ }
+ }
+ }
+ List<Object> results = rpcService.executeCommandOnAllNodes(removeRepository, true, repositoryName);
for (Object result : results)
{
if (result != null)
@@ -767,7 +811,23 @@
}
else
{
- removeRepositoryLocally(repositoryName, forceCloseSessions);
+ if (!forceRemove)
+ {
+ try
+ {
+ if (!repositoryService.canRemoveRepository(repositoryName))
+ {
+ throw new RepositoryCreationException("Can't remove repository " + repositoryName
+ + ". The repository in use.");
+ }
+ }
+ catch (RepositoryException e)
+ {
+ throw new RepositoryCreationException("It is not possible to check is repository " + repositoryName + " in usage or not", e);
+ }
+ }
+
+ removeRepositoryLocally(repositoryName);
}
}
@@ -776,11 +836,9 @@
*
* @param repositoryName
* the repository name
- * @param forceCloseSessions - indicates if need to close session before repository removing, if
- * sessions are opened is it not possbile to remove repository and exception will be throw
* @throws RepositoryCreationException
*/
- protected void removeRepositoryLocally(String repositoryName, boolean forceCloseSessions)
+ protected void removeRepositoryLocally(String repositoryName)
throws RepositoryCreationException
{
try
@@ -789,16 +847,13 @@
ManageableRepository repositorty = repositoryService.getRepository(repositoryName);
Set<String> datasources = extractDataSourceNames(repositorty.getConfiguration(), false);
- if (forceCloseSessions)
+ // close all opened sessions
+ for (String workspaceName : repositorty.getWorkspaceNames())
{
- // close all opened sessions
- for (String workspaceName : repositorty.getWorkspaceNames())
- {
- WorkspaceContainerFacade wc = repositorty.getWorkspaceContainer(workspaceName);
- SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
+ WorkspaceContainerFacade wc = repositorty.getWorkspaceContainer(workspaceName);
+ SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
- sessionRegistry.closeSessions(workspaceName);
- }
+ sessionRegistry.closeSessions(workspaceName);
}
// remove repository from configuration
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml 2011-07-05 12:42:16 UTC (rev 4598)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-creation-service.xml 2011-07-05 13:49:29 UTC (rev 4599)
@@ -220,12 +220,12 @@
* Remove previously created repository.
*
* @param repositoryName - the repository name to delete
- * @param forceCloseSessions - indicates if need to close session before repository removing, if
- * sessions are opened is it not possbile to remove repository and exception will be thrown
+ * @param forceRemove - force close all opened sessions
* @throws RepositoryCreationServiceException
* if some exception occurred during repository removing occurred
*/
- void removeRepository(String repositoryName, boolean forceCloseSessions) throws RepositoryCreationException;
+ void removeRepository(String repositoryName, boolean forceRemove) throws RepositoryCreationException;
+
}</programlisting>
</section>
14 years, 10 months
exo-jcr SVN: r4598 - in jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation: cluster and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2011-07-05 08:42:16 -0400 (Tue, 05 Jul 2011)
New Revision: 4598
Modified:
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java
Log:
EXOJCR-1396: fix tests
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-07-05 11:51:45 UTC (rev 4597)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-07-05 12:42:16 UTC (rev 4598)
@@ -97,7 +97,7 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(tenantName));
// remove repository
- creatorService.removeRepository(tenantName);
+ creatorService.removeRepository(tenantName, true);
try
{
@@ -164,7 +164,7 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(tenantName));
// remove repository
- creatorService.removeRepository(tenantName);
+ creatorService.removeRepository(tenantName, true);
try
{
@@ -240,7 +240,7 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(tenantName));
// remove repository
- creatorService.removeRepository(tenantName);
+ creatorService.removeRepository(tenantName, true);
try
{
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java 2011-07-05 11:51:45 UTC (rev 4597)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNode1.java 2011-07-05 12:42:16 UTC (rev 4598)
@@ -111,7 +111,7 @@
Thread.sleep(60000);
// remove repository
- creatorService.removeRepository(tenantName);
+ creatorService.removeRepository(tenantName, true);
try
{
14 years, 10 months