From do-not-reply at jboss.org Fri Jul 1 04:50:59 2011
Content-Type: multipart/mixed; boundary="===============3407206996448342476=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4570 -
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/management.
Date: Fri, 01 Jul 2011 04:50:59 -0400
Message-ID: <201107010850.p618ox9o006259@svn01.web.mwc.hst.phx2.redhat.com>
--===============3407206996448342476==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: nzamosenchuk
Date: 2011-07-01 04:50:58 -0400 (Fri, 01 Jul 2011)
New Revision: 4570
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/containe=
r/management/ManageableContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/containe=
r/management/ManagementContextImpl.java
Log:
EXOJCR-1068 : Unregister all MBeans on container stop.
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/c=
ontainer/management/ManageableContainer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/management/ManageableContainer.java 2011-06-30 14:54:37 UTC (rev 4569)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/management/ManageableContainer.java 2011-07-01 08:50:58 UTC (rev 4570)
@@ -52,8 +52,7 @@
* @author Julien Viet
* @version $Revision$
*/
-public class ManageableContainer
- extends CachingContainer
+public class ManageableContainer extends CachingContainer
{
=
/**
@@ -69,7 +68,7 @@
=
/** . */
private static final ThreadLocal hac=
k =3D
- new ThreadLocal();
+ new ThreadLocal();
=
/** . */
final ManagementContextImpl managementContext;
@@ -78,8 +77,9 @@
private MBeanServer server;
=
private volatile boolean objectNameSet;
+
private ObjectName objectName;
- =
+
/** . */
private final Set providers;
=
@@ -88,7 +88,7 @@
=
public ManageableContainer()
{
- this((PicoContainer) null);
+ this((PicoContainer)null);
}
=
public ManageableContainer(PicoContainer parent)
@@ -113,12 +113,12 @@
ManagementContextImpl parentCtx =3D null;
if (parent instanceof ManageableContainer)
{
- ManageableContainer manageableParent =3D (ManageableContainer) pa=
rent;
+ ManageableContainer manageableParent =3D (ManageableContainer)par=
ent;
parentCtx =3D manageableParent.managementContext;
}
=
//
- this.parent =3D parent instanceof ManageableContainer ? (ManageableC=
ontainer) parent : null;
+ this.parent =3D parent instanceof ManageableContainer ? (ManageableC=
ontainer)parent : null;
=
//
if (parentCtx !=3D null)
@@ -156,7 +156,7 @@
}
=
private static ManageableComponentAdapterFactory getComponentAdapterFac=
tory(
- ComponentAdapterFactory componentAdapterFactory)
+ ComponentAdapterFactory componentAdapterFactory)
{
ManageableComponentAdapterFactory factory =3D new ManageableComponen=
tAdapterFactory(componentAdapterFactory);
hack.set(factory);
@@ -196,7 +196,7 @@
{
MBeanScopingData scopingData =3D list.get(i - 1);
props.putAll(scopingData);
- } =
+ }
try
{
this.objectName =3D JMX.createObjectName("exo", props=
);
@@ -204,7 +204,7 @@
catch (Exception e)
{
LOG.error("Could not create the object name", e);
- } =
+ }
}
this.objectNameSet =3D true;
}
@@ -212,9 +212,9 @@
}
return objectName;
}
- =
+
public ComponentAdapter registerComponentInstance(Object componentKey, =
Object componentInstance)
- throws PicoRegistrationException
+ throws PicoRegistrationException
{
ComponentAdapter adapter =3D super.registerComponentInstance(compone=
ntKey, componentInstance);
if (managementContext !=3D null)
@@ -224,13 +224,36 @@
// Register if it is a management provider
if (componentInstance instanceof ManagementProvider)
{
- ManagementProvider provider =3D (ManagementProvider) component=
Instance;
+ ManagementProvider provider =3D (ManagementProvider)componentI=
nstance;
addProvider(provider);
}
}
return adapter;
}
=
+ @Override
+ public ComponentAdapter unregisterComponent(Object componentKey)
+ {
+ ComponentAdapter adapter =3D getComponentAdapter(componentKey);
+
+ if (managementContext !=3D null && adapter !=3D null)
+ {
+ managementContext.unregister(adapter.getComponentInstance(this));
+ }
+ return super.unregisterComponent(componentKey);
+ }
+
+ @Override
+ public void stop()
+ {
+ if (managementContext !=3D null)
+ {
+ // un-manage all registered MBeans
+ managementContext.unregisterAll();
+ }
+ super.stop();
+ };
+
/**
* Returns the list of the providers which are relevant for this contai=
ner.
*
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/c=
ontainer/management/ManagementContextImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/management/ManagementContextImpl.java 2011-06-30 14:54:37 UTC (rev 4569)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/management/ManagementContextImpl.java 2011-07-01 08:50:58 UTC (rev 4570)
@@ -33,8 +33,10 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
=
/**
* @author Julien Viet
@@ -237,6 +239,10 @@
}
}
=
+ /**
+ * =
+ * {@inheritDoc}
+ */
public void unregister(Object o)
{
ManagementContextImpl context =3D registrations.remove(o);
@@ -247,6 +253,26 @@
}
}
}
+ =
+ /**
+ * Unmanages (unregisters) all early registered MBeans in ManagementPro=
viders
+ */
+ public void unregisterAll()
+ {
+ Iterator> iterator =3D registra=
tions.entrySet().iterator();
+ while (iterator.hasNext())
+ {
+ Entry
=
@@ -141,11 +142,95 @@
Indicates if the log is enabled. This field is optional.
This field is used for backward compatibility.
+
+
+ avoidValueReplication
+
+ Indicates whether the values of the cache should be
+ replicated or not in case of a replicated cache. This field is
+ optional. By default it is disabled. Find more details about t=
his
+ field in the next section.
+
+
=
-
+
+ Advanced concepts
+
+
+ Invalidation
+
+ In case, you have big values or non serializable values and you
+ need a replicated cache to at list invalidate the data when it is
+ needed, you can use the invalidation mode that will work on top of a=
ny
+ replicated cache implementations. This is possible thanks to the cla=
ss
+ InvalidationExoCache which is actually a decora=
tor
+ whose idea is to replicate the the hash code of the value in order to
+ know if it is needed or not to invalidate the local data, if the new
+ hash code of the value is the same as the old value, we assume that =
it
+ is the same value so we don't invalidate the old value. This is requ=
ired
+ to avoid the following infinite loop that we will face with invalida=
tion
+ mode proposed out of the box by JBoss Cache for example:
+
+
+
+ Cluster node #1 puts (key1, value1) into the cache
+
+
+
+ On cluster node #2 key1 is invalidated by put call in node
+ #1
+
+
+
+ Node #2 re-loads key1 and puts (key1, value1) into the
+ cache
+
+
+
+ On cluster node #1 key1 is invalidated, so we get back to =
step
+ #1
+
+
+
+ In the use case above, thanks to the
+ InvalidationExoCache since the value loaded at =
step
+ #3 has the same hash code as the value loaded as step #1, the step #4
+ won't invalidate the data on the cluster node #1.
+
+ It exists 2 ways to use the invalidation mode which are the
+ following:
+
+
+
+ By configuration: For this you simply need to set the
+ parameter avoidValueReplication to
+ true in your eXo cache configuration, this =
will
+ indicate the CacheService to wrap your eXo cache instance into an
+ InvalidationExoCache.
+
+
+
+ Programmatically; You can wrap your eXo cache instance int=
o an
+ org.exoplatform.services.cache.impl.InvalidationExoCac=
he
+ yourself using the public constructors that are available. Please
+ note that if you use CacheListeners add the=
m to
+ the InvalidationExoCache instance instead of the nested eXo Cache
+ because the nested eXo Cache will contain only hash codes so the
+ related listeners will get hash codes instead of the real
+ values.
+
+
+
+
+ The invalidation will be efficient if and only if the hash c=
ode
+ method is properly implemented, in other words 2 value objects
+ representing the same data will return the same hash code otherwise
+ the infinite loop described above will still be effective.
+
+
=
@@ -158,7 +243,7 @@
=
You just need to implement your own ExoCacheFactory
and register it in an eXo container, as described below:
- =
+
package org.exoplatform.services.cac=
he;
...
public interface ExoCacheFactory {
@@ -178,7 +263,7 @@
can simply register your factory by adding a file
conf/portal/configuration.xml with a content of t=
he
following type:
- =
+
<configuration>
<component>
<key>org.exoplatform.services.cache.ExoCacheFactory</key>
@@ -188,14 +273,14 @@
</configuration>
=
-
- Since kernel 2.3.0-CR1, if the configuration is not a sub cl=
ass
- of ExoCacheConfig and the implementation given in t=
he
- configuration is the full qualified name of an existing implementa=
tion
- of eXo Cache, we will assume that the user expects to have an inst=
ance
- of this eXo Cache type so we won't use the configured cache
- factory.
-
+
+ Since kernel 2.3.0-CR1, if the configuration is not a sub clas=
s of
+ ExoCacheConfig and the implementation given in the
+ configuration is the full qualified name of an existing implementati=
on
+ of eXo Cache, we will assume that the user expects to have an instan=
ce
+ of this eXo Cache type so we won't use the configured cache
+ factory.
+
=
@@ -210,7 +295,7 @@
wish as you can do with any components.
=
The default configuration of the factory is:
- =
+
<configuration> =
<component>
<key>org.exoplatform.services.cache.ExoCacheFactory</key>
@@ -278,7 +363,7 @@
If for a given reason, you need to use a specific configuration
for a cache, you can register one thanks to an "external
plugin", see an example below:
- =
+
<configuration>
...
<external-component-plugins>
@@ -323,9 +408,8 @@
Understanding a cache creator
=
The factory for jboss cache, delegates the cache creation to
- ExoCacheCreator that is defined as
- below:
- =
+ ExoCacheCreator that is defined as below:
+
package org.exoplatform.services=
.cache.impl.jboss;
...
public interface ExoCacheCreator {
@@ -387,9 +471,8 @@
Registering a cache creator
=
You can register any cache creator that you want thanks to an
- "external plugin", see an example
- below:
- =
+ "external plugin", see an example below:
+
<external-component-plugins&=
gt;
<target-component>org.exoplatform.services.cache.ExoCacheFactory=
</target-component>
<component-plugin>
@@ -483,7 +566,6 @@
<object type=3D"org.exoplatform.services.cache.impl.jboss.fifo.FIFOExo=
CacheCreator"></object>
</object-param>
...
-
=
@@ -496,7 +578,6 @@
<object type=3D"org.exoplatform.services.cache.impl.jboss.mru.MRUExoC=
acheCreator"></object>
</object-param>
...
-
=
@@ -707,56 +788,54 @@
</object-param> =
...
=
-
- Fields description
+
+ Fields description
=
-
-
-
- maxNodes
+
+
+
+ maxNodes
=
- This is the maximum number of nodes allowed in
- this region. 0 denotes immediate expiry, -1 denotes =
no
- limit.
-
+ This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.
+
=
-
- minTimeToLive
+
+ minTimeToLive
=
- The minimum amount of time (in milliseconds) =
that
- a node must be allowed to live after being accessed
- before it is allowed to be considered for eviction. 0
- denotes that this feature is disabled, which is the
- default value.
-
+ The minimum amount of time (in milliseconds) that a
+ node must be allowed to live after being accessed before i=
t is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.
+
=
-
- maxAge
+
+ maxAge
=
- Lifespan of a node (in milliseconds) regardle=
ss
- of idle time before the node is swept away. 0 denotes
- immediate expiry, -1 denotes no limit.
-
+ Lifespan of a node (in milliseconds) regardless of =
idle
+ time before the node is swept away. 0 denotes immediate
+ expiry, -1 denotes no limit.
+
=
-
- timeToLive
+
+ timeToLive
=
- The amount of time that a node is not written=
to
- or read (in milliseconds) before the node is swept a=
way.
- 0 denotes immediate expiry, -1 denotes no limit.
-
-
-
-
- =
-
+ The amount of time that a node is not written to or
+ read (in milliseconds) before the node is swept away. 0
+ denotes immediate expiry, -1 denotes no limit.
+
+
+
+
+ Fields description
=
-
-
-
- maxSize
+
+
+
+ maxSize
=
- This is the maximum number of nodes allowed in =
this
- region. 0 denotes immediate expiry, -1 denotes no
- limit.
-
+ This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.
+
=
-
- liveTime
+
+ liveTime
=
- The minimum amount of time (in seconds) that a =
node
- must be allowed to live after being accessed before it=
is
- allowed to be considered for eviction. 0 denotes that =
this
- feature is disabled, which is the default value.
-
-
-
-
+ The minimum amount of time (in seconds) that a node
+ must be allowed to live after being accessed before it is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.
+
+
+
+
=
-
- For the fields maxAge and
- timeToLive needed by JBoss cache, we =
will
- use the default values provided by the creator.
-
- =
- =
+
+ For the fields maxAge and
+ timeToLive needed by JBoss cache, we will u=
se
+ the default values provided by the creator.
+
=
@@ -811,8 +888,8 @@
New configuration
- =
- ...
+
+ ...
<object-param>
<name>fifo</name>
<description>The fifo cache configuration</description>
@@ -824,38 +901,38 @@
</object-param>
...
=
-
- Fields description
+
+ Fields description
=
-
-
-
- maxNodes
+
+
+
+ maxNodes
=
- This is the maximum number of nodes allowed in =
this
- region. 0 denotes immediate expiry, -1 denotes no
- limit.
-
+ This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.
+
=
-
- minTimeToLive
+
+ minTimeToLive
=
- The minimum amount of time (in milliseconds) th=
at a
- node must be allowed to live after being accessed befo=
re
- it is allowed to be considered for eviction. 0 denotes
- that this feature is disabled, which is the default
- value.
-
-
-
-
-
-
- Old configuration
-
-
- =
- ...
+ The minimum amount of time (in milliseconds) that a
+ node must be allowed to live after being accessed before i=
t is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.
+
+
+
+
+ Fields description
=
-
-
-
- maxSize
+
+
+
+ maxSize
=
- This is the maximum number of nodes allowed in =
this
- region. 0 denotes immediate expiry, -1 denotes no
- limit.
-
+ This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.
+
=
-
- liveTime
+
+ liveTime
=
- The minimum amount of time (in seconds) that a =
node
- must be allowed to live after being accessed before it=
is
- allowed to be considered for eviction. 0 denotes that =
this
- feature is disabled, which is the default value.
-
-
-
-
+ The minimum amount of time (in seconds) that a node
+ must be allowed to live after being accessed before it is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.
+
+
+
+
+ Fields description
=
-
-
-
- maxNodes
+
+
+
+ maxNodes
=
- This is the maximum number of nodes allowed in =
this
- region. 0 denotes immediate expiry, -1 denotes no
- limit.
-
+ This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.
+
=
-
- minTimeToLive
+
+ minTimeToLive
=
- The minimum amount of time (in milliseconds) th=
at a
- node must be allowed to live after being accessed befo=
re
- it is allowed to be considered for eviction. 0 denotes
- that this feature is disabled, which is the default
- value.
-
-
-
-
- =
+ The minimum amount of time (in milliseconds) that a
+ node must be allowed to live after being accessed before i=
t is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.
+
+
+
+
+ Fields description
=
-
-
-
- maxSize
+
+
+
+ maxSize
=
- This is the maximum number of nodes allowed in =
this
- region. 0 denotes immediate expiry, -1 denotes no
- limit.
-
+ This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.
+
=
-
- liveTime
+
+ liveTime
=
- The minimum amount of time (in seconds) that a =
node
- must be allowed to live after being accessed before it=
is
- allowed to be considered for eviction. 0 denotes that =
this
- feature is disabled, which is the default value.
-
-
-
-
+ The minimum amount of time (in seconds) that a node
+ must be allowed to live after being accessed before it is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.
+
+
+
+
+ Fields description
=
-
-
-
- maxNodes
+
+
+
+ maxNodes
=
- This is the maximum number of nodes allowed in =
this
- region. 0 denotes immediate expiry, -1 denotes no
- limit.
-
+ This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.
+
=
-
- minNodes
+
+ minNodes
=
- This is the minimum number of nodes allowed in =
this
- region. This value determines what the eviction queue
- should prune down to per pass. e.g. If minNodes is 10 =
and
- the cache grows to 100 nodes, the cache is pruned down=
to
- the 10 most frequently used nodes when the eviction ti=
mer
- makes a pass through the eviction algorithm.
-
+ This is the minimum number of nodes allowed in this
+ region. This value determines what the eviction queue shou=
ld
+ prune down to per pass. e.g. If minNodes is 10 and the cac=
he
+ grows to 100 nodes, the cache is pruned down to the 10 most
+ frequently used nodes when the eviction timer makes a pass
+ through the eviction algorithm.
+
=
-
- minTimeToLive
+
+ minTimeToLive
=
- The minimum amount of time (in milliseconds) th=
at a
- node must be allowed to live after being accessed befo=
re
- it is allowed to be considered for eviction. 0 denotes
- that this feature is disabled, which is the default
- value.
-
-
-
-
- =
-
- Old configuration
-
-
- =
- ...
+ The minimum amount of time (in milliseconds) that a
+ node must be allowed to live after being accessed before i=
t is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.
+
+
+
+
+ Fields description
=
-
-
-
- maxSize
+
+
+
+ maxSize
=
- This is the maximum number of nodes allowed in =
this
- region. 0 denotes immediate expiry, -1 denotes no
- limit.
-
+ This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.
+
=
-
- liveTime
+
+ liveTime
=
- The minimum amount of time (in milliseconds) th=
at a
- node must be allowed to live after being accessed befo=
re
- it is allowed to be considered for eviction. 0 denotes
- that this feature is disabled, which is the default
- value.
-
-
-
-
+ The minimum amount of time (in milliseconds) that a
+ node must be allowed to live after being accessed before i=
t is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.
+
+
+
+
=
-
- For the fields minNodes and
- timeToLive needed by JBoss cache, we =
will
- use the default values provided by the creator.
-
+
+ For the fields minNodes and
+ timeToLive needed by JBoss cache, we will=
use
+ the default values provided by the creator.
+
=
@@ -1104,8 +1179,8 @@
New configuration
- =
- ...
+
+ ...
<object-param>
<name>ea</name>
<description>The ea cache configuration</description>
@@ -1118,46 +1193,45 @@
</object-param> =
...
=
-
- Fields description
+
+ Fields description
=
-
-
-
- maxNodes
+
+
+
+ maxNodes
=
- This is the maximum number of nodes allowed in =
this
- region. 0 denotes immediate expiry, -1 denotes no
- limit.
-
+ This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.
+
=
-
- minTimeToLive
+
+ minTimeToLive
=
- The minimum amount of time (in milliseconds) th=
at a
- node must be allowed to live after being accessed befo=
re
- it is allowed to be considered for eviction. 0 denotes
- that this feature is disabled, which is the default
- value.
-
+ The minimum amount of time (in milliseconds) that a
+ node must be allowed to live after being accessed before i=
t is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.
+
=
-
- expirationTimeout
+
+ expirationTimeout
=
- This is the timeout after which the cache entry
- must be evicted.
-
-
-
-
- =
+ This is the timeout after which the cache entry mus=
t be
+ evicted.
+
+
+
+
+ Fields description
=
-
-
-
- maxSize
+
+
+
+ maxSize
=
- This is the maximum number of nodes allowed in =
this
- region. 0 denotes immediate expiry, -1 denotes no
- limit.
-
+ This is the maximum number of nodes allowed in this
+ region. 0 denotes immediate expiry, -1 denotes no
+ limit.
+
=
-
- liveTime
+
+ liveTime
=
- The minimum amount of time (in milliseconds) th=
at a
- node must be allowed to live after being accessed befo=
re
- it is allowed to be considered for eviction. 0 denotes
- that this feature is disabled, which is the default
- value.
-
-
-
-
+ The minimum amount of time (in milliseconds) that a
+ node must be allowed to live after being accessed before i=
t is
+ allowed to be considered for eviction. 0 denotes that this
+ feature is disabled, which is the default value.
+
+
+
+
=
-
- For the fields expirationTimeout
- needed by JBoss cache, we will use the default values prov=
ided
- by the creator.
-
- =
+
+ For the fields expirationTimeout ne=
eded
+ by JBoss cache, we will use the default values provided by the
+ creator.
+
@@ -1218,7 +1290,7 @@
if you wish as you can do with any components.
=
The default configuration of the factory is:
- =
+
<configuration> =
<component>
<key>org.exoplatform.services.cache.ExoCacheFactory</key>
@@ -1241,12 +1313,13 @@
=
The default configuration template aims to be the skeleton from
which we will create any type of infinispan cache instance, thus it =
must
- be very generic. =
+ be very generic.
+
- All the cache instances that will rely on this cache
- configuration will share the same
- EmbeddedCacheManager.
-
+ All the cache instances that will rely on this cache
+ configuration will share the same
+ EmbeddedCacheManager.
+
=
@@ -1255,7 +1328,7 @@
If for a given reason, you need to use a specific configuration
for a cache, you can register one thanks to an "external
plugin", see an example below:
- =
+
<configuration>
...
<external-component-plugins>
@@ -1306,9 +1379,8 @@
Understanding a cache creator
=
The factory for infinispan, delegates the cache creation to
- ExoCacheCreator that is defined as
- below:
- =
+ ExoCacheCreator that is defined as below:
+
package org.exoplatform.services=
.cache.impl.infinispan;
...
public interface ExoCacheCreator {
@@ -1374,9 +1446,8 @@
Register a cache creator
=
You can register any cache creator you want thanks to an
- "external plugin", see an example
- below:
- =
+ "external plugin", see an example below:
+
<external-component-plugins&=
gt;
<target-component>org.exoplatform.services.cache.ExoCacheFactory=
</target-component>
<component-plugin>
@@ -1535,8 +1606,8 @@
New configuration
- =
- ...
+
+ ...
<object-param>
<name>myCache</name>
<description>My cache configuration</description>
@@ -1550,67 +1621,65 @@
</object>
</object-param> =
...
-
- Fields description
=
-
-
-
- strategy
+
+ Fields description
=
- The name of the strategy to use such as
- 'UNORDERED', 'FIFO', 'LRU', 'LIRS' and 'NONE' (to
- disable eviction).
-
+
+
+
+ strategy
=
-
- maxEntries
+ The name of the strategy to use such as 'UNORDERED',
+ 'FIFO', 'LRU', 'LIRS' and 'NONE' (to disable
+ eviction).
+
=
- Maximum number of entries in a cache instance=
. If
- selected value is not a power of two the actual value
- will default to the least power of two larger than
- selected value. -1 means no limit which is also the
- default value.
-
+
+ maxEntries
=
-
- lifespan
+ Maximum number of entries in a cache instance. If
+ selected value is not a power of two the actual value will
+ default to the least power of two larger than selected val=
ue.
+ -1 means no limit which is also the default value.
+
=
- Maximum lifespan of a cache entry, after which
- the entry is expired cluster-wide, in milliseconds. =
-1
- means the entries never expire which is also the def=
ault
- value.
-
+
+ lifespan
=
-
- maxIdle
+ Maximum lifespan of a cache entry, after which the
+ entry is expired cluster-wide, in milliseconds. -1 means t=
he
+ entries never expire which is also the default value.
+
=
- Maximum idle time a cache entry will be
- maintained in the cache, in milliseconds. If the idle
- time is exceeded, the entry will be expired
- cluster-wide. -1 means the entries never expire whic=
h is
- also the default value.
-
+
+ maxIdle
=
-
- wakeUpInterval
+ Maximum idle time a cache entry will be maintained =
in
+ the cache, in milliseconds. If the idle time is exceeded, =
the
+ entry will be expired cluster-wide. -1 means the entries n=
ever
+ expire which is also the default value.
+
=
- Interval between subsequent eviction runs, in
- milliseconds. If you wish to disable the periodic
- eviction process altogether, set wakeupInterval to -=
1.
- The default value is 5000.
-
-
-
-
- =
+
+ wakeUpInterval
+
+ Interval between subsequent eviction runs, in
+ milliseconds. If you wish to disable the periodic eviction
+ process altogether, set wakeupInterval to -1. The default
+ value is 5000.
+
+
+
+
+ Fields description
=
-
-
-
- maxSize
+
+
+
+ maxSize
=
- Maximum number of entries in a cache instance. =
If
- selected value is not a power of two the actual value =
will
- default to the least power of two larger than selected
- value. -1 means no limit which is also the default
- value.
-
+ Maximum number of entries in a cache instance. If
+ selected value is not a power of two the actual value will
+ default to the least power of two larger than selected val=
ue.
+ -1 means no limit which is also the default value.
+
=
-
- liveTime
+
+ liveTime
=
- Maximum lifespan of a cache entry, after which =
the
- entry is expired cluster-wide, in milliseconds. -1 mea=
ns
- the entries never expire which is also the default
- value.
-
+ Maximum lifespan of a cache entry, after which the
+ entry is expired cluster-wide, in milliseconds. -1 means t=
he
+ entries never expire which is also the default value.
+
=
-
- implementation
+
+ implementation
=
- The name of the implementation to use the expec=
ted
- value is one of the eviction strategies defined in the
- field implementations of the gene=
ric
- cache creator.
-
-
-
-
+ The name of the implementation to use the expected
+ value is one of the eviction strategies defined in the fie=
ld
+ implementations of the generic cache
+ creator.
+
+
+
+
=
-
- For the fields maxIdle and
- wakeUpInterval needed by infinispan, =
we
- will use the default values provided by the creator.
-
- =
+
+ For the fields maxIdle and
+ wakeUpInterval needed by infinispan, we w=
ill
+ use the default values provided by the creator.
+
Modified: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplat=
form/services/cache/ExoCacheConfig.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/ExoCacheConfig.java 2011-07-01 14:27:05 UTC (rev 4586)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/ExoCacheConfig.java 2011-07-04 12:56:27 UTC (rev 4587)
@@ -68,6 +68,11 @@
*/
private boolean logEnabled;
=
+ /**
+ * Indicates whether or not the replication of the values should be avo=
ided
+ */
+ public boolean avoidValueReplication;
+
public String getName()
{
return name;
@@ -147,8 +152,24 @@
{
this.logEnabled =3D enableLogging;
}
+ =
+ /**
+ * @return the avoidValueReplication
+ */
+ public boolean avoidValueReplication()
+ {
+ return avoidValueReplication;
+ }
=
/**
+ * @param avoidValueReplication the avoidValueReplication to set
+ */
+ public void setAvoidValueReplication(boolean avoidValueReplication)
+ {
+ this.avoidValueReplication =3D avoidValueReplication;
+ }
+
+ /**
* @see java.lang.Object#clone()
*/
@Override
Modified: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplat=
form/services/cache/impl/CacheServiceImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/impl/CacheServiceImpl.java 2011-07-01 14:27:05 UTC (rev 4586)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/impl/CacheServiceImpl.java 2011-07-04 12:56:27 UTC (rev 4587)
@@ -154,6 +154,7 @@
return null;
}
=
+ @SuppressWarnings({"rawtypes", "unchecked"})
private ExoCache extends Serializable, ?> createCacheInstance(String =
region) throws Exception
{
ExoCacheConfig config =3D configs_.get(region);
@@ -198,7 +199,9 @@
{
managed.registerCache(simple);
}
- return simple;
+ // If the flag avoid value replication is enabled we wrap the eXo ca=
che instance
+ // into an InvalidationExoCache to enable the invalidation
+ return safeConfig.avoidValueReplication() ? new InvalidationExoCache=
(simple) : simple;
}
=
public Collection> getAllCacheInsta=
nces()
Added: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatfor=
m/services/cache/impl/InvalidationExoCache.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/impl/InvalidationExoCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/impl/InvalidationExoCache.java 2011-07-04 12:56:27 UTC (rev 4=
587)
@@ -0,0 +1,560 @@
+/*
+ * 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 inv=
alidation
+ * mechanism. To prevent infinite loop described below, we replicate the h=
ash code of
+ * the value such that if the hash code is the same, we don't invalidate t=
he value locally
+ *
+ *
Cluster node #1 puts (key1, value1) into the cache
+ *
On cluster node #2 key1 is invalidated by the put call in node #1=
li>
+ *
Node #2 re-loads key1 and puts (key1, value1) into the cache
+ *
On cluster node #1 key1 is invalidated, so we get back to step #1=
li>
+ *
+ * =
+ * @author Nicolas Filotto=
a>
+ * @version $Id$
+ *
+ */
+public class InvalidationExoCache implements Ex=
oCache, CacheListener>
+{
+ /**
+ * Logger.
+ */
+ private static final Log LOG =3D ExoLogger.getLogger("exo.kernel.compon=
ent.cache.InvalidationExoCache");
+
+ /**
+ * The eXo cache instance that we would like to replicate using the inv=
alidation
+ * mechanism
+ */
+ private final ExoCache> delegate;
+ =
+ /**
+ * The listeners of the cache
+ */
+ private final CopyOnWriteArrayList>=
listeners;
+ =
+ /**
+ * The local cache that contains the real values
+ */
+ private final ConcurrentMap localCache;
+ =
+ /**
+ * @param delegate the underneath eXo cache instance, we assume that th=
e eXo cache
+ * implementation behind is fully functional.
+ */
+ public InvalidationExoCache(ExoCache delegate)
+ {
+ this(delegate, 16);
+ }
+ =
+ /**
+ * @param delegate the underneath eXo cache instance, we assume that th=
e 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 delegate, int concurrencyLev=
el)
+ {
+ this.delegate =3D (ExoCache>)delegate;
+ // We listen to the cache in order to get a callbacks in case of int=
ernal puts for example
+ this.delegate.addCacheListener(this);
+ this.listeners =3D new CopyOnWriteArrayList>();
+ this.localCache =3D new ConcurrentHashMap(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.Strin=
g)
+ */
+ 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.Stri=
ng)
+ */
+ public void setLabel(String s)
+ {
+ delegate.setLabel(s);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#get(java.io.Serializabl=
e)
+ */
+ public V get(Serializable name)
+ {
+ HashCode result =3D delegate.get(name);
+ return result =3D=3D null ? null : localCache.get(name);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#remove(java.io.Serializ=
able)
+ */
+ public V remove(Serializable key) throws NullPointerException
+ {
+ V value =3D localCache.get(key);
+ delegate.remove(key);
+ return value;
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#put(java.io.Serializabl=
e, java.lang.Object)
+ */
+ public void put(K key, V value) throws NullPointerException
+ {
+ delegate.put(key, new HashCode(value));
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#putMap(java.util.Map)
+ */
+ public void putMap(Map extends K, ? extends V> objs) throws NullPoint=
erException, IllegalArgumentException
+ {
+ if (objs =3D=3D null)
+ {
+ throw new NullPointerException("No null map accepted");
+ }
+ Map> map =3D new LinkedHashMap>();
+ for (Entry extends K, ? extends V> entry : objs.entrySet())
+ {
+ if (entry.getKey() =3D=3D null)
+ {
+ throw new IllegalArgumentException("No null cache key accepted=
");
+ }
+ else if (entry.getValue() =3D=3D null)
+ {
+ throw new IllegalArgumentException("No null cache value accept=
ed"); =
+ }
+ map.put(entry.getKey(), new HashCode(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 =3D=3D null)
+ {
+ throw new IllegalArgumentException("No null selector");
+ }
+ for (Entry entry : localCache.entrySet())
+ {
+ final K key =3D entry.getKey();
+ final V value =3D entry.getValue();
+ ObjectCacheInfo info =3D new ObjectCacheInfo()
+ {
+ public V get()
+ {
+ return value;
+ }
+
+ public long getExpireTime()
+ {
+ // Cannot know: The expire time is managed by JBoss Cache i=
tself
+ 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(localCache.values());
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#removeCachedObjects()
+ */
+ public List extends V> removeCachedObjects()
+ {
+ final List extends V> list =3D getCachedObjects();
+ clearCache();
+ return list;
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.ExoCache#addCacheListener(org.ex=
oplatform.services.cache.CacheListener)
+ */
+ public void addCacheListener(CacheListener super K, ? super V> listen=
er) throws NullPointerException
+ {
+ if (listener =3D=3D 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);
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.CacheListener#onExpire(org.exopl=
atform.services.cache.CacheListenerContext, java.io.Serializable, java.lang=
.Object)
+ */
+ public void onExpire(CacheListenerContext context, K key, HashCode o=
bj) throws Exception
+ {
+ V value =3D 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);
+ }
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.CacheListener#onRemove(org.exopl=
atform.services.cache.CacheListenerContext, java.io.Serializable, java.lang=
.Object)
+ */
+ public void onRemove(CacheListenerContext context, K key, HashCode o=
bj) throws Exception
+ {
+ V value =3D 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);
+ }
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.CacheListener#onPut(org.exoplatf=
orm.services.cache.CacheListenerContext, java.io.Serializable, java.lang.Ob=
ject)
+ */
+ public void onPut(CacheListenerContext context, K key, HashCode obj)=
throws Exception
+ {
+ V value =3D obj.getValue();
+ if (value !=3D 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 insid=
e the HashCode object
+ V currentValue =3D localCache.get(key);
+ if (currentValue !=3D null && obj !=3D null && currentValue.hashC=
ode() =3D=3D obj.hashCode())
+ {
+ // We assume that it is the same value so we don't change the =
value in the cache
+ value =3D currentValue;
+ }
+ else
+ {
+ // A new value has been added to the cache so we invalidate th=
e local one
+ value =3D 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);
+ }
+ }
+
+ /**
+ * @see org.exoplatform.services.cache.CacheListener#onGet(org.exoplatf=
orm.services.cache.CacheListenerContext, java.io.Serializable, java.lang.Ob=
ject)
+ */
+ public void onGet(CacheListenerContext context, K key, HashCode obj)=
throws Exception
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ V value =3D obj =3D=3D 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.e=
xoplatform.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 efficientl=
y over the network
+ */
+ public static class HashCode 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 =3D value.hashCode();
+ this.value =3D 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, ClassNo=
tFoundException
+ {
+ this.hashCode =3D 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 =3D=3D obj)
+ return true;
+ if (obj =3D=3D null)
+ return false;
+ if (getClass() !=3D obj.getClass())
+ return false;
+ @SuppressWarnings("rawtypes")
+ HashCode other =3D (HashCode)obj;
+ if (hashCode !=3D other.hashCode)
+ return false;
+ if (value !=3D null && other.value !=3D null)
+ {
+ return value.equals(other.value);
+ }
+ return true;
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "HashCode [hashCode=3D" + hashCode + ", value=3D" + value =
+ "]";
+ }
+ } =
+}
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/sr=
c/main/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache=
.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main=
/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java =
2011-07-01 14:27:05 UTC (rev 4586)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.infinispan.v4/src/main=
/java/org/exoplatform/services/cache/impl/infinispan/AbstractExoCache.java =
2011-07-04 12:56:27 UTC (rev 4587)
@@ -31,8 +31,10 @@
import org.infinispan.Cache;
import org.infinispan.context.Flag;
import org.infinispan.notifications.Listener;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryEvi=
cted;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryMod=
ified;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryRem=
oved;
+import org.infinispan.notifications.cachelistener.event.CacheEntryEvictedE=
vent;
import org.infinispan.notifications.cachelistener.event.CacheEntryModified=
Event;
import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedE=
vent;
=
@@ -472,18 +474,21 @@
@Listener
public class CacheEventListener
{
-// Infinispan triggers a CacheEntryEvictedEvent only at explicit eviction =
which is
-// not what we want here. So it will be considered as non supported =
-// @CacheEntryEvicted
-// public void cacheEntryEvicted(CacheEntryEvictedEvent evt)
-// {
-// if (evt.isPre())
-// {
-// final K key =3D (K)evt.getKey();
-// final V value =3D cache.withFlags(Flag.SKIP_LOCKING).get(key=
);
-// onExpire(key, value);
-// }
-// }
+ /**
+ * Warning Infinispan triggers a CacheEntryEvictedEvent=
only at explicit eviction
+ * that is done lazily which is not exactly what we expect, we still=
use it to be =
+ * able to use it with avoidValueReplication set to true.
+ */
+ @CacheEntryEvicted
+ public void cacheEntryEvicted(CacheEntryEvictedEvent evt)
+ {
+ if (evt.isPre())
+ {
+ final K key =3D (K)evt.getKey();
+ final V value =3D cache.withFlags(Flag.SKIP_LOCKING).get(key);
+ onExpire(key, value);
+ }
+ }
=
@CacheEntryRemoved
public void cacheEntryRemoved(CacheEntryRemovedEvent evt)
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/tes=
t/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java=
/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2011-0=
7-01 14:27:05 UTC (rev 4586)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/test/java=
/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2011-0=
7-04 12:56:27 UTC (rev 4587)
@@ -31,6 +31,7 @@
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.test.BasicTestCase;
=
@@ -41,8 +42,8 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
-import java.util.Map.Entry;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
=
@@ -270,17 +271,17 @@
config2.setLiveTime(1);
config2.setImplementation("LRU");
config2.setDistributed(true);
- AbstractExoCache cache1 =3D
- (AbstractExoCache)getExoCacheFactoryInstanc=
e().createCache(config);
- MyCacheListener listener1 =3D new MyCacheListener();
+ AbstractExoCache cache1 =3D
+ (AbstractExoCache)getExoCacheFactoryInstanc=
e().createCache(config);
+ MyCacheListener listener1 =3D new MyCacheListener();
cache1.addCacheListener(listener1);
- AbstractExoCache cache2 =3D
- (AbstractExoCache)getExoCacheFactoryInstanc=
e().createCache(config);
- MyCacheListener listener2 =3D new MyCacheListener();
+ AbstractExoCache cache2 =3D
+ (AbstractExoCache)getExoCacheFactoryInstanc=
e().createCache(config);
+ MyCacheListener listener2 =3D new MyCacheListener();
cache2.addCacheListener(listener2);
- AbstractExoCache cache3 =3D
- (AbstractExoCache)getExoCacheFactoryInstanc=
e().createCache(config2);
- MyCacheListener listener3 =3D new MyCacheListener();
+ AbstractExoCache cache3 =3D
+ (AbstractExoCache)getExoCacheFactoryInstanc=
e().createCache(config2);
+ MyCacheListener listener3 =3D new MyCacheListener();
cache3.addCacheListener(listener3);
try
{
@@ -358,7 +359,7 @@
assertEquals(1, listener1.clearCache);
assertEquals(0, listener2.clearCache);
assertEquals(0, listener3.clearCache);
- Map values =3D new HashMap();
+ Map values =3D new HashMap();
values.put(new MyKey("a"), "a");
values.put(new MyKey("b"), "b");
cache1.putMap(values);
@@ -379,22 +380,22 @@
assertEquals(1, listener1.clearCache);
assertEquals(0, listener2.clearCache);
assertEquals(0, listener3.clearCache);
- values =3D new HashMap()
+ values =3D new HashMap()
{
private static final long serialVersionUID =3D 1L;
=
- public Set> entrySet()
+ public Set> entrySet()
{
- Set> set =3D new LinkedHashSet<=
Entry>(super.entrySet());
- set.add(new Entry()
+ Set> set =3D new LinkedHashSet<=
Entry>(super.entrySet());
+ set.add(new Entry()
{
=
- public Object setValue(Object paramV)
+ public String setValue(String paramV)
{
return null;
}
=
- public Object getValue()
+ public String getValue()
{
throw new RuntimeException("An exception");
}
@@ -456,6 +457,247 @@
}
}
=
+ @SuppressWarnings("unchecked")
+ public void testDistributedCacheWithNSValues() throws Exception
+ {
+ System.out
+ .println("WARNING: For Linux distributions the following JVM para=
meter must be set to true, java.net.preferIPv4Stack =3D "
+ + System.getProperty("java.net.preferIPv4Stack"));
+ ExoCacheConfig config =3D new ExoCacheConfig();
+ config.setName("MyCacheDistributedWithNSValues");
+ config.setMaxSize(5);
+ config.setLiveTime(1);
+ config.setImplementation("LRU");
+ config.setDistributed(true);
+ config.setAvoidValueReplication(true);
+ ExoCacheConfig config2 =3D new ExoCacheConfig();
+ config2.setName("MyCacheDistributedWithNSValues2");
+ config2.setMaxSize(5);
+ config2.setLiveTime(1);
+ config2.setImplementation("LRU");
+ config2.setDistributed(true);
+ config2.setAvoidValueReplication(true);
+ AbstractExoCache acache1 =3D
+ (AbstractExoCache)getExoCac=
heFactoryInstance().createCache(config);
+ MyCacheListener listener1 =3D new MyCacheLis=
tener();
+ ExoCache cache1 =3D new Invali=
dationExoCache(acache1);
+ cache1.addCacheListener(listener1);
+ AbstractExoCache acache2 =3D
+ (AbstractExoCache)getExoCac=
heFactoryInstance().createCache(config);
+ MyCacheListener listener2 =3D new MyCacheLis=
tener();
+ ExoCache cache2 =3D new Invali=
dationExoCache(acache2);
+ cache2.addCacheListener(listener2);
+ AbstractExoCache acache3 =3D
+ (AbstractExoCache)getExoCac=
heFactoryInstance().createCache(config2);
+ MyCacheListener listener3 =3D new MyCacheLis=
tener();
+ ExoCache cache3 =3D new Invali=
dationExoCache(acache3);
+ cache3.addCacheListener(listener3);
+ try
+ {
+ cache1.put(new MyKey("a"), new MyNonSerializableValue("b"));
+ assertEquals(1, cache1.getCacheSize());
+ assertNull(cache2.get(new MyKey("a")));
+ assertEquals(0, cache2.getCacheSize());
+ assertEquals(0, cache3.getCacheSize());
+ assertEquals(1, listener1.put);
+ assertEquals(1, listener2.put);
+ assertEquals(0, listener3.put);
+ assertEquals(0, listener1.get);
+ assertEquals(1, listener2.get);
+ assertEquals(0, listener3.get);
+ cache2.put(new MyKey("b"), new MyNonSerializableValue("c"));
+ assertEquals(1, cache1.getCacheSize());
+ assertEquals(1, cache2.getCacheSize());
+ assertNull(cache1.get(new MyKey("b")));
+ assertEquals(0, cache3.getCacheSize());
+ assertEquals(2, listener1.put);
+ assertEquals(2, listener2.put);
+ assertEquals(0, listener3.put);
+ assertEquals(1, listener1.get);
+ assertEquals(1, listener2.get);
+ assertEquals(0, listener3.get);
+ cache3.put(new MyKey("c"), new MyNonSerializableValue("d"));
+ assertEquals(1, cache1.getCacheSize());
+ assertEquals(1, cache2.getCacheSize());
+ assertEquals(1, cache3.getCacheSize());
+ assertEquals(new MyNonSerializableValue("d"), cache3.get(new MyKe=
y("c")));
+ assertEquals(2, listener1.put);
+ assertEquals(2, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(1, listener1.get);
+ assertEquals(1, listener2.get);
+ assertEquals(1, listener3.get);
+ cache2.put(new MyKey("a"), new MyNonSerializableValue("a"));
+ assertEquals(0, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertNull(cache1.get(new MyKey("a")));
+ assertEquals(3, listener1.put);
+ assertEquals(3, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(1, listener2.get);
+ assertEquals(1, listener3.get);
+ cache2.remove(new MyKey("a"));
+ assertEquals(0, cache1.getCacheSize());
+ assertEquals(1, cache2.getCacheSize());
+ assertEquals(3, listener1.put);
+ assertEquals(3, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(1, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+ assertEquals(0, listener3.remove);
+ cache1.put(new MyKey("c"), new MyNonSerializableValue("c"));
+ cache1.clearCache();
+ assertEquals(0, cache1.getCacheSize());
+ assertNull(cache1.get(new MyKey("b")));
+ assertEquals(new MyNonSerializableValue("c"), cache2.get(new MyKe=
y("b")));
+ assertNull(cache2.get(new MyKey("c")));
+ assertEquals(1, cache2.getCacheSize());
+ assertEquals(4, listener1.put);
+ assertEquals(4, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(3, listener1.get);
+ assertEquals(3, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ Map values =3D new HashMap<=
Serializable, MyNonSerializableValue>();
+ values.put(new MyKey("a"), new MyNonSerializableValue("a"));
+ values.put(new MyKey("b"), new MyNonSerializableValue("b"));
+ cache1.putMap(values);
+ assertEquals(2, cache1.getCacheSize());
+ Thread.sleep(40);
+ assertNull(cache2.get(new MyKey("a")));
+ assertNull(cache2.get(new MyKey("b")));
+ assertEquals(0, cache2.getCacheSize());
+ assertEquals(6, listener1.put);
+ assertEquals(6, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(3, listener1.get);
+ assertEquals(5, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ values =3D new HashMap()
+ {
+ private static final long serialVersionUID =3D 1L;
+
+ public Set> entryS=
et()
+ {
+ Set> set =3D ne=
w LinkedHashSet>(super.entrySet=
());
+ set.add(new Entry()
+ {
+
+ public MyNonSerializableValue setValue(MyNonSerializable=
Value paramV)
+ {
+ return null;
+ }
+
+ public MyNonSerializableValue getValue()
+ {
+ throw new RuntimeException("An exception");
+ }
+
+ public Serializable getKey()
+ {
+ return "c";
+ }
+ });
+ return set;
+ }
+ };
+ values.put(new MyKey("e"), new MyNonSerializableValue("e"));
+ values.put(new MyKey("d"), new MyNonSerializableValue("d"));
+ try
+ {
+ cache1.putMap(values);
+ }
+ catch (Exception e)
+ {
+ // ignore me
+ }
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(0, cache2.getCacheSize());
+ assertEquals(1, cache3.getCacheSize());
+ assertEquals(6, listener1.put);
+ assertEquals(6, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(3, listener1.get);
+ assertEquals(5, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ assertEquals(0, listener1.expire);
+ assertEquals(0, listener2.expire);
+ assertEquals(0, listener3.expire);
+ Thread.sleep(1600);
+ assertEquals(0, cache1.getCacheSize());
+ assertEquals(0, cache2.getCacheSize());
+ assertEquals(0, cache3.getCacheSize());
+ assertEquals(6, listener1.put);
+ assertEquals(6, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(3, listener1.get);
+ assertEquals(5, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ assertEquals(2, listener1.expire);
+ assertEquals(3, listener2.expire);
+ assertEquals(1, listener3.expire);
+ cache1.put(new MyKey("a"), new MyNonSerializableValue("b"));
+ assertNotNull(cache1.get(new MyKey("a")));
+ assertNull(cache2.get(new MyKey("a")));
+ cache2.put(new MyKey("a"), new MyNonSerializableValue("c"));
+ assertNotNull(cache2.get(new MyKey("a")));
+ assertNull(cache1.get(new MyKey("a")));
+ cache1.put(new MyKey("a"), new MyNonSerializableValue("c"));
+ assertEquals(new MyNonSerializableValue("c"), cache2.get(new MyKe=
y("a")));
+ assertEquals(new MyNonSerializableValue("c"), cache1.get(new MyKe=
y("a")));
+ assertEquals(9, listener1.put);
+ assertEquals(9, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(6, listener1.get);
+ assertEquals(8, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(1, listener1.remove);
+ assertEquals(1, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ assertEquals(2, listener1.expire);
+ assertEquals(3, listener2.expire);
+ assertEquals(1, listener3.expire);
+ =
+ }
+ finally
+ {
+ acache1.cache.stop();
+ acache2.cache.stop();
+ acache3.cache.stop();
+ }
+ }
+
public void testMultiThreading() throws Exception
{
long time =3D System.currentTimeMillis();
@@ -645,7 +887,7 @@
System.out.println("Total Time =3D " + (System.currentTimeMillis() -=
time));
}
=
- public static class MyCacheListener implements CacheListener
+ public static class MyCacheListener implements CacheListener
{
=
public int clearCache;
@@ -658,64 +900,67 @@
=
public int remove;
=
- public void onClearCache(ExoCache cache) throw=
s Exception
+ public void onClearCache(CacheListenerContext context) throws Except=
ion
{
clearCache++;
}
=
- public void onExpire(ExoCache cache, Serializa=
ble key, Object obj) throws Exception
+ public void onExpire(CacheListenerContext context, Serializable key,=
T obj) throws Exception
{
expire++;
}
=
- public void onGet(ExoCache cache, Serializable=
key, Object obj) throws Exception
+ public void onGet(CacheListenerContext context, Serializable key, T =
obj) throws Exception
{
get++;
}
=
- public void onPut(ExoCache cache, Serializable=
key, Object obj) throws Exception
+ public void onPut(CacheListenerContext context, Serializable key, T =
obj) throws Exception
{
put++;
}
=
- public void onRemove(ExoCache cache, Serializa=
ble key, Object obj) throws Exception
+ public void onRemove(CacheListenerContext context, Serializable key,=
T obj) throws Exception
{
remove++;
}
+ }
=
- public void onClearCache(CacheListenerContext context) throws Except=
ion
- {
- clearCache++;
- }
+ public static class MyKey implements Serializable
+ {
+ private static final long serialVersionUID =3D 1L;
=
- public void onExpire(CacheListenerContext context, Serializable key,=
Object obj) throws Exception
+ public String value;
+
+ public MyKey(String value)
{
- expire++;
+ this.value =3D value;
}
=
- public void onGet(CacheListenerContext context, Serializable key, Ob=
ject obj) throws Exception
+ @Override
+ public boolean equals(Object paramObject)
{
- get++;
+ return paramObject instanceof MyKey && ((MyKey)paramObject).value=
.endsWith(value);
}
=
- public void onPut(CacheListenerContext context, Serializable key, Ob=
ject obj) throws Exception
+ @Override
+ public int hashCode()
{
- put++;
+ return value.hashCode();
}
=
- public void onRemove(CacheListenerContext context, Serializable key,=
Object obj) throws Exception
+ @Override
+ public String toString()
{
- remove++;
+ return value;
}
}
-
- public static class MyKey implements Serializable
+ =
+ public static class MyNonSerializableValue
{
- private static final long serialVersionUID =3D 1L;
-
public String value;
=
- public MyKey(String value)
+ public MyNonSerializableValue(String value)
{
this.value =3D value;
}
@@ -723,7 +968,7 @@
@Override
public boolean equals(Object paramObject)
{
- return paramObject instanceof MyKey && ((MyKey)paramObject).value=
.endsWith(value);
+ return paramObject instanceof MyNonSerializableValue && ((MyNonSe=
rializableValue)paramObject).value.endsWith(value);
}
=
@Override
--===============2655590484208058450==--
From do-not-reply at jboss.org Mon Jul 4 13:12:40 2011
Content-Type: multipart/mixed; boundary="===============0631861768934586273=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4588 -
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache
and 3 other directories.
Date: Mon, 04 Jul 2011 13:12:39 -0400
Message-ID: <201107041712.p64HCdfk020270@svn01.web.mwc.hst.phx2.redhat.com>
--===============0631861768934586273==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: nfilotto
Date: 2011-07-04 13:12:39 -0400 (Mon, 04 Jul 2011)
New Revision: 4588
Added:
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/se=
rvices/cache/future/
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/se=
rvices/cache/future/FutureCache.java
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/se=
rvices/cache/future/FutureExoCache.java
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/se=
rvices/cache/future/Loader.java
kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/se=
rvices/cache/future/
kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/se=
rvices/cache/future/ConcurrentGetWhenPutTestCase.java
kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/se=
rvices/cache/future/FutureMap.java
kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/se=
rvices/cache/future/GetTestCase.java
kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/se=
rvices/cache/future/StringLoader.java
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/=
modules/kernel/cache.xml
Log:
EXOJCR-1419: Move FutureExoCache from GateIn commons to eXo kernel
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook=
/en-US/modules/kernel/cache.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US=
/modules/kernel/cache.xml 2011-07-04 12:56:27 UTC (rev 4587)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US=
/modules/kernel/cache.xml 2011-07-04 17:12:39 UTC (rev 4588)
@@ -133,7 +133,7 @@
replicated
=
Indicates if the cache is replicated. This field is
- optional.
+ optional.
=
@@ -231,6 +231,36 @@
the infinite loop described above will still be effective.
+
+
+ FutureExoCache
+
+ If the data that you want to store into your eXo Cache instance
+ and/or you would like to prevent multiple concurrent loading of the =
same
+ data at the same time, you can use
+ org.exoplatform.services.cache.future.FutureExoCache
+ on top of your eXo Cache instance in order to delegate the loading of
+ your data to a loader that will be called only once whatever the tot=
al
+ amount of concurrent thread looking for it. See below an example of =
how
+ the FutureExoCache can be used:
+
+ import org.exoplatform.services.ca=
che.future.Loader;
+import org.exoplatform.services.cache.future.FutureExoCache;
+...
+ // Define first your loader and choose properly your context object in =
order
+ // to be able to reuse the same loader for different FutureExoCache ins=
tances
+ Loader<String, String, String> loader =3D new Loader<String, S=
tring, String>()
+ { =
+ public String retrieve(String context, String key) throws Exception
+ {
+ return "Value loaded thanks to the key =3D '" + key + "' and the =
context =3D '" + context + "'";
+ }
+ };
+ // Create your FutureExoCache from your eXo cache instance and your loa=
der
+ FutureExoCache<String, String, String> myFutureExoCache =3D new F=
utureExoCache<String, String, String>(loader, myExoCache);
+ // Get your data from your future cache instance
+ System.out.println(myFutureExoCache.get("my context", "foo"));
+
=
Added: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatfor=
m/services/cache/future/FutureCache.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/future/FutureCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/future/FutureCache.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,148 @@
+/*
+ * 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.future;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.FutureTask;
+
+/**
+ * A future cache that prevents the loading of the same resource twice. Th=
is should be used when the resource
+ * to load is very expensive or cannot be concurrently retrieved (like a c=
lassloading). =
+ *
+ * @author Julien Viet
+ * @version $Revision$
+ * @param the key type parameter
+ * @param the value type parameter
+ * @param the context type parameter
+ */
+public abstract class FutureCache
+{
+
+ /** . */
+ private final Loader loader;
+
+ /** . */
+ private final ConcurrentMap> futureEntries;
+
+ /** . */
+ private static final Log log =3D ExoLogger.getLogger("exo.kernel.compon=
ent.cache.FutureCache");
+
+
+ public FutureCache(Loader loader)
+ {
+ this.loader =3D loader;
+ this.futureEntries =3D new ConcurrentHashMap>();
+ }
+
+ protected abstract V get(K key);
+
+ protected abstract void put(K key, V value);
+
+ /**
+ * Perform a cache lookup for the specified key within the specified co=
ntext.
+ * When the value cannot be loaded (because it does not exist or it fai=
led or anything else that
+ * does not come to my mind), the value null is returned.
+ *
+ * @param context the context in which the resource is accessed
+ * @param key the key identifying the resource
+ * @return the value
+ */
+ public final V get(final C context, final K key)
+ {
+ // First we try a simple cache get
+ V value =3D get(key);
+
+ // If it does not succeed then we go through a process that will avo=
id to load
+ // the same resource concurrently
+ if (value =3D=3D null)
+ {
+ // Create our future
+ FutureTask future =3D new FutureTask(new Callable()
+ {
+ public V call() throws Exception
+ {
+ // Retrieve the value from the loader
+ V value =3D loader.retrieve(context, key);
+
+ //
+ if (value !=3D null)
+ {
+ // Cache it, it is made available to other threads (unle=
ss someone removes it)
+ put(key, value);
+
+ // Return value
+ return value;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ });
+
+ // This boolean means we inserted in the local
+ boolean inserted =3D true;
+
+ //
+ try
+ {
+ FutureTask phantom =3D futureEntries.putIfAbsent(key, futur=
e);
+
+ // Use the value that could have been inserted by another thre=
ad
+ if (phantom !=3D null)
+ {
+ future =3D phantom;
+ inserted =3D false;
+ }
+ else
+ {
+ future.run();
+ }
+
+ // Returns the value
+ value =3D future.get();
+ }
+ catch (ExecutionException e)
+ {
+ log.error("Computing of resource " + key + " threw an exceptio=
n", e.getCause());
+ }
+ catch (Exception e)
+ {
+ log.error("Retrieval of resource " + key + " threw an exceptio=
n", e);
+ }
+ finally
+ {
+ // Clean up the per key map but only if our insertion succeede=
d and with our future
+ if (inserted)
+ {
+ futureEntries.remove(key, future);
+ }
+ }
+ }
+
+ //
+ return value;
+ }
+}
Added: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatfor=
m/services/cache/future/FutureExoCache.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/future/FutureExoCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/future/FutureExoCache.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,55 @@
+/*
+ * 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.future;
+
+import org.exoplatform.services.cache.ExoCache;
+
+import java.io.Serializable;
+
+/**
+ * @author Julien Viet
+ * @version $Revision$
+ */
+public class FutureExoCache extends FutureCa=
che
+{
+
+ /** . */
+ private final ExoCache cache;
+
+ public FutureExoCache(Loader loader, ExoCache cache)
+ {
+ super(loader);
+
+ //
+ this.cache =3D cache;
+ }
+
+ @Override
+ protected V get(K key)
+ {
+ return cache.get(key);
+ }
+
+ @Override
+ protected void put(K key, V entry)
+ {
+ cache.put(key, entry);
+ }
+}
+
Added: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatfor=
m/services/cache/future/Loader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/future/Loader.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/future/Loader.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,44 @@
+/*
+ * 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.future;
+
+/**
+ * The loader interface is used by the future cache to retrieves the value=
from the key when it does not exist.
+ *
+ * @author Julien Viet
+ * @version $Revision$
+ * @param the key type parameter
+ * @param the value type parameter
+ * @param the context type parameter
+ */
+public interface Loader
+{
+
+ /**
+ * Retrieves the value from the key within the specified context. If th=
e resource is not found then the value
+ * null must be returned.
+ *
+ * @param context the context
+ * @param key the key
+ * @return the value
+ * @throws Exception any exception that would prevent the value to be l=
oaded
+ */
+ V retrieve(C context, K key) throws Exception;
+
+}
Added: kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatfor=
m/services/cache/future/ConcurrentGetWhenPutTestCase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/s=
ervices/cache/future/ConcurrentGetWhenPutTestCase.java =
(rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/s=
ervices/cache/future/ConcurrentGetWhenPutTestCase.java 2011-07-04 17:12:39 =
UTC (rev 4588)
@@ -0,0 +1,177 @@
+/*
+ * 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.future;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+/**
+ * @author Julien Viet
+ * @version $Revision$
+ */
+public class ConcurrentGetWhenPutTestCase extends TestCase
+{
+
+ /** . */
+ private AssertionFailedError failure;
+
+ /** . */
+ private List events =3D Collections.synchronizedList(new Linked=
List());
+
+ FutureCache> futureCache =3D new Futur=
eCache>(new StringLoader()) {
+
+
+ @Override
+ protected String get(String key)
+ {
+ if (key =3D=3D key1)
+ {
+ if (Thread.currentThread() !=3D thread1)
+ {
+ failure =3D new AssertionFailedError();
+ }
+ events.add("get/key1");
+ }
+ else if (key =3D=3D key2)
+ {
+ if (Thread.currentThread() !=3D thread2)
+ {
+ failure =3D new AssertionFailedError();
+ }
+ events.add("get/key2");
+ }
+ else
+ {
+ failure =3D new AssertionFailedError();
+ }
+ return null;
+ }
+
+ @Override
+ protected void put(String key, String value)
+ {
+ if (key =3D=3D key1)
+ {
+ if (Thread.currentThread() =3D=3D thread1)
+ {
+ events.add("begin_put/key1/" + value);
+
+ //
+ thread2.start();
+
+ //
+ while (thread2.getState() !=3D Thread.State.WAITING)
+ {
+ // Wait until thread 2 is blocked
+ }
+
+ //
+ events.add("end_put/key1");
+ }
+ else
+ {
+ failure =3D new AssertionFailedError();
+ }
+ }
+ else
+ {
+ failure =3D new AssertionFailedError();
+ }
+ }
+ };
+
+ /** . */
+ private final String key1 =3D new String("foo");
+
+ /** . */
+ private final String key2 =3D new String("foo");
+
+ Thread thread1 =3D new Thread()
+ {
+ @Override
+ public void run()
+ {
+ String v =3D futureCache.get(new Callable()
+ {
+ public String call() throws Exception
+ {
+ events.add("call/key1");
+ return "foo_value_1";
+ }
+ }, key1);
+ events.add("retrieved/key1/" + v);
+ }
+ };
+
+ Thread thread2 =3D new Thread()
+ {
+ @Override
+ public void run()
+ {
+ String v =3D futureCache.get(new Callable()
+ {
+ public String call() throws Exception
+ {
+ failure =3D new AssertionFailedError();
+ return "foo_value_2";
+ }
+ }, key2);
+ events.add("retrieved/key2/" + v);
+ }
+ };
+
+ public void testMain() throws Exception
+ {
+ thread1.start();
+
+ //
+ thread1.join();
+ thread2.join();
+
+ //
+ if (failure !=3D null)
+ {
+ throw failure;
+ }
+
+ //
+ List expectedEvents =3D Arrays.asList(
+ "get/key1",
+ "call/key1",
+ "begin_put/key1/foo_value_1",
+ "get/key2",
+ "end_put/key1"
+ );
+
+ //
+ assertEquals(expectedEvents, events.subList(0, expectedEvents.size()=
));
+
+ //
+ Set expectedEndEvents =3D new HashSet(Arrays.asList(=
"retrieved/key1/foo_value_1", "retrieved/key2/foo_value_1"));
+ assertEquals(expectedEndEvents, new HashSet(events.subList(e=
xpectedEvents.size(), events.size())));
+ }
+}
\ No newline at end of file
Added: kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatfor=
m/services/cache/future/FutureMap.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/s=
ervices/cache/future/FutureMap.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/s=
ervices/cache/future/FutureMap.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,54 @@
+/*
+ * 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.future;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Julien Viet
+ * @version $Revision$
+ */
+public class FutureMap extends FutureCache
+{
+
+ /** . */
+ final Map data;
+
+ public FutureMap(Loader loader)
+ {
+ super(loader);
+
+ //
+ this.data =3D Collections.synchronizedMap(new HashMap());
+ }
+
+ @Override
+ protected String get(String key)
+ {
+ return data.get(key);
+ }
+
+ @Override
+ protected void put(String key, String value)
+ {
+ data.put(key, value);
+ }
+}
Added: kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatfor=
m/services/cache/future/GetTestCase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/s=
ervices/cache/future/GetTestCase.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/s=
ervices/cache/future/GetTestCase.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,70 @@
+/*
+ * 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.future;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import java.util.concurrent.Callable;
+
+/**
+ * @author Julien Viet
+ * @version $Revision$
+ */
+public class GetTestCase extends TestCase
+{
+ public void testGet()
+ {
+ FutureMap> futureCache =3D new FutureMap>(new StringLoader());
+ Assert.assertEquals("foo_value", futureCache.get(new Callable()
+ {
+ public String call() throws Exception
+ {
+ return "foo_value";
+ }
+ }, "foo"));
+ Assert.assertEquals("foo_value", futureCache.data.get("foo"));
+ }
+
+ public void testNullValue()
+ {
+ FutureMap> futureCache =3D new FutureMap>(new StringLoader());
+ Assert.assertEquals(null, futureCache.get(new Callable()
+ {
+ public String call() throws Exception
+ {
+ return null;
+ }
+ }, "foo"));
+ Assert.assertFalse(futureCache.data.containsKey("foo"));
+ }
+
+ public void testThrowException()
+ {
+ FutureMap> futureCache =3D new FutureMap>(new StringLoader());
+ Assert.assertEquals(null, futureCache.get(new Callable()
+ {
+ public String call() throws Exception
+ {
+ throw new Exception("DON'T FREAK OUT");
+ }
+ }, "foo"));
+ Assert.assertFalse(futureCache.data.containsKey("foo"));
+ }
+}
Added: kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatfor=
m/services/cache/future/StringLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/s=
ervices/cache/future/StringLoader.java (rev 0)
+++ kernel/trunk/exo.kernel.component.cache/src/test/java/org/exoplatform/s=
ervices/cache/future/StringLoader.java 2011-07-04 17:12:39 UTC (rev 4588)
@@ -0,0 +1,33 @@
+/*
+ * 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.future;
+
+import java.util.concurrent.Callable;
+
+/**
+ * @author Julien Viet
+ * @version $Revision$
+ */
+public class StringLoader implements Loader>
+{
+ public String retrieve(Callable context, String key) throws Exc=
eption
+ {
+ return context.call();
+ }
+}
--===============0631861768934586273==--
From do-not-reply at jboss.org Mon Jul 4 13:19:31 2011
Content-Type: multipart/mixed; boundary="===============8892680362888245628=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4589 -
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel.
Date: Mon, 04 Jul 2011 13:19:31 -0400
Message-ID: <201107041719.p64HJViM020649@svn01.web.mwc.hst.phx2.redhat.com>
--===============8892680362888245628==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: nfilotto
Date: 2011-07-04 13:19:31 -0400 (Mon, 04 Jul 2011)
New Revision: 4589
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/=
modules/kernel/cache.xml
Log:
EXOJCR-1419: Complete the doc
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook=
/en-US/modules/kernel/cache.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US=
/modules/kernel/cache.xml 2011-07-04 17:12:39 UTC (rev 4588)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US=
/modules/kernel/cache.xml 2011-07-04 17:19:31 UTC (rev 4589)
@@ -236,12 +236,12 @@
FutureExoCache
=
If the data that you want to store into your eXo Cache instance
- and/or you would like to prevent multiple concurrent loading of the =
same
- data at the same time, you can use
+ takes a lot of time to load and/or you would like to prevent multiple
+ concurrent loading of the same data at the same time, you can use
org.exoplatform.services.cache.future.FutureExoCache
on top of your eXo Cache instance in order to delegate the loading of
your data to a loader that will be called only once whatever the tot=
al
- amount of concurrent thread looking for it. See below an example of =
how
+ amount of concurrent threads looking for it. See below an example of=
how
the FutureExoCache can be used:
=
import org.exoplatform.services.ca=
che.future.Loader;
--===============8892680362888245628==--
From do-not-reply at jboss.org Tue Jul 5 02:23:08 2011
Content-Type: multipart/mixed; boundary="===============0339408794279793708=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4590 -
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
Date: Tue, 05 Jul 2011 02:23:08 -0400
Message-ID: <201107050623.p656N8hV015668@svn01.web.mwc.hst.phx2.redhat.com>
--===============0339408794279793708==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: dkuleshov
Date: 2011-07-05 02:23:08 -0400 (Tue, 05 Jul 2011)
New Revision: 4590
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/=
jcr/impl/core/AuditPropertyImpl.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/=
jcr/impl/core/ItemImpl.java
Log:
EXOJCR-1408: added AuditPropertyImpl which extends PropertyImpl to avoid re=
dundant operations not used during trail audit
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/servi=
ces/jcr/impl/core/AuditPropertyImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/core/AuditPropertyImpl.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/core/AuditPropertyImpl.java 2011-07-05 06:23:08 UTC (rev 4590)
@@ -0,0 +1,56 @@
+package org.exoplatform.services.jcr.impl.core;
+
+import org.exoplatform.services.jcr.core.nodetype.ItemDefinitionData;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.PropertyDefinition;
+
+/**
+ * Created to avoid huge operations on PropertyImpl instance initializatio=
n, =
+ * as they are not needed for trail audit.
+ * =
+ * @author Dmitry Kuleshov
+ * @version $Id: $
+ */
+public class AuditPropertyImpl extends PropertyImpl
+{
+
+ AuditPropertyImpl(ItemData data, SessionImpl session) throws Repository=
Exception, ConstraintViolationException
+ {
+ super(data, session);
+ }
+
+ /**
+ * The most expensive method. In parent class it fulfills useless opera=
tions
+ * in context of trail audit.
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ void loadData(ItemData data) throws RepositoryException
+ {
+ this.qpath =3D data.getQPath();
+ return;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ItemDefinitionData getItemDefinitionData()
+ {
+ throw new UnsupportedOperationException("getItemDefinitionData metho=
d is not supported by this class");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public PropertyDefinition getDefinition()
+ {
+ throw new UnsupportedOperationException("getItemDefinitionData metho=
d is not supported by this class");
+ }
+
+}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/ItemImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/core/ItemImpl.java 2011-07-04 17:19:31 UTC (rev 4589)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/core/ItemImpl.java 2011-07-05 06:23:08 UTC (rev 4590)
@@ -478,7 +478,7 @@
{
// update of the property
prevProp =3D (PropertyImpl)prevItem;
- prevProperty =3D new PropertyImpl(prevProp.getData(), prevProp.pa=
rentData(), prevProp.getSession());
+ prevProperty =3D new AuditPropertyImpl(prevProp.getData(), prevPr=
op.getSession());
isMultiValue =3D prevProp.isMultiValued();
defs =3D
ntm.getPropertyDefinitions(propertyName, parentData.getPrimary=
TypeName(), parentData.getMixinTypeNames());
--===============0339408794279793708==--
From do-not-reply at jboss.org Tue Jul 5 03:42:37 2011
Content-Type: multipart/mixed; boundary="===============0295300399477350242=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4591 - in jcr/trunk:
exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl
and 4 other directories.
Date: Tue, 05 Jul 2011 03:42:37 -0400
Message-ID: <201107050742.p657gbto029386@svn01.web.mwc.hst.phx2.redhat.com>
--===============0295300399477350242==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: tolusha
Date: 2011-07-05 03:42:37 -0400 (Tue, 05 Jul 2011)
New Revision: 4591
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/=
jcr/impl/RepositoryServiceImpl.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/ext/backup/impl/JobExistingRepositoryRestore.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/ext/repository/RestRepositoryService.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/ext/repository/creation/RepositoryCreationService.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/ext/repository/creation/RepositoryCreationServiceImpl.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/j=
cr/ext/backup/AbstractBackupTestCase.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/j=
cr/ext/repository/creation/TestRepositoryCreationService.java
Log:
EXOJCR-1420: Remove repository in Standalone mode
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/RepositoryServiceImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/RepositoryServiceImpl.java 2011-07-05 06:23:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/RepositoryServiceImpl.java 2011-07-05 07:42:37 UTC (rev 4591)
@@ -46,8 +46,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.StringTokenizer;
import java.util.Map.Entry;
+import java.util.StringTokenizer;
=
import javax.jcr.RepositoryException;
=
@@ -119,14 +119,6 @@
}
=
/**
- * {@inheritDoc}
- */
- public boolean canRemoveRepository(String name) throws RepositoryExcept=
ion
- {
- return canRemoveRepository(name, false);
- }
-
- /**
* Create repository.
* Init worksapces for initial start or them load from persistence.
* Add namespaces and nodetypes from service plugins.
@@ -232,14 +224,6 @@
return (ManageableRepository)repositoryContainer.getComponentInstanc=
eOfType(ManageableRepository.class);
}
=
- /**
- * {@inheritDoc}
- */
- public void removeRepository(String name) throws RepositoryException
- {
- removeRepository(name, false);
- }
-
public void setCurrentRepositoryName(String repositoryName) throws Repo=
sitoryConfigurationException
{
// Need privileges to manage repository.
@@ -312,17 +296,6 @@
managerStartChanges.cleanup();
}
=
- /**
- * Remove default repository.
- * =
- * @throws RepositoryException
- * if any Exception occurred during removing
- */
- public void removeDefaultRepository() throws RepositoryException
- {
- removeRepository(config.getDefaultRepositoryName(), true);
- }
-
private void init(ExoContainer container) throws RepositoryConfiguratio=
nException, RepositoryException
{
this.parentContainer =3D container;
@@ -396,16 +369,9 @@
}
=
/**
- * Remove repository with specific name.
- * =
- * @param name
- * repository name
- * @param allowRemoveDefaultRepository
- * allow to remove default repository
- * @throws RepositoryException
- * if any Exception occurred
+ * {@inheritDoc}
*/
- private void removeRepository(String name, boolean allowRemoveDefaultRe=
pository) throws RepositoryException
+ public void removeRepository(String name) throws RepositoryException
{
// Need privileges to manage repository.
SecurityManager security =3D System.getSecurityManager();
@@ -414,7 +380,7 @@
security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_=
PERMISSION);
}
=
- if (!canRemoveRepository(name, allowRemoveDefaultRepository))
+ if (!canRemoveRepository(name))
throw new RepositoryException("Repository " + name + " in use. If=
you want to "
+ " remove repository close all open sessions");
=
@@ -458,24 +424,10 @@
}
=
/**
- * Indicates if repository with specific name can be removed.
- * =
- * @param name
- * repository name
- * @param allowRemoveDefaultRepository
- * allow to remove default repository =
- * @return
- * true if repository can be removed or false in other case
- * @throws RepositoryException
- * if any Exception occurred
+ * {@inheritDoc}
*/
- private boolean canRemoveRepository(String name, boolean allowRemoveDef=
aultRepository) throws RepositoryException
+ public boolean canRemoveRepository(String name) throws RepositoryExcept=
ion
{
- if (!allowRemoveDefaultRepository && name.equals(config.getDefaultRe=
positoryName()))
- {
- return false;
- }
-
RepositoryImpl repo =3D (RepositoryImpl)getRepository(name);
try
{
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/backup/impl/JobExistingRepositoryRestore.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/backup/impl/JobExistingRepositoryRestore.java 2011-07-05 06:23:08 U=
TC (rev 4590)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/backup/impl/JobExistingRepositoryRestore.java 2011-07-05 07:42:37 U=
TC (rev 4591)
@@ -25,7 +25,6 @@
import org.exoplatform.services.jcr.ext.backup.BackupChainLog;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChainLog;
import org.exoplatform.services.jcr.ext.backup.RepositoryRestoreExeption;
-import org.exoplatform.services.jcr.impl.RepositoryServiceImpl;
import org.exoplatform.services.jcr.impl.backup.Backupable;
import org.exoplatform.services.jcr.impl.core.SessionRegistry;
=
@@ -101,14 +100,7 @@
}
=
//remove repository
- if (isDefault)
- {
- ((RepositoryServiceImpl)repositoryService).removeDefaultReposi=
tory();
- }
- else
- {
- repositoryService.removeRepository(repositoryEntry.getName());
- }
+ repositoryService.removeRepository(repositoryEntry.getName());
=
// clean
for (Backupable component : backupable)
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/repository/RestRepositoryService.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/RestRepositoryService.java 2011-07-05 06:23:08 UTC (rev =
4590)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/RestRepositoryService.java 2011-07-05 07:42:37 UTC (rev =
4591)
@@ -18,6 +18,19 @@
*/
package org.exoplatform.services.jcr.ext.repository;
=
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationExceptio=
n;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
+import org.exoplatform.services.jcr.impl.core.SessionRegistry;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rest.resource.ResourceContainer;
+
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
@@ -34,23 +47,9 @@
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
=
-import org.exoplatform.services.jcr.RepositoryService;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationExceptio=
n;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.config.RepositoryServiceConfiguration;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.core.ManageableRepository;
-import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
-import org.exoplatform.services.jcr.impl.RepositoryServiceImpl;
-import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
-import org.exoplatform.services.jcr.impl.core.SessionRegistry;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.rest.resource.ResourceContainer;
-
/**
* Created by The eXo Platform SAS.
* =
@@ -390,14 +389,7 @@
}
}
=
- if (repositoryService.getDefaultRepository().getConfiguration().g=
etName().equals(repositoryName))
- {
- ((RepositoryServiceImpl) repositoryService).removeDefaultRepos=
itory();
- }
- else
- {
- repositoryService.removeRepository(repositoryName);
- }
+ repositoryService.removeRepository(repositoryName);
repositoryService.getConfig().retain(); // save configuration to =
persistence (file or persister) =
return Response.ok().build();
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/RepositoryCreationService.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationService.java 2011-07-05 06:23=
:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationService.java 2011-07-05 07:42=
:37 UTC (rev 4591)
@@ -96,4 +96,13 @@
*/
void createRepository(String backupId, RepositoryEntry rEntry, String r=
Token)
throws RepositoryConfigurationException, RepositoryCreationException;
+
+ /**
+ * Remove previously created repository. =
+ * =
+ * @param repositoryName - the repository name to delete
+ * @throws RepositoryCreationServiceException
+ * if some exception occurred during repository removing occur=
red
+ */
+ void removeRepository(String repositoryName) throws RepositoryCreationE=
xception;
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 0=
6:23:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 0=
7:42:37 UTC (rev 4591)
@@ -27,11 +27,14 @@
import org.exoplatform.services.jcr.config.RepositoryConfigurationExceptio=
n;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
import org.exoplatform.services.jcr.ext.backup.BackupConfigurationExceptio=
n;
import org.exoplatform.services.jcr.ext.backup.BackupManager;
import org.exoplatform.services.jcr.ext.backup.BackupOperationException;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChainLog;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.SessionRegistry;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataCon=
tainer;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
@@ -377,24 +380,6 @@
{
if (rpcService !=3D null)
{
- // check does repository already created
- try
- {
- if (repositoryService.getRepository(repositoryName) !=3D null)
- {
- throw new RepositoryCreationException("Repository " + repos=
itoryName + " already exists.");
- }
- }
- catch (RepositoryConfigurationException e)
- {
- throw new RepositoryCreationException("Can not check does repo=
sitory " + repositoryName + " exists: "
- + e.getMessage(), e);
- }
- catch (RepositoryException e)
- {
- //ok - repository does not exists
- }
-
// reserve RepositoryName at coordinator-node
try
{
@@ -718,6 +703,49 @@
}
}
=
+ /**
+ * {@inheritDoc}
+ */
+ public void removeRepository(String repositoryName) throws RepositoryCr=
eationException
+ {
+ removeRepositoryLocally(repositoryName);
+ }
+
+ /**
+ * Remove repository locally.
+ * =
+ * @param repositoryName
+ * the repository name
+ * @throws RepositoryCreationException
+ */
+ protected void removeRepositoryLocally(String repositoryName) throws Re=
positoryCreationException
+ {
+ try
+ {
+ // close all opened sessions
+ ManageableRepository repositorty =3D repositoryService.getReposit=
ory(repositoryName);
+ for (String workspaceName : repositorty.getWorkspaceNames())
+ {
+ WorkspaceContainerFacade wc =3D repositorty.getWorkspaceContai=
ner(workspaceName);
+ SessionRegistry sessionRegistry =3D (SessionRegistry)wc.getCom=
ponent(SessionRegistry.class);
+
+ sessionRegistry.closeSessions(workspaceName);
+ }
+
+ // remove repository from configuration
+ repositoryService.removeRepository(repositoryName);
+ repositoryService.getConfig().retain();
+ }
+ catch (RepositoryException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository", =
e);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository", =
e);
+ }
+ }
+
private DBCreator getDBCreator(DBCreationProperties creationProps) thro=
ws ConfigurationException
{
if (creationProps =3D=3D null)
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/ser=
vices/jcr/ext/backup/AbstractBackupTestCase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/backup/AbstractBackupTestCase.java 2011-07-05 06:23:08 UTC (rev 459=
0)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/backup/AbstractBackupTestCase.java 2011-07-05 07:42:37 UTC (rev 459=
1)
@@ -35,7 +35,6 @@
import org.exoplatform.services.jcr.ext.backup.impl.BackupManagerImpl;
import org.exoplatform.services.jcr.ext.backup.impl.JobRepositoryRestore;
import org.exoplatform.services.jcr.ext.backup.impl.JobWorkspaceRestore;
-import org.exoplatform.services.jcr.impl.RepositoryServiceImpl;
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleanService;
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
@@ -557,9 +556,6 @@
throw new RepositoryRestoreExeption("Current repository configura=
tion " + repositoryName + " did not found");
}
=
- boolean isDefault =3D
- repositoryService.getDefaultRepository().getConfiguration()=
.getName().equals(repositoryEntry.getName());
-
//Create local copy of WorkspaceEntry for all workspaces
ArrayList workspaceList =3D new ArrayList();
workspaceList.addAll(repositoryEntry.getWorkspaceEntries());
@@ -574,14 +570,7 @@
repositoryService.getRepository(repositoryName).getConfiguration(=
).getSystemWorkspaceName();
=
//remove repository
- if (isDefault)
- {
- ((RepositoryServiceImpl)repositoryService).removeDefaultRepositor=
y();
- }
- else
- {
- repositoryService.removeRepository(repositoryEntry.getName());
- }
+ repositoryService.removeRepository(repositoryEntry.getName());
=
// clean data
for (WorkspaceEntry wEntry : workspaceList)
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/TestRepositoryCreationService.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-07-05 0=
6:23:08 UTC (rev 4590)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-07-05 0=
7:42:37 UTC (rev 4591)
@@ -32,6 +32,8 @@
import java.util.HashMap;
import java.util.Map;
=
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS.
* =
@@ -93,6 +95,19 @@
//check repositoryConfiguration
RepositoryService repoService =3D (RepositoryService)this.container.=
getComponentInstance(RepositoryService.class);
assertNotNull(repoService.getConfig().getRepositoryConfiguration(ten=
antName));
+
+ // remove repository
+ creatorService.removeRepository(tenantName);
+
+ try
+ {
+ repoService.getRepository(tenantName);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryException e)
+ {
+ // expected behavior, repository should be missing =
+ }
}
=
public void testCreateRepositorySingleDB() throws Exception
@@ -147,6 +162,19 @@
//check repositoryConfiguration
RepositoryService repoService =3D (RepositoryService)this.container.=
getComponentInstance(RepositoryService.class);
assertNotNull(repoService.getConfig().getRepositoryConfiguration(ten=
antName));
+
+ // remove repository =
+ creatorService.removeRepository(tenantName);
+
+ try
+ {
+ repoService.getRepository(tenantName);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryException e)
+ {
+ // expected behavior, repository should be missing =
+ }
}
=
public void testCreateRepositorySingleDBWithSpecificCreationProps() thr=
ows Exception
@@ -210,6 +238,19 @@
//check repositoryConfiguration
RepositoryService repoService =3D (RepositoryService)this.container.=
getComponentInstance(RepositoryService.class);
assertNotNull(repoService.getConfig().getRepositoryConfiguration(ten=
antName));
+
+ // remove repository
+ creatorService.removeRepository(tenantName);
+
+ try
+ {
+ repoService.getRepository(tenantName);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryException e)
+ {
+ // expected behavior, repository should be missing =
+ }
}
=
public void testReserveRepositoryNameException() throws Exception
--===============0295300399477350242==--
From do-not-reply at jboss.org Tue Jul 5 04:49:26 2011
Content-Type: multipart/mixed; boundary="===============5985408779376219203=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4592 - in
jcr/trunk/exo.jcr.component.ext/src:
test/java/org/exoplatform/services/jcr/ext/repository/creation/cluster and 1
other directory.
Date: Tue, 05 Jul 2011 04:49:26 -0400
Message-ID: <201107050849.p658nQVt009763@svn01.web.mwc.hst.phx2.redhat.com>
--===============5985408779376219203==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: tolusha
Date: 2011-07-05 04:49:25 -0400 (Tue, 05 Jul 2011)
New Revision: 4592
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/ext/repository/creation/RepositoryCreationServiceImpl.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/j=
cr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNo=
de1.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/j=
cr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNo=
de2.java
Log:
EXOJCR-1422: Remove repository in cluster mode
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 0=
7:42:37 UTC (rev 4591)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 0=
8:49:25 UTC (rev 4592)
@@ -122,6 +122,8 @@
=
private RemoteCommand startRepository;
=
+ private RemoteCommand removeRepository;
+
/**
* Constructor RepositoryCreationServiceImpl.
*/
@@ -218,6 +220,22 @@
return null;
}
});
+
+ removeRepository =3D rpcService.registerCommand(new RemoteCommand=
()
+ {
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.ext.repository.creatio=
n.RepositoryCreationServiceImpl-removeRepository";
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwa=
ble
+ {
+ String repositoryName =3D (String)args[0];
+ removeRepositoryLocally(repositoryName);
+
+ return null;
+ }
+ });
}
else
{
@@ -308,7 +326,15 @@
=
if (result !=3D null)
{
- throw new RepositoryCreationException("CreateRepository com=
mand must not return any results.");
+ if (result instanceof Throwable)
+ {
+ throw new RepositoryCreationException("Can't create repo=
sitory " + rEntry.getName(),
+ (Throwable)result);
+ }
+ else
+ {
+ throw new RepositoryCreationException("createRepository =
command returned uknown result type.");
+ }
}
}
catch (RPCException e)
@@ -336,22 +362,18 @@
=
for (Object result : results)
{
- if (result instanceof RPCException)
+ if (result !=3D null)
{
- Throwable cause =3D ((RPCException)result).getCause();
- if (cause instanceof RepositoryCreationException)
+ if (result instanceof Throwable)
{
throw new RepositoryCreationException("Repository " +=
rEntry.getName()
- + " created on coordinator, but can not be started=
at other cluster nodes: "
- + cause.getMessage(), cause);
+ + " created on coordinator, but can not be started=
at other cluster nodes", ((Throwable)result));
}
+ else
+ {
+ throw new RepositoryCreationException("startRepositor=
y command returns uknown result type");
+ }
}
- if (result instanceof Throwable)
- {
- throw new RepositoryCreationException("Repository " + rE=
ntry.getName()
- + " created on coordinator, but can not be started at=
other cluster nodes: "
- + ((Throwable)result).getMessage(), ((Throwable)resul=
t));
- }
}
}
catch (RPCException e)
@@ -389,6 +411,10 @@
{
return (String)result;
}
+ else if (result instanceof Throwable)
+ {
+ throw new RepositoryCreationException("Can't reserve reposi=
tory " + repositoryName, (Throwable)result);
+ }
else
{
throw new RepositoryCreationException("ReserveRepositoryNam=
e command returns unknown type result.");
@@ -700,6 +726,7 @@
this.rpcService.unregisterCommand(reserveRepositoryName);
this.rpcService.unregisterCommand(createRepository);
this.rpcService.unregisterCommand(startRepository);
+ this.rpcService.unregisterCommand(removeRepository);
}
}
=
@@ -708,7 +735,37 @@
*/
public void removeRepository(String repositoryName) throws RepositoryCr=
eationException
{
- removeRepositoryLocally(repositoryName);
+ if (rpcService !=3D null)
+ {
+ try
+ {
+ List results =3D rpcService.executeCommandOnAllNodes(r=
emoveRepository, true, repositoryName);
+
+ for (Object result : results)
+ {
+ if (result !=3D null)
+ {
+ if (result instanceof Throwable)
+ {
+ throw new RepositoryCreationException("Can't remove r=
epository " + repositoryName,
+ (Throwable)result);
+ }
+ else
+ {
+ throw new RepositoryCreationException("removeReposito=
ry command returned uknown result type");
+ }
+ }
+ }
+ }
+ catch (RPCException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository=
" + repositoryName, e);
+ }
+ }
+ else
+ {
+ removeRepositoryLocally(repositoryName);
+ }
}
=
/**
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInCl=
usterNode1.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterN=
ode1.java 2011-07-05 07:42:37 UTC (rev 4591)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterN=
ode1.java 2011-07-05 08:49:25 UTC (rev 4592)
@@ -32,6 +32,8 @@
import java.util.HashMap;
import java.util.Map;
=
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS.
* =
@@ -53,8 +55,8 @@
connProps.put("password", "24635457");
=
DBCreationProperties creationProps =3D
- new DBCreationProperties("jdbc:mysql://localhost/", connProps,
- "src/test/resources/test-mysql.sql", "user1", "pass1");
+ new DBCreationProperties("jdbc:mysql://localhost/", connProps, "s=
rc/test/resources/test-mysql.sql", "user3",
+ "pass3");
=
// prepare
String dsName =3D helper.createDatasource();
@@ -81,7 +83,7 @@
(RepositoryCreationService)container.getComponentInstanceOfType(R=
epositoryCreationService.class);
assertNotNull(creatorService);
=
- String tenantName =3D "tenant_2";
+ String tenantName =3D "tenant_4";
String repoToken =3D creatorService.reserveRepositoryName(tenantName=
);
=
// restore =
@@ -106,7 +108,22 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(ten=
antName));
=
log.info("Node1: Repository has been created");
- Thread.sleep(100000);
+ Thread.sleep(60000);
+ =
+ // remove repository
+ creatorService.removeRepository(tenantName);
+
+ try
+ {
+ repoService.getRepository(tenantName);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryException e)
+ {
+ // expected behavior, repository should be missing =
+ }
+ =
+ log.info("Node1: Repository removed");
}
=
@Override
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInCl=
usterNode2.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterN=
ode2.java 2011-07-05 07:42:37 UTC (rev 4591)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterN=
ode2.java 2011-07-05 08:49:25 UTC (rev 4592)
@@ -16,11 +16,14 @@
*/
package org.exoplatform.services.jcr.ext.repository.creation.cluster;
=
+import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.ext.backup.AbstractBackupTestCase;
import org.exoplatform.services.jcr.ext.backup.ExtendedBackupManager;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
=
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS.
* =
@@ -36,7 +39,7 @@
log.info("Node2: Waits for the repository creation");
Thread.sleep(60000);
=
- String tenantName =3D "tenant_2";
+ String tenantName =3D "tenant_4";
=
// check
ManageableRepository restoredRepository =3D repositoryService.getRep=
ository(tenantName);
@@ -48,7 +51,21 @@
session.getRootNode();
=
log.info("Node2: test passed. I have root node");
- Thread.sleep(100000);
+ Thread.sleep(120000);
+
+ RepositoryService repoService =3D (RepositoryService)this.container.=
getComponentInstance(RepositoryService.class);
+
+ try
+ {
+ repoService.getRepository(tenantName);
+ fail("Exception should be thrown");
+ }
+ catch (RepositoryException e)
+ {
+ // expected behavior, repository should be missing =
+ }
+
+ log.info("Node2: Repository removed");
}
=
@Override
--===============5985408779376219203==--
From do-not-reply at jboss.org Tue Jul 5 05:11:23 2011
Content-Type: multipart/mixed; boundary="===============2657833817330639007=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4593 -
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/naming.
Date: Tue, 05 Jul 2011 05:11:22 -0400
Message-ID: <201107050911.p659BMQC018429@svn01.web.mwc.hst.phx2.redhat.com>
--===============2657833817330639007==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: tolusha
Date: 2011-07-05 05:11:22 -0400 (Tue, 05 Jul 2011)
New Revision: 4593
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/s=
ervices/naming/InitialContextBinder.java
Log:
EXOJCR-1423: Remove reference from InitialContextBinder
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exopla=
tform/services/naming/InitialContextBinder.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/=
services/naming/InitialContextBinder.java 2011-07-05 08:49:25 UTC (rev 4592)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/=
services/naming/InitialContextBinder.java 2011-07-05 09:11:22 UTC (rev 4593)
@@ -177,6 +177,25 @@
}
=
/**
+ * Unbind the Reference with defined name, remove from the bindings lis=
t and persists the rest of references
+ * into the file.
+ * =
+ * @param bindName
+ * the Reference's bind name
+ * @throws NamingException
+ * @throws FileNotFoundException
+ * @throws XMLStreamException
+ */
+ public void unbind(String bindName) throws NamingException, FileNotFoun=
dException,
+ XMLStreamException
+ {
+ initialContextInitializer.getInitialContext().unbind(bindName);
+ bindings.remove(bindName);
+
+ saveBindings();
+ }
+
+ /**
* Returns reference associated with defined name.
* =
* @param bindName the name on which the reference was binded.
--===============2657833817330639007==--
From do-not-reply at jboss.org Tue Jul 5 05:11:59 2011
Content-Type: multipart/mixed; boundary="===============3090267630589491533=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4594 -
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation.
Date: Tue, 05 Jul 2011 05:11:59 -0400
Message-ID: <201107050911.p659Bxav018450@svn01.web.mwc.hst.phx2.redhat.com>
--===============3090267630589491533==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: tolusha
Date: 2011-07-05 05:11:58 -0400 (Tue, 05 Jul 2011)
New Revision: 4594
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/ext/repository/creation/RepositoryCreationServiceImpl.java
Log:
EXOJCR-1423: Remove reference from InitialContextBinder
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 0=
9:11:22 UTC (rev 4593)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 0=
9:11:58 UTC (rev 4594)
@@ -779,8 +779,11 @@
{
try
{
+ // extract list of all datasources
+ ManageableRepository repositorty =3D repositoryService.getReposit=
ory(repositoryName);
+ Set datasources =3D extractDataSourceNames(repositorty.ge=
tConfiguration(), false);
+
// close all opened sessions
- ManageableRepository repositorty =3D repositoryService.getReposit=
ory(repositoryName);
for (String workspaceName : repositorty.getWorkspaceNames())
{
WorkspaceContainerFacade wc =3D repositorty.getWorkspaceContai=
ner(workspaceName);
@@ -792,6 +795,12 @@
// remove repository from configuration
repositoryService.removeRepository(repositoryName);
repositoryService.getConfig().retain();
+ =
+ // unbind datasource
+ for (String ds : datasources)
+ {
+ initialContextInitializer.getInitialContextBinder().unbind(ds);
+ }
}
catch (RepositoryException e)
{
@@ -801,6 +810,18 @@
{
throw new RepositoryCreationException("Can't remove repository", =
e);
}
+ catch (FileNotFoundException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository", =
e);
+ }
+ catch (NamingException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository", =
e);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new RepositoryCreationException("Can't remove repository", =
e);
+ }
}
=
private DBCreator getDBCreator(DBCreationProperties creationProps) thro=
ws ConfigurationException
--===============3090267630589491533==--
From do-not-reply at jboss.org Tue Jul 5 05:18:02 2011
Content-Type: multipart/mixed; boundary="===============0615265910048348081=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4595 -
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/impl.
Date: Tue, 05 Jul 2011 05:18:02 -0400
Message-ID: <201107050918.p659I2sF018819@svn01.web.mwc.hst.phx2.redhat.com>
--===============0615265910048348081==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: tolusha
Date: 2011-07-05 05:18:02 -0400 (Tue, 05 Jul 2011)
New Revision: 4595
Modified:
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/se=
rvices/cache/impl/InvalidationExoCache.java
Log:
EXOJCR-1418: remove violations
Modified: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplat=
form/services/cache/impl/InvalidationExoCache.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/impl/InvalidationExoCache.java 2011-07-05 09:11:58 UTC (rev 4=
594)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/impl/InvalidationExoCache.java 2011-07-05 09:18:02 UTC (rev 4=
595)
@@ -56,7 +56,8 @@
* @version $Id$
*
*/
-public class InvalidationExoCache implements Ex=
oCache, CacheListener>
+public class InvalidationExoCache implements Ex=
oCache,
+ CacheListener>
{
/**
* Logger.
@@ -333,7 +334,7 @@
}
=
/**
- * @see org.exoplatform.services.cache.CacheListener#onExpire(org.exopl=
atform.services.cache.CacheListenerContext, java.io.Serializable, java.lang=
.Object)
+ * {@inheritDoc}
*/
public void onExpire(CacheListenerContext context, K key, HashCode o=
bj) throws Exception
{
@@ -357,7 +358,7 @@
}
=
/**
- * @see org.exoplatform.services.cache.CacheListener#onRemove(org.exopl=
atform.services.cache.CacheListenerContext, java.io.Serializable, java.lang=
.Object)
+ * {@inheritDoc}
*/
public void onRemove(CacheListenerContext context, K key, HashCode o=
bj) throws Exception
{
@@ -381,7 +382,7 @@
}
=
/**
- * @see org.exoplatform.services.cache.CacheListener#onPut(org.exoplatf=
orm.services.cache.CacheListenerContext, java.io.Serializable, java.lang.Ob=
ject)
+ * {@inheritDoc}
*/
public void onPut(CacheListenerContext context, K key, HashCode obj)=
throws Exception
{
@@ -424,7 +425,7 @@
}
=
/**
- * @see org.exoplatform.services.cache.CacheListener#onGet(org.exoplatf=
orm.services.cache.CacheListenerContext, java.io.Serializable, java.lang.Ob=
ject)
+ * {@inheritDoc}
*/
public void onGet(CacheListenerContext context, K key, HashCode obj)=
throws Exception
{
--===============0615265910048348081==--
From do-not-reply at jboss.org Tue Jul 5 05:24:54 2011
Content-Type: multipart/mixed; boundary="===============5847871692964878877=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4596 - in
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules:
kernel and 1 other directory.
Date: Tue, 05 Jul 2011 05:24:54 -0400
Message-ID: <201107050924.p659OsUO019327@svn01.web.mwc.hst.phx2.redhat.com>
--===============5847871692964878877==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: tolusha
Date: 2011-07-05 05:24:54 -0400 (Tue, 05 Jul 2011)
New Revision: 4596
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/kernel/initialcontext-binder-service.xml
Log:
EXOJCR-1396: docbook updated
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook=
/en-US/modules/jcr/repository-creation-service.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US=
/modules/jcr/repository-creation-service.xml 2011-07-05 09:18:02 UTC (rev 4=
595)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US=
/modules/jcr/repository-creation-service.xml 2011-07-05 09:24:54 UTC (rev 4=
596)
@@ -215,6 +215,15 @@
*/
void createRepository(String backupId, RepositoryEntry rEntry, String r=
Token)
throws RepositoryConfigurationException, RepositoryCreationException;
+
+ /**
+ * Remove previously created repository. =
+ * =
+ * @param repositoryName - the repository name to delete
+ * @throws RepositoryCreationServiceException
+ * if some exception occurred during repository removing occur=
red
+ */
+ void removeRepository(String repositoryName) throws RepositoryCreationE=
xception;
}
=
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook=
/en-US/modules/kernel/initialcontext-binder-service.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US=
/modules/kernel/initialcontext-binder-service.xml 2011-07-05 09:18:02 UTC (=
rev 4595)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US=
/modules/kernel/initialcontext-binder-service.xml 2011-07-05 09:24:54 UTC (=
rev 4596)
@@ -49,5 +49,9 @@
Returns reference associated with defined name:
=
public Reference getReference(String=
bindName)
+
+ Unbind the Reference with defined name:
+
+ public void unbind(String bindName) =
throws NamingException, FileNotFoundException, XMLStreamException
--===============5847871692964878877==--
From do-not-reply at jboss.org Tue Jul 5 07:51:45 2011
Content-Type: multipart/mixed; boundary="===============4080988188989063580=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4597 - in jcr/trunk:
exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr and
1 other directory.
Date: Tue, 05 Jul 2011 07:51:45 -0400
Message-ID: <201107051151.p65Bpj2v014085@svn01.web.mwc.hst.phx2.redhat.com>
--===============4080988188989063580==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: tolusha
Date: 2011-07-05 07:51:45 -0400 (Tue, 05 Jul 2011)
New Revision: 4597
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/ext/repository/creation/RepositoryCreationService.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/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: added possibility to control sessions closing before repositor=
y removing
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/RepositoryCreationService.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationService.java 2011-07-05 09:24=
:54 UTC (rev 4596)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationService.java 2011-07-05 11:51=
:45 UTC (rev 4597)
@@ -101,8 +101,10 @@
* Remove previously created repository. =
* =
* @param repositoryName - the repository name to delete
+ * @param forceCloseSessions - indicates if need to close sessions befo=
re repository removing, if
+ * sessions are opened is it not possbile to remove repository and exce=
ption will be thrown
* @throws RepositoryCreationServiceException
* if some exception occurred during repository removing occur=
red
*/
- void removeRepository(String repositoryName) throws RepositoryCreationE=
xception;
+ void removeRepository(String repositoryName, boolean forceCloseSessions=
) throws RepositoryCreationException;
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 0=
9:24:54 UTC (rev 4596)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 1=
1:51:45 UTC (rev 4597)
@@ -231,8 +231,10 @@
public Serializable execute(Serializable[] args) throws Throwa=
ble
{
String repositoryName =3D (String)args[0];
- removeRepositoryLocally(repositoryName);
+ boolean forceCloseSessions =3D (Boolean)args[1];
=
+ removeRepositoryLocally(repositoryName, forceCloseSessions);
+
return null;
}
});
@@ -733,13 +735,14 @@
/**
* {@inheritDoc}
*/
- public void removeRepository(String repositoryName) throws RepositoryCr=
eationException
+ public void removeRepository(String repositoryName, boolean forceCloseS=
essions) throws RepositoryCreationException
{
if (rpcService !=3D null)
{
try
{
- List results =3D rpcService.executeCommandOnAllNodes(r=
emoveRepository, true, repositoryName);
+ List results =3D
+ rpcService.executeCommandOnAllNodes(removeRepository, true,=
repositoryName, forceCloseSessions);
=
for (Object result : results)
{
@@ -764,7 +767,7 @@
}
else
{
- removeRepositoryLocally(repositoryName);
+ removeRepositoryLocally(repositoryName, forceCloseSessions);
}
}
=
@@ -773,9 +776,12 @@
* =
* @param repositoryName
* the repository name
+ * @param forceCloseSessions - indicates if need to close session befor=
e repository removing, if
+ * sessions are opened is it not possbile to remove repository and exce=
ption will be throw =
* @throws RepositoryCreationException
*/
- protected void removeRepositoryLocally(String repositoryName) throws Re=
positoryCreationException
+ protected void removeRepositoryLocally(String repositoryName, boolean f=
orceCloseSessions)
+ throws RepositoryCreationException
{
try
{
@@ -783,13 +789,16 @@
ManageableRepository repositorty =3D repositoryService.getReposit=
ory(repositoryName);
Set datasources =3D extractDataSourceNames(repositorty.ge=
tConfiguration(), false);
=
- // close all opened sessions
- for (String workspaceName : repositorty.getWorkspaceNames())
+ if (forceCloseSessions)
{
- WorkspaceContainerFacade wc =3D repositorty.getWorkspaceContai=
ner(workspaceName);
- SessionRegistry sessionRegistry =3D (SessionRegistry)wc.getCom=
ponent(SessionRegistry.class);
+ // close all opened sessions
+ for (String workspaceName : repositorty.getWorkspaceNames())
+ {
+ WorkspaceContainerFacade wc =3D repositorty.getWorkspaceCon=
tainer(workspaceName);
+ SessionRegistry sessionRegistry =3D (SessionRegistry)wc.get=
Component(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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US=
/modules/jcr/repository-creation-service.xml 2011-07-05 09:24:54 UTC (rev 4=
596)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US=
/modules/jcr/repository-creation-service.xml 2011-07-05 11:51:45 UTC (rev 4=
597)
@@ -220,10 +220,12 @@
* Remove previously created repository. =
* =
* @param repositoryName - the repository name to delete
+ * @param forceCloseSessions - indicates if need to close session befor=
e repository removing, if
+ * sessions are opened is it not possbile to remove repository and exce=
ption will be thrown
* @throws RepositoryCreationServiceException
* if some exception occurred during repository removing occur=
red
*/
- void removeRepository(String repositoryName) throws RepositoryCreationE=
xception;
+ void removeRepository(String repositoryName, boolean forceCloseSessions=
) throws RepositoryCreationException;
}
=
--===============4080988188989063580==--
From do-not-reply at jboss.org Tue Jul 5 08:42:17 2011
Content-Type: multipart/mixed; boundary="===============0242704681054010289=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] 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.
Date: Tue, 05 Jul 2011 08:42:16 -0400
Message-ID: <201107051242.p65CgGEx025310@svn01.web.mwc.hst.phx2.redhat.com>
--===============0242704681054010289==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/j=
cr/ext/repository/creation/TestRepositoryCreationService.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/j=
cr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNo=
de1.java
Log:
EXOJCR-1396: fix tests
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/TestRepositoryCreationService.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-07-05 1=
1: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 1=
2:42:16 UTC (rev 4598)
@@ -97,7 +97,7 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(ten=
antName));
=
// remove repository
- creatorService.removeRepository(tenantName);
+ creatorService.removeRepository(tenantName, true);
=
try
{
@@ -164,7 +164,7 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(ten=
antName));
=
// remove repository =
- creatorService.removeRepository(tenantName);
+ creatorService.removeRepository(tenantName, true);
=
try
{
@@ -240,7 +240,7 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(ten=
antName));
=
// remove repository
- creatorService.removeRepository(tenantName);
+ creatorService.removeRepository(tenantName, true);
=
try
{
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInCl=
usterNode1.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterN=
ode1.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/TestRepositoryCreationServiceInClusterN=
ode1.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
{
--===============0242704681054010289==--
From do-not-reply at jboss.org Tue Jul 5 09:49:29 2011
Content-Type: multipart/mixed; boundary="===============5548497337955669480=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] 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.
Date: Tue, 05 Jul 2011 09:49:29 -0400
Message-ID: <201107051349.p65DnTNp005353@svn01.web.mwc.hst.phx2.redhat.com>
--===============5548497337955669480==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/j=
cr/ext/repository/creation/RepositoryCreationService.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/j=
cr/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/ser=
vices/jcr/ext/repository/creation/RepositoryCreationService.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 befo=
re repository removing, if
- * sessions are opened is it not possbile to remove repository and exce=
ption will be thrown
+ * @param forceRemove - force close all opened sessions =
* @throws RepositoryCreationServiceException
* if some exception occurred during repository removing occur=
red
*/
- void removeRepository(String repositoryName, boolean forceCloseSessions=
) throws RepositoryCreationException;
+ void removeRepository(String repositoryName, boolean forceRemove) throw=
s RepositoryCreationException;
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/=
jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-07-05 1=
2: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 1=
3: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 repositoryServic=
e, BackupManager backupManager,
+ public RepositoryCreationServiceImpl(final RepositoryService repository=
Service, BackupManager backupManager,
ExoContainerContext context, InitialContextInitializer initialContex=
tInitializer, final RPCService rpcService)
{
this.repositoryService =3D repositoryService;
@@ -231,13 +233,27 @@
public Serializable execute(Serializable[] args) throws Throwa=
ble
{
String repositoryName =3D (String)args[0];
- boolean forceCloseSessions =3D (Boolean)args[1];
=
- removeRepositoryLocally(repositoryName, forceCloseSessions);
+ removeRepositoryLocally(repositoryName);
=
return null;
}
});
+
+ canRemoveRepository =3D rpcService.registerCommand(new RemoteComm=
and()
+ {
+ public String getId()
+ {
+ return "org.exoplatform.services.jcr.ext.repository.creatio=
n.RepositoryCreationServiceImpl-checkRepositoryInUse";
+ }
+
+ public Serializable execute(Serializable[] args) throws Throwa=
ble
+ {
+ String repositoryName =3D (String)args[0];
+ =
+ return new Boolean(repositoryService.canRemoveRepository(re=
positoryName));
+ }
+ });
}
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 forceCloseS=
essions) throws RepositoryCreationException
+ public void removeRepository(String repositoryName, boolean forceRemove=
) throws RepositoryCreationException
{
if (rpcService !=3D null)
{
try
{
- List results =3D
- rpcService.executeCommandOnAllNodes(removeRepository, true,=
repositoryName, forceCloseSessions);
+ if (!forceRemove)
+ {
+ List results =3D rpcService.executeCommandOnAllNode=
s(canRemoveRepository, true, repositoryName);
+ for (Object result : results)
+ {
+ if (result !=3D null)
+ {
+ if (result instanceof Throwable)
+ {
+ throw new RepositoryCreationException("It is not p=
ossible to check is repository "
+ + repositoryName + " in usage or not", (Throwab=
le)result);
+ }
+ else if (result instanceof Boolean)
+ {
+ if (!(Boolean)result)
+ {
+ throw new RepositoryCreationException("Can't re=
move repository " + repositoryName
+ + ". The repository in use.");
+ }
+ }
+ else
+ {
+ throw new RepositoryCreationException(
+ "checkRepositoryInUse command returned uknown r=
esult type");
+ }
+ }
+ }
+ }
=
+ List results =3D rpcService.executeCommandOnAllNodes(r=
emoveRepository, true, repositoryName);
for (Object result : results)
{
if (result !=3D null)
@@ -767,7 +811,23 @@
}
else
{
- removeRepositoryLocally(repositoryName, forceCloseSessions);
+ if (!forceRemove)
+ {
+ try
+ {
+ if (!repositoryService.canRemoveRepository(repositoryName))
+ {
+ throw new RepositoryCreationException("Can't remove repo=
sitory " + repositoryName
+ + ". The repository in use.");
+ }
+ }
+ catch (RepositoryException e)
+ {
+ throw new RepositoryCreationException("It is not possible t=
o 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 befor=
e repository removing, if
- * sessions are opened is it not possbile to remove repository and exce=
ption will be throw =
* @throws RepositoryCreationException
*/
- protected void removeRepositoryLocally(String repositoryName, boolean f=
orceCloseSessions)
+ protected void removeRepositoryLocally(String repositoryName)
throws RepositoryCreationException
{
try
@@ -789,16 +847,13 @@
ManageableRepository repositorty =3D repositoryService.getReposit=
ory(repositoryName);
Set datasources =3D extractDataSourceNames(repositorty.ge=
tConfiguration(), false);
=
- if (forceCloseSessions)
+ // close all opened sessions
+ for (String workspaceName : repositorty.getWorkspaceNames())
{
- // close all opened sessions
- for (String workspaceName : repositorty.getWorkspaceNames())
- {
- WorkspaceContainerFacade wc =3D repositorty.getWorkspaceCon=
tainer(workspaceName);
- SessionRegistry sessionRegistry =3D (SessionRegistry)wc.get=
Component(SessionRegistry.class);
+ WorkspaceContainerFacade wc =3D repositorty.getWorkspaceContai=
ner(workspaceName);
+ SessionRegistry sessionRegistry =3D (SessionRegistry)wc.getCom=
ponent(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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 4=
598)
+++ 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 4=
599)
@@ -220,12 +220,12 @@
* Remove previously created repository. =
* =
* @param repositoryName - the repository name to delete
- * @param forceCloseSessions - indicates if need to close session befor=
e repository removing, if
- * sessions are opened is it not possbile to remove repository and exce=
ption will be thrown
+ * @param forceRemove - force close all opened sessions =
* @throws RepositoryCreationServiceException
* if some exception occurred during repository removing occur=
red
*/
- void removeRepository(String repositoryName, boolean forceCloseSessions=
) throws RepositoryCreationException;
+ void removeRepository(String repositoryName, boolean forceRemove) throw=
s RepositoryCreationException;
+
}
=
--===============5548497337955669480==--
From do-not-reply at jboss.org Tue Jul 5 09:52:31 2011
Content-Type: multipart/mixed; boundary="===============5295845543406127630=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] 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.
Date: Tue, 05 Jul 2011 09:52:30 -0400
Message-ID: <201107051352.p65DqUWH005823@svn01.web.mwc.hst.phx2.redhat.com>
--===============5295845543406127630==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/j=
cr/ext/repository/creation/TestRepositoryCreationService.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/j=
cr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterNo=
de1.java
Log:
EXOJCR-1396: tests updated
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/ser=
vices/jcr/ext/repository/creation/TestRepositoryCreationService.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-07-05 1=
3: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 1=
3:52:30 UTC (rev 4600)
@@ -97,6 +97,17 @@
assertNotNull(repoService.getConfig().getRepositoryConfiguration(ten=
antName));
=
// 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 =3D (RepositoryService)this.container.=
getComponentInstance(RepositoryService.class);
assertNotNull(repoService.getConfig().getRepositoryConfiguration(ten=
antName));
=
+ // 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(ten=
antName));
=
// 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/ser=
vices/jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInCl=
usterNode1.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/=
jcr/ext/repository/creation/cluster/TestRepositoryCreationServiceInClusterN=
ode1.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/TestRepositoryCreationServiceInClusterN=
ode1.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.DBCreationProp=
erties;
+import org.exoplatform.services.jcr.ext.repository.creation.RepositoryCrea=
tionException;
import org.exoplatform.services.jcr.ext.repository.creation.RepositoryCrea=
tionService;
=
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
--===============5295845543406127630==--
From do-not-reply at jboss.org Tue Jul 5 10:46:12 2011
Content-Type: multipart/mixed; boundary="===============8430981487676576074=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4601 -
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent.
Date: Tue, 05 Jul 2011 10:46:12 -0400
Message-ID: <201107051446.p65EkCbh017467@svn01.web.mwc.hst.phx2.redhat.com>
--===============8430981487676576074==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/se=
rvices/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/dataflow/persistent/StreamPersistedValueData.java 2011-07-05 13:5=
2: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:4=
6:12 UTC (rev 4601)
@@ -40,6 +40,8 @@
public class StreamPersistedValueData extends FilePersistedValueData
{
=
+ private static final long serialVersionUID =3D -5831609242005946202L;
+
protected InputStream stream;
=
protected SpoolFile tempFile;
--===============8430981487676576074==--
From do-not-reply at jboss.org Tue Jul 5 11:14:00 2011
Content-Type: multipart/mixed; boundary="===============6594487251509361682=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] 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.
Date: Tue, 05 Jul 2011 11:14:00 -0400
Message-ID: <201107051514.p65FE0gX026209@svn01.web.mwc.hst.phx2.redhat.com>
--===============6594487251509361682==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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.currentTimeMilli=
s() calls
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/NodeImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 =3D System.currentTimeMillis();
+ long start =3D 0;
if (LOG.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
LOG.debug("getNodes() >>>>>");
}
=
@@ -1086,9 +1087,10 @@
public NodeIterator getNodes(String namePattern) throws RepositoryExcep=
tion
{
=
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (LOG.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
LOG.debug("getNodes(String) >>>>>");
}
=
@@ -1197,9 +1199,10 @@
public PropertyIterator getProperties() throws RepositoryException
{
=
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (LOG.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
LOG.debug("getProperties() >>>>>");
}
=
@@ -1252,9 +1255,10 @@
*/
public PropertyIterator getProperties(String namePattern) throws Reposi=
toryException
{
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (LOG.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
LOG.debug("getProperties(String) >>>>>");
}
=
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/SessionDataManager.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D 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 =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D 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 =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
String debugPath =3D "";
for (QPathEntry rp : relPath)
{
@@ -529,9 +532,10 @@
*/
public ItemImpl getItem(QPath path, boolean pool) throws RepositoryExce=
ption
{
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
log.debug("getItem(" + path.getAsString() + " ) >>>>>");
}
=
@@ -649,9 +653,10 @@
*/
public ItemImpl getItemByIdentifier(String identifier, boolean pool, bo=
olean apiRead) throws RepositoryException
{
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
log.debug("getItemByIdentifier(" + identifier + " ) >>>>>");
}
=
@@ -850,9 +855,10 @@
public List getChildNodes(NodeData parent, boolean pool) thro=
ws RepositoryException, AccessDeniedException
{
=
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
log.debug("getChildNodes(" + parent.getQPath().getAsString() + ")=
>>>>>");
}
=
@@ -903,9 +909,10 @@
AccessDeniedException
{
=
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
log.debug("getChildProperties(" + parent.getQPath().getAsString()=
+ ") >>>>>");
}
=
@@ -941,9 +948,10 @@
*/
public List getChildNodesData(NodeData parent) throws Reposit=
oryException
{
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
log.debug("getChildNodesData(" + parent.getQPath().getAsString() =
+ ") >>>>>");
}
=
@@ -967,9 +975,10 @@
public List getChildNodesData(NodeData parent, List patternFilters)
throws RepositoryException
{
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
log.debug("getChildNodesData(" + parent.getQPath().getAsString() =
+ " , itemDataFilter) >>>>>");
}
=
@@ -1113,9 +1122,10 @@
*/
public AccessControlList getACL(QPath path) throws RepositoryException
{
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
log.debug("getACL(" + path.getAsString() + " ) >>>>>");
}
=
@@ -1178,9 +1188,10 @@
=
public AccessControlList getACL(NodeData parent, QPathEntry name) throw=
s RepositoryException
{
- long start =3D System.currentTimeMillis();
+ long start =3D 0;
if (log.isDebugEnabled())
{
+ start =3D System.currentTimeMillis();
log.debug("getACL(" + parent.getQPath().getAsString() + " + " + n=
ame.getAsString() + " ) >>>>>");
}
=
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 =3D new PlainChangesLogImpl();
TransientNodeData jcrNodetypes;
=
- long start =3D System.currentTimeMillis();
-
+ long start =3D 0;
+ if (log.isDebugEnabled())
+ {
+ start =3D System.currentTimeMillis();
+ }
+ =
if (addACL)
{
InternalQName[] mixins =3D new InternalQName[]{Constants.EXO_OWNE=
ABLE, Constants.EXO_PRIVILEGEABLE};
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/query/QueryImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
QueryResult result =3D query.execute(offset, limit);
if (log.isDebugEnabled())
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/query/lucene/CachingIndexReader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
final Map docs =3D new HashMap();
// read UUIDs
collectTermDocs(reader, new Term(FieldNames.UUID, ""), new TermDo=
csCollector()
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/query/lucene/ChildAxisQuery.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 (re=
v 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 (re=
v 4602)
@@ -716,10 +716,17 @@
//NodeId id =3D new NodeId(UUID.fromString(uuid));
try
{
- long time =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
NodeData state =3D (NodeData)itemMgr.getItemData(uuid);
- time =3D System.currentTimeMillis() - time;
- log.debug("got NodeState with id {} in {} ms.", uuid, new L=
ong(time));
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis() - time;
+ log.debug("got NodeState with id {} in {} ms.", uuid, ne=
w Long(time)); =
+ }
Iterator entries;
if (nameTest !=3D null)
{
@@ -813,7 +820,11 @@
@Override
public Hits getHits() throws IOException
{
- long time =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
Hits childrenHits =3D new AdaptingHits();
Hits nameHits =3D new ScorerHits(nameTestScorer);
int[] docs =3D new int[1];
@@ -839,9 +850,11 @@
}
}
}
- time =3D System.currentTimeMillis() - time;
-
- log.debug("Filtered hits in {} ms.", new Long(time));
+ if (log.isDebugEnabled())
+ {
+ time =3D 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/se=
rvices/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java 2011-07-05 14:46:1=
2 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:5=
9 UTC (rev 4602)
@@ -587,7 +587,11 @@
{
if (!contextHitsCalculated)
{
- long time =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
contextScorer.score(new AbstractHitCollector()
{
@Override
@@ -597,9 +601,9 @@
}
}); // find all
contextHitsCalculated =3D true;
- time =3D System.currentTimeMillis() - time;
if (log.isDebugEnabled())
{
+ time =3D 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/se=
rvices/jcr/impl/core/query/lucene/DocOrderScoreNodeIterator.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
ScoreNode[][] nodes =3D (ScoreNode[][])scoreNodes.toArray(new ScoreN=
ode[scoreNodes.size()][]);
=
final Set invalidIDs =3D new HashSet(2);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/query/lucene/MultiIndex.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 46=
01)
+++ 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 46=
02)
@@ -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 =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExcept=
ionAction()
{
public Object run() throws Exception
@@ -1162,8 +1166,11 @@
return null;
}
});
- time =3D System.currentTimeMillis() - time;
- log.debug("hierarchy cache initialized in {} ms", new Long(time));
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis() - time;
+ log.debug("hierarchy cache initialized in {} ms", new Long(tim=
e)); =
+ }
}
=
synchronized (this)
@@ -1754,7 +1761,11 @@
if (volatileIndex.getNumDocuments() > 0)
{
=
- long time =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
// create index
CreateIndex create =3D new CreateIndex(getTransactionId(), null);
executeAndLog(create);
@@ -1769,8 +1780,11 @@
// create new volatile index
resetVolatileIndex();
=
- time =3D System.currentTimeMillis() - time;
- log.debug("Committed in-memory index in " + time + "ms.");
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis() - time;
+ log.debug("Committed in-memory index in " + time + "ms."); =
=
+ }
}
}
=
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/query/lucene/QueryResultImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 (r=
ev 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 (r=
ev 4602)
@@ -308,9 +308,16 @@
MultiColumnQueryHits result =3D null;
try
{
- long time =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
result =3D executeQuery(maxResultSize);
- log.debug("query executed in {} ms", new Long(System.currentTimeM=
illis() - time));
+ if (log.isDebugEnabled())
+ {
+ log.debug("query executed in {} ms", new Long(System.currentTi=
meMillis() - time)); =
+ }
// set selector names
selectorNames =3D result.getSelectorNames();
=
@@ -325,9 +332,15 @@
result.skip(start);
}
=
- time =3D System.currentTimeMillis();
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis(); =
+ }
collectScoreNodes(result, resultNodes, maxResultSize);
- log.debug("retrieved ScoreNodes in {} ms", new Long(System.curren=
tTimeMillis() - time));
+ if (log.isDebugEnabled())
+ {
+ log.debug("retrieved ScoreNodes in {} ms", new Long(System.cur=
rentTimeMillis() - time)); =
+ }
=
// update numResults
numResults =3D result.getSize();
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/query/lucene/RowIteratorImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 (r=
ev 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 (r=
ev 4602)
@@ -781,11 +781,18 @@
}
try
{
- long time =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
String excerpt =3D excerptProvider.getExcerpt(id, 3, 150);
-
- time =3D System.currentTimeMillis() - time;
- log.debug("Created excerpt in {} ms.", new Long(time));
+ =
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis() - time;
+ log.debug("Created excerpt in {} ms.", new Long(time)); =
=
+ }
if (excerpt !=3D null)
{
return valueFactory.createValue(excerpt);
@@ -815,10 +822,17 @@
HighlightingExcerptProvider hep =3D (HighlightingExcerptProvider)=
excerptProvider;
try
{
- long time =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
text =3D hep.highlight(text);
- time =3D System.currentTimeMillis() - time;
- log.debug("Highlighted text in {} ms.", new Long(time));
+ if (log.isDebugEnabled())
+ {
+ time =3D 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/se=
rvices/jcr/impl/core/query/lucene/SearchIndex.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 4=
601)
+++ 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 4=
602)
@@ -1881,7 +1881,11 @@
{
return;
}
- long time =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis();
+ }
int found =3D SecurityHelper.doPrivilegedAction(new PrivilegedAct=
ion()
{
public Integer run()
@@ -1937,8 +1941,11 @@
return found;
}
});
- time =3D System.currentTimeMillis() - time;
- log.debug("Retrieved {} aggregate roots in {} ms.", new Integer(f=
ound), new Long(time));
+ if (log.isDebugEnabled())
+ {
+ time =3D System.currentTimeMillis() - time;
+ log.debug("Retrieved {} aggregate roots in {} ms.", new Intege=
r(found), new Long(time)); =
+ }
}
}
=
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2011-07-0=
5 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-0=
5 15:13:59 UTC (rev 4602)
@@ -517,8 +517,11 @@
// save state
if (itemState.isPersisted())
{
- long start =3D System.currentTimeMillis();
-
+ long start =3D 0;
+ if (LOG.isDebugEnabled())
+ {
+ start =3D System.currentTimeMillis();
+ }
ItemData data =3D itemState.getData();
=
WorkspaceStorageConnection conn;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jdbc/indexing/JdbcNodeDataIndexingIterator.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/storage/jdbc/indexing/JdbcNodeDataIndexingIterator.java 2011-07-0=
5 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-0=
5 15:13:59 UTC (rev 4602)
@@ -115,7 +115,11 @@
currentLastNodeId =3D lastNodeId.get();
currentPage =3D page.incrementAndGet();
}
- long time =3D System.currentTimeMillis();
+ long time =3D 0;
+ if (PropertyManager.isDevelopping())
+ {
+ time =3D System.currentTimeMillis();
+ }
List result =3D conn.getNodesAndProperties(curr=
entLastNodeId, currentOffset, pageSize);
if (PropertyManager.isDevelopping())
{
--===============6594487251509361682==--
From do-not-reply at jboss.org Tue Jul 5 11:21:53 2011
Content-Type: multipart/mixed; boundary="===============1796781269138246125=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4603 -
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup.
Date: Tue, 05 Jul 2011 11:21:53 -0400
Message-ID: <201107051521.p65FLr2V027033@svn01.web.mwc.hst.phx2.redhat.com>
--===============1796781269138246125==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/j=
cr/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/ser=
vices/jcr/ext/backup/AbstractBackupUseCasesTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 =3D
"\\${java.io.tmpdir}"
+ bch.getBackupConfig().getBackupDir().getCanonica=
lPath()
- .replaceAll(backupDitEnv, "");
+ .replace(backupDitEnv, "");
=
File dest =3D new File(repositoryBackupChainLogPath + ".xml");
dest.createNewFile();
--===============1796781269138246125==--
From do-not-reply at jboss.org Wed Jul 6 05:34:02 2011
Content-Type: multipart/mixed; boundary="===============7477191166036412835=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r4604 -
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache
and 2 other directories.
Date: Wed, 06 Jul 2011 05:34:02 -0400
Message-ID: <201107060934.p669Y2NS017756@svn01.web.mwc.hst.phx2.redhat.com>
--===============7477191166036412835==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/se=
rvices/cache/invalidation/
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/se=
rvices/cache/invalidation/InvalidationExoCache.java
Removed:
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/se=
rvices/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/se=
rvices/cache/impl/CacheServiceImpl.java
Log:
EXOJCR-1418: Moved InvalidationExoCache in a dedicated package, auto wrap t=
he eXo cache instance into an InvalidationExoCache only if the cache is rep=
licated 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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 avoidValueReplication to
true in your eXo cache configuration, this =
will
indicate the CacheService to wrap your eXo cache instance into an
- InvalidationExoCache.
+ InvalidationExoCache in case the cache is
+ defined as replicated or distributed.
=
Programmatically; You can wrap your eXo cache instance int=
o an
- org.exoplatform.services.cache.impl.InvalidationExoCac=
he
+ org.exoplatform.services.cache.invalidation.Invalidati=
onExoCache
yourself using the public constructors that are available. Please
note that if you use CacheListeners add the=
m to
the InvalidationExoCache instance instead of the nested eXo Cache
@@ -227,7 +228,7 @@
The invalidation will be efficient if and only if the hash c=
ode
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 other=
wise
the infinite loop described above will still be effective.
Modified: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplat=
form/services/cache/impl/CacheServiceImpl.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/impl/CacheServiceImpl.java 2011-07-05 15:21:53 UTC (rev 4603)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/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 ca=
che 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 r=
eplicated
+ // or distributed we wrap the eXo cache instance into an Invalidatio=
nExoCache =
+ // to enable the invalidation
+ return safeConfig.avoidValueReplication() && (safeConfig.isRepicated=
() || safeConfig.isDistributed())
+ ? new InvalidationExoCache(simple) : simple;
}
=
public Collection> getAllCacheInsta=
nces()
Deleted: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatf=
orm/services/cache/impl/InvalidationExoCache.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/impl/InvalidationExoCache.java 2011-07-05 15:21:53 UTC (rev 4=
603)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/s=
ervices/cache/impl/InvalidationExoCache.java 2011-07-06 09:34:01 UTC (rev 4=
604)
@@ -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 inv=
alidation
- * mechanism. To prevent infinite loop described below, we replicate the h=
ash code of
- * the value such that if the hash code is the same, we don't invalidate t=
he value locally
- *
- *
Cluster node #1 puts (key1, value1) into the cache
- *
On cluster node #2 key1 is invalidated by the put call in node #1=
li>
- *
Node #2 re-loads key1 and puts (key1, value1) into the cache
- *
On cluster node #1 key1 is invalidated, so we get back to step #1=
li>
- *