exo-jcr SVN: r898 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl: dataflow and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-26 21:12:58 -0500 (Thu, 26 Nov 2009)
New Revision: 898
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
Log:
EXOJCR-275: Version.restore workaround for Value storage right work (it's normal logic actually, but not so good tested yet)
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java 2009-11-26 16:53:49 UTC (rev 897)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java 2009-11-27 02:12:58 UTC (rev 898)
@@ -104,7 +104,11 @@
List<ValueData> values = new ArrayList<ValueData>();
for (ValueData valueData : property.getValues())
{
- values.add(((TransientValueData)valueData).createTransientCopy());
+ //values.add(((TransientValueData)valueData).createTransientCopy());
+
+ // TODO workaround for JBC branch, issued by the FileRestoreTest
+ TransientValueData tvd = (TransientValueData)valueData;
+ values.add(tvd.createTransientCopy1());
}
boolean mv = property.isMultiValued();
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2009-11-26 16:53:49 UTC (rev 897)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2009-11-27 02:12:58 UTC (rev 898)
@@ -125,7 +125,7 @@
* @param orderNumber
* int
*/
- protected TransientValueData(InputStream stream, int orderNumber)
+ public TransientValueData(InputStream stream, int orderNumber)
{
super(orderNumber);
this.tmpStream = stream;
@@ -428,6 +428,37 @@
}
/**
+ * Create TransientCopy of data.
+ *
+ * TODO workaround for JBC branch, issued by the FileRestoreTest.
+ *
+ * @return TransientValueData
+ * @throws RepositoryException
+ */
+ public TransientValueData createTransientCopy1() throws RepositoryException
+ {
+ try
+ {
+ if (isByteArray())
+ {
+ // bytes based
+ return new TransientValueData(orderNumber, data, null, null, fileCleaner, maxBufferSize, tempDirectory,
+ deleteSpoolFile);
+ }
+ else
+ {
+ // stream (or file) based , i.e. shared across sessions
+ return new TransientValueData(orderNumber, null, getAsStream(), null, fileCleaner, maxBufferSize,
+ tempDirectory, true);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
* Create editable ValueData copy.
*
* @return EditableValueData
@@ -931,23 +962,23 @@
// write streams
out.writeInt(2);
//TODO Need optimization in backup service.
- byte[] buf = new byte[4*1024];
-
- if (!spooled)
+ byte[] buf = new byte[4 * 1024];
+
+ if (!spooled)
spoolInputStream();
InputStream in = (spoolFile == null ? new ByteArrayInputStream(data) : new FileInputStream(spoolFile));
long dataLength = (spoolFile == null ? data.length : spoolFile.length());
int len;
-
+
//write length of spoolFile
out.writeLong(dataLength);
-
+
while ((len = in.read(buf)) > 0)
- out.write(buf, 0, len);
-
+ out.write(buf, 0, len);
+
in.close();
}
-
+
out.writeInt(orderNumber);
out.writeInt(maxBufferSize);
}
@@ -967,16 +998,17 @@
else
{
//read file form stream
- long lengthSpoolFile = in.readLong();
-
+ long lengthSpoolFile = in.readLong();
+
//TODO May be optimization.
SpoolFile sf = SpoolFile.createTempFile("jcrvd", null, tempDirectory);
sf.acquire(this);
- OutputStream outStream = new FileOutputStream(sf);
-
- byte[] buf = new byte[4*1024];
-
- while (lengthSpoolFile > 0) {
+ OutputStream outStream = new FileOutputStream(sf);
+
+ byte[] buf = new byte[4 * 1024];
+
+ while (lengthSpoolFile > 0)
+ {
if (lengthSpoolFile - buf.length > 0)
{
in.readFully(buf);
@@ -984,17 +1016,17 @@
}
else
{
- in.readFully(buf, 0, (int) lengthSpoolFile);
- outStream.write(buf, 0, (int) lengthSpoolFile);
+ in.readFully(buf, 0, (int)lengthSpoolFile);
+ outStream.write(buf, 0, (int)lengthSpoolFile);
}
- lengthSpoolFile-=buf.length;
+ lengthSpoolFile -= buf.length;
}
outStream.flush();
outStream.close();
spoolFile = sf;
spooled = true;
}
-
+
orderNumber = in.readInt();
maxBufferSize = in.readInt();
}
16 years, 5 months
exo-jcr SVN: r897 - jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-26 11:53:49 -0500 (Thu, 26 Nov 2009)
New Revision: 897
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml
Log:
EXOJCR-199 : The configuration in main/conf/portal was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml 2009-11-26 16:41:13 UTC (rev 896)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml 2009-11-26 16:53:49 UTC (rev 897)
@@ -21,14 +21,14 @@
use_incoming_packet_handler="true" />
<PING num_initial_members="3" timeout="2000" /-->
- <TCP bind_addr="127.0.0.1" start_port="9800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ <TCP bind_addr="127.0.0.1" start_port="7800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true" use_send_queues="false" sock_conn_timeout="300"
skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34521" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="3" mcast_port="34532" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml 2009-11-26 16:41:13 UTC (rev 896)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml 2009-11-26 16:53:49 UTC (rev 897)
@@ -21,14 +21,14 @@
use_incoming_packet_handler="true" />
<PING num_initial_members="3" timeout="2000" /-->
- <TCP bind_addr="127.0.0.1" start_port="9800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ <TCP bind_addr="127.0.0.1" start_port="7800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true" use_send_queues="false" sock_conn_timeout="300"
skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34522" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="3" mcast_port="34533" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml 2009-11-26 16:41:13 UTC (rev 896)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml 2009-11-26 16:53:49 UTC (rev 897)
@@ -21,14 +21,14 @@
use_incoming_packet_handler="true" />
<PING num_initial_members="3" timeout="2000" /-->
- <TCP bind_addr="127.0.0.1" start_port="9800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ <TCP bind_addr="127.0.0.1" start_port="7800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true" use_send_queues="false" sock_conn_timeout="300"
skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34520" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="3" mcast_port="34531" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
16 years, 5 months
exo-jcr SVN: r896 - jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-26 11:41:13 -0500 (Thu, 26 Nov 2009)
New Revision: 896
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/exo-jcr-config.xml
Log:
EXOJCR-199 : The configuration in main/conf/portal was changed to use JBossCacheWorkspaceDataContainer.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/exo-jcr-config.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/exo-jcr-config.xml 2009-11-26 16:26:29 UTC (rev 895)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/exo-jcr-config.xml 2009-11-26 16:41:13 UTC (rev 896)
@@ -28,8 +28,9 @@
<workspaces>
<workspace name="production">
<!-- for system storage -->
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jbosscache.JBossCacheWorkspaceDataContainer">
<properties>
+ <property name="jbosscache-configuration" value="conf/portal/jbosscache-configuration_repository_production.xml" />
<property name="source-name" value="jdbcjcr" />
<property name="dialect" value="hsqldb" />
<property name="multi-db" value="false" />
@@ -75,8 +76,9 @@
</workspace>
<workspace name="backup">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jbosscache.JBossCacheWorkspaceDataContainer">
<properties>
+ <property name="jbosscache-configuration" value="conf/portal/jbosscache-configuration_repository_backup.xml" />
<property name="source-name" value="jdbcjcr" />
<property name="dialect" value="hsqldb" />
<property name="multi-db" value="false" />
@@ -114,8 +116,9 @@
</workspace>
<workspace name="digital-assets">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jbosscache.JBossCacheWorkspaceDataContainer">
<properties>
+ <property name="jbosscache-configuration" value="conf/portal/jbosscache-configuration_repository_digital-assets.xml" />
<property name="source-name" value="jdbcjcr" />
<property name="dialect" value="hsqldb" />
<property name="multi-db" value="false" />
Added: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml 2009-11-26 16:41:13 UTC (rev 896)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <!-- Configure the TransactionManager -->
+ <transaction
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
+
+ <clustering mode="replication" clusterName="JBoss-Cache-Cluster_repository_backup">
+
+ <jgroupsConfig>
+ <!--UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
+ loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10"
+ mcast_port="45588" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000"
+ oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4"
+ oob_thread_pool.min_threads="1" oob_thread_pool.queue_enabled="true" oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl" thread_pool.enabled="true"
+ thread_pool.keep_alive_time="30000" thread_pool.max_threads="25" thread_pool.min_threads="1"
+ thread_pool.queue_enabled="true" thread_pool.queue_max_size="10" thread_pool.rejection_policy="Run"
+ tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true"
+ use_incoming_packet_handler="true" />
+ <PING num_initial_members="3" timeout="2000" /-->
+
+ <TCP bind_addr="127.0.0.1" start_port="9800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true" use_send_queues="false" sock_conn_timeout="300"
+ skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
+
+ oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
+ <MPING timeout="2000" num_initial_members="3" mcast_port="34521" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+
+
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD max_tries="5" shun="true" timeout="10000"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
+ use_mcast_xmit="false"/>
+ <UNICAST timeout="300,600,1200,2400,3600"/>
+ <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/>
+ <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000"
+ view_bundling="true"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
+ <pbcast.FLUSH timeout="0"/>
+
+ </jgroupsConfig>
+
+ <sync />
+ <!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
+ <!-- <async /> -->
+ </clustering>
+
+ <loaders passivation="false" shared="false">
+
+ <loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
+ async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ </properties>
+ </loader>
+
+ </loaders>
+
+ <!-- Enable batching -->
+ <invocationBatching enabled="true"/>
+</jbosscache>
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_backup.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml 2009-11-26 16:41:13 UTC (rev 896)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <!-- Configure the TransactionManager -->
+ <transaction
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
+
+ <clustering mode="replication" clusterName="JBoss-Cache-Cluster_repository_digital-assets">
+
+ <jgroupsConfig>
+ <!--UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
+ loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10"
+ mcast_port="45588" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000"
+ oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4"
+ oob_thread_pool.min_threads="1" oob_thread_pool.queue_enabled="true" oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl" thread_pool.enabled="true"
+ thread_pool.keep_alive_time="30000" thread_pool.max_threads="25" thread_pool.min_threads="1"
+ thread_pool.queue_enabled="true" thread_pool.queue_max_size="10" thread_pool.rejection_policy="Run"
+ tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true"
+ use_incoming_packet_handler="true" />
+ <PING num_initial_members="3" timeout="2000" /-->
+
+ <TCP bind_addr="127.0.0.1" start_port="9800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true" use_send_queues="false" sock_conn_timeout="300"
+ skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
+
+ oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
+ <MPING timeout="2000" num_initial_members="3" mcast_port="34522" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+
+
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD max_tries="5" shun="true" timeout="10000"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
+ use_mcast_xmit="false"/>
+ <UNICAST timeout="300,600,1200,2400,3600"/>
+ <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/>
+ <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000"
+ view_bundling="true"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
+ <pbcast.FLUSH timeout="0"/>
+
+ </jgroupsConfig>
+
+ <sync />
+ <!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
+ <!-- <async /> -->
+ </clustering>
+
+ <loaders passivation="false" shared="false">
+
+ <loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
+ async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ </properties>
+ </loader>
+
+ </loaders>
+
+ <!-- Enable batching -->
+ <invocationBatching enabled="true"/>
+</jbosscache>
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_digital-assets.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml 2009-11-26 16:41:13 UTC (rev 896)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <!-- Configure the TransactionManager -->
+ <transaction
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
+
+ <clustering mode="replication" clusterName="JBoss-Cache-Cluster_repository_production">
+
+ <jgroupsConfig>
+ <!--UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
+ loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10"
+ mcast_port="45588" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000"
+ oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4"
+ oob_thread_pool.min_threads="1" oob_thread_pool.queue_enabled="true" oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl" thread_pool.enabled="true"
+ thread_pool.keep_alive_time="30000" thread_pool.max_threads="25" thread_pool.min_threads="1"
+ thread_pool.queue_enabled="true" thread_pool.queue_max_size="10" thread_pool.rejection_policy="Run"
+ tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true"
+ use_incoming_packet_handler="true" />
+ <PING num_initial_members="3" timeout="2000" /-->
+
+ <TCP bind_addr="127.0.0.1" start_port="9800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true" use_send_queues="false" sock_conn_timeout="300"
+ skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
+
+ oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
+ <MPING timeout="2000" num_initial_members="3" mcast_port="34520" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+
+
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD max_tries="5" shun="true" timeout="10000"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
+ use_mcast_xmit="false"/>
+ <UNICAST timeout="300,600,1200,2400,3600"/>
+ <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/>
+ <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000"
+ view_bundling="true"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
+ <pbcast.FLUSH timeout="0"/>
+
+ </jgroupsConfig>
+
+ <sync />
+ <!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
+ <!-- <async /> -->
+ </clustering>
+
+ <loaders passivation="false" shared="false">
+
+ <loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
+ async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ </properties>
+ </loader>
+
+ </loaders>
+
+ <!-- Enable batching -->
+ <invocationBatching enabled="true"/>
+</jbosscache>
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/resources/conf/portal/jbosscache-configuration_repository_production.xml
___________________________________________________________________
Name: svn:eol-style
+ native
16 years, 5 months
exo-jcr SVN: r895 - kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-11-26 11:26:29 -0500 (Thu, 26 Nov 2009)
New Revision: 895
Modified:
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java
Log:
EXOJCR-268 Unimplemented methods added
Modified: kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java 2009-11-26 16:23:34 UTC (rev 894)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java 2009-11-26 16:26:29 UTC (rev 895)
@@ -62,18 +62,7 @@
}
- public void clearCache() throws Exception
- {
- // TODO Auto-generated method stub
- }
-
- public Object get(Serializable name) throws Exception
- {
- // TODO Auto-generated method stub
- return null;
- }
-
public int getCacheHit()
{
// TODO Auto-generated method stub
@@ -139,76 +128,89 @@
return false;
}
- public void put(Serializable name, Object obj) throws Exception
+
+ public void select(CachedObjectSelector selector) throws Exception
{
// TODO Auto-generated method stub
}
- public void putMap(Map<Serializable, Object> objs) throws Exception
+ public void setDistributed(boolean b)
{
// TODO Auto-generated method stub
}
- public Object remove(Serializable name) throws Exception
+ public void setLabel(String s)
{
// TODO Auto-generated method stub
- return null;
+
}
- public List removeCachedObjects() throws Exception
+ public void setLiveTime(long period)
{
// TODO Auto-generated method stub
- return null;
+
}
- public void select(CachedObjectSelector selector) throws Exception
+ public void setLogEnabled(boolean b)
{
// TODO Auto-generated method stub
}
- public void setDistributed(boolean b)
+ public void setMaxSize(int max)
{
// TODO Auto-generated method stub
}
- public void setLabel(String s)
+ public void setName(String name)
{
// TODO Auto-generated method stub
}
- public void setLiveTime(long period)
+ public void setReplicated(boolean b)
{
// TODO Auto-generated method stub
}
- public void setLogEnabled(boolean b)
+ public void clearCache()
{
// TODO Auto-generated method stub
+
+ }
+ public Object get(Serializable key)
+ {
+ // TODO Auto-generated method stub
+ return null;
}
- public void setMaxSize(int max)
+ public void put(Serializable key, Object value) throws NullPointerException
{
// TODO Auto-generated method stub
+
+ }
+ public void putMap(Map objs) throws NullPointerException, IllegalArgumentException
+ {
+ // TODO Auto-generated method stub
+
}
- public void setName(String name)
+ public Object remove(Serializable key) throws NullPointerException
{
// TODO Auto-generated method stub
-
+ return null;
}
- public void setReplicated(boolean b)
+ public List removeCachedObjects()
{
// TODO Auto-generated method stub
-
+ return null;
}
}
16 years, 5 months
exo-jcr SVN: r894 - kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-11-26 11:23:34 -0500 (Thu, 26 Nov 2009)
New Revision: 894
Modified:
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
Log:
EXOJCR-268 Unimplemented methods added
Modified: kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2009-11-26 16:21:21 UTC (rev 893)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2009-11-26 16:23:34 UTC (rev 894)
@@ -20,6 +20,7 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CacheListenerContext;
import org.exoplatform.services.cache.CacheService;
import org.exoplatform.services.cache.CachedObjectSelector;
import org.exoplatform.services.cache.ExoCache;
@@ -617,6 +618,31 @@
{
remove++;
}
+
+ public void onClearCache(CacheListenerContext context) throws Exception
+ {
+ clearCache++;
+ }
+
+ public void onExpire(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ expire++;
+ }
+
+ public void onGet(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ get++;
+ }
+
+ public void onPut(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ put++;
+ }
+
+ public void onRemove(CacheListenerContext context, Serializable key, Object obj) throws Exception
+ {
+ remove++;
+ }
}
public static class MyKey implements Serializable
16 years, 5 months
exo-jcr SVN: r893 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-26 11:21:21 -0500 (Thu, 26 Nov 2009)
New Revision: 893
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-201: rework of transitive changes apply (mixins and paths)
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-26 15:41:36 UTC (rev 892)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-26 16:21:21 UTC (rev 893)
@@ -727,8 +727,7 @@
childNode.put(ITEM_ID, data.getIdentifier());
// 4. update all child nodes
- updateTreePath(node, data.getQPath()); //treePrint(node)
-
+ updateTreePath(node, data.getQPath());
}
/**
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-26 15:41:36 UTC (rev 892)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-26 16:21:21 UTC (rev 893)
@@ -118,7 +118,13 @@
}
break;
case PUT_KEY_VALUE :
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("PUT_KEY_VALUE modification");
+ }
+
doUpdate(m, conn);
+
break;
case REMOVE_DATA :
if (LOG.isDebugEnabled())
@@ -133,7 +139,13 @@
}
break;
case REMOVE_NODE :
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("REMOVE_NODE modification");
+ }
+
doRemove(m, conn);
+
break;
case MOVE :
if (LOG.isDebugEnabled())
@@ -227,16 +239,12 @@
if (modification.getValue() instanceof NodeData)
{
//add node data
- NodeData nodeData = (NodeData)modification.getValue();
-
- conn.add(nodeData);
+ conn.add((NodeData)modification.getValue());
}
else if (modification.getValue() instanceof PropertyData)
{
//add property data
- PropertyData propertyData = (PropertyData)modification.getValue();
-
- conn.add(propertyData);
+ conn.add((PropertyData)modification.getValue());
}
}
@@ -255,24 +263,26 @@
//Check flag it's mixin update for node, if this flag set we have node need to
TransientItemData item = (TransientItemData)m.getValue();
- // TODO try
- // if ((item.getState() == TransientItemData.TRANSITIVE_NONE)
-
- if ((item.getState() & TransientItemData.TRANSITIVE_PATH_UPDATED) == 0
- || (item.getState() & TransientItemData.TRANSITIVE_MIXIN_UPDATED) == 0)
+ if ((item.getState() & TransientItemData.TRANSITIVE_PATH_UPDATED) == 0)
{
+ // if not a transitive update of path, update it in the database
if (conn.itemExists((String)m.getFqn().get(1), item.isNode()))
{
// update if it's non transitive update
if (item.isNode())
{
- // TODO conn.rename() is used to update all the fields in DB.
- // Original conn.update() will be matched as deprecated,
- // and conn.rename() should be renamed to update. This
- // is done to solve the issue, when we need to guess each
- // time whether node is moved or just updated. This
- // solution is used as the fastest among other.
- conn.rename((NodeData)item);
+ if ((item.getState() & TransientItemData.TRANSITIVE_MIXIN_UPDATED) == 0)
+ {
+ // TODO do not handle mixin updates in db; it's a workaround - review logic in the connection
+
+ // TODO conn.rename() is used to update all the fields in DB.
+ // Original conn.update() will be matched as deprecated,
+ // and conn.rename() should be renamed to update. This
+ // is done to solve the issue, when we need to guess each
+ // time whether node is moved or just updated. This
+ // solution is used as the fastest among other.
+ conn.rename((NodeData)item);
+ }
}
else
{
@@ -731,7 +741,7 @@
}
catch (Throwable e)
{
- // TODO why we cannot throw an exception???
+ // TODO why we cannot throw an exception??? (throws Exception expected)
LOG.error("Error of transaction " + tx + " rollback.", e);
}
}
16 years, 5 months
exo-jcr SVN: r892 - kernel/trunk/exo.kernel.component.ext.cache.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-11-26 10:41:36 -0500 (Thu, 26 Nov 2009)
New Revision: 892
Modified:
kernel/trunk/exo.kernel.component.ext.cache/pom.xml
Log:
EXOJCR-162 transitibe dependencies fixed
Modified: kernel/trunk/exo.kernel.component.ext.cache/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/pom.xml 2009-11-26 15:38:39 UTC (rev 891)
+++ kernel/trunk/exo.kernel.component.ext.cache/pom.xml 2009-11-26 15:41:36 UTC (rev 892)
@@ -10,19 +10,27 @@
<artifactId>exo.kernel.component.ext.cache</artifactId>
<description>JBoss Cache Implementation for the Cache Service</description>
-
- <dependencies>
+
+ <dependencies>
<dependency>
+ <groupId>org.exoplatform.tool</groupId>
+ <artifactId>exo.tool.framework.junit</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.commons</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.component.cache</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
</dependency>
- <dependency>
- <groupId>jgroups</groupId>
- <artifactId>jgroups</artifactId>
- </dependency>
</dependencies>
</project>
16 years, 5 months
exo-jcr SVN: r891 - kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-11-26 10:38:39 -0500 (Thu, 26 Nov 2009)
New Revision: 891
Modified:
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java
Log:
EXOJCR-268 org.apache.commons.logging replaced with exo logger
Modified: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-11-26 15:32:33 UTC (rev 890)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-11-26 15:38:39 UTC (rev 891)
@@ -26,13 +26,13 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.commons.logging.Log;
import org.exoplatform.services.cache.CacheListener;
import org.exoplatform.services.cache.CachedObjectSelector;
import org.exoplatform.services.cache.ExoCache;
import org.exoplatform.services.cache.ExoCacheConfig;
import org.exoplatform.services.cache.ObjectCacheInfo;
import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
Modified: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java 2009-11-26 15:32:33 UTC (rev 890)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java 2009-11-26 15:38:39 UTC (rev 891)
@@ -24,7 +24,6 @@
import java.util.List;
import java.util.Map;
-import org.apache.commons.logging.Log;
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.ValueParam;
@@ -34,6 +33,7 @@
import org.exoplatform.services.cache.ExoCacheInitException;
import org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheCreator;
import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
16 years, 5 months
exo-jcr SVN: r890 - kernel/trunk/exo.kernel.component.ext.cache.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-11-26 10:32:33 -0500 (Thu, 26 Nov 2009)
New Revision: 890
Removed:
kernel/trunk/exo.kernel.component.ext.cache/pom.xml~
Log:
EXOJCR-268 Added an implementation of ExoCache for JBoss Cache 3
Deleted: kernel/trunk/exo.kernel.component.ext.cache/pom.xml~
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/pom.xml~ 2009-11-26 15:30:27 UTC (rev 889)
+++ kernel/trunk/exo.kernel.component.ext.cache/pom.xml~ 2009-11-26 15:32:33 UTC (rev 890)
@@ -1,28 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>kernel-parent</artifactId>
- <version>2.2.0-Beta05-SNAPSHOT</version>
- </parent>
-
- <artifactId>exo.kernel.component.ext.cache</artifactId>
-
- <description>JBoss Cache Implementation for the Cache Service</description>
-
- <dependencies>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.component.cache</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.cache</groupId>
- <artifactId>jbosscache-core</artifactId>
- </dependency>
- <dependency>
- <groupId>jgroups</groupId>
- <artifactId>jgroups</artifactId>
- </dependency>
- </dependencies>
-</project>
16 years, 5 months
exo-jcr SVN: r889 - in kernel/trunk/exo.kernel.component.ext.cache: src and 26 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-11-26 10:30:27 -0500 (Thu, 26 Nov 2009)
New Revision: 889
Added:
kernel/trunk/exo.kernel.component.ext.cache/pom.xml
kernel/trunk/exo.kernel.component.ext.cache/pom.xml~
kernel/trunk/exo.kernel.component.ext.cache/src/
kernel/trunk/exo.kernel.component.ext.cache/src/main/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/
kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/
kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/
kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml
kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml
kernel/trunk/exo.kernel.component.ext.cache/src/test/
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java
kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java
kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/
kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/
kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/
kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml
kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml
Log:
EXOJCR-268 Added an implementation of ExoCache for JBoss Cache 3
Added: kernel/trunk/exo.kernel.component.ext.cache/pom.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/pom.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/pom.xml 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,28 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>kernel-parent</artifactId>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>exo.kernel.component.ext.cache</artifactId>
+
+ <description>JBoss Cache Implementation for the Cache Service</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.cache</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: kernel/trunk/exo.kernel.component.ext.cache/pom.xml~
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/pom.xml~ (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/pom.xml~ 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,28 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>kernel-parent</artifactId>
+ <version>2.2.0-Beta05-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>exo.kernel.component.ext.cache</artifactId>
+
+ <description>JBoss Cache Implementation for the Cache Service</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.cache</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,573 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.commons.logging.Log;
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ObjectCacheInfo;
+import org.exoplatform.services.log.ExoLogger;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.notifications.annotation.NodeCreated;
+import org.jboss.cache.notifications.annotation.NodeEvicted;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.event.EventImpl;
+import org.jboss.cache.notifications.event.NodeEvent;
+
+/**
+ * An {@link org.exoplatform.services.cache.ExoCache} implementation based on {@link org.jboss.cache.Node}.
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 20 juil. 2009
+ */
+public abstract class AbstractExoCache implements ExoCache
+{
+
+ /**
+ * Logger.
+ */
+ private static final Log LOG = ExoLogger.getLogger(AbstractExoCache.class);
+
+ protected final AtomicInteger size = new AtomicInteger();
+
+ private volatile int hits;
+
+ private volatile int misses;
+
+ private String label;
+
+ private String name;
+
+ private boolean distributed;
+
+ private boolean replicated;
+
+ private boolean logEnabled;
+
+ private final CopyOnWriteArrayList<CacheListener> listeners;
+
+ protected final Cache<Serializable, Object> cache;
+
+ protected final boolean isCacheSPI;
+
+ @SuppressWarnings("unchecked")
+ public AbstractExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache)
+ {
+ this.cache = cache;
+ this.isCacheSPI = cache instanceof CacheSPI;
+ this.listeners = new CopyOnWriteArrayList<CacheListener>();
+ if (!isCacheSPI)
+ {
+ LOG.warn("The cache is not an instance of CacheSPI, the cache size will be evaluated but won't be accurate");
+ }
+ setDistributed(config.isDistributed());
+ setLabel(config.getLabel());
+ setName(config.getName());
+ setLogEnabled(config.isLogEnabled());
+ setReplicated(config.isRepicated());
+ cache.getConfiguration().setInvocationBatchingEnabled(true);
+ cache.addCacheListener(new SizeManager());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addCacheListener(CacheListener listener)
+ {
+ if (listener == null)
+ {
+ return;
+ }
+ listeners.add(listener);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void clearCache() throws Exception
+ {
+ final Node<Serializable, Object> rootNode = cache.getRoot();
+ for (Node<Serializable, Object> node : rootNode.getChildren())
+ {
+ if (node == null)
+ {
+ continue;
+ }
+ remove(getKey(node));
+ }
+ onClearCache();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object get(Serializable name) throws Exception
+ {
+ final Object result = cache.get(Fqn.fromElements(name), name);
+ if (result == null)
+ {
+ misses++;
+ }
+ else
+ {
+ hits++;
+ }
+ onGet(name, result);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheHit()
+ {
+ return hits;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getCacheMiss()
+ {
+ return misses;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ public int getCacheSize()
+ {
+ if (isCacheSPI)
+ {
+ return ((CacheSPI)cache).getNumberOfNodes();
+ }
+ return size.intValue();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<Object> getCachedObjects()
+ {
+ final LinkedList<Object> list = new LinkedList<Object>();
+ for (Node<Serializable, Object> node : cache.getRoot().getChildren())
+ {
+ if (node == null)
+ {
+ continue;
+ }
+ final Object value = node.get(getKey(node));
+ if (value != null)
+ {
+ list.add(value);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getLabel()
+ {
+ return label;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDistributed()
+ {
+ return distributed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isLogEnabled()
+ {
+ return logEnabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isReplicated()
+ {
+ return replicated;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(Serializable name, Object obj) throws Exception
+ {
+ putOnly(name, obj);
+ onPut(name, obj);
+ }
+
+ /**
+ * Only puts the data into the cache nothing more
+ */
+ private Object putOnly(Serializable name, Object obj) throws Exception
+ {
+ return cache.put(Fqn.fromElements(name), name, obj);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void putMap(Map<Serializable, Object> objs) throws Exception
+ {
+ cache.startBatch();
+ int total = 0;
+ try
+ {
+ // Start transaction
+ for (Entry<Serializable, Object> entry : objs.entrySet())
+ {
+ Object value = putOnly(entry.getKey(), entry.getValue());
+ if (value == null)
+ {
+ total++;
+ }
+ }
+ cache.endBatch(true);
+ // End transaction
+ for (Entry<Serializable, Object> entry : objs.entrySet())
+ {
+ onPut(entry.getKey(), entry.getValue());
+ }
+ }
+ catch (Exception e)
+ {
+ if (!isCacheSPI)
+ size.addAndGet(-total);
+ cache.endBatch(false);
+ throw e;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object remove(Serializable name) throws Exception
+ {
+ final Fqn<Serializable> fqn = Fqn.fromElements(name);
+ final Node<Serializable, Object> node = cache.getNode(fqn);
+ if (node != null)
+ {
+ final Object result = node.get(name);
+ if (cache.removeNode(fqn))
+ {
+ onRemove(name, result);
+ }
+ return result;
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<Object> removeCachedObjects() throws Exception
+ {
+ final List<Object> list = getCachedObjects();
+ clearCache();
+ return list;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void select(CachedObjectSelector selector) throws Exception
+ {
+ for (Node<Serializable, Object> node : cache.getRoot().getChildren())
+ {
+ if (node == null)
+ {
+ continue;
+ }
+ final Serializable key = getKey(node);
+ final Object value = node.get(key);
+ ObjectCacheInfo info = new ObjectCacheInfo()
+ {
+ public Object get()
+ {
+ return value;
+ }
+
+ public long getExpireTime()
+ {
+ // Cannot know: The expire time is managed by JBoss Cache itself
+ return -1;
+ }
+ };
+ if (selector.select(key, info))
+ {
+ selector.onSelect(this, key, info);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDistributed(boolean distributed)
+ {
+ this.distributed = distributed;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setLabel(String label)
+ {
+ this.label = label;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setLogEnabled(boolean logEnabled)
+ {
+ this.logEnabled = logEnabled;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setReplicated(boolean replicated)
+ {
+ this.replicated = replicated;
+ }
+
+ /**
+ * Returns the key related to the given node
+ */
+ private Serializable getKey(Node<Serializable, Object> node)
+ {
+ return getKey(node.getFqn());
+ }
+
+ /**
+ * Returns the key related to the given Fqn
+ */
+ @SuppressWarnings("unchecked")
+ private Serializable getKey(Fqn fqn)
+ {
+ return (Serializable)fqn.get(0);
+ }
+
+ void onExpire(Serializable key, Object obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener listener : listeners)
+ {
+ try
+ {
+ listener.onExpire(this, key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ void onRemove(Serializable key, Object obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener listener : listeners)
+ {
+ try
+ {
+ listener.onRemove(this, key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+ }
+
+ void onPut(Serializable key, Object obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener listener : listeners)
+ try
+ {
+ listener.onPut(this, key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ void onGet(Serializable key, Object obj)
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener listener : listeners)
+ try
+ {
+ listener.onGet(this, key, obj);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ void onClearCache()
+ {
+ if (listeners.isEmpty())
+ {
+ return;
+ }
+ for (CacheListener listener : listeners)
+ try
+ {
+ listener.onClearCache(this);
+ }
+ catch (Exception e)
+ {
+ if (LOG.isWarnEnabled())
+ LOG.warn("Cannot execute the CacheListener properly", e);
+ }
+ }
+
+ @org.jboss.cache.notifications.annotation.CacheListener
+ public class SizeManager
+ {
+
+ @NodeEvicted
+ public void nodeEvicted(NodeEvent ne)
+ {
+ if (ne.isPre())
+ {
+ // Cannot give the value since
+ // since it disturbs the eviction
+ // algorithms
+ onExpire(getKey(ne.getFqn()), null);
+ }
+ else if (!isCacheSPI)
+ {
+ size.decrementAndGet();
+ }
+ }
+
+ @NodeRemoved
+ public void nodeRemoved(NodeEvent ne)
+ {
+ if (ne.isPre())
+ {
+ if (!ne.isOriginLocal())
+ {
+ final Node<Serializable, Object> node = cache.getNode(ne.getFqn());
+ final Serializable key = getKey(ne.getFqn());
+ onRemove(key, node.get(key));
+ }
+ }
+ else if (!isCacheSPI)
+ {
+ size.decrementAndGet();
+ }
+ }
+
+ @NodeCreated
+ public void nodeCreated(NodeEvent ne)
+ {
+ if (!ne.isPre() && !isCacheSPI)
+ {
+ size.incrementAndGet();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @NodeModified
+ public void nodeModified(NodeEvent ne)
+ {
+ if (!ne.isOriginLocal() && !ne.isPre())
+ {
+ final Serializable key = getKey(ne.getFqn());
+ if (ne instanceof EventImpl)
+ {
+ EventImpl evt = (EventImpl)ne;
+ Map<Serializable, Object> data = evt.getData();
+ if (data != null)
+ {
+ onPut(key, data.get(key));
+ return;
+ }
+ }
+ final Node<Serializable, Object> node = cache.getNode(ne.getFqn());
+ onPut(key, node.get(key));
+ }
+ }
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreator.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import java.io.Serializable;
+
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.jboss.cache.Cache;
+
+/**
+ * This class is used to create the cache according to the given
+ * configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 20 juil. 2009
+ */
+public interface ExoCacheCreator
+{
+
+ /**
+ * Creates an eXo cache according to the given configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
+ * @param config the configuration of the cache to apply
+ * @param cache the cache to initialize
+ * @exception ExoCacheInitException if an exception happens while initializing the cache
+ */
+ public ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException;
+
+ /**
+ * Returns the type of {@link org.exoplatform.services.cache.ExoCacheConfig} expected by the creator
+ * @return the expected type
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType();
+
+ /**
+ * Returns the name of the implementation expected by the creator. This is mainly used to be backward compatible
+ * @return the expected by the creator
+ */
+ public String getExpectedImplementation();
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheCreatorPlugin.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+
+/**
+ * This class allows us to define new creators
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 20 juil. 2009
+ */
+public class ExoCacheCreatorPlugin extends BaseComponentPlugin
+{
+
+ /**
+ * The list of all the creators defined for this ComponentPlugin
+ */
+ private final List<ExoCacheCreator> creators;
+
+ public ExoCacheCreatorPlugin(InitParams params)
+ {
+ creators = new ArrayList<ExoCacheCreator>();
+ List<?> configs = params.getObjectParamValues(ExoCacheCreator.class);
+ for (int i = 0; i < configs.size(); i++)
+ {
+ ExoCacheCreator config = (ExoCacheCreator)configs.get(i);
+ creators.add(config);
+ }
+ }
+
+ /**
+ * Returns all the creators defined for this ComponentPlugin
+ */
+ public List<ExoCacheCreator> getCreators()
+ {
+ return creators;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryConfigPlugin.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+
+/**
+ * This class is used to define custom configurations
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 23 juil. 2009
+ */
+public class ExoCacheFactoryConfigPlugin extends BaseComponentPlugin
+{
+
+ /**
+ * The map of all the creators defined for this ComponentPlugin
+ */
+ private final Map<String, String> configs;
+
+ @SuppressWarnings("unchecked")
+ public ExoCacheFactoryConfigPlugin(InitParams params)
+ {
+ configs = new HashMap<String, String>();
+ for (Iterator<ValueParam> iterator = params.getValueParamIterator(); iterator.hasNext();)
+ {
+ ValueParam vParam = iterator.next();
+ configs.put(vParam.getName(), vParam.getValue());
+ }
+ }
+
+ /**
+ * Returns all the configurations defined for this ComponentPlugin
+ */
+ public Map<String, String> getConfigs()
+ {
+ return configs;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/ExoCacheFactoryImpl.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,242 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheFactory;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheCreator;
+import org.exoplatform.services.log.ExoLogger;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.Configuration.CacheMode;
+
+/**
+ * This class is the JBoss Cache implementation of the {@link org.exoplatform.services.cache.ExoCacheFactory}
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 17 juil. 2009
+ */
+public class ExoCacheFactoryImpl implements ExoCacheFactory
+{
+
+ /**
+ * The logger
+ */
+ private static final Log LOG = ExoLogger.getLogger(ExoCacheFactoryImpl.class);
+
+ /**
+ * The initial parameter key that defines the full path of the configuration template
+ */
+ private static final String CACHE_CONFIG_TEMPLATE_KEY = "cache.config.template";
+
+ /**
+ * The configuration manager that allows us to retrieve a configuration file in several different
+ * manners
+ */
+ private final ConfigurationManager configManager;
+
+ /**
+ * The full path of the configuration template
+ */
+ private final String cacheConfigTemplate;
+
+ /**
+ * The mapping between the configuration types and the creators
+ */
+ private final Map<Class<? extends ExoCacheConfig>, ExoCacheCreator> mappingConfigTypeCreators =
+ new HashMap<Class<? extends ExoCacheConfig>, ExoCacheCreator>();
+
+ /**
+ * The mapping between the implementations and the creators. This is mainly used for backward compatibility
+ */
+ private final Map<String, ExoCacheCreator> mappingImplCreators = new HashMap<String, ExoCacheCreator>();
+
+ /**
+ * The mapping between the cache names and the configuration paths
+ */
+ private final Map<String, String> mappingCacheNameConfig = new HashMap<String, String>();
+
+ /**
+ * The default creator
+ */
+ private final ExoCacheCreator defaultCreator = new FIFOExoCacheCreator();
+
+ public ExoCacheFactoryImpl(InitParams params, ConfigurationManager configManager)
+ {
+ this.configManager = configManager;
+ this.cacheConfigTemplate = getValueParam(params, CACHE_CONFIG_TEMPLATE_KEY);
+ if (cacheConfigTemplate == null)
+ {
+ throw new RuntimeException("The parameter '" + CACHE_CONFIG_TEMPLATE_KEY + "' must be set");
+ }
+ }
+
+ /**
+ * To create a new cache instance according to the given configuration, we follow the steps below:
+ *
+ * 1. We first try to find if a specific location of the cache configuration has been defined thanks
+ * to an external component plugin of type ExoCacheFactoryConfigPlugin
+ * 2. If no specific location has been defined, we use the default configuration which is
+ * "${CACHE_CONFIG_TEMPLATE_KEY}"
+ */
+ public ExoCache createCache(ExoCacheConfig config) throws ExoCacheInitException
+ {
+ final String region = config.getName();
+ final String customConfig = mappingCacheNameConfig.get(region);
+ final Cache<Serializable, Object> cache;
+ final CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
+ final ExoCache eXoCache;
+ try
+ {
+ if (customConfig != null)
+ {
+ // A custom configuration has been set
+ if (LOG.isInfoEnabled())
+ LOG.info("A custom configuration has been set for the cache '" + region + "'.");
+ cache = factory.createCache(configManager.getInputStream(customConfig), false);
+ }
+ else
+ {
+ // No custom configuration has been found, a configuration template will be used
+ if (LOG.isInfoEnabled())
+ LOG.info("The configuration template will be used for the the cache '" + region + "'.");
+ cache = factory.createCache(configManager.getInputStream(cacheConfigTemplate), false);
+ if (!config.isDistributed())
+ {
+ // The cache is local
+ cache.getConfiguration().setCacheMode(CacheMode.LOCAL);
+ }
+ // Re initialize the template to avoid conflicts
+ cleanConfigurationTemplate(cache, region);
+ }
+ final ExoCacheCreator creator = getExoCacheCreator(config);
+ // Create the cache
+ eXoCache = creator.create(config, cache);
+ // Create the cache
+ cache.create();
+ // Start the cache
+ cache.start();
+ }
+ catch (Exception e)
+ {
+ throw new ExoCacheInitException("The cache '" + region + "' could not be initialized", e);
+ }
+ return eXoCache;
+ }
+
+ /**
+ * Add a list of creators to register
+ * @param plugin the plugin that contains the creators
+ */
+ public void addCreator(ExoCacheCreatorPlugin plugin)
+ {
+ final List<ExoCacheCreator> creators = plugin.getCreators();
+ for (ExoCacheCreator creator : creators)
+ {
+ mappingConfigTypeCreators.put(creator.getExpectedConfigType(), creator);
+ mappingImplCreators.put(creator.getExpectedImplementation(), creator);
+ }
+ }
+
+ /**
+ * Add a list of custom configuration to register
+ * @param plugin the plugin that contains the configs
+ */
+ public void addConfig(ExoCacheFactoryConfigPlugin plugin)
+ {
+ final Map<String, String> configs = plugin.getConfigs();
+ mappingCacheNameConfig.putAll(configs);
+ }
+
+ /**
+ * Returns the value of the ValueParam if and only if the value is not empty
+ */
+ private static String getValueParam(InitParams params, String key)
+ {
+ if (params == null)
+ {
+ return null;
+ }
+ final ValueParam vp = params.getValueParam(key);
+ String result;
+ if (vp == null || (result = vp.getValue()) == null || (result = result.trim()).length() == 0)
+ {
+ return null;
+ }
+ return result;
+ }
+
+ /**
+ * Returns the most relevant ExoCacheCreator according to the give configuration
+ */
+ protected ExoCacheCreator getExoCacheCreator(ExoCacheConfig config)
+ {
+ ExoCacheCreator creator = mappingConfigTypeCreators.get(config.getClass());
+ if (creator == null)
+ {
+ // No creator for this type has been found, let's try the implementation field
+ creator = mappingImplCreators.get(config.getImplementation());
+ if (creator == null)
+ {
+ // No creator can be found, we will use the default creator
+ if (LOG.isInfoEnabled())
+ LOG.info("No cache creator has been found for the the cache '" + config.getName()
+ + "', the default one will be used.");
+ return defaultCreator;
+ }
+ }
+ if (LOG.isInfoEnabled())
+ LOG.info("The cache '" + config.getName() + "' will be created with '" + creator.getClass() + "'.");
+ return creator;
+ }
+
+ /**
+ * Clean the configuration template to prevent conflicts
+ */
+ protected void cleanConfigurationTemplate(Cache<Serializable, Object> cache, String region)
+ {
+ final Configuration config = cache.getConfiguration();
+ // Reset the eviction policies
+ final EvictionConfig evictionConfig = config.getEvictionConfig();
+ evictionConfig.setEvictionRegionConfigs(new LinkedList<EvictionRegionConfig>());
+ // Rename the cluster name
+ String clusterName = config.getClusterName();
+ if (clusterName != null && (clusterName = clusterName.trim()).length() > 0)
+ {
+ config.setClusterName(clusterName + " " + region);
+ }
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheConfig.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.fifo;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the FIFO implementation
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class FIFOExoCacheConfig extends ExoCacheConfig
+{
+
+ private int maxNodes;
+
+ private long minTimeToLive;
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ this.maxNodes = maxNodes;
+ }
+
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ this.minTimeToLive = minTimeToLive;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/fifo/FIFOExoCacheCreator.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.fifo;
+
+import java.io.Serializable;
+
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
+import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.FIFOAlgorithmConfig;
+
+/**
+ * The FIFO Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 20 juil. 2009
+ */
+public class FIFOExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The expected implementation name
+ */
+ public static final String EXPECTED_IMPL = "FIFO";
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getExpectedImplementation()
+ {
+ return EXPECTED_IMPL;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return FIFOExoCacheConfig.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
+ {
+ if (config instanceof FIFOExoCacheConfig)
+ {
+ final FIFOExoCacheConfig fifoConfig = (FIFOExoCacheConfig)config;
+ return create(config, cache, fifoConfig.getMaxNodes(), fifoConfig.getMinTimeToLive());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cache, config.getMaxSize(), period > 0 ? period * 1000 : 0);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ */
+ private ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long minTimeToLive)
+ throws ExoCacheInitException
+ {
+ final Configuration configuration = cache.getConfiguration();
+ final FIFOAlgorithmConfig fifo = new FIFOAlgorithmConfig(maxNodes);
+ fifo.setMinTimeToLive(minTimeToLive);
+ // Create an eviction region config
+ final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, fifo);
+
+ final EvictionConfig evictionConfig = configuration.getEvictionConfig();
+ evictionConfig.setDefaultEvictionRegionConfig(erc);
+
+ return new AbstractExoCache(config, cache)
+ {
+
+ public void setMaxSize(int max)
+ {
+ fifo.setMaxNodes(max);
+ }
+
+ public void setLiveTime(long period)
+ {
+ fifo.setMinTimeToLive(period);
+ }
+
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return fifo.getMaxNodes();
+ }
+
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time 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.")
+ public long getLiveTime()
+ {
+ return fifo.getMinTimeToLive();
+ }
+ };
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheConfig.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.lfu;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the LFU implementation
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class LFUExoCacheConfig extends ExoCacheConfig
+{
+
+ private int maxNodes;
+
+ private int minNodes;
+
+ private long minTimeToLive;
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ this.maxNodes = maxNodes;
+ }
+
+ public int getMinNodes()
+ {
+ return minNodes;
+ }
+
+ public void setMinNodes(int minNodes)
+ {
+ this.minNodes = minNodes;
+ }
+
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ this.minTimeToLive = minTimeToLive;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lfu/LFUExoCacheCreator.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.lfu;
+
+import java.io.Serializable;
+
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
+import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.LFUAlgorithmConfig;
+
+/**
+ * The LFU Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class LFUExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The expected implementation name
+ */
+ public static final String EXPECTED_IMPL = "LFU";
+
+ /**
+ * The default value for the parameter maxAge
+ */
+ protected int defaultMinNodes;
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
+ {
+ if (config instanceof LFUExoCacheConfig)
+ {
+ final LFUExoCacheConfig lfuConfig = (LFUExoCacheConfig)config;
+ return create(config, cache, lfuConfig.getMaxNodes(), lfuConfig.getMinNodes(), lfuConfig.getMinTimeToLive());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cache, config.getMaxSize(), defaultMinNodes, period > 0 ? period * 1000 : 0);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ */
+ private ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, int minNodes,
+ long minTimeToLive) throws ExoCacheInitException
+ {
+ final Configuration configuration = cache.getConfiguration();
+ final LFUAlgorithmConfig lfu = new LFUAlgorithmConfig(maxNodes, minNodes);
+ lfu.setMinTimeToLive(minTimeToLive);
+ // Create an eviction region config
+ final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, lfu);
+
+ final EvictionConfig evictionConfig = configuration.getEvictionConfig();
+ evictionConfig.setDefaultEvictionRegionConfig(erc);
+ return new LFUExoCache(config, cache, lfu);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return LFUExoCacheConfig.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getExpectedImplementation()
+ {
+ return EXPECTED_IMPL;
+ }
+
+ /**
+ * The LRU implementation of an ExoCache
+ */
+ public static class LFUExoCache extends AbstractExoCache
+ {
+
+ private final LFUAlgorithmConfig lfu;
+
+ public LFUExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache, LFUAlgorithmConfig lfu)
+ {
+ super(config, cache);
+ this.lfu = lfu;
+ }
+
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time 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.")
+ public long getLiveTime()
+ {
+ return lfu.getMinTimeToLive();
+ }
+
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return lfu.getMaxNodes();
+ }
+
+ @Managed
+ @ManagedName("MinNodes")
+ @ManagedDescription("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 timer makes a pass through the eviction algorithm.")
+ public long getMinNodes()
+ {
+ return lfu.getMinNodes();
+ }
+
+ public void setLiveTime(long period)
+ {
+ lfu.setMinTimeToLive(period);
+ }
+
+ public void setMaxSize(int max)
+ {
+ lfu.setMaxNodes(max);
+ }
+
+ @Managed
+ public void setMinNodes(int minNodes)
+ {
+ lfu.setMinNodes(minNodes);
+ }
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheConfig.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.lru;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the LRU implementation
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class LRUExoCacheConfig extends ExoCacheConfig
+{
+
+ private int maxNodes;
+
+ private long timeToLive;
+
+ private long maxAge;
+
+ private long minTimeToLive;
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ this.maxNodes = maxNodes;
+ }
+
+ public long getTimeToLive()
+ {
+ return timeToLive;
+ }
+
+ public void setTimeToLive(long timeToLive)
+ {
+ this.timeToLive = timeToLive;
+ }
+
+ public long getMaxAge()
+ {
+ return maxAge;
+ }
+
+ public void setMaxAge(long maxAge)
+ {
+ this.maxAge = maxAge;
+ }
+
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ this.minTimeToLive = minTimeToLive;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/lru/LRUExoCacheCreator.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.lru;
+
+import java.io.Serializable;
+
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
+import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.LRUAlgorithmConfig;
+
+/**
+ * The LRU Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class LRUExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The expected implementation name
+ */
+ public static final String EXPECTED_IMPL = "LRU";
+
+ /**
+ * The default value for the parameter timeToLive
+ */
+ protected long defaultTimeToLive;
+
+ /**
+ * The default value for the parameter maxAge
+ */
+ protected long defaultMaxAge;
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
+ {
+ if (config instanceof LRUExoCacheConfig)
+ {
+ final LRUExoCacheConfig lruConfig = (LRUExoCacheConfig)config;
+ return create(config, cache, lruConfig.getMaxNodes(), lruConfig.getTimeToLive(), lruConfig.getMaxAge(),
+ lruConfig.getMinTimeToLive());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cache, config.getMaxSize(), defaultTimeToLive, defaultMaxAge, period > 0 ? period * 1000
+ : 0);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ */
+ private ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long timeToLive,
+ long maxAge, long minTimeToLive) throws ExoCacheInitException
+ {
+ final Configuration configuration = cache.getConfiguration();
+ final LRUAlgorithmConfig lru = new LRUAlgorithmConfig(timeToLive, maxAge, maxNodes);
+ lru.setMinTimeToLive(minTimeToLive);
+ // Create an eviction region config
+ final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, lru);
+
+ final EvictionConfig evictionConfig = configuration.getEvictionConfig();
+ evictionConfig.setDefaultEvictionRegionConfig(erc);
+ return new LRUExoCache(config, cache, lru);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return LRUExoCacheConfig.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getExpectedImplementation()
+ {
+ return EXPECTED_IMPL;
+ }
+
+ /**
+ * The LRU implementation of an ExoCache
+ */
+ public static class LRUExoCache extends AbstractExoCache
+ {
+
+ private final LRUAlgorithmConfig lru;
+
+ public LRUExoCache(ExoCacheConfig config, Cache<Serializable, Object> cache, LRUAlgorithmConfig lru)
+ {
+ super(config, cache);
+ this.lru = lru;
+ }
+
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time 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.")
+ public long getLiveTime()
+ {
+ return lru.getMinTimeToLive();
+ }
+
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return lru.getMaxNodes();
+ }
+
+ @Managed
+ @ManagedName("TimeToLive")
+ @ManagedDescription("The amount of time a node is not written to or read (in milliseconds) before the node is swept away. 0 denotes immediate expiry, -1 denotes no limit.")
+ public long getTimeToLive()
+ {
+ return lru.getTimeToLive();
+ }
+
+ @Managed
+ @ManagedName("MaxAges")
+ @ManagedDescription("Lifespan of a node (in milliseconds) regardless of idle time before the node is swept away. 0 denotes immediate expiry, -1 denotes no limit.")
+ public long getMaxAge()
+ {
+ return lru.getMaxAge();
+ }
+
+ public void setLiveTime(long period)
+ {
+ lru.setMinTimeToLive(period);
+ }
+
+ public void setMaxSize(int max)
+ {
+ lru.setMaxNodes(max);
+ }
+
+ @Managed
+ public void setTimeToLive(long timeToLive)
+ {
+ lru.setTimeToLive(timeToLive);
+ }
+
+ @Managed
+ public void setMaxAge(long maxAge)
+ {
+ lru.setMaxAge(maxAge);
+ }
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheConfig.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.mru;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * The {@link org.exoplatform.services.cache.ExoCacheConfig} for the MRU implementation
+ *
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class MRUExoCacheConfig extends ExoCacheConfig
+{
+
+ private int maxNodes;
+
+ private long minTimeToLive;
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ this.maxNodes = maxNodes;
+ }
+
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ this.minTimeToLive = minTimeToLive;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/java/org/exoplatform/services/cache/impl/jboss/mru/MRUExoCacheCreator.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss.mru;
+
+import java.io.Serializable;
+
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.exoplatform.services.cache.impl.jboss.AbstractExoCache;
+import org.exoplatform.services.cache.impl.jboss.ExoCacheCreator;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.MRUAlgorithmConfig;
+
+/**
+ * The MRU Implementation of an {@link org.exoplatform.services.cache.impl.jboss.ExoCacheCreator}
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class MRUExoCacheCreator implements ExoCacheCreator
+{
+
+ /**
+ * The expected implementation name
+ */
+ public static final String EXPECTED_IMPL = "MRU";
+
+ /**
+ * {@inheritDoc}
+ */
+ public ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
+ {
+ if (config instanceof MRUExoCacheConfig)
+ {
+ final MRUExoCacheConfig mruConfig = (MRUExoCacheConfig)config;
+ return create(config, cache, mruConfig.getMaxNodes(), mruConfig.getMinTimeToLive());
+ }
+ else
+ {
+ final long period = config.getLiveTime();
+ return create(config, cache, config.getMaxSize(), period > 0 ? period * 1000 : 0);
+ }
+ }
+
+ /**
+ * Creates a new ExoCache instance with the relevant parameters
+ */
+ private ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache, int maxNodes, long minTimeToLive)
+ throws ExoCacheInitException
+ {
+ final Configuration configuration = cache.getConfiguration();
+ final MRUAlgorithmConfig mru = new MRUAlgorithmConfig(maxNodes);
+ mru.setMinTimeToLive(minTimeToLive);
+ // Create an eviction region config
+ final EvictionRegionConfig erc = new EvictionRegionConfig(Fqn.ROOT, mru);
+
+ final EvictionConfig evictionConfig = configuration.getEvictionConfig();
+ evictionConfig.setDefaultEvictionRegionConfig(erc);
+
+ return new AbstractExoCache(config, cache)
+ {
+
+ public void setMaxSize(int max)
+ {
+ mru.setMaxNodes(max);
+ }
+
+ public void setLiveTime(long period)
+ {
+ mru.setMinTimeToLive(period);
+ }
+
+ @ManagedName("MaxNodes")
+ @ManagedDescription("This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.")
+ public int getMaxSize()
+ {
+ return mru.getMaxNodes();
+ }
+
+ @ManagedName("MinTimeToLive")
+ @ManagedDescription("the minimum amount of time 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.")
+ public long getLiveTime()
+ {
+ return mru.getMinTimeToLive();
+ }
+ };
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return MRUExoCacheConfig.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getExpectedImplementation()
+ {
+ return EXPECTED_IMPL;
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/cache-configuration-template.xml 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <!--
+ isolation levels supported: READ_COMMITTED and REPEATABLE_READ nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic (deprecated)
+ -->
+ <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" nodeLockingScheme="mvcc"
+ writeSkewCheck="false" concurrencyLevel="500" />
+
+ <!--
+ Used to register a transaction manager and participate in ongoing
+ transactions.
+ -->
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" syncRollbackPhase="false"
+ syncCommitPhase="false" />
+
+
+ <!--
+ Used to register JMX statistics in any available MBean server
+ -->
+ <jmxStatistics enabled="false" />
+
+ <!--
+ If region based marshalling is used, defines whether new regions are
+ inactive on startup.
+ -->
+ <startup regionsInactiveOnStartup="true" />
+
+ <!--
+ Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER,
+ DONT_REGISTER
+ -->
+ <shutdown hookBehavior="DEFAULT" />
+
+ <!--
+ Used to define async listener notification thread pool size
+ -->
+ <listeners asyncPoolSize="1" asyncQueueSize="100000" />
+
+ <!--
+ Used to enable invocation batching and allow the use of
+ Cache.startBatch()/endBatch() methods.
+ -->
+ <invocationBatching enabled="true" />
+
+
+ <!--
+ This element specifies that the cache is clustered. modes supported:
+ replication (r) or invalidation (i).
+ -->
+ <clustering mode="replication" clusterName="JBossCache-cluster">
+
+ <!--
+ Defines whether to retrieve state on startup
+ -->
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
+
+ <!--
+ Network calls are synchronous.
+ -->
+ <sync replTimeout="20000" />
+
+ <!--
+ Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml ships with jgroups.jar and will be picked up by
+ the class loader.
+ -->
+ <jgroupsConfig configFile="udp.xml">
+ </jgroupsConfig>
+ </clustering>
+
+ <!--
+ Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means the eviction thread will never run.
+ -->
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="200000">
+ <property name="maxNodes" value="3000" />
+ <property name="timeToLive" value="0" />
+ </default>
+ </eviction>
+</jbosscache>
+
Added: kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/main/resources/conf/portal/configuration.xml 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration>
+ <component>
+ <key>org.exoplatform.services.cache.ExoCacheFactory</key>
+ <type>org.exoplatform.services.cache.impl.jboss.ExoCacheFactoryImpl</type>
+ <init-params>
+ <value-param>
+ <name>cache.config.template</name>
+ <value>jar:/conf/portal/cache-configuration-template.xml</value>
+ </value-param>
+ </init-params>
+ </component>
+</configuration>
Added: kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestAbstractExoCache.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,643 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheFactory;
+import org.exoplatform.services.cache.ObjectCacheInfo;
+import org.exoplatform.test.BasicTestCase;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestAbstractExoCache extends BasicTestCase
+{
+
+ CacheService service;
+
+ AbstractExoCache cache;
+
+ ExoCacheFactory factory;
+
+ public TestAbstractExoCache(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ this.service = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ this.cache = (AbstractExoCache)service.getCacheInstance("myCache");
+ this.factory = (ExoCacheFactory)PortalContainer.getInstance().getComponentInstanceOfType(ExoCacheFactory.class);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ cache.clearCache();
+ }
+
+ public void testPut() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ assertEquals(3, cache.getCacheSize());
+ cache.put(new MyKey("a"), "c");
+ assertEquals(3, cache.getCacheSize());
+ cache.put(new MyKey("d"), "c");
+ assertEquals(4, cache.getCacheSize());
+ }
+
+ public void testClearCache() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ assertTrue(cache.getCacheSize() > 0);
+ cache.clearCache();
+ assertTrue(cache.getCacheSize() == 0);
+ }
+
+ public void testGet() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ assertEquals("a", cache.get(new MyKey("a")));
+ cache.put(new MyKey("a"), "c");
+ assertEquals("c", cache.get(new MyKey("a")));
+ cache.remove(new MyKey("a"));
+ assertEquals(null, cache.get(new MyKey("a")));
+ assertEquals(null, cache.get(new MyKey("x")));
+ }
+
+ public void testRemove() throws Exception
+ {
+ cache.put(new MyKey("a"), 1);
+ cache.put(new MyKey("b"), 2);
+ cache.put(new MyKey("c"), 3);
+ assertEquals(3, cache.getCacheSize());
+ assertEquals(1, cache.remove(new MyKey("a")));
+ assertEquals(2, cache.getCacheSize());
+ assertEquals(2, cache.remove(new MyKey("b")));
+ assertEquals(1, cache.getCacheSize());
+ assertEquals(null, cache.remove(new MyKey("x")));
+ assertEquals(1, cache.getCacheSize());
+ }
+
+ public void testPutMap() throws Exception
+ {
+ Map<Serializable, Object> values = new HashMap<Serializable, Object>();
+ values.put(new MyKey("a"), "a");
+ values.put(new MyKey("b"), "b");
+ assertEquals(0, cache.getCacheSize());
+ cache.putMap(values);
+ assertEquals(2, cache.getCacheSize());
+ values = new HashMap<Serializable, Object>()
+ {
+ public Set<Entry<Serializable, Object>> entrySet()
+ {
+ Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
+ set.add(new Entry<Serializable, Object>()
+ {
+
+ public Object setValue(Object paramV)
+ {
+ return null;
+ }
+
+ public Object getValue()
+ {
+ throw new RuntimeException("An exception");
+ }
+
+ public Serializable getKey()
+ {
+ return "c";
+ }
+ });
+ return set;
+ }
+ };
+ values.put(new MyKey("e"), "e");
+ values.put(new MyKey("d"), "d");
+ try
+ {
+ cache.putMap(values);
+ assertTrue("An error was expected", false);
+ }
+ catch (Exception e)
+ {
+ }
+ assertEquals(2, cache.getCacheSize());
+ }
+
+ public void testGetCachedObjects() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ cache.put(new MyKey("d"), null);
+ assertEquals(4, cache.getCacheSize());
+ List<Object> values = cache.getCachedObjects();
+ assertEquals(3, values.size());
+ assertTrue(values.contains("a"));
+ assertTrue(values.contains("b"));
+ assertTrue(values.contains("c"));
+ }
+
+ public void testRemoveCachedObjects() throws Exception
+ {
+ cache.put(new MyKey("a"), "a");
+ cache.put(new MyKey("b"), "b");
+ cache.put(new MyKey("c"), "c");
+ cache.put(new MyKey("d"), null);
+ assertEquals(4, cache.getCacheSize());
+ List<Object> values = cache.removeCachedObjects();
+ assertEquals(3, values.size());
+ assertTrue(values.contains("a"));
+ assertTrue(values.contains("b"));
+ assertTrue(values.contains("c"));
+ assertEquals(0, cache.getCacheSize());
+ }
+
+ public void testSelect() throws Exception
+ {
+ cache.put(new MyKey("a"), 1);
+ cache.put(new MyKey("b"), 2);
+ cache.put(new MyKey("c"), 3);
+ final AtomicInteger count = new AtomicInteger();
+ CachedObjectSelector selector = new CachedObjectSelector()
+ {
+
+ public void onSelect(ExoCache cache, Serializable key, ObjectCacheInfo ocinfo) throws Exception
+ {
+ assertTrue(key.equals(new MyKey("a")) || key.equals(new MyKey("b")) || key.equals(new MyKey("c")));
+ assertTrue(ocinfo.get().equals(1) || ocinfo.get().equals(2) || ocinfo.get().equals(3));
+ count.incrementAndGet();
+ }
+
+ public boolean select(Serializable key, ObjectCacheInfo ocinfo)
+ {
+ return true;
+ }
+ };
+ cache.select(selector);
+ assertEquals(3, count.intValue());
+ }
+
+ public void testGetHitsNMisses() throws Exception
+ {
+ int hits = cache.getCacheHit();
+ int misses = cache.getCacheMiss();
+ cache.put(new MyKey("a"), "a");
+ cache.get(new MyKey("a"));
+ cache.remove(new MyKey("a"));
+ cache.get(new MyKey("a"));
+ cache.get(new MyKey("z"));
+ assertEquals(1, cache.getCacheHit() - hits);
+ assertEquals(2, cache.getCacheMiss() - misses);
+ }
+
+ public void testDistributedCache() throws Exception
+ {
+ ExoCacheConfig config = new ExoCacheConfig();
+ config.setName("MyCacheDistributed");
+ config.setMaxSize(5);
+ config.setLiveTime(1000);
+ config.setDistributed(true);
+ ExoCacheConfig config2 = new ExoCacheConfig();
+ config2.setName("MyCacheDistributed2");
+ config2.setMaxSize(5);
+ config2.setLiveTime(1000);
+ config2.setDistributed(true);
+ AbstractExoCache cache1 = (AbstractExoCache)factory.createCache(config);
+ MyCacheListener listener1 = new MyCacheListener();
+ cache1.addCacheListener(listener1);
+ AbstractExoCache cache2 = (AbstractExoCache)factory.createCache(config);
+ MyCacheListener listener2 = new MyCacheListener();
+ cache2.addCacheListener(listener2);
+ AbstractExoCache cache3 = (AbstractExoCache)factory.createCache(config2);
+ MyCacheListener listener3 = new MyCacheListener();
+ cache3.addCacheListener(listener3);
+ try
+ {
+ cache1.put(new MyKey("a"), "b");
+ assertEquals(1, cache1.getCacheSize());
+ assertEquals("b", cache2.get(new MyKey("a")));
+ assertEquals(1, 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"), "c");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals("c", 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"), "d");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals(1, cache3.getCacheSize());
+ assertEquals("d", cache3.get(new MyKey("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"), "a");
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals("a", 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(1, 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.clearCache();
+ assertEquals(0, cache1.getCacheSize());
+ assertEquals(null, cache2.get(new MyKey("b")));
+ assertEquals(0, cache2.getCacheSize());
+ assertEquals(3, listener1.put);
+ assertEquals(3, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(2, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(2, listener1.remove);
+ assertEquals(2, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ Map<Serializable, Object> values = new HashMap<Serializable, Object>();
+ values.put(new MyKey("a"), "a");
+ values.put(new MyKey("b"), "b");
+ cache1.putMap(values);
+ assertEquals(2, cache1.getCacheSize());
+ Thread.sleep(40);
+ assertEquals("a", cache2.get(new MyKey("a")));
+ assertEquals("b", cache2.get(new MyKey("b")));
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals(5, listener1.put);
+ assertEquals(5, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(4, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(2, listener1.remove);
+ assertEquals(2, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ values = new HashMap<Serializable, Object>()
+ {
+ public Set<Entry<Serializable, Object>> entrySet()
+ {
+ Set<Entry<Serializable, Object>> set = new LinkedHashSet<Entry<Serializable, Object>>(super.entrySet());
+ set.add(new Entry<Serializable, Object>()
+ {
+
+ public Object setValue(Object paramV)
+ {
+ return null;
+ }
+
+ public Object getValue()
+ {
+ throw new RuntimeException("An exception");
+ }
+
+ public Serializable getKey()
+ {
+ return "c";
+ }
+ });
+ return set;
+ }
+ };
+ values.put(new MyKey("e"), "e");
+ values.put(new MyKey("d"), "d");
+ try
+ {
+ cache1.putMap(values);
+ assertTrue("An error was expected", false);
+ }
+ catch (Exception e)
+ {
+ }
+ assertEquals(2, cache1.getCacheSize());
+ assertEquals(2, cache2.getCacheSize());
+ assertEquals(5, listener1.put);
+ assertEquals(5, listener2.put);
+ assertEquals(1, listener3.put);
+ assertEquals(2, listener1.get);
+ assertEquals(4, listener2.get);
+ assertEquals(1, listener3.get);
+ assertEquals(2, listener1.remove);
+ assertEquals(2, listener2.remove);
+ assertEquals(0, listener3.remove);
+ assertEquals(1, listener1.clearCache);
+ assertEquals(0, listener2.clearCache);
+ assertEquals(0, listener3.clearCache);
+ }
+ finally
+ {
+ cache1.cache.stop();
+ cache2.cache.stop();
+ cache3.cache.stop();
+ }
+ }
+
+ public void testMultiThreading() throws Exception
+ {
+ final ExoCache cache = service.getCacheInstance("test-multi-threading");
+ final int totalElement = 100;
+ final int totalTimes = 100;
+ int reader = 20;
+ int writer = 10;
+ int remover = 5;
+ int cleaner = 1;
+ final CountDownLatch startSignalWriter = new CountDownLatch(1);
+ final CountDownLatch startSignalOthers = new CountDownLatch(1);
+ final CountDownLatch doneSignal = new CountDownLatch(reader + writer + remover);
+ final List<Exception> errors = Collections.synchronizedList(new ArrayList<Exception>());
+ for (int i = 0; i < writer; i++)
+ {
+ final int index = i;
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignalWriter.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.put(new MyKey("key" + i), "value" + i);
+ }
+ if (index == 0 && j == 0)
+ {
+ // The cache is full, we can launch the others
+ startSignalOthers.countDown();
+ }
+ sleep(50);
+ }
+ doneSignal.countDown();
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ }
+ };
+ thread.start();
+ }
+ startSignalWriter.countDown();
+ for (int i = 0; i < reader; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignalOthers.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.get(new MyKey("key" + i));
+ }
+ sleep(50);
+ }
+ doneSignal.countDown();
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ }
+ };
+ thread.start();
+ }
+ for (int i = 0; i < remover; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignalOthers.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.remove(new MyKey("key" + i));
+ }
+ sleep(50);
+ }
+ doneSignal.countDown();
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ }
+ };
+ thread.start();
+ }
+ doneSignal.await();
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.put(new MyKey("key" + i), "value" + i);
+ }
+ assertEquals(totalElement, cache.getCacheSize());
+ final CountDownLatch startSignal = new CountDownLatch(1);
+ final CountDownLatch doneSignal2 = new CountDownLatch(writer + cleaner);
+ for (int i = 0; i < writer; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignal.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ for (int i = 0; i < totalElement; i++)
+ {
+ cache.put(new MyKey("key" + i), "value" + i);
+ }
+ sleep(50);
+ }
+ doneSignal2.countDown();
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ }
+ };
+ thread.start();
+ }
+ for (int i = 0; i < cleaner; i++)
+ {
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ startSignal.await();
+ for (int j = 0; j < totalTimes; j++)
+ {
+ sleep(150);
+ cache.clearCache();
+ }
+ doneSignal2.countDown();
+ }
+ catch (Exception e)
+ {
+ errors.add(e);
+ }
+ }
+ };
+ thread.start();
+ }
+ cache.clearCache();
+ assertEquals(0, cache.getCacheSize());
+ if (!errors.isEmpty())
+ {
+ for (Exception e : errors)
+ {
+ e.printStackTrace();
+ }
+ throw errors.get(0);
+ }
+
+ }
+
+ public static class MyCacheListener implements CacheListener
+ {
+
+ public int clearCache;
+
+ public int expire;
+
+ public int get;
+
+ public int put;
+
+ public int remove;
+
+ public void onClearCache(ExoCache cache) throws Exception
+ {
+ clearCache++;
+ }
+
+ public void onExpire(ExoCache cache, Serializable key, Object obj) throws Exception
+ {
+ expire++;
+ }
+
+ public void onGet(ExoCache cache, Serializable key, Object obj) throws Exception
+ {
+ get++;
+ }
+
+ public void onPut(ExoCache cache, Serializable key, Object obj) throws Exception
+ {
+ put++;
+ }
+
+ public void onRemove(ExoCache cache, Serializable key, Object obj) throws Exception
+ {
+ remove++;
+ }
+ }
+
+ public static class MyKey implements Serializable
+ {
+ public String value;
+
+ public MyKey(String value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object paramObject)
+ {
+ return paramObject instanceof MyKey && ((MyKey)paramObject).value.endsWith(value);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheConfig.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.services.cache.ExoCacheConfig;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestExoCacheConfig extends ExoCacheConfig
+{
+
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheCreator.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.services.cache.CacheListener;
+import org.exoplatform.services.cache.CachedObjectSelector;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ExoCacheConfig;
+import org.exoplatform.services.cache.ExoCacheInitException;
+import org.jboss.cache.Cache;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestExoCacheCreator implements ExoCacheCreator
+{
+
+ public ExoCache create(ExoCacheConfig config, Cache<Serializable, Object> cache) throws ExoCacheInitException
+ {
+ return new TestExoCache();
+ }
+
+ public Class<? extends ExoCacheConfig> getExpectedConfigType()
+ {
+ return TestExoCacheConfig.class;
+ }
+
+ public String getExpectedImplementation()
+ {
+ return "TEST";
+ }
+
+ public static class TestExoCache implements ExoCache
+ {
+
+ public void addCacheListener(CacheListener listener)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void clearCache() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object get(Serializable name) throws Exception
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getCacheHit()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getCacheMiss()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getCacheSize()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public List getCachedObjects()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getLabel()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public long getLiveTime()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getMaxSize()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getName()
+ {
+ return "name";
+ }
+
+ public boolean isDistributed()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isLogEnabled()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isReplicated()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void put(Serializable name, Object obj) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void putMap(Map<Serializable, Object> objs) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object remove(Serializable name) throws Exception
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List removeCachedObjects() throws Exception
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void select(CachedObjectSelector selector) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setDistributed(boolean b)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLabel(String s)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLiveTime(long period)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLogEnabled(boolean b)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setMaxSize(int max)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setName(String name)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setReplicated(boolean b)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestExoCacheFactoryImpl.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.impl.jboss.TestExoCacheCreator.TestExoCache;
+import org.exoplatform.test.BasicTestCase;
+import org.jboss.cache.config.Configuration.CacheMode;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 20 juil. 2009
+ */
+public class TestExoCacheFactoryImpl extends BasicTestCase
+{
+
+ CacheService service_;
+
+ public TestExoCacheFactoryImpl(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ }
+
+ public void testCacheFactory()
+ {
+ ExoCache cache = service_.getCacheInstance("myCache");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ AbstractExoCache aCache = (AbstractExoCache)cache;
+ assertTrue("expect a local cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.LOCAL);
+ aCache.cache.stop();
+ cache = service_.getCacheInstance("cacheDistributed");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ aCache = (AbstractExoCache)cache;
+ assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
+ aCache.cache.stop();
+ cache = service_.getCacheInstance("myCustomCache");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ aCache = (AbstractExoCache)cache;
+ assertTrue("expect a distributed cache", aCache.cache.getConfiguration().getCacheMode() == CacheMode.REPL_SYNC);
+ aCache.cache.stop();
+ }
+
+ public void testExoCacheCreator()
+ {
+ ExoCache cache = service_.getCacheInstance("test-default-impl");
+ assertTrue("expect an instance of AbstractExoCache", cache instanceof AbstractExoCache);
+ AbstractExoCache aCache = (AbstractExoCache)cache;
+ aCache.cache.stop();
+ cache = service_.getCacheInstance("test-custom-impl-with-old-config");
+ assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
+ cache = service_.getCacheInstance("test-custom-impl-with-new-config");
+ assertTrue("expect an instance of TestExoCache", cache instanceof TestExoCache);
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestFIFOCache.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.test.BasicTestCase;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestFIFOCache extends BasicTestCase
+{
+
+ CacheService service_;
+
+ public TestFIFOCache(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ }
+
+ public void testPolicy() throws Exception
+ {
+ testPolicy("test-fifo");
+ testPolicy("test-fifo-with-old-config");
+ }
+
+ private void testPolicy(String cacheName) throws Exception
+ {
+ ExoCache cache = service_.getCacheInstance(cacheName);
+ cache.put("a", "a");
+ cache.put("b", "a");
+ cache.put("c", "a");
+ cache.put("d", "a");
+ assertEquals(4, cache.getCacheSize());
+ cache.put("e", "a");
+ assertEquals(5, cache.getCacheSize());
+ cache.put("f", "a");
+ assertEquals(6, cache.getCacheSize());
+ Thread.sleep(500);
+ assertEquals(6, cache.getCacheSize());
+ Thread.sleep(600);
+ assertEquals(5, cache.getCacheSize());
+ cache.setMaxSize(3);
+ cache.setLiveTime(1500);
+ cache.put("g", "a");
+ assertEquals(6, cache.getCacheSize());
+ Thread.sleep(1100);
+ assertEquals(3, cache.getCacheSize());
+ cache.put("h", "a");
+ cache.put("i", "a");
+ cache.put("j", "a");
+ cache.put("k", "a");
+ assertEquals(7, cache.getCacheSize());
+ Thread.sleep(500);
+ assertEquals(4, cache.getCacheSize());
+ Thread.sleep(1100);
+ assertEquals(3, cache.getCacheSize());
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/java/org/exoplatform/services/cache/impl/jboss/TestLRUCache.java 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.cache.impl.jboss;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheCreator.LRUExoCache;
+import org.exoplatform.test.BasicTestCase;
+
+/**
+ * Created by The eXo Platform SAS
+ * Author : eXoPlatform
+ * exo(a)exoplatform.com
+ * 21 juil. 2009
+ */
+public class TestLRUCache extends BasicTestCase
+{
+
+ CacheService service_;
+
+ public TestLRUCache(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ service_ = (CacheService)PortalContainer.getInstance().getComponentInstanceOfType(CacheService.class);
+ }
+
+ public void testPolicy() throws Exception
+ {
+ testPolicy("test-lru");
+ testPolicy("test-lru-with-old-config");
+ }
+
+ private void testPolicy(String cacheName) throws Exception
+ {
+ LRUExoCache cache = (LRUExoCache)service_.getCacheInstance(cacheName);
+ cache.put("a", "a");
+ cache.put("b", "a");
+ cache.put("c", "a");
+ cache.put("d", "a");
+ assertEquals(4, cache.getCacheSize());
+ cache.put("e", "a");
+ assertEquals(5, cache.getCacheSize());
+ cache.put("f", "a");
+ assertEquals(6, cache.getCacheSize());
+ Thread.sleep(1000);
+ assertFalse(cache.get("b") == null);
+ assertFalse(cache.get("c") == null);
+ assertFalse(cache.get("d") == null);
+ Thread.sleep(600);
+ assertEquals(3, cache.getCacheSize());
+ Thread.sleep(500);
+ assertEquals(0, cache.getCacheSize());
+ cache.setMaxSize(3);
+ cache.setTimeToLive(500);
+ cache.setMaxAge(1000);
+ cache.put("a", "a");
+ cache.put("b", "a");
+ cache.put("c", "a");
+ cache.put("d", "a");
+ assertEquals(4, cache.getCacheSize());
+ cache.put("e", "a");
+ assertEquals(5, cache.getCacheSize());
+ cache.put("f", "a");
+ Thread.sleep(500);
+ cache.get("a");
+ cache.get("b");
+ assertEquals(3, cache.getCacheSize());
+ Thread.sleep(600);
+ assertEquals(0, cache.getCacheSize());
+ }
+}
Added: kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/cache-configuration-template.xml 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <!--
+ isolation levels supported: READ_COMMITTED and REPEATABLE_READ nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic (deprecated)
+ -->
+ <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" nodeLockingScheme="mvcc"
+ writeSkewCheck="false" concurrencyLevel="500" />
+
+
+ <!--
+ Used to register a transaction manager and participate in ongoing
+ transactions.
+ -->
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" syncRollbackPhase="false"
+ syncCommitPhase="false" />
+
+
+ <!--
+ Used to register JMX statistics in any available MBean server
+ -->
+ <jmxStatistics enabled="false" />
+
+ <!--
+ If region based marshalling is used, defines whether new regions are
+ inactive on startup.
+ -->
+ <startup regionsInactiveOnStartup="true" />
+
+ <!--
+ Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER,
+ DONT_REGISTER
+ -->
+ <shutdown hookBehavior="DEFAULT" />
+
+
+ <!--
+ Used to define async listener notification thread pool size
+ -->
+ <listeners asyncPoolSize="1" asyncQueueSize="100000" />
+
+ <!--
+ Used to enable invocation batching and allow the use of
+ Cache.startBatch()/endBatch() methods.
+ -->
+ <invocationBatching enabled="false" />
+
+ <!--
+ serialization related configuration, used for replication and cache
+ loading
+ -->
+
+ <!--
+ serialization objectInputStreamPoolSize="12" objectOutputStreamPoolSize="14" version="3.0.0"
+ marshallerClass="org.jboss.cache.marshall.VersionAwareMarshaller" useLazyDeserialization="false" useRegionBasedMarshalling="false" /
+ -->
+
+ <!--
+ This element specifies that the cache is clustered. modes supported:
+ replication (r) or invalidation (i).
+ -->
+ <clustering mode="replication" clusterName="JBossCache-cluster">
+
+ <!--
+ Defines whether to retrieve state on startup
+ -->
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
+
+ <!--
+ Network calls are synchronous.
+ -->
+ <sync replTimeout="20000" />
+
+ <!--
+ Uncomment this for async replication.
+ -->
+
+ <!--
+ <async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20"
+ serializationExecutorQueueSize="5000000"/>
+ -->
+
+ <!-- Uncomment to use Buddy Replication -->
+ <!--
+ <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000"> <dataGravitation auto="true" removeOnFind="true"
+ searchBackupTrees="true"/> <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator"> <properties> numBuddies = 1 ignoreColocatedBuddies
+ = true </properties> </locator> </buddy>
+ -->
+
+ <!--
+ Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml ships with jgroups.jar and will be picked up by
+ the class loader.
+ -->
+ <jgroupsConfig configFile="udp.xml">
+ <!--
+ uncomment to define a JGroups stack here <PING timeout="2000" num_initial_members="3"/> <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/> <FD timeout="10000" max_tries="5" shun="true"/> <VERIFY_SUSPECT timeout="1500"/> <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+
+ retransmit_timeout="300,600,1200,2400,4800" discard_delivered_msgs="true"/> <UNICAST timeout="300,600,1200,2400,3600"/> <pbcast.STABLE
+ stability_delay="1000" desired_avg_gossip="50000" max_bytes="400000"/> <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/> <FRAG2 frag_size="60000"/> <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+
+ <pbcast.FLUSH timeout="0"/>
+ -->
+ </jgroupsConfig>
+ </clustering>
+
+ <!--
+ Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means the eviction thread will never run.
+ -->
+ <eviction wakeUpInterval="50">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <property name="maxNodes" value="1" />
+ <property name="timeToLive" value="5000" />
+ </default>
+ <!--
+ region name="/org/jboss/data1"> <property name="timeToLive" value="2000" /> </region> <region name="/org/jboss/data2"
+ algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="100000"> <property name="maxNodes" value="3000" /> <property
+ name="minTimeToLive" value="4000" /> </region
+ -->
+ </eviction>
+
+ <!--
+ Cache loaders. If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state is accessed again, it is
+ removed from the cache loader and loaded into memory. Otherwise, state is always maintained in the cache loader as well as in memory. Set 'shared' to true
+ if all instances in the cluster use the same cache loader instance, e.g., are talking to the same database.
+ -->
+ <!--
+ <loaders passivation="false" shared="false"> <preload> <node fqn="/org/jboss" /> <node fqn="/org/tempdata" /> </preload>
+ -->
+ <!--
+ we can have multiple cache loaders, which get chained
+ -->
+
+ <!--
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true" ignoreModifications="true" purgeOnStartup="true">
+
+ <properties> cache.jdbc.table.name=jbosscache cache.jdbc.table.create=true cache.jdbc.table.drop=true </properties> <singletonStore enabled="true"
+ class="org.jboss.cache.loader.SingletonStoreCacheLoader"> <properties> pushStateWhenCoordinator=true pushStateWhenCoordinatorTimeout=20000 </properties>
+
+ </singletonStore> </loader> </loaders>
+ -->
+
+
+ <!--
+
+ Define custom interceptors. All custom interceptors need to extend
+ org.jboss.cache.interceptors.base.CommandInterceptor
+ -->
+
+ <!--
+
+ <customInterceptors> <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"> <property
+ name="attrOne" value="value1" /> <property name="attrTwo" value="value2" /> </interceptor> <interceptor position="last"
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor index="3"
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> <interceptor before="org.jboss.cache.interceptors.CallInterceptor"
+
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor after="org.jboss.cache.interceptors.CallInterceptor"
+
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> </customInterceptors>
+ -->
+</jbosscache>
+
Added: kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/distributed-cache-configuration-template.xml 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.1">
+
+ <!--
+ isolation levels supported: READ_COMMITTED and REPEATABLE_READ
+
+ nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic
+ (deprecated)
+ -->
+
+ <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" nodeLockingScheme="mvcc"
+ writeSkewCheck="false" concurrencyLevel="500" />
+
+ <!--
+ Used to register a transaction manager and participate in ongoing
+ transactions.
+ -->
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" syncRollbackPhase="false"
+ syncCommitPhase="false" />
+
+ <!--
+ Used to register JMX statistics in any available MBean server
+ -->
+ <jmxStatistics enabled="false" />
+
+ <!--
+ If region based marshalling is used, defines whether new regions are
+ inactive on startup.
+ -->
+ <startup regionsInactiveOnStartup="true" />
+
+ <!--
+ Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER,
+ DONT_REGISTER
+ -->
+ <shutdown hookBehavior="DEFAULT" />
+
+ <!--
+ Used to define async listener notification thread pool size
+ -->
+ <listeners asyncPoolSize="1" asyncQueueSize="100000" />
+
+ <!--
+ Used to enable invocation batching and allow the use of
+ Cache.startBatch()/endBatch() methods.
+ -->
+ <invocationBatching enabled="false" />
+
+ <!--
+ serialization related configuration, used for replication and cache
+ loading
+ -->
+
+ <!--
+ serialization objectInputStreamPoolSize="12" objectOutputStreamPoolSize="14" version="3.0.0"
+
+ marshallerClass="org.jboss.cache.marshall.VersionAwareMarshaller" useLazyDeserialization="false" useRegionBasedMarshalling="false" /
+ -->
+
+ <!--
+ This element specifies that the cache is clustered. modes supported:
+ replication (r) or invalidation (i).
+ -->
+ <clustering mode="replication" clusterName="JBossCache-cluster">
+
+
+ <!--
+ Defines whether to retrieve state on startup
+ -->
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
+
+ <!--
+ Network calls are synchronous.
+ -->
+ <sync replTimeout="20000" />
+
+ <!--
+ Uncomment this for async replication.
+ -->
+
+ <!--
+ <async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20"
+ serializationExecutorQueueSize="5000000"/>
+ -->
+
+ <!-- Uncomment to use Buddy Replication -->
+ <!--
+ <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000"> <dataGravitation auto="true" removeOnFind="true"
+ searchBackupTrees="true"/> <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator"> <properties> numBuddies = 1 ignoreColocatedBuddies
+ = true </properties> </locator> </buddy>
+ -->
+
+ <!--
+
+ Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml ships with jgroups.jar and will be picked up by
+ the class loader.
+ -->
+ <jgroupsConfig configFile="udp.xml">
+ <!--
+ uncomment to define a JGroups stack here <PING timeout="2000" num_initial_members="3"/> <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/> <FD timeout="10000" max_tries="5" shun="true"/> <VERIFY_SUSPECT timeout="1500"/> <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+
+ retransmit_timeout="300,600,1200,2400,4800" discard_delivered_msgs="true"/> <UNICAST timeout="300,600,1200,2400,3600"/> <pbcast.STABLE
+ stability_delay="1000" desired_avg_gossip="50000" max_bytes="400000"/> <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/> <FRAG2 frag_size="60000"/> <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+
+ <pbcast.FLUSH timeout="0"/>
+ -->
+ </jgroupsConfig>
+ </clustering>
+
+ <!--
+
+ Eviction configuration. WakeupInterval defines how often the eviction
+ thread runs, in milliseconds. 0 means the eviction thread will never
+ run.
+ -->
+ <eviction wakeUpInterval="500">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <property name="maxNodes" value="1" />
+ <property name="timeToLive" value="5000" />
+ </default>
+
+ <!--
+ region name="/org/jboss/data1"> <property name="timeToLive" value="2000" /> </region> <region name="/org/jboss/data2"
+ algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="100000"> <property name="maxNodes" value="3000" /> <property
+ name="minTimeToLive" value="4000" /> </region
+ -->
+ </eviction>
+
+ <!--
+ Cache loaders. If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state is accessed again, it is
+ removed from the cache loader and loaded into memory. Otherwise, state is always maintained in the cache loader as well as in memory. Set 'shared' to true
+ if all instances in the cluster use the same cache loader instance, e.g., are talking to the same database.
+ -->
+ <!--
+ <loaders passivation="false" shared="false">
+ <preload>
+ <node fqn="/org/jboss" />
+ <node fqn="/org/tempdata" />
+ </preload>
+ -->
+
+ <!--
+ we can have multiple cache loaders, which get chained
+ -->
+
+ <!--
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true" ignoreModifications="true" purgeOnStartup="true">
+
+ <properties> cache.jdbc.table.name=jbosscache cache.jdbc.table.create=true cache.jdbc.table.drop=true </properties> <singletonStore enabled="true"
+ class="org.jboss.cache.loader.SingletonStoreCacheLoader"> <properties> pushStateWhenCoordinator=true pushStateWhenCoordinatorTimeout=20000 </properties>
+
+ </singletonStore> </loader> </loaders>
+ -->
+
+ <!--
+ Define custom interceptors. All custom interceptors need to extend
+ org.jboss.cache.interceptors.base.CommandInterceptor
+ -->
+
+ <!--
+ <customInterceptors> <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"> <property
+ name="attrOne" value="value1" /> <property name="attrTwo" value="value2" /> </interceptor> <interceptor position="last"
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor index="3"
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> <interceptor before="org.jboss.cache.interceptors.CallInterceptor"
+
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor after="org.jboss.cache.interceptors.CallInterceptor"
+
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> </customInterceptors>
+ -->
+</jbosscache>
+
Added: kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml (rev 0)
+++ kernel/trunk/exo.kernel.component.ext.cache/src/test/resources/conf/portal/test-configuration.xml 2009-11-26 15:30:27 UTC (rev 889)
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration>
+
+ <component>
+ <key>org.exoplatform.services.cache.CacheService</key>
+ <type>org.exoplatform.services.cache.impl.CacheServiceImpl</type>
+
+ <init-params>
+ <object-param>
+ <name>cache.config.default</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>default</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-multi-threading</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheConfig">
+ <field name="name"><string>test-multi-threading</string></field>
+ <field name="maxNodes"><int>-1</int></field>
+ <field name="minTimeToLive"><long>0</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>cacheDistributed</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>cacheDistributed</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ <field name="distributed"><boolean>true</boolean></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-default-impl</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-default-impl</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-custom-impl-with-old-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-custom-impl-with-old-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ <field name="implementation"><string>TEST</string></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-custom-impl-with-new-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.TestExoCacheConfig">
+ <field name="name"><string>test-custom-impl-with-new-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>2</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-fifo-with-old-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-fifo-with-old-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>1</long></field>
+ <field name="implementation"><string>FIFO</string></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-fifo</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheConfig">
+ <field name="name"><string>test-fifo</string></field>
+ <field name="maxNodes"><int>5</int></field>
+ <field name="minTimeToLive"><long>1000</long></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-lru-with-old-config</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.ExoCacheConfig">
+ <field name="name"><string>test-lru-with-old-config</string></field>
+ <field name="maxSize"><int>5</int></field>
+ <field name="liveTime"><long>1</long></field>
+ <field name="implementation"><string>LRU</string></field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>test-lru</name>
+ <description>The default cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheConfig">
+ <field name="name"><string>test-lru</string></field>
+ <field name="maxNodes"><int>5</int></field>
+ <field name="minTimeToLive"><long>1000</long></field>
+ <field name="maxAge"><long>2000</long></field>
+ <field name="timeToLive"><long>1500</long></field>
+ </object>
+ </object-param>
+ </init-params>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.cache.ExoCacheFactory</key>
+ <type>org.exoplatform.services.cache.impl.jboss.ExoCacheFactoryImpl</type>
+ <init-params>
+ <value-param>
+ <name>cache.config.template</name>
+ <value>jar:/conf/portal/cache-configuration-template.xml</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.cache.ExoCacheFactory</target-component>
+ <component-plugin>
+ <name>addConfig</name>
+ <set-method>addConfig</set-method>
+ <type>org.exoplatform.services.cache.impl.jboss.ExoCacheFactoryConfigPlugin</type>
+ <description>add Custom Configurations</description>
+ <init-params>
+ <value-param>
+ <name>myCustomCache</name>
+ <value>jar:/conf/portal/distributed-cache-configuration-template.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>addCreator</name>
+ <set-method>addCreator</set-method>
+ <type>org.exoplatform.services.cache.impl.jboss.ExoCacheCreatorPlugin</type>
+ <description>add Exo Cache Creator</description>
+ <init-params>
+ <object-param>
+ <name>Test</name>
+ <description>The cache creator for testing purpose</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.TestExoCacheCreator"></object>
+ </object-param>
+ <object-param>
+ <name>FIFO</name>
+ <description>The fifo cache creator</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.fifo.FIFOExoCacheCreator"></object>
+ </object-param>
+ <object-param>
+ <name>LRU</name>
+ <description>The lru cache creator</description>
+ <object type="org.exoplatform.services.cache.impl.jboss.lru.LRUExoCacheCreator">
+ <field name="defaultTimeToLive"><long>1500</long></field>
+ <field name="defaultMaxAge"><long>2000</long></field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
16 years, 5 months