[exo-jcr-commits] exo-jcr SVN: r1426 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: main/resources and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Jan 16 05:13:10 EST 2010


Author: areshetnyak
Date: 2010-01-16 05:13:10 -0500 (Sat, 16 Jan 2010)
New Revision: 1426

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/resources/binding.xml
   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-jcr-config.xml
Log:
EXOJCR-332 : Add setting parameners as property to lock manager configuration.

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-16 09:59:17 UTC (rev 1425)
+++ 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-16 10:13:10 UTC (rev 1426)
@@ -22,6 +22,7 @@
 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.SimpleParameterEntry;
 import org.exoplatform.services.jcr.config.WorkspaceEntry;
 import org.exoplatform.services.jcr.core.ExtendedSession;
 import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
@@ -85,9 +86,21 @@
  */
 @Managed
 @NameTemplate(@Property(key = "service", value = "lockmanager"))
-public class CacheableLockManager extends AbstractLockManager implements ItemsPersistenceListener, Startable
+public class CacheableLockManager
+   extends AbstractLockManager
+   implements ItemsPersistenceListener, Startable
 {
    /**
+    *  The name to property time out. 
+    */
+   public static final String TIME_OUT = "time-out";
+
+   /**
+    *  The name to property cache configuration. 
+    */
+   public static final String JBOSSCACCHE_CONFIG = "jbosscache-configuration";
+
+   /**
     * Default lock time out. 30min
     */
    public static final long DEFAULT_LOCK_TIMEOUT = 1000 * 60 * 30;
@@ -121,7 +134,7 @@
    /**
     * Logger
     */
-   private final Log log = ExoLogger.getLogger("jcr.lock.LockManager");
+   private final Log log = ExoLogger.getLogger("jcr.lock.CacheableLockManager");
 
    /**
     * Data manager.
@@ -159,19 +172,31 @@
     * @param config
     */
    public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config)
-      throws RepositoryConfigurationException
+            throws RepositoryConfigurationException
    {
       this(dataManager, config, null);
    }
 
    public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
-      LockPersister persister) throws RepositoryConfigurationException
+            LockPersister persister) throws RepositoryConfigurationException
    {
+       List<SimpleParameterEntry> paramenerts = config.getLockManager().getParameters();
+      
       this.dataManager = dataManager;
       if (config.getLockManager() != null)
       {
-         lockTimeOut =
-            config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout() : DEFAULT_LOCK_TIMEOUT;
+         if (paramenerts != null && config.getLockManager().getParameterValue(TIME_OUT, null) != null)
+         {
+            long timeOut = config.getLockManager().getParameterTime(TIME_OUT);
+            lockTimeOut = timeOut > 0 ? timeOut : DEFAULT_LOCK_TIMEOUT;
+         }
+         else
+         {
+            lockTimeOut =
+                     config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout()
+                              : DEFAULT_LOCK_TIMEOUT;
+         }
+
       }
       else
          lockTimeOut = DEFAULT_LOCK_TIMEOUT;
@@ -182,9 +207,12 @@
       dataManager.addItemPersistenceListener(this);
 
       // make cache
-      if (config.getLockManager() != null && config.getLockManager().getCacheConfig() != null)
+      if (config.getLockManager() != null
+               && (config.getLockManager().getCacheConfig() != null || (paramenerts != null && config
+                        .getLockManager().getParameterValue(JBOSSCACCHE_CONFIG, null) != null)))
       {
-         String pathToConfig = config.getLockManager().getCacheConfig();
+         String pathToConfig = (paramenerts != null && config.getLockManager().getParameterValue(JBOSSCACCHE_CONFIG, null) != null) ? config.getLockManager()
+                           .getParameterValue(JBOSSCACCHE_CONFIG) : config.getLockManager().getCacheConfig();
          CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
          cache = factory.createCache(pathToConfig, false);
          cache.create();
@@ -213,9 +241,9 @@
     * .jcr.impl.core.NodeImpl, boolean, boolean, long)
     */
    public synchronized Lock addPendingLock(NodeImpl node, boolean isDeep, boolean isSessionScoped, long timeOut)
-      throws LockException
+            throws LockException
    {
-      LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+      LockData lData = getLockData((NodeData) node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
       if (lData != null)
       {
          if (lData.getNodeIdentifier().equals(node.getInternalIdentifier()))
@@ -228,15 +256,15 @@
          }
       }
 
-      if (isDeep && getLockData((NodeData)node.getData(), SEARCH_CLOSEDCHILD) != null)
+      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);
+               new LockData(node.getInternalIdentifier(), lockToken, isDeep, isSessionScoped, node.getSession()
+                        .getUserID(), timeOut > 0 ? timeOut : lockTimeOut);
 
       holdLockToken(node.getSession().getId(), lockToken);
       pendingLocks.put(node.getInternalIdentifier(), lData);
@@ -261,7 +289,7 @@
    public LockImpl getLock(NodeImpl node) throws LockException, RepositoryException
    {
 
-      LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+      LockData lData = getLockData((NodeData) node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
 
       if (lData == null || (!node.getInternalIdentifier().equals(lData.getNodeIdentifier()) && !lData.isDeep()))
       {
@@ -344,7 +372,7 @@
     */
    public boolean isLockHolder(NodeImpl node) throws RepositoryException
    {
-      LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+      LockData lData = getLockData((NodeData) node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
       return lData != null && isLockHolder(node.getSession().getId(), lData.getToken());
    }
 
@@ -364,21 +392,21 @@
     */
    public synchronized void onCloseSession(ExtendedSession session)
    {
-      SessionImpl sessionImpl = (SessionImpl)session;
+      SessionImpl sessionImpl = (SessionImpl) session;
 
       for (LockData lockData : getLockList())
       {
          // check is lock holder
          if (lockTokenHolders.containsKey(session.getId())
-            && lockTokenHolders.get(session.getId()).contains(lockData.getToken()))
+                  && 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();
+                  ((NodeImpl) sessionImpl.getTransientNodesManager().getItemByIdentifier(lockData.getNodeIdentifier(),
+                           false)).unlock();
                }
                catch (UnsupportedRepositoryOperationException e)
                {
@@ -416,7 +444,7 @@
       List<PlainChangesLog> chengesLogList = new ArrayList<PlainChangesLog>();
       if (changesLog instanceof TransactionChangesLog)
       {
-         ChangesLogIterator logIterator = ((TransactionChangesLog)changesLog).getLogIterator();
+         ChangesLogIterator logIterator = ((TransactionChangesLog) changesLog).getLogIterator();
 
          while (logIterator.hasNextLog())
          {
@@ -425,11 +453,11 @@
       }
       else if (changesLog instanceof PlainChangesLog)
       {
-         chengesLogList.add((PlainChangesLog)changesLog);
+         chengesLogList.add((PlainChangesLog) changesLog);
       }
       else if (changesLog instanceof CompositeChangesLog)
       {
-         for (ChangesLogIterator iter = ((CompositeChangesLog)changesLog).getLogIterator(); iter.hasNextLog();)
+         for (ChangesLogIterator iter = ((CompositeChangesLog) changesLog).getLogIterator(); iter.hasNextLog();)
          {
             chengesLogList.add(iter.nextLog());
          }
@@ -446,7 +474,7 @@
                   if (currChangesLog.getSize() < 2)
                   {
                      log.error("Incorrect changes log  of type ExtendedEvent.LOCK size=" + currChangesLog.getSize()
-                        + "<2 \n" + currChangesLog.dump());
+                              + "<2 \n" + currChangesLog.dump());
                      break;
                   }
                   nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
@@ -464,12 +492,12 @@
                   if (currChangesLog.getSize() < 2)
                   {
                      log.error("Incorrect changes log  of type ExtendedEvent.UNLOCK size=" + currChangesLog.getSize()
-                        + "<2 \n" + currChangesLog.dump());
+                              + "<2 \n" + currChangesLog.dump());
                      break;
                   }
 
                   internalUnLock(currChangesLog.getSessionId(), currChangesLog.getAllStates().get(0).getData()
-                     .getParentIdentifier());
+                           .getParentIdentifier());
                   break;
                default :
                   HashSet<String> removedLock = new HashSet<String>();
@@ -529,7 +557,7 @@
          else
          {
             throw new LockException("Can't refresh lock for node " + newLockData.getNodeIdentifier()
-               + " since lock is not exist");
+                     + " since lock is not exist");
          }
       }
    }
@@ -621,8 +649,8 @@
 
       // 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());
+               new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(), prop
+                        .getType(), prop.getParentIdentifier(), prop.isMultiValued(), prop.getValues());
 
       return newData;
    }
@@ -670,7 +698,7 @@
          if (retval == null && (searchType & SEARCH_CLOSEDPARENT) != 0)
          {
 
-            NodeData parentData = (NodeData)dataManager.getItemData(data.getParentIdentifier());
+            NodeData parentData = (NodeData) dataManager.getItemData(data.getParentIdentifier());
             if (parentData != null)
             {
                retval = getLockDataById(parentData.getIdentifier());
@@ -740,12 +768,12 @@
          node.setResident(true);
 
          // this will return null if success. And old data if something exists...
-         LockData oldLockData = (LockData)node.putIfAbsent(LOCK_DATA, lockData);
+         LockData oldLockData = (LockData) node.putIfAbsent(LOCK_DATA, lockData);
 
          if (oldLockData != null)
          {
             throw new LockException("Unable to write LockData. Node [" + lockData.getNodeIdentifier()
-               + "] already has LockData!");
+                     + "] already has LockData!");
          }
          pendingLocks.remove(nodeIdentifier);
       }
@@ -832,7 +860,7 @@
       Node<Serializable, Object> node = lockRoot.getChild(Fqn.fromString(nodeId));
       if (node != null)
       {
-         lockData = (LockData)node.get(LOCK_DATA);
+         lockData = (LockData) node.get(LOCK_DATA);
       }
       return lockData;
    }
@@ -846,7 +874,7 @@
       {
          if (node != null)
          {
-            LockData lockData = (LockData)node.get(LOCK_DATA);
+            LockData lockData = (LockData) node.get(LOCK_DATA);
             if (lockData != null)
             {
                locksData.add(lockData);
@@ -865,17 +893,19 @@
    {
       try
       {
-         NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier);
+         NodeData nData = (NodeData) dataManager.getItemData(nodeIdentifier);
          PlainChangesLog changesLog =
-            new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
+                  new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
 
          ItemData lockOwner =
-            copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
+                  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)));
+                  copyItemData((PropertyData) dataManager.getItemData(nData,
+                           new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
          changesLog.add(ItemState.createDeletedState(lockIsDeep));
 
          // lock probably removed by other thread

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/resources/binding.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/resources/binding.xml	2010-01-16 09:59:17 UTC (rev 1425)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/resources/binding.xml	2010-01-16 10:13:10 UTC (rev 1426)
@@ -66,9 +66,11 @@
 
     <structure name="lock-manager" field="lockManager" usage="optional">
       <value name="class" field="type" style="attribute" usage="optional" />
+      <collection name="properties" field="parameters" usage="optional"
+        item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
+        factory="org.jibx.runtime.Utility.arrayListFactory" />
       <value name="time-out" field="timeout" usage="optional" 
 			  deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseTime" />
-      
       <value name="jbosscache-configuration" field="cacheConfig" usage="optional" />
       
       <structure name="persister" field="persister" usage="optional">

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-16 09:59:17 UTC (rev 1425)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lockconfig.xml	2010-01-16 10:13:10 UTC (rev 1426)
@@ -3,4 +3,26 @@
 
    <locking useLockStriping="false" concurrencyLevel="50000" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="3600000"/>
    
+   <!-- loaders passivation="false" shared="false">
+        
+      <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="true"
+              ignoreModifications="false" purgeOnStartup="false">
+         <properties>
+            cache.jdbc.table.name=jdbcjcr
+            cache.jdbc.table.create=true
+            cache.jdbc.table.drop=true
+            cache.jdbc.table.primarykey=exojcr_pk
+            cache.jdbc.fqn.column=fqn
+            cache.jdbc.fqn.type=VARCHAR(512)
+            cache.jdbc.node.column=node
+            cache.jdbc.node.type=VARBINARY(65535)
+            cache.jdbc.parent.column=parent
+            cache.jdbc.driver=org.hsqldb.jdbcDriver
+            cache.jdbc.url="jdbc:hsqldb:file:target/temp/data/exojcr
+            cache.jdbc.user=sa
+            cache.jdbc.password=
+          </properties>
+      </loader>  
+   </loaders -->
+   
 </jbosscache>

Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml	2010-01-16 09:59:17 UTC (rev 1425)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml	2010-01-16 10:13:10 UTC (rev 1426)
@@ -80,8 +80,10 @@
                    </properties>
                </query-handler>
                <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
-                  <time-out>15m</time-out>
-                  <jbosscache-configuration>conf/standalone/test-jbosscache-lockconfig.xml</jbosscache-configuration>
+                  <properties>
+                     <property name="time-out" value="15m" />
+                     <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lockconfig.xml" />
+                  </properties>
                </lock-manager>
             </workspace>
 
@@ -123,8 +125,10 @@
                   </properties>
                </query-handler>
                <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
-                  <time-out>15m</time-out>
-                  <jbosscache-configuration>conf/standalone/test-jbosscache-lockconfig.xml</jbosscache-configuration>
+                  <properties>
+                     <property name="time-out" value="15m" />
+                     <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lockconfig.xml" />
+                  </properties>
                </lock-manager>
             </workspace>
 
@@ -166,8 +170,10 @@
                   </properties>
                </query-handler>
                <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
-                  <time-out>15m</time-out>
-                  <jbosscache-configuration>conf/standalone/test-jbosscache-lockconfig.xml</jbosscache-configuration>
+                  <properties>
+                     <property name="time-out" value="15m" />
+                     <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lockconfig.xml" />
+                  </properties>
                </lock-manager>
             </workspace>
             
@@ -241,8 +247,10 @@
 						</properties>
 					</query-handler>
                     <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
-                      <time-out>15m</time-out>
-                      <jbosscache-configuration>conf/standalone/test-jbosscache-lockconfig.xml</jbosscache-configuration>
+                      <properties>
+                         <property name="time-out" value="15m" />
+                         <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lockconfig.xml" />
+                      </properties>
                     </lock-manager>
 				</workspace>
          </workspaces>
@@ -301,8 +309,10 @@
                   </properties>
                </query-handler>
                <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
-                  <time-out>15m</time-out>
-                  <jbosscache-configuration>conf/standalone/test-jbosscache-lockconfig.xml</jbosscache-configuration>
+                  <properties>
+                     <property name="time-out" value="15m" />
+                     <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lockconfig.xml" />
+                  </properties>
                </lock-manager>
             </workspace>
 
@@ -350,8 +360,10 @@
                   </properties>
                </query-handler>
                <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
-                  <time-out>15m</time-out>
-                  <jbosscache-configuration>conf/standalone/test-jbosscache-lockconfig.xml</jbosscache-configuration>
+                  <properties>
+                     <property name="time-out" value="15m" />
+                     <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lockconfig.xml" />
+                  </properties>
                </lock-manager>
             </workspace>
 
@@ -402,8 +414,10 @@
                   </properties>
                </query-handler>
                <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManager">
-                  <time-out>15m</time-out>
-                  <jbosscache-configuration>conf/standalone/test-jbosscache-lockconfig.xml</jbosscache-configuration>
+                  <properties>
+                     <property name="time-out" value="15m" />
+                     <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lockconfig.xml" />
+                  </properties>
                </lock-manager>
             </workspace>
          </workspaces>



More information about the exo-jcr-commits mailing list