exo-jcr SVN: r1415 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2010-01-15 09:55:12 -0500 (Fri, 15 Jan 2010)
New Revision: 1415
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws1.xml
Log:
EXOJCR-331 : update configuration
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml 2010-01-15 14:44:39 UTC (rev 1414)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml 2010-01-15 14:55:12 UTC (rev 1415)
@@ -84,9 +84,9 @@
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
- <property name="timeToLive" value="60000" />
+ <property name="timeToLive" value="120000" />
</default>
</eviction>
</jbosscache>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml 2010-01-15 14:44:39 UTC (rev 1414)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml 2010-01-15 14:55:12 UTC (rev 1415)
@@ -84,9 +84,9 @@
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
- <property name="timeToLive" value="60000" />
+ <property name="timeToLive" value="120000" />
</default>
</eviction>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml 2010-01-15 14:44:39 UTC (rev 1414)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml 2010-01-15 14:55:12 UTC (rev 1415)
@@ -71,9 +71,9 @@
</clustering>
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
- <property name="timeToLive" value="60000" />
+ <property name="timeToLive" value="120000" />
</default>
</eviction>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws1.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws1.xml 2010-01-15 14:44:39 UTC (rev 1414)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws1.xml 2010-01-15 14:55:12 UTC (rev 1415)
@@ -71,9 +71,9 @@
</clustering>
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
- <property name="timeToLive" value="60000" />
+ <property name="timeToLive" value="120000" />
</default>
</eviction>
16 years, 6 months
exo-jcr SVN: r1414 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-15 09:44:39 -0500 (Fri, 15 Jan 2010)
New Revision: 1414
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
Log:
EXOJCR-391: Extended event queue size.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-01-15 14:36:43 UTC (rev 1413)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-01-15 14:44:39 UTC (rev 1414)
@@ -11,9 +11,9 @@
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="1000000">
<property name="maxNodes" value="5000" />
- <property name="timeToLive" value="120000" />
+ <property name="timeToLive" value="60000" />
</default>
</eviction>
16 years, 6 months
exo-jcr SVN: r1413 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core: lock and 1 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-15 09:36:43 -0500 (Fri, 15 Jan 2010)
New Revision: 1413
Added:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/AbstractLockManager.java
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
Log:
EXOJCR-332 : The CacheLockImpl was changed.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2010-01-15 14:32:01 UTC (rev 1412)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2010-01-15 14:36:43 UTC (rev 1413)
@@ -31,7 +31,7 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
+import org.exoplatform.services.jcr.impl.core.lock.AbstractLockManager;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeImpl;
import org.exoplatform.services.jcr.impl.core.observation.ObservationManagerImpl;
import org.exoplatform.services.jcr.impl.core.observation.ObservationManagerRegistry;
@@ -120,7 +120,7 @@
private final LocationFactory systemLocationFactory;
- private final LockManagerImpl lockManager;
+ private final AbstractLockManager lockManager;
protected final String workspaceName;
@@ -156,7 +156,7 @@
this.systemLocationFactory = (LocationFactory)container.getComponentInstanceOfType(LocationFactory.class);
this.accessManager = (AccessManager)container.getComponentInstanceOfType(AccessManager.class);
- this.lockManager = (LockManagerImpl)container.getComponentInstanceOfType(LockManagerImpl.class);
+ this.lockManager = (AbstractLockManager)container.getComponentInstanceOfType(AbstractLockManager.class);
WorkspaceEntry wsConfig = (WorkspaceEntry)container.getComponentInstanceOfType(WorkspaceEntry.class);
this.lazyReadThreshold =
@@ -551,7 +551,7 @@
return locationFactory;
}
- public LockManagerImpl getLockManager()
+ public AbstractLockManager getLockManager()
{
return lockManager;
}
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/AbstractLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/AbstractLockManager.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/AbstractLockManager.java 2010-01-15 14:36:43 UTC (rev 1413)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.core.lock;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+
+import org.exoplatform.services.jcr.core.ExtendedSession;
+import org.exoplatform.services.jcr.core.SessionLifecycleListener;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2010
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public abstract class AbstractLockManager implements SessionLifecycleListener, LockManager
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract void onCloseSession(ExtendedSession session);
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract void addLockToken(String sessionId, String lt);
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract Lock addPendingLock(NodeImpl node, boolean isDeep, boolean isSessionScoped, long timeOut)
+ throws LockException, RepositoryException;
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract LockImpl getLock(NodeImpl node) throws LockException, RepositoryException;
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract String[] getLockTokens(String sessionID);
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract boolean holdsLock(NodeData node) throws RepositoryException;
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract boolean isLockHolder(NodeImpl node) throws RepositoryException;
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract boolean isLocked(NodeData node);
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract void removeExpired();
+
+ /**
+ * {@inheritDoc}
+ */
+ public abstract void removeLockToken(String sessionId, String lt);
+
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/AbstractLockManager.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2010-01-15 14:32:01 UTC (rev 1412)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2010-01-15 14:36:43 UTC (rev 1413)
@@ -18,6 +18,21 @@
*/
package org.exoplatform.services.jcr.impl.core.lock;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.jmx.annotations.NameTemplate;
@@ -25,7 +40,6 @@
import org.exoplatform.services.jcr.access.SystemIdentity;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ExtendedSession;
-import org.exoplatform.services.jcr.core.SessionLifecycleListener;
import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
import org.exoplatform.services.jcr.dataflow.DataManager;
@@ -52,21 +66,6 @@
import org.exoplatform.services.log.Log;
import org.picocontainer.Startable;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.lock.Lock;
-import javax.jcr.lock.LockException;
-
/**
* Created by The eXo Platform SAS.
*
@@ -75,7 +74,7 @@
*/
@Managed
@NameTemplate(@Property(key = "service", value = "lockmanager"))
-public class LockManagerImpl implements ItemsPersistenceListener, SessionLifecycleListener, LockManager, Startable
+public class LockManagerImpl extends AbstractLockManager implements ItemsPersistenceListener, Startable
{
/**
* Default lock time out. 30min
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-15 14:32:01 UTC (rev 1412)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-15 14:36:43 UTC (rev 1413)
@@ -16,6 +16,23 @@
*/
package org.exoplatform.services.jcr.impl.core.lock.jbosscache;
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.jmx.annotations.NameTemplate;
@@ -32,6 +49,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
+import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
@@ -39,8 +57,8 @@
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.core.lock.AbstractLockManager;
import org.exoplatform.services.jcr.impl.core.lock.LockImpl;
-import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
import org.exoplatform.services.jcr.impl.core.lock.LockPersister;
import org.exoplatform.services.jcr.impl.core.lock.LockRemover;
import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
@@ -55,24 +73,8 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.picocontainer.Startable;
-import java.io.Serializable;
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.lock.Lock;
-import javax.jcr.lock.LockException;
-
/**
* Created by The eXo Platform SAS.
*
@@ -83,7 +85,7 @@
*/
@Managed
@NameTemplate(@Property(key = "service", value = "lockmanager"))
-public class CacheableLockManager extends LockManagerImpl
+public class CacheableLockManager extends AbstractLockManager implements ItemsPersistenceListener, Startable
{
/**
* Default lock time out. 30min
@@ -164,7 +166,6 @@
public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
LockPersister persister) throws RepositoryConfigurationException
{
- super(dataManager, config, null);
this.dataManager = dataManager;
if (config.getLockManager() != null)
{
@@ -177,7 +178,7 @@
lockTokenHolders = new HashMap<String, Set<String>>();
pendingLocks = new HashMap<String, LockData>();
- // dataManager.addItemPersistenceListener(this);
+ dataManager.addItemPersistenceListener(this);
// make cache
if (config.getLockManager() != null && config.getLockManager().getCacheConfig() != null)
16 years, 6 months
exo-jcr SVN: r1412 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache and 1 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-15 09:32:01 -0500 (Fri, 15 Jan 2010)
New Revision: 1412
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestExoEvictionActionPolicy.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
Log:
EXOJCR-391: Code update and cleanup.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-01-15 14:30:29 UTC (rev 1411)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-01-15 14:32:01 UTC (rev 1412)
@@ -34,7 +34,6 @@
import org.jgroups.Address;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -540,7 +539,8 @@
}
/**
- * Gets object by key. If it is List<Object> adds new value to it.
+ * It tries to get Set by given key. If it is Set then adds new value and puts new set back.
+ * If null found, then new Set created (ordinary cache does).
*
* @param fqn
* @param key
@@ -557,7 +557,7 @@
}
/**
- * Gets object by key. If it is List<Object> removes value from it.
+ * It tries to get set by given key. If it is set then removes value and puts new modified set back.
*
* @param fqn
* @param key
@@ -689,8 +689,8 @@
}
/**
- * Put to list container.
- * It tries to get list by given key. If it is list adds new value and puts list.
+ * It tries to get Set by given key. If it is Set then adds new value and puts new set back.
+ * If null found, then new Set created (ordinary cache does).
*/
public static class AddToListContainer extends ChangesContainer
{
@@ -727,15 +727,14 @@
}
else
{
- LOG.error("Unexpected value found by FQN:" + getFqn() + " and key:" + key + ". Expected list, found:"
+ LOG.error("Unexpected object found by FQN:" + getFqn() + " and key:" + key + ". Expected Set, but found:"
+ existingObject.getClass().getName());
}
}
}
/**
- * Removes from list container.
- * It tries to get list by given key. If it is list removes value and puts list.
+ * It tries to get set by given key. If it is set then removes value and puts new modified set back.
*/
public static class RemoveFromListContainer extends ChangesContainer
{
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-15 14:30:29 UTC (rev 1411)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-15 14:32:01 UTC (rev 1412)
@@ -48,7 +48,6 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
@@ -66,9 +65,9 @@
* <li>cache consists of next resident nodes:
* <ul>
* <li>/$ITEMS - stores items by Id (i.e. /$ITEMS/itemId)</li>
- * <li>/$CHILD_NODES, /$CHILD_PROPS - stores items by parentId and name (i.e. /$CHILD_NODES/parentId/childName/$ITEM_ID)</li>
- * <li>/$CHILD_NODES_LIST, /$CHILD_PROPS_LIST - stores childs list by parentId and child Id
- * (i.e. /$CHILD_NODES_LIST/parentId/childId)</li>
+ * <li>/$CHILD_NODES, /$CHILD_PROPS - stores items by parentId and name (i.e. /$CHILD_NODES/parentId/childName.$ITEM_ID)</li>
+ * <li>/$CHILD_NODES_LIST, /$CHILD_PROPS_LIST - stores child list by parentId and child Id
+ * (i.e. /$CHILD_NODES_LIST/parentId.lists = serialized Set<Object>)</li>
* </ul>
* </li>
* <li>all child properties/nodes lists should be evicted from parent at same time
@@ -114,14 +113,7 @@
public static final String ITEM_ID = "$id".intern();
public static final String ITEM_LIST = "$lists".intern();
-
- /**
- * Empty cache node data for CHILD_x_LIST.
- */
- public static final Map<Serializable, Object> NULL_DATA = Collections.emptyMap();
- public static final Set<String> NO_CHILDS = Collections.emptySet();
-
protected final BufferedJBossCache cache;
protected final Fqn<String> itemsRoot;
@@ -173,7 +165,6 @@
this.root = root;
Fqn<String> parentFqn = makeChildListFqn(root, parentId);
- // TODO replace getNode with get attr -> use ITEMS with CHILDS etc
Node<Serializable, Object> parent = cache.getNode(parentFqn);
if (parent != null)
{
@@ -195,7 +186,7 @@
T n = null;
do
{
- String itemId = (String)cache.get(makeChildListFqn(root, parentId, (String)childs.next()), ITEM_ID);
+ String itemId = (String)cache.get(makeChildFqn(root, parentId, (String)childs.next()), ITEM_ID);
if (itemId != null)
{
n = (T)cache.get(makeItemFqn(itemId), ITEM_DATA);
@@ -235,7 +226,6 @@
class ChildNodesIterator<N extends NodeData> extends ChildItemsIterator<N>
{
-
ChildNodesIterator(String parentId)
{
super(childNodes, parentId);
@@ -302,7 +292,7 @@
this.cache = new BufferedJBossCache(factory.createCache(jbcConfig, false));
if (transactionManager != null)
{
- cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionManager);
+ cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionManager);
}
this.cache.create();
@@ -382,7 +372,6 @@
*/
public void put(ItemData item)
{
- // TODO: Omit writing to list!
if (item.isNode())
{
putNode((NodeData)item, ModifyChildOption.NOT_MODIFY);
@@ -433,11 +422,6 @@
}
else if (state.isRenamed())
{
- // TODO cleanup: update subtree paths
- // if (prevState.isDeleted() && prevState.isNode())
- // {
- // renameNode((NodeData)prevState.getData(), (NodeData)state.getData());
- // }
putItem(state.getData());
}
else if (state.isMixinChanged())
@@ -448,10 +432,6 @@
updateMixin((NodeData)state.getData());
}
}
- else
- {
- // TODO warn it?
- }
}
}
@@ -475,7 +455,6 @@
{
// cache fact of empty childs list
cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST, new HashSet<Object>());
- //cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), NULL_DATA);
}
}
@@ -506,17 +485,6 @@
public void addChildPropertiesList(NodeData parent, List<PropertyData> childProperties)
{
// TODO not implemented, will force read from DB
-
- // start();
- // try
- // {
- // commit();
- // }
- // catch (Throwable e)
- // {
- // rollback();
- // LOG.error("addChildNodes error " + parent.getQPath().getAsString(), e);
- // }
}
/**
@@ -555,9 +523,9 @@
public List<NodeData> getChildNodes(final NodeData parent)
{
final List<NodeData> childs = new ArrayList<NodeData>();
- //final Node<Serializable, Object> parentNode =
- // cache.getNode(makeChildListFqn(childNodesList, parent.getIdentifier()));
- final Set<Object> set = (Set<Object>)cache.get(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST);
+ // get list of children uuids
+ final Set<Object> set =
+ (Set<Object>)cache.get(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST);
if (set != null)
{
for (Object child : set)
@@ -571,7 +539,7 @@
childs.add(node);
}
- // order childs by orderNumber, as JBC returns childs in any order
+ // order children by orderNumber, as HashSet returns children in other order
Collections.sort(childs, new NodesOrderComparator<NodeData>());
return childs;
@@ -608,27 +576,24 @@
protected List<PropertyData> getChildProps(String parentId, boolean withValue)
{
final List<PropertyData> childs = new ArrayList<PropertyData>();
- //final Node<Serializable, Object> parentNode = cache.getNode(makeChildListFqn(childPropsList, parentId));
- final Set<Object> list = (Set<Object>)cache.get(makeChildListFqn(childPropsList, parentId), ITEM_LIST);
- if (list != null)
+ // get set of property uuids
+ final Set<Object> set = (Set<Object>)cache.get(makeChildListFqn(childPropsList, parentId), ITEM_LIST);
+ if (set != null)
{
- for (Object child : list)
+ for (Object child : set)
{
PropertyData node = (PropertyData)cache.get(makeItemFqn((String)child), ITEM_DATA);
if (node == null)
{
return null;
}
-
if (withValue && node.getValues().size() <= 0)
{
// don't return list of empty-valued props (but listChildProperties() can)
return null;
}
-
childs.add(node);
}
-
return childs;
}
else
@@ -642,7 +607,7 @@
*/
public long getSize()
{
- // TODO
+ // TODO, cache seems doesn't have a methods to calculate it's size
return -1;
}
@@ -651,11 +616,10 @@
*/
public boolean isEnabled()
{
- // TODO
return true;
}
- // ****************
+ // non-public members
/**
* Make Item absolute Fqn, i.e. /$ITEMS/itemID.
@@ -682,16 +646,16 @@
}
/**
- * Make child absolute Fqn, i.e. /root/parentId/childId.
+ * Make child Item absolute Fqn, i.e. /root/parentId/childName.
*
* @param root Fqn
* @param parentId String
- * @param itemId String
+ * @param childName String
* @return Fqn
*/
- protected Fqn<String> makeChildListFqn(Fqn<String> root, String parentId, String childId)
+ protected Fqn<String> makeChildFqn(Fqn<String> root, String parentId, String childName)
{
- return Fqn.fromRelativeElements(root, parentId, childId);
+ return Fqn.fromRelativeElements(root, parentId, childName);
}
/**
@@ -732,33 +696,21 @@
*/
protected ItemData putNode(NodeData node, ModifyChildOption modifyListsOfChild)
{
+ // if not a root node
if (node.getParentIdentifier() != null)
{
- // if not a root node
-
// add in CHILD_NODES
cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
.getEntries().length - 1]), ITEM_ID, node.getIdentifier());
-
- // add in CHILD_NODES_LIST
- // TODO
- // Node<Serializable, Object> childsParent =
- // cache.getNode(makeChildListFqn(childNodesList, node.getParentIdentifier()));
- // if (childsParent != null)
- // {
- // cache.put(makeChildListFqn(childNodesList, node.getParentIdentifier(), node.getIdentifier()), NULL_DATA);
- // }
- if (modifyListsOfChild == ModifyChildOption.MODIFY || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+ // if MODIFY and List present OR FORCE_MODIFY, then write
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
+ .getParentIdentifier())) != null)
+ || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
{
- if (cache.getNode(makeChildListFqn(childNodesList, node.getParentIdentifier())) != null
- || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
- {
- //cache.put(makeChildListFqn(childNodesList, node.getParentIdentifier(), node.getIdentifier()), NULL_DATA);
- cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST, node.getIdentifier());
- }
+ cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST, node
+ .getIdentifier());
}
}
-
// add in ITEMS
return (ItemData)cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
}
@@ -774,31 +726,13 @@
// add in CHILD_PROPS
cache.put(makeChildFqn(childProps, prop.getParentIdentifier(), prop.getQPath().getEntries()[prop.getQPath()
.getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
-
- // add in CHILD_PROPS_LIST
- // TODO
- // Node<Serializable, Object> childsParent =
- // cache.getNode(makeChildListFqn(childPropsList, prop.getParentIdentifier()));
- // if (childsParent != null)
- // {
- // cache.put(makeChildListFqn(childPropsList, prop.getParentIdentifier(), prop.getIdentifier()), NULL_DATA);
- // }
- if (modifyListsOfChild == ModifyChildOption.MODIFY || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+ // if MODIFY and List present OR FORCE_MODIFY, then write
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childPropsList, prop
+ .getParentIdentifier())) != null)
+ || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
{
- if (cache.getNode(makeChildListFqn(childPropsList, prop.getParentIdentifier())) != null
- || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
- {
- //cache.put(makeChildListFqn(childPropsList, prop.getParentIdentifier(), prop.getIdentifier()), NULL_DATA);
- cache.addToList(makeChildListFqn(childPropsList, prop.getParentIdentifier()), ITEM_LIST, prop.getIdentifier());
- }
+ cache.addToList(makeChildListFqn(childPropsList, prop.getParentIdentifier()), ITEM_LIST, prop.getIdentifier());
}
-
- // TODO REFERENCEs hadnling
- //if (prop.getType() == PropertyType.REFERENCE)
- //{
- // addReferences(data);
- //}
-
// add in ITEMS
return (PropertyData)cache.put(makeItemFqn(prop.getIdentifier()), ITEM_DATA, prop);
}
@@ -816,8 +750,8 @@
.getQPath().getEntries().length - 1]));
// remove from CHILD_NODES_LIST of parent
- //cache.removeNode(makeChildListFqn(childNodesList, item.getParentIdentifier(), item.getIdentifier()));
- cache.removeFromList(makeChildListFqn(childNodesList, item.getParentIdentifier()), ITEM_LIST, item.getIdentifier());
+ cache.removeFromList(makeChildListFqn(childNodesList, item.getParentIdentifier()), ITEM_LIST, item
+ .getIdentifier());
// remove from CHILD_NODES as parent
cache.removeNode(makeChildListFqn(childNodes, item.getIdentifier()));
@@ -839,33 +773,13 @@
.getQPath().getEntries().length - 1]));
// remove from CHILD_PROPS_LIST
- //cache.removeNode(makeChildListFqn(childPropsList, item.getParentIdentifier(), item.getIdentifier()));
- cache.removeFromList(makeChildListFqn(childPropsList, item.getParentIdentifier()), ITEM_LIST, item.getIdentifier());
-
- // TODO REFERENCEs hadnling
- //if (prop.getType() == PropertyType.REFERENCE)
- //{
- // addReferences(data);
- //}
+ cache.removeFromList(makeChildListFqn(childPropsList, item.getParentIdentifier()), ITEM_LIST, item
+ .getIdentifier());
}
-
// remove from ITEMS
cache.removeNode(makeItemFqn(item.getIdentifier()));
}
- @Deprecated
- protected void renameNode(NodeData from, NodeData to)
- {
- // TODO do move more cache-friendly, i.e. change ACL & paths of whole cached sub-tree
-
- // remove "from", whole subtree will be removed
- removeItem(from);
-
- // add "to" only root will be added
- // moved subtree will be populated to the cache on read
- putItem(to);
- }
-
/**
* Update Node's mixin and ACL.
*
@@ -932,19 +846,16 @@
boolean inheritACL = acl != null;
// update properties
- // TODO for (Object child : cache.getChildrenNames(makeChildListFqn(childPropsList, parentId)))
for (Iterator<PropertyData> iter = new ChildPropertiesIterator<PropertyData>(parentId); iter.hasNext();)
{
PropertyData prevProp = iter.next();
- // TODO if ACL related set on this Node...
if (inheritACL
&& (prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath().getName()
.equals(Constants.EXO_OWNER)))
{
inheritACL = false;
}
-
// recreate with new path for child Props only
QPath newPath =
QPath
@@ -956,11 +867,9 @@
}
// update child nodes
- // TODO for (Object child : cache.getChildrenNames(makeChildListFqn(childNodesList, parentId)))
for (Iterator<NodeData> iter = new ChildNodesIterator<NodeData>(parentId); iter.hasNext();)
{
NodeData prevNode = iter.next();
-
// recreate with new path for child Nodes only
QPath newPath =
QPath
@@ -969,10 +878,8 @@
new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
.getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
-
// update this node
cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
-
// update childs recursive
updateTreePath(newNode.getIdentifier(), newNode.getQPath(), inheritACL ? acl : null);
}
@@ -989,7 +896,6 @@
for (Iterator<NodeData> iter = new ChildNodesIterator<NodeData>(parentId); iter.hasNext();)
{
NodeData prevNode = iter.next();
-
// is ACL changes on this node (i.e. ACL inheritance brokes)
for (InternalQName mixin : prevNode.getMixinTypeNames())
{
@@ -998,16 +904,13 @@
continue;
}
}
-
// recreate with new path for child Nodes only
TransientNodeData newNode =
new TransientNodeData(prevNode.getQPath(), prevNode.getIdentifier(), prevNode.getPersistedVersion(),
prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
.getParentIdentifier(), acl);
-
// update this node
cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
-
// update childs recursive
updateChildsACL(newNode.getIdentifier(), acl);
}
@@ -1016,19 +919,16 @@
public void beginTransaction()
{
cache.beginTransaction();
-
}
public void commitTransaction()
{
cache.commitTransaction();
-
}
public void rollbackTransaction()
{
cache.rollbackTransaction();
-
}
/**
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestExoEvictionActionPolicy.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestExoEvictionActionPolicy.java 2010-01-15 14:30:29 UTC (rev 1411)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestExoEvictionActionPolicy.java 2010-01-15 14:32:01 UTC (rev 1412)
@@ -17,6 +17,8 @@
package org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache;
import java.io.Serializable;
+import java.util.Collections;
+import java.util.Map;
import org.exoplatform.services.cache.CacheListenerContext;
import org.exoplatform.services.jcr.JcrImplBaseTest;
@@ -58,6 +60,8 @@
protected String jbcConfig;
+ public static final Map<Serializable, Object> NULL_DATA = Collections.emptyMap();
+
public void setUp() throws Exception
{
super.setUp();
@@ -114,16 +118,16 @@
cache.put(Fqn.fromRelativeElements(itemsRoot, evictionPropData.getIdentifier()), JBossCacheWorkspaceStorageCache.ITEM_DATA, evictionPropData);
// put to CHILD_NODES_LIST
- cache.put(Fqn.fromRelativeElements(childNodesList, evictionNodeData.getParentIdentifier(), evictionNodeData.getIdentifier()), JBossCacheWorkspaceStorageCache.NULL_DATA);
+ cache.put(Fqn.fromRelativeElements(childNodesList, evictionNodeData.getParentIdentifier(), evictionNodeData.getIdentifier()), NULL_DATA);
for (int i = 0 ; i < 10; i++)
- cache.put(Fqn.fromRelativeElements(childNodesList, evictionNodeData.getParentIdentifier(), IdGenerator.generate()), JBossCacheWorkspaceStorageCache.NULL_DATA);
+ cache.put(Fqn.fromRelativeElements(childNodesList, evictionNodeData.getParentIdentifier(), IdGenerator.generate()), NULL_DATA);
// put to CHILD_PROPS_LIST
- cache.put(Fqn.fromRelativeElements(childPropsList, evictionPropData.getParentIdentifier(), evictionPropData.getIdentifier()), JBossCacheWorkspaceStorageCache.NULL_DATA);
+ cache.put(Fqn.fromRelativeElements(childPropsList, evictionPropData.getParentIdentifier(), evictionPropData.getIdentifier()), NULL_DATA);
for (int i = 0 ; i < 10; i++)
- cache.put(Fqn.fromRelativeElements(childPropsList, evictionPropData.getParentIdentifier(), IdGenerator.generate()), JBossCacheWorkspaceStorageCache.NULL_DATA);
+ cache.put(Fqn.fromRelativeElements(childPropsList, evictionPropData.getParentIdentifier(), IdGenerator.generate()), NULL_DATA);
// check for exists
@@ -171,10 +175,10 @@
String parentId = IdGenerator.generate();
// put to CHILD_PROPS_LIST
- cache.put(Fqn.fromRelativeElements(childPropsList, parentId, IdGenerator.generate()), JBossCacheWorkspaceStorageCache.NULL_DATA);
+ cache.put(Fqn.fromRelativeElements(childPropsList, parentId, IdGenerator.generate()), NULL_DATA);
for (int i = 0 ; i < 10; i++)
- cache.put(Fqn.fromRelativeElements(childPropsList, parentId, IdGenerator.generate()), JBossCacheWorkspaceStorageCache.NULL_DATA);
+ cache.put(Fqn.fromRelativeElements(childPropsList, parentId, IdGenerator.generate()), NULL_DATA);
assertEquals( 11, cache.getChildrenNames(Fqn.fromRelativeElements(childPropsList, parentId)).size());
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-01-15 14:30:29 UTC (rev 1411)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-01-15 14:32:01 UTC (rev 1412)
@@ -11,7 +11,7 @@
<!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
<property name="maxNodes" value="5000" />
<property name="timeToLive" value="120000" />
</default>
16 years, 6 months
exo-jcr SVN: r1411 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2010-01-15 09:30:29 -0500 (Fri, 15 Jan 2010)
New Revision: 1411
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws1.xml
Log:
EXOJCR-331 : update configuration
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml 2010-01-15 14:26:43 UTC (rev 1410)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws.xml 2010-01-15 14:30:29 UTC (rev 1411)
@@ -81,17 +81,12 @@
<transaction
transactionManagerLookupClass="org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup" />
- <!-- Enable batching -->
- <invocationBatching enabled="true" />
- <!-- Eviction configuration -->
+
+ <!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <property name="maxNodes" value="50000" />
- <property name="timeToLive" value="900000" />
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="60000" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
- <property name="maxNodes" value="50000" />
- <property name="timeToLive" value="900000" />
- </region>
</eviction>
</jbosscache>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml 2010-01-15 14:26:43 UTC (rev 1410)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-config-ws1.xml 2010-01-15 14:30:29 UTC (rev 1411)
@@ -81,17 +81,13 @@
<transaction
transactionManagerLookupClass="org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup" />
- <!-- Enable batching -->
- <invocationBatching enabled="true" />
- <!-- Eviction configuration -->
+
+ <!-- Eviction configuration -->
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <property name="maxNodes" value="50000" />
- <property name="timeToLive" value="900000" />
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="60000" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
- <property name="maxNodes" value="50000" />
- <property name="timeToLive" value="900000" />
- </region>
</eviction>
+
</jbosscache>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml 2010-01-15 14:26:43 UTC (rev 1410)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml 2010-01-15 14:30:29 UTC (rev 1411)
@@ -69,17 +69,12 @@
<sync />
</clustering>
- <invocationBatching enabled="false" />
-
- <eviction wakeUpInterval="3000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <property name="maxNodes" value="5000" />
- <property name="timeToLive" value="60000" />
- </default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="1000000">
- <property name="maxNodes" value="10000" />
- <property name="timeToLive" value="60000" />
- </region>
- </eviction>
+ <!-- Eviction configuration -->
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="60000" />
+ </default>
+ </eviction>
</jbosscache>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws1.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws1.xml 2010-01-15 14:26:43 UTC (rev 1410)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws1.xml 2010-01-15 14:30:29 UTC (rev 1411)
@@ -69,17 +69,12 @@
<sync />
</clustering>
- <invocationBatching enabled="false" />
-
- <eviction wakeUpInterval="3000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <property name="maxNodes" value="5000" />
- <property name="timeToLive" value="60000" />
- </default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="1000000">
- <property name="maxNodes" value="10000" />
- <property name="timeToLive" value="60000" />
- </region>
- </eviction>
+ <!-- Eviction configuration -->
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
+ <property name="maxNodes" value="5000" />
+ <property name="timeToLive" value="60000" />
+ </default>
+ </eviction>
</jbosscache>
16 years, 6 months
exo-jcr SVN: r1410 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow: persistent and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-01-15 09:26:43 -0500 (Fri, 15 Jan 2010)
New Revision: 1410
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractPersistedValueData.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
Log:
EXOJCR-404 : The serializatio to AbstractPersistedValueData, FilePersistentValueData, CleanableFilePersistedValuData was changed.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractPersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractPersistedValueData.java 2010-01-15 13:08:01 UTC (rev 1409)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractPersistedValueData.java 2010-01-15 14:26:43 UTC (rev 1410)
@@ -18,41 +18,36 @@
*/
package org.exoplatform.services.jcr.impl.dataflow;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import javax.jcr.RepositoryException;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import javax.jcr.RepositoryException;
-
/**
* @author <a href="mailto:peter.nedonosko@exoplatform.com">Peter Nedonosko</a>
* @version $Id$
*/
-public abstract class AbstractPersistedValueData implements ValueData, Externalizable
+public abstract class AbstractPersistedValueData implements ValueData
{
protected final static Log LOG = ExoLogger.getLogger("jcr.PersistedValueData");
protected int orderNumber;
+ /**
+ * The empty constructor to serialization.
+ */
+ protected AbstractPersistedValueData()
+ {
+ }
+
protected AbstractPersistedValueData(int orderNumber)
{
this.orderNumber = orderNumber;
}
/**
- * Empty constructor to serialization.
- */
- protected AbstractPersistedValueData()
- {
- }
-
- /**
* {@inheritDoc}
*/
public final int getOrderNumber()
@@ -82,13 +77,4 @@
*/
public abstract TransientValueData createTransientCopy() throws RepositoryException;
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- orderNumber = in.readInt();
- }
-
- public void writeExternal(ObjectOutput out) throws IOException
- {
- out.writeInt(orderNumber);
- }
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java 2010-01-15 13:08:01 UTC (rev 1409)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java 2010-01-15 14:26:43 UTC (rev 1410)
@@ -46,6 +46,7 @@
* The serialVersionUID.
*/
private static final long serialVersionUID = -9131328056670315388L;
+
protected byte[] data;
/**
@@ -160,6 +161,9 @@
return new TransientValueData(orderNumber, data);
}
+ /**
+ * {@inheritDoc}
+ */
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
orderNumber = in.readInt();
@@ -168,6 +172,9 @@
in.readFully(data);
}
+ /**
+ * {@inheritDoc}
+ */
public void writeExternal(ObjectOutput out) throws IOException
{
out.writeInt(orderNumber);
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java 2010-01-15 13:08:01 UTC (rev 1409)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java 2010-01-15 14:26:43 UTC (rev 1410)
@@ -84,14 +84,14 @@
//TODO FileCleaner maybe null.
if (cleaner != null)
{
- cleaner.addFile(file);
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Could not remove temporary file on finalize: inUse=" + (((SwapFile)file).inUse()) + ", "
- + file.getAbsolutePath());
- }
+ cleaner.addFile(file);
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Could not remove temporary file on finalize: inUse=" + (((SwapFile)file).inUse()) + ", "
+ + file.getAbsolutePath());
}
+ }
}
}
finally
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java 2010-01-15 13:08:01 UTC (rev 1409)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java 2010-01-15 14:26:43 UTC (rev 1410)
@@ -46,9 +46,12 @@
* @version $Id$
*/
-public class FilePersistedValueData extends AbstractPersistedValueData
+public class FilePersistedValueData extends AbstractPersistedValueData implements Externalizable
{
+ /**
+ * The serialVersionUID.
+ */
private static final long serialVersionUID = -8183328056670315388L;
protected File file;
@@ -60,6 +63,7 @@
*/
public FilePersistedValueData()
{
+ super();
}
/**
@@ -227,19 +231,26 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
- super.readExternal(in);
+ orderNumber = in.readInt();
// read canonical file path
byte[] buf = new byte[in.readInt()];
+ in.readFully(buf);
file = new File(new String(buf, "UTF-8"));
}
+ /**
+ * {@inheritDoc}
+ */
public void writeExternal(ObjectOutput out) throws IOException
{
- super.writeExternal(out);
+ out.writeInt(orderNumber);
// write canonical file path
byte[] buf = file.getCanonicalPath().getBytes("UTF-8");
16 years, 6 months
exo-jcr SVN: r1409 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-01-15 08:08:01 -0500 (Fri, 15 Jan 2010)
New Revision: 1409
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockData.java
Log:
EXOJCR-332: package fixed
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java 2010-01-15 13:04:40 UTC (rev 1408)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java 2010-01-15 13:08:01 UTC (rev 1409)
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see<http://www.gnu.org/licenses/>.
*/
-package org.exoplatform.services.jcr.impl.core.lock.cache;
+package org.exoplatform.services.jcr.impl.core.lock.jbosscache;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.exoplatform.services.jcr.impl.core.lock.LockImpl;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-15 13:04:40 UTC (rev 1408)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-15 13:08:01 UTC (rev 1409)
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see<http://www.gnu.org/licenses/>.
*/
-package org.exoplatform.services.jcr.impl.core.lock.cache;
+package org.exoplatform.services.jcr.impl.core.lock.jbosscache;
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockData.java 2010-01-15 13:04:40 UTC (rev 1408)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockData.java 2010-01-15 13:08:01 UTC (rev 1409)
@@ -16,7 +16,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.exoplatform.services.jcr.impl.core.lock.cache;
+package org.exoplatform.services.jcr.impl.core.lock.jbosscache;
import org.exoplatform.services.jcr.impl.Constants;
16 years, 6 months
exo-jcr SVN: r1408 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-15 08:04:40 -0500 (Fri, 15 Jan 2010)
New Revision: 1408
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
Log:
EXOJCR-391: Remove ChildListEvictionActionPolicy from configuration.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-01-15 13:03:07 UTC (rev 1407)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-config.xml 2010-01-15 13:04:40 UTC (rev 1408)
@@ -15,10 +15,6 @@
<property name="maxNodes" value="5000" />
<property name="timeToLive" value="120000" />
</default>
- <region name="/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ChildListEvictionActionPolicy" eventQueueSize="1000000">
- <property name="maxNodes" value="20000" />
- <property name="timeToLive" value="120000" />
- </region>
</eviction>
</jbosscache>
16 years, 6 months
exo-jcr SVN: r1406 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/lock and 2 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-01-15 08:00:59 -0500 (Fri, 15 Jan 2010)
New Revision: 1406
Added:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockData.java
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig.xml
Log:
EXOJCR-332: CacheableLockManager moved to ../lock/jbosscache package
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2010-01-15 12:48:11 UTC (rev 1405)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2010-01-15 13:00:59 UTC (rev 1406)
@@ -41,7 +41,7 @@
import org.exoplatform.services.jcr.impl.core.WorkspaceInitializer;
import org.exoplatform.services.jcr.impl.core.access.DefaultAccessManagerImpl;
import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
-import org.exoplatform.services.jcr.impl.core.lock.cache.CacheableLockManager;
+import org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
import org.exoplatform.services.jcr.impl.core.nodetype.registration.JCRNodeTypeDataPersister;
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheLockImpl.java 2010-01-15 13:00:59 UTC (rev 1406)
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.core.lock.cache;
+
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.core.lock.LockImpl;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: CacheLockImpl.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class CacheLockImpl extends LockImpl
+{
+ private boolean live;
+
+ private LockData lockData;
+
+ private SessionImpl session;
+
+ private CacheableLockManager lockManager;
+
+ public CacheLockImpl(SessionImpl session, LockData lockData, CacheableLockManager lockManager)
+ {
+ this.lockData = lockData;
+ this.session = session;
+ this.lockManager = lockManager;
+ this.live = true;
+ }
+
+ public String getLockOwner()
+ {
+ return lockData.getOwner();
+ }
+
+ public String getLockToken()
+ {
+ return lockManager.getLockToken(session.getId(), lockData);
+ }
+
+ public boolean isLive()
+ {
+ // it is already not alive
+ if (!live)
+ {
+ return false;
+ }
+ // update from cache. If it is not present there - means it is not live
+ // node unlocked and/or re-locked with another session
+ LockData newlockData = lockManager.getLockDataById(lockData.getNodeIdentifier());
+ if (newlockData == null || newlockData.getToken() != lockData.getToken())
+ {
+ live = false;
+ return false;
+ }
+ else
+ {
+ // update, whether time to death changed, or whatever
+ this.lockData = newlockData;
+ return true;
+ }
+ }
+
+ public void refresh() throws LockException, RepositoryException
+ {
+ if (!isLive())
+ throw new LockException("Lock is not live");
+
+ LockData newLockData =
+ new LockData(lockData.getNodeIdentifier(), lockData.getToken(), lockData.isDeep(), lockData.isSessionScoped(),
+ lockData.getOwner(), lockData.getTimeOut());
+
+ lockManager.refresh(newLockData);
+ lockData = newLockData;
+ }
+
+ public Node getNode()
+ {
+ try
+ {
+ return (Node)session.getTransientNodesManager().getItemByIdentifier(lockData.getNodeIdentifier(), true);
+ }
+ catch (RepositoryException e)
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public boolean isDeep()
+ {
+
+ return lockData.isDeep();
+ }
+
+ public boolean isSessionScoped()
+ {
+ return lockData.isSessionScoped();
+ }
+
+ public long getTimeToDeath()
+ {
+ return lockData.getTimeToDeath();
+ }
+
+ protected void setTimeOut(long timeOut)
+ {
+ lockData.setTimeOut(timeOut);
+
+ //reset lock data
+ try
+ {
+ lockManager.refresh(lockData);
+ }
+ catch (LockException e)
+ {
+ // TODO remove or change this
+ e.printStackTrace();
+ }
+ }
+}
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManager.java 2010-01-15 13:00:59 UTC (rev 1406)
@@ -0,0 +1,912 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.core.lock.cache;
+
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.jmx.annotations.NameTemplate;
+import org.exoplatform.management.jmx.annotations.Property;
+import org.exoplatform.services.jcr.access.SystemIdentity;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.ExtendedSession;
+import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
+import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
+import org.exoplatform.services.jcr.dataflow.DataManager;
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
+import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.core.lock.LockImpl;
+import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
+import org.exoplatform.services.jcr.impl.core.lock.LockPersister;
+import org.exoplatform.services.jcr.impl.core.lock.LockRemover;
+import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+import org.exoplatform.services.jcr.observation.ExtendedEvent;
+import org.exoplatform.services.jcr.util.IdGenerator;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: CacheableLockManager.java 111 2008-11-11 11:11:11Z serg $
+ */
+@Managed
+@NameTemplate(@Property(key = "service", value = "lockmanager"))
+public class CacheableLockManager extends LockManagerImpl
+{
+ /**
+ * Default lock time out. 30min
+ */
+ public static final long DEFAULT_LOCK_TIMEOUT = 1000 * 60 * 30;
+
+ // Search constants
+ /**
+ * The exact lock token.
+ */
+ private static final int SEARCH_EXECMATCH = 1;
+
+ /**
+ * Lock token of closed parent
+ */
+ private static final int SEARCH_CLOSEDPARENT = 2;
+
+ /**
+ * Lock token of closed child
+ */
+ private static final int SEARCH_CLOSEDCHILD = 4;
+
+ /**
+ * Path to jbosscache-configuration
+ */
+ public static final String JBOSSCACHE_CONFIG = "jbosscache-configuration";
+
+ public static final String LOCK_DATA = "$LOCK_DATA";
+
+ public static final String LOCKS = "$LOCKS";
+
+ /**
+ * Logger
+ */
+ private final Log log = ExoLogger.getLogger("jcr.lock.LockManager");
+
+ /**
+ * Data manager.
+ */
+ private final DataManager dataManager;
+
+ /**
+ * Map NodeIdentifier -- lockData
+ */
+ private final Map<String, LockData> pendingLocks;
+
+ /**
+ * [session id , [lock tokens id..]]
+ */
+ private final Map<String, Set<String>> lockTokenHolders;
+
+ /**
+ * Run time lock time out.
+ */
+ private long lockTimeOut;
+
+ /**
+ * Lock remover thread.
+ */
+ private LockRemover lockRemover;
+
+ private Cache<Serializable, Object> cache;
+
+ private Node<Serializable, Object> lockRoot;
+
+ /**
+ * Constructor for workspace without LockPersister
+ *
+ * @param dataManager
+ * @param config
+ */
+ public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config)
+ throws RepositoryConfigurationException
+ {
+ this(dataManager, config, null);
+ }
+
+ public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
+ LockPersister persister) throws RepositoryConfigurationException
+ {
+ super(dataManager, config, null);
+ this.dataManager = dataManager;
+ if (config.getLockManager() != null)
+ {
+ lockTimeOut =
+ config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout() : DEFAULT_LOCK_TIMEOUT;
+ }
+ else
+ lockTimeOut = DEFAULT_LOCK_TIMEOUT;
+
+ lockTokenHolders = new HashMap<String, Set<String>>();
+ pendingLocks = new HashMap<String, LockData>();
+
+ // dataManager.addItemPersistenceListener(this);
+
+ // make cache
+ if (config.getLockManager() != null && config.getLockManager().getCacheConfig() != null)
+ {
+ String pathToConfig = config.getLockManager().getCacheConfig();
+ CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
+ cache = factory.createCache(pathToConfig, false);
+ cache.create();
+ }
+ else
+ {
+ throw new RepositoryConfigurationException("Cache configuration not found");
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#lockTokenAdded(org.exoplatform.services
+ * .jcr.impl.core.SessionImpl, java.lang.String)
+ */
+ public synchronized void addLockToken(String sessionId, String lt)
+ {
+ holdLockToken(sessionId, lt);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#addPendingLock(org.exoplatform.services
+ * .jcr.impl.core.NodeImpl, boolean, boolean, long)
+ */
+ public synchronized Lock addPendingLock(NodeImpl node, boolean isDeep, boolean isSessionScoped, long timeOut)
+ throws LockException
+ {
+ LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+ if (lData != null)
+ {
+ if (lData.getNodeIdentifier().equals(node.getInternalIdentifier()))
+ {
+ throw new LockException("Node already locked: " + node.getData().getQPath());
+ }
+ else if (lData.isDeep())
+ {
+ throw new LockException("Parent node has deep lock.");
+ }
+ }
+
+ if (isDeep && getLockData((NodeData)node.getData(), SEARCH_CLOSEDCHILD) != null)
+ {
+ throw new LockException("Some child node is locked.");
+ }
+
+ String lockToken = IdGenerator.generate();
+ lData =
+ new LockData(node.getInternalIdentifier(), lockToken, isDeep, isSessionScoped, node.getSession().getUserID(),
+ timeOut > 0 ? timeOut : lockTimeOut);
+
+ holdLockToken(node.getSession().getId(), lockToken);
+ pendingLocks.put(node.getInternalIdentifier(), lData);
+
+ LockImpl lock = new CacheLockImpl(node.getSession(), lData, this);
+ return lock;
+ }
+
+ @Managed
+ @ManagedDescription("Remove the expired locks")
+ public void cleanExpiredLocks()
+ {
+ removeExpired();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#getLock(org.exoplatform.services.jcr
+ * .impl.core.NodeImpl)
+ */
+ public LockImpl getLock(NodeImpl node) throws LockException, RepositoryException
+ {
+
+ LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+
+ if (lData == null || (!node.getInternalIdentifier().equals(lData.getNodeIdentifier()) && !lData.isDeep()))
+ {
+ throw new LockException("Node not locked: " + node.getData().getQPath());
+ }
+ return new CacheLockImpl(node.getSession(), lData, this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.exoplatform.services.jcr.impl.core.lock.LockManager#getLockTokens(java.lang.String)
+ */
+ public synchronized String[] getLockTokens(String sessionID)
+ {
+ Set<String> lockTokens = lockTokenHolders.get(sessionID);
+
+ if (lockTokens != null)
+ {
+ String[] arr = new String[lockTokens.size()];
+ lockTokens.toArray(arr);
+ return arr;
+ }
+ else
+ {
+ return new String[0];
+ }
+ }
+
+ /**
+ * Returns real token, if session has it
+ *
+ * @param lockData
+ * @return
+ */
+ // public String getLockToken(LockData lockData)
+ // {
+ // return tokenHash.get(lockData.getTokenHash());
+ // }
+
+ @Managed
+ @ManagedDescription("The number of active locks")
+ public int getNumLocks()
+ {
+ return lockRoot.getChildrenNames().size();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#holdsLock(org.exoplatform.services.
+ * jcr.impl.core.NodeImpl)
+ */
+ public boolean holdsLock(NodeData node) throws RepositoryException
+ {
+ return getLockData(node, SEARCH_EXECMATCH) != null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#isLocked(org.exoplatform.services.jcr
+ * .datamodel.NodeData)
+ */
+ public boolean isLocked(NodeData node)
+ {
+ LockData lData = getLockData(node, SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+
+ if (lData == null || (!node.getIdentifier().equals(lData.getNodeIdentifier()) && !lData.isDeep()))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#isLockHolder(org.exoplatform.services
+ * .jcr.impl.core.NodeImpl)
+ */
+ public boolean isLockHolder(NodeImpl node) throws RepositoryException
+ {
+ LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+ return lData != null && isLockHolder(node.getSession().getId(), lData.getToken());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.core.SessionLifecycleListener#onCloseSession(org.exoplatform.services
+ * .jcr.core.ExtendedSession)
+ */
+ public synchronized void onCloseSession(ExtendedSession session)
+ {
+ SessionImpl sessionImpl = (SessionImpl)session;
+
+ for (LockData lockData : getLockList())
+ {
+ //TODO check is live or remove it
+ //if (lockData.isLive())
+ //{
+ // check is lock holder
+ if (lockTokenHolders.containsKey(session.getId())
+ && lockTokenHolders.get(session.getId()).contains(lockData.getToken()))
+ {
+ if (lockData.isSessionScoped())
+ {
+ // if no session currently holds lock except this
+ try
+ {
+ ((NodeImpl)sessionImpl.getTransientNodesManager().getItemByIdentifier(lockData.getNodeIdentifier(),
+ false)).unlock();
+ }
+ catch (UnsupportedRepositoryOperationException e)
+ {
+ log.error(e.getLocalizedMessage());
+ }
+ catch (LockException e)
+ {
+ log.error(e.getLocalizedMessage());
+ }
+ catch (AccessDeniedException e)
+ {
+ log.error(e.getLocalizedMessage());
+ }
+ catch (RepositoryException e)
+ {
+ log.error(e.getLocalizedMessage());
+ }
+
+ }
+ else
+ {
+ this.removeLockToken(session.getId(), lockData.getToken());
+ }
+ }
+ //TODO
+ // }
+ // else
+ // {
+ // entries.remove();
+ // }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @seeorg.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener#onSaveItems(org.
+ * exoplatform.services.jcr.dataflow.ItemStateChangesLog)
+ */
+ public void onSaveItems(ItemStateChangesLog changesLog)
+ {
+ List<PlainChangesLog> chengesLogList = new ArrayList<PlainChangesLog>();
+ if (changesLog instanceof TransactionChangesLog)
+ {
+ ChangesLogIterator logIterator = ((TransactionChangesLog)changesLog).getLogIterator();
+
+ while (logIterator.hasNextLog())
+ {
+ chengesLogList.add(logIterator.nextLog());
+ }
+ }
+ else if (changesLog instanceof PlainChangesLog)
+ {
+ chengesLogList.add((PlainChangesLog)changesLog);
+ }
+ else if (changesLog instanceof CompositeChangesLog)
+ {
+ for (ChangesLogIterator iter = ((CompositeChangesLog)changesLog).getLogIterator(); iter.hasNextLog();)
+ {
+ chengesLogList.add(iter.nextLog());
+ }
+ }
+
+ for (PlainChangesLog currChangesLog : chengesLogList)
+ {
+ String nodeIdentifier;
+ try
+ {
+ switch (currChangesLog.getEventType())
+ {
+ case ExtendedEvent.LOCK :
+ if (currChangesLog.getSize() < 2)
+ {
+ log.error("Incorrect changes log of type ExtendedEvent.LOCK size=" + currChangesLog.getSize()
+ + "<2 \n" + currChangesLog.dump());
+ break;
+ }
+ nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
+
+ if (pendingLocks.containsKey(nodeIdentifier))
+ {
+ internalLock(nodeIdentifier);
+ }
+ else
+ {
+ throw new LockException("Lock must exist in pending locks.");
+ }
+ break;
+ case ExtendedEvent.UNLOCK :
+ if (currChangesLog.getSize() < 2)
+ {
+ log.error("Incorrect changes log of type ExtendedEvent.UNLOCK size=" + currChangesLog.getSize()
+ + "<2 \n" + currChangesLog.dump());
+ break;
+ }
+
+ internalUnLock(currChangesLog.getSessionId(), currChangesLog.getAllStates().get(0).getData()
+ .getParentIdentifier());
+ break;
+ default :
+ HashSet<String> removedLock = new HashSet<String>();
+ for (ItemState itemState : currChangesLog.getAllStates())
+ {
+ // this is a node and node is locked
+ if (itemState.getData().isNode() && lockExist(itemState.getData().getIdentifier()))
+ {
+ nodeIdentifier = itemState.getData().getIdentifier();
+ if (itemState.isDeleted())
+ {
+ removedLock.add(nodeIdentifier);
+ }
+ else if (itemState.isAdded() || itemState.isRenamed() || itemState.isUpdated())
+ {
+ removedLock.remove(nodeIdentifier);
+ }
+ }
+ }
+ for (String identifier : removedLock)
+ {
+ internalUnLock(currChangesLog.getSessionId(), identifier);
+ }
+ break;
+ }
+ }
+ catch (LockException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ catch (IllegalStateException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ }
+ }
+
+ /**
+ * Refreshed lock data in cache
+ *
+ * @param newLockData
+ */
+ public void refresh(LockData newLockData) throws LockException
+ {
+ //first look pending locks
+ if (pendingLocks.containsKey(newLockData.getNodeIdentifier()))
+ {
+ pendingLocks.put(newLockData.getNodeIdentifier(), newLockData);
+ }
+ else
+ {
+ Fqn<String> id = Fqn.fromString(newLockData.getNodeIdentifier());
+ if (lockRoot.hasChild(id))
+ {
+ lockRoot.addChild(id);
+ }
+ else
+ {
+ throw new LockException("Can't refresh lock for node " + newLockData.getNodeIdentifier()
+ + " since lock is not exist");
+ }
+ }
+ }
+
+ /**
+ * Remove expired locks. Used from LockRemover.
+ */
+ public synchronized void removeExpired()
+ {
+ final List<String> removeLockList = new ArrayList<String>();
+
+ for (LockData lock : getLockList())
+ {
+ if (!lock.isSessionScoped() && lock.getTimeToDeath() < 0)
+ {
+ removeLockList.add(lock.getNodeIdentifier());
+ }
+ }
+
+ for (String rLock : removeLockList)
+ {
+ removeLock(rLock);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#lockTokenRemoved(org.exoplatform.services
+ * .jcr.impl.core.SessionImpl, java.lang.String)
+ */
+ public synchronized void removeLockToken(String sessionId, String lt)
+ {
+ if (lockTokenHolders.containsKey(sessionId) && lockTokenHolders.get(sessionId).contains(lt))
+ {
+ lockTokenHolders.get(sessionId).remove(lt);
+ if (lockTokenHolders.get(sessionId).size() == 0)
+ {
+ lockTokenHolders.remove(sessionId);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.picocontainer.Startable#start()
+ */
+ public void start()
+ {
+ cache.start();
+ //tokenRoot = cache.getRoot().addChild(Fqn.fromString(TOKENS));
+ lockRoot = cache.getRoot().addChild(Fqn.fromString(LOCKS));
+ lockRoot.setResident(true);
+ lockRemover = new LockRemover(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.picocontainer.Startable#stop()
+ */
+ public void stop()
+ {
+ lockRemover.halt();
+ lockRemover.interrupt();
+ pendingLocks.clear();
+
+ // clear lockTokenHolders
+ for (String sessionId : lockTokenHolders.keySet())
+ {
+ lockTokenHolders.get(sessionId).clear();
+ }
+ lockTokenHolders.clear();
+
+ cache.stop();
+ }
+
+ /**
+ * Copy <code>PropertyData prop<code> to new TransientItemData
+ *
+ * @param prop
+ * @return
+ * @throws RepositoryException
+ */
+ private TransientItemData copyItemData(PropertyData prop) throws RepositoryException
+ {
+
+ if (prop == null)
+ return null;
+
+ // make a copy, value may be null for deleting items
+ TransientPropertyData newData =
+ new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(), prop.getType(),
+ prop.getParentIdentifier(), prop.isMultiValued(), prop.getValues());
+
+ return newData;
+ }
+
+ /**
+ * Calculates md5 hash of string.
+ *
+ * @param token
+ * @return
+ */
+ private String getHash(String token)
+ {
+ String hash = "";
+ try
+ {
+ MessageDigest m = MessageDigest.getInstance("MD5");
+ m.update(token.getBytes(), 0, token.length());
+ hash = new BigInteger(1, m.digest()).toString(16);
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ log.error("Can't get instanse of MD5 MessageDigest!", e);
+ }
+ return hash;
+ }
+
+ /**
+ * Search lock in maps.
+ *
+ * @param data
+ * @param searchType
+ * @return
+ */
+ private LockData getLockData(NodeData data, int searchType)
+ {
+ if (data == null || getNumLocks() == 0)
+ return null;
+ LockData retval = null;
+ try
+ {
+ if ((searchType & SEARCH_EXECMATCH) != 0)
+ {
+ retval = getLockDataById(data.getIdentifier());
+ }
+ if (retval == null && (searchType & SEARCH_CLOSEDPARENT) != 0)
+ {
+
+ NodeData parentData = (NodeData)dataManager.getItemData(data.getParentIdentifier());
+ if (parentData != null)
+ {
+ retval = getLockDataById(parentData.getIdentifier());
+ // parent not found try to fo upper
+ if (retval == null)
+ {
+ retval = getLockData(parentData, SEARCH_CLOSEDPARENT);
+ }
+ }
+ }
+ if (retval == null && (searchType & SEARCH_CLOSEDCHILD) != 0)
+ {
+
+ List<NodeData> childData = dataManager.getChildNodesData(data);
+ for (NodeData nodeData : childData)
+ {
+ retval = getLockDataById(nodeData.getIdentifier());
+ if (retval != null)
+ break;
+ }
+ if (retval == null)
+ {
+ // child not found try to find diper
+ for (NodeData nodeData : childData)
+ {
+ retval = getLockData(nodeData, SEARCH_CLOSEDCHILD);
+ if (retval != null)
+ break;
+ }
+ }
+ }
+ }
+ catch (RepositoryException e)
+ {
+ return null;
+ }
+
+ return retval;
+ }
+
+ private void holdLockToken(String sessionId, String lt)
+ {
+ if (lockTokenHolders.get(sessionId) == null)
+ {
+ lockTokenHolders.put(sessionId, new HashSet<String>());
+ }
+ lockTokenHolders.get(sessionId).add(lt);
+ }
+
+ /**
+ * Internal lock
+ *
+ * @param nodeIdentifier
+ * @throws LockException
+ */
+ private synchronized void internalLock(String nodeIdentifier) throws LockException
+ {
+ LockData lockData = pendingLocks.get(nodeIdentifier);
+ if (lockData != null)
+ {
+ Fqn<String> lockPath = Fqn.fromString(lockData.getNodeIdentifier());
+
+ // addChild will add if absent or return old if present
+ Node<Serializable, Object> node = lockRoot.addChild(lockPath);
+
+ // this will prevent from deleting by eviction.
+ node.setResident(true);
+
+ // this will return null if success. And old data if something exists...
+ LockData oldLockData = (LockData)node.putIfAbsent(LOCK_DATA, lockData);
+
+ if (oldLockData != null)
+ {
+ throw new LockException("Unable to write LockData. Node [" + lockData.getNodeIdentifier()
+ + "] already has LockData!");
+ }
+ pendingLocks.remove(nodeIdentifier);
+ }
+ else
+ {
+ throw new LockException("No lock in pending locks");
+ }
+ }
+
+ /**
+ * For locks comes from remote JCRs (replication usecase)
+ *
+ * @param sessionId
+ * String
+ * @param nodeIdentifier
+ * String
+ * @param lockToken
+ * String
+ * @param isDeep
+ * boolean
+ * @param sessionScoped
+ * boolean
+ * @param owner
+ * String
+ * @return LockData
+ */
+ // private synchronized LockData createRemoteLock(String sessionId, String nodeIdentifier, String lockToken,
+ // boolean isDeep, boolean sessionScoped, String owner)
+ // {
+ // LockData lData = new LockData(nodeIdentifier, lockToken, isDeep, sessionScoped, owner, lockTimeOut);
+ // lData.addLockHolder(sessionId);
+ // locks.put(nodeIdentifier, lData);
+ // tokensMap.put(lockToken, lData);
+ //
+ // return lData;
+ // }
+
+ /**
+ * Internal unlock.
+ *
+ * @param sessionId
+ * @param nodeIdentifier
+ * @throws LockException
+ */
+ private synchronized void internalUnLock(String sessionId, String nodeIdentifier) throws LockException
+ {
+ LockData lData = getLockDataById(nodeIdentifier);
+
+ if (lData != null)
+ {
+ //tokenRoot.removeChild(Fqn.fromString(lData.getToken()));
+ lockRoot.removeChild(Fqn.fromString(nodeIdentifier));
+
+ // remove session holder
+ if (lockTokenHolders.containsKey(sessionId))
+ {
+ lockTokenHolders.get(sessionId).remove(lData.getToken());
+ if (lockTokenHolders.get(sessionId).size() == 0)
+ {
+ lockTokenHolders.remove(sessionId);
+ }
+ }
+ }
+ }
+
+ private boolean isLockHolder(String sessionId, String lockToken)
+ {
+ Set<String> lockTokens = lockTokenHolders.get(sessionId);
+ if (lockTokens != null)
+ {
+ return lockTokens.contains(lockToken);
+ }
+ return false;
+ }
+
+ private boolean lockExist(String nodeId)
+ {
+ return lockRoot.hasChild(Fqn.fromString(nodeId));
+ }
+
+ protected LockData getLockDataById(String nodeId)
+ {
+ LockData lockData = null;
+ Node<Serializable, Object> node = lockRoot.getChild(Fqn.fromString(nodeId));
+ if (node != null)
+ {
+ lockData = (LockData)node.get(LOCK_DATA);
+ }
+ return lockData;
+ }
+
+ protected synchronized List<LockData> getLockList()
+ {
+ Set<Node<Serializable, Object>> lockSet = lockRoot.getChildren();
+
+ List<LockData> locksData = new ArrayList<LockData>();
+ for (Node<Serializable, Object> node : lockSet)
+ {
+ if (node != null)
+ {
+ LockData lockData = (LockData)node.get(LOCK_DATA);
+ if (lockData != null)
+ {
+ locksData.add(lockData);
+ }
+ }
+ }
+ return locksData;
+ }
+
+ /**
+ * Remove lock, used by Lock remover.
+ *
+ * @param nodeIdentifier String
+ */
+ protected void removeLock(String nodeIdentifier)
+ {
+ try
+ {
+ NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier);
+ PlainChangesLog changesLog =
+ new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
+
+ ItemData lockOwner =
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
+
+ changesLog.add(ItemState.createDeletedState(lockOwner));
+
+ ItemData lockIsDeep =
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
+ changesLog.add(ItemState.createDeletedState(lockIsDeep));
+
+ // lock probably removed by other thread
+ if (lockOwner == null && lockIsDeep == null)
+ return;
+ dataManager.save(new TransactionChangesLog(changesLog));
+
+ }
+ catch (RepositoryException e)
+ {
+ log.error("Error occur during removing lock" + e.getLocalizedMessage(), e);
+ }
+ }
+
+ public String getLockToken(String sessionId, LockData lockData)
+ {
+ if (lockTokenHolders.containsKey(sessionId) && lockTokenHolders.get(sessionId).contains(lockData.getToken()))
+ {
+ return lockData.getToken();
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockData.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/LockData.java 2010-01-15 13:00:59 UTC (rev 1406)
@@ -0,0 +1,243 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.core.lock.cache;
+
+import org.exoplatform.services.jcr.impl.Constants;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady Azarenkov</a>
+ * @version $Id: LockData.java 787 2009-11-20 11:36:15Z nzamosenchuk $
+ */
+
+public class LockData implements Externalizable //extends org.exoplatform.services.jcr.impl.core.lock.LockData
+{
+ /**
+ * The time of birth. From this time we start count the time of death. death = birthday+TIME_OUT;
+ */
+ private long birthday;
+
+ /**
+ * If isDeep is true then the lock applies to this node and all its descendant nodes; if false,
+ * the lock applies only to this, the holding node.
+ */
+ private boolean deep;
+
+ /**
+ * A lock token is a string that uniquely identifies a particular lock and acts as a “key”
+ * allowing a user to alter a locked node. LockData stores only token hash.
+ */
+ private String token;
+
+ /**
+ * Identifier of locked node.
+ */
+ private String nodeIdentifier;
+
+ /**
+ * The owner of the locked node.
+ */
+ private String owner;
+
+ /**
+ * If isSessionScoped is true then this lock will expire upon the expiration of the current
+ * session (either through an automatic or explicit Session.logout); if false, this lock does not
+ * expire until explicitly unlocked or automatically unlocked due to a implementation-specific
+ * limitation, such as a timeout.
+ */
+ private boolean sessionScoped;
+
+ /**
+ * <B>8.4.9 Timing Out</B> An implementation may unlock any lock at any time due to
+ * implementation-specific criteria, such as time limits on locks.
+ */
+ private long timeOut;
+
+ // Need for Externalizable
+ public LockData()
+ {
+ this.sessionScoped = false;
+ this.deep = false;
+ }
+
+ /**
+ * @param nodeIdentifier
+ * @param lockToken
+ * @param deep
+ * @param sessionScoped
+ * @param owner
+ * @param timeOut
+ * is seconds!
+ */
+ public LockData(String nodeIdentifier, String lockToken, boolean deep, boolean sessionScoped, String owner,
+ long timeOut)
+ {
+ this.nodeIdentifier = nodeIdentifier;
+ this.token = lockToken;
+ this.deep = deep;
+ this.sessionScoped = sessionScoped;
+ this.owner = owner;
+ this.timeOut = timeOut;
+ this.birthday = System.currentTimeMillis() / 1000;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (super.equals(obj))
+ {
+ return true;
+ }
+ if (obj instanceof LockData)
+ {
+ return hashCode() == obj.hashCode();
+ }
+ return false;
+ }
+
+ /**
+ * @return the nodeIdentifier
+ */
+ public String getNodeIdentifier()
+ {
+ return nodeIdentifier;
+ }
+
+ /**
+ * @return
+ */
+ public String getOwner()
+ {
+ return owner;
+ }
+
+ /**
+ * @return The time to death in millis
+ */
+ public long getTimeToDeath()
+ {
+ return birthday + timeOut - System.currentTimeMillis() / 1000;
+ }
+
+ public String getToken()
+ {
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode()
+ {
+ return token.hashCode();
+ }
+
+ public boolean isDeep()
+ {
+ return deep;
+ }
+
+ /**
+ * @return
+ */
+ public boolean isSessionScoped()
+ {
+ return sessionScoped;
+ }
+
+ /**
+ * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ // read boolean
+ this.deep = in.readBoolean();
+ this.sessionScoped = in.readBoolean();
+ // read long
+ this.birthday = in.readLong();
+ this.timeOut = in.readLong();
+ //read strings
+ // read uuid
+ byte[] buf;
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ this.nodeIdentifier = new String(buf, Constants.DEFAULT_ENCODING);
+ // read owner
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ this.owner = new String(buf, Constants.DEFAULT_ENCODING);
+ // read token
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ this.token = new String(buf, Constants.DEFAULT_ENCODING);
+ }
+
+ /**
+ * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ // write boolean
+ out.writeBoolean(deep);
+ out.writeBoolean(sessionScoped);
+ // write long
+ out.writeLong(birthday);
+ out.writeLong(timeOut);
+ // write string
+ // node uuid
+ byte[] ptbuf = nodeIdentifier.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(ptbuf.length);
+ out.write(ptbuf);
+ // node owner
+ ptbuf = owner.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(ptbuf.length);
+ out.write(ptbuf);
+ // node token
+ ptbuf = token.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(ptbuf.length);
+ out.write(ptbuf);
+
+ }
+
+ /**
+ * @return
+ */
+ protected long getTimeOut()
+ {
+ return timeOut;
+ }
+
+ public void setTimeOut(long timeOut)
+ {
+ this.timeOut = timeOut;
+ }
+
+}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig.xml 2010-01-15 12:48:11 UTC (rev 1405)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig.xml 2010-01-15 13:00:59 UTC (rev 1406)
@@ -3,10 +3,4 @@
<locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="3600000"/>
- <!-- Configure the TransactionManager -->
- <transaction transactionManagerLookupClass="org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup" />
-
- <!-- Enable batching -->
- <invocationBatching enabled="true" />
-
</jbosscache>
16 years, 6 months