Author: nzamosenchuk
Date: 2011-08-11 09:22:33 -0400 (Thu, 11 Aug 2011)
New Revision: 4743
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
Log:
EXOJCR-267 : (partial commit)
1. Limited minimal page size
2. Added isChildNodesByPageSupported() to WorkspaceStorageCache according to remark:
"In WorkspaceStorageCache, we need to add a method of type
isChildNodesByPageSupported to be able to call getChildNodesData(NodeData) and return
false directly when we call CacheableWorkspaceDataManager.getChildNodesDataByPage
otherwise for implementation like LinkedWorkspaceStorageCacheImpl that doesn't support
this feature the result will never be stored into the cache so it will be very
slow."
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java 2011-08-11
13:18:23 UTC (rev 4742)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java 2011-08-11
13:22:33 UTC (rev 4743)
@@ -248,7 +248,7 @@
* @return enabled status flag, if true then cache is enabled
*/
@Managed
- @ManagedDescription("Indicates whether the cache is enabled or not")
+ @ManagedDescription("Indicates whether the cache is enabled or not")
boolean isEnabled();
/**
@@ -258,12 +258,18 @@
boolean isPatternSupported();
/**
+ * @return isPatternSupported status flag, if true then cache can store child lists
grouped
+ * by pages
+ */
+ boolean isChildNodesByPageSupported();
+
+ /**
* Cache size.
*
* @return long value
*/
@Managed
- @ManagedDescription("Indicates the total amount of items into the cache")
+ @ManagedDescription("Indicates the total amount of items into the cache")
long getSize();
/**
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2011-08-11
13:18:23 UTC (rev 4742)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2011-08-11
13:22:33 UTC (rev 4743)
@@ -127,7 +127,7 @@
}
private static final AtomicLong SEQUENCE = new AtomicLong();
-
+
public static final int DEFAULT_LAZY_READ_THRESHOLD = 100;
private final RepositoryImpl repository;
@@ -249,7 +249,7 @@
sessionRegistry.registerSession(this);
this.lastAccessTime = System.currentTimeMillis();
-
+
this.triggerEventsForDescendentsOnRename =
wsConfig.getContainer().getParameterBoolean(WorkspaceDataContainer.TRIGGER_EVENTS_FOR_DESCENDENTS_ON_RENAME,
WorkspaceDataContainer.TRIGGER_EVENTS_FOR_DESCENDENTS_ON_RENAME_DEFAULT);
@@ -257,6 +257,13 @@
this.lazyNodeIteatorPageSize =
wsConfig.getContainer().getParameterInteger(WorkspaceDataContainer.LAZY_NODE_ITERATOR_PAGE_SIZE,
WorkspaceDataContainer.LAZY_NODE_ITERATOR_PAGE_SIZE_DEFAULT);
+ if (this.lazyNodeIteatorPageSize <
WorkspaceDataContainer.LAZY_NODE_ITERATOR_PAGE_SIZE_MIN)
+ {
+ this.lazyNodeIteatorPageSize =
WorkspaceDataContainer.LAZY_NODE_ITERATOR_PAGE_SIZE_MIN;
+ log.warn("Value for \"lazy-node-iterator-page-size\" is too
small. Allowed minimum page size is "
+ + WorkspaceDataContainer.LAZY_NODE_ITERATOR_PAGE_SIZE_MIN + ". Using
required value: "
+ + WorkspaceDataContainer.LAZY_NODE_ITERATOR_PAGE_SIZE_MIN + ".");
+ }
}
/**
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2011-08-11
13:18:23 UTC (rev 4742)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2011-08-11
13:22:33 UTC (rev 4743)
@@ -97,7 +97,7 @@
* The resource manager
*/
private final TransactionableResourceManager txResourceManager;
-
+
private TransactionManager transactionManager;
/**
@@ -362,7 +362,7 @@
* the service for executing commands on all nodes of cluster
*/
public CacheableWorkspaceDataManager(WorkspaceDataContainer dataContainer,
WorkspaceStorageCache cache,
- SystemDataContainerHolder systemDataContainerHolder, TransactionableResourceManager
txResourceManager,
+ SystemDataContainerHolder systemDataContainerHolder, TransactionableResourceManager
txResourceManager,
TransactionService transactionService, RPCService rpcService)
{
super(dataContainer, systemDataContainerHolder, txResourceManager);
@@ -422,7 +422,8 @@
try
{
- transactionManager =
(TransactionManager)cache.getClass().getMethod("getTransactionManager",
null).invoke(null, null);
+ transactionManager =
+
(TransactionManager)cache.getClass().getMethod("getTransactionManager",
null).invoke(null, null);
}
catch (Exception e)
{
@@ -431,7 +432,7 @@
}
this.rpcService = rpcService;
- this.txResourceManager = txResourceManager;
+ this.txResourceManager = txResourceManager;
doInitRemoteCommands();
}
@@ -517,6 +518,14 @@
public boolean getChildNodesDataByPage(final NodeData nodeData, final int
fromOrderNum, final int limit,
final List<NodeData> childs) throws RepositoryException
{
+ // if child nodes lazy iteration feature not supported by cache
+ // then call old-style getChildNodes method
+ if (!cache.isChildNodesByPageSupported())
+ {
+ childs.addAll(getChildNodesData(nodeData));
+ return false;
+ }
+ // if child nodes by page iteration supported, then do it
List<NodeData> childNodes = null;
if (cache.isEnabled())
{
@@ -638,7 +647,8 @@
* {@inheritDoc}
*/
@Override
- public ItemData getItemData(final NodeData parentData, final QPathEntry name, final
ItemType itemType) throws RepositoryException
+ public ItemData getItemData(final NodeData parentData, final QPathEntry name, final
ItemType itemType)
+ throws RepositoryException
{
if (cache.isEnabled())
{
@@ -825,7 +835,7 @@
doSave(changesLog);
return null;
}
- });
+ });
}
catch (PrivilegedActionException e)
{
@@ -891,9 +901,9 @@
// notify listeners after storage commit
notifySaveItems(logWrapper.getChangesLog(), false);
- }
+ }
}
-
+
/**
* Commits the tx
* @throws RepositoryException if the tx could not be committed.
@@ -925,7 +935,7 @@
throw new RepositoryException("Could not create a new Tx", e);
}
}
-
+
/**
* Performs rollback of the action.
*/
@@ -978,7 +988,7 @@
if (status == Status.STATUS_COMMITTED)
{
// Since the tx is successfully committed we can call components non tx
aware
-
+
// The listeners will need to be executed outside the current tx so we
suspend
// the current tx we can face enlistment issues on product like ISPN
transactionManager.suspend();
@@ -1098,8 +1108,8 @@
}
}
- protected List<NodeData> getChildNodesDataByPattern(final NodeData parentData,
final List<QPathEntryFilter> patternFilters)
- throws RepositoryException
+ protected List<NodeData> getChildNodesDataByPattern(final NodeData parentData,
+ final List<QPathEntryFilter> patternFilters) throws RepositoryException
{
if (!cache.isEnabled())
{
@@ -1975,7 +1985,7 @@
public String getId()
{
return
"org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager"
- + "-requestForResponsibilityForResuming-" +
dataContainer.getUniqueName();
+ + "-requestForResponsibilityForResuming-" +
dataContainer.getUniqueName();
}
public Serializable execute(Serializable[] args) throws Throwable
@@ -1987,7 +1997,7 @@
rpcService.registerTopologyChangeListener(this);
}
}
-
+
private <T> T executeAction(PrivilegedExceptionAction<T> action) throws
RepositoryException
{
try
@@ -2033,16 +2043,16 @@
{
// use parent ACL
node =
- new TransientNodeData(node.getQPath(), node.getIdentifier(),
node.getPersistedVersion(),
- node.getPrimaryTypeName(), node.getMixinTypeNames(),
node.getOrderNumber(),
+ new TransientNodeData(node.getQPath(), node.getIdentifier(),
node.getPersistedVersion(), node
+ .getPrimaryTypeName(), node.getMixinTypeNames(),
node.getOrderNumber(),
node.getParentIdentifier(), parent.getACL());
}
else
{
// use nearest ancestor ACL... case of get by id
node =
- new TransientNodeData(node.getQPath(), node.getIdentifier(),
node.getPersistedVersion(),
- node.getPrimaryTypeName(), node.getMixinTypeNames(),
node.getOrderNumber(),
+ new TransientNodeData(node.getQPath(), node.getIdentifier(),
node.getPersistedVersion(), node
+ .getPrimaryTypeName(), node.getMixinTypeNames(),
node.getOrderNumber(),
node.getParentIdentifier(), getNearestACAncestorAcl(node));
}
}
@@ -2052,9 +2062,9 @@
AccessControlList ancestorAcl = getNearestACAncestorAcl(node);
node =
- new TransientNodeData(node.getQPath(), node.getIdentifier(),
node.getPersistedVersion(),
- node.getPrimaryTypeName(), node.getMixinTypeNames(),
node.getOrderNumber(),
- node.getParentIdentifier(), new AccessControlList(acl.getOwner(),
ancestorAcl.getPermissionEntries()));
+ new TransientNodeData(node.getQPath(), node.getIdentifier(),
node.getPersistedVersion(), node
+ .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
node.getParentIdentifier(),
+ new AccessControlList(acl.getOwner(),
ancestorAcl.getPermissionEntries()));
}
else if (!acl.hasOwner())
{
@@ -2062,9 +2072,9 @@
AccessControlList ancestorAcl = getNearestACAncestorAcl(node);
node =
- new TransientNodeData(node.getQPath(), node.getIdentifier(),
node.getPersistedVersion(),
- node.getPrimaryTypeName(), node.getMixinTypeNames(),
node.getOrderNumber(),
- node.getParentIdentifier(), new
AccessControlList(ancestorAcl.getOwner(), acl.getPermissionEntries()));
+ new TransientNodeData(node.getQPath(), node.getIdentifier(),
node.getPersistedVersion(), node
+ .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
node.getParentIdentifier(),
+ new AccessControlList(ancestorAcl.getOwner(),
acl.getPermissionEntries()));
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2011-08-11
13:18:23 UTC (rev 4742)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2011-08-11
13:22:33 UTC (rev 4743)
@@ -1709,6 +1709,14 @@
{
return false;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isChildNodesByPageSupported()
+ {
+ return false;
+ }
/**
* Enable cache.
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2011-08-11
13:18:23 UTC (rev 4742)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2011-08-11
13:22:33 UTC (rev 4743)
@@ -597,10 +597,14 @@
if (skipVersionStorage)
{
if (!ref.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
+ {
refProps.add(ref);
+ }
}
else
+ {
refProps.add(ref);
+ }
}
return refProps;
}
@@ -832,9 +836,13 @@
{
if (item.isNode())
+ {
con.delete((NodeData)item);
+ }
else
+ {
con.delete((PropertyData)item);
+ }
}
/**
@@ -933,22 +941,34 @@
public void addItemPersistenceListener(ItemsPersistenceListener listener)
{
if (listener instanceof MandatoryItemsPersistenceListener)
+ {
mandatoryListeners.add((MandatoryItemsPersistenceListener)listener);
+ }
else
+ {
listeners.add(listener);
+ }
if (LOG.isDebugEnabled())
+ {
LOG.debug("Workspace '" + this.dataContainer.getName() +
"' listener registered: " + listener);
+ }
}
public void removeItemPersistenceListener(ItemsPersistenceListener listener)
{
if (listener instanceof MandatoryItemsPersistenceListener)
+ {
mandatoryListeners.remove(listener);
+ }
else
+ {
listeners.remove(listener);
+ }
if (LOG.isDebugEnabled())
+ {
LOG.debug("Workspace '" + this.dataContainer.getName() +
"' listener unregistered: " + listener);
+ }
}
/**
@@ -980,7 +1000,9 @@
for (ItemsPersistenceListenerFilter f : liestenerFilters)
{
if (!f.accept(listener))
+ {
return false;
+ }
}
return true;
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2011-08-11
13:18:23 UTC (rev 4742)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/ISPNCacheWorkspaceStorageCache.java 2011-08-11
13:22:33 UTC (rev 4743)
@@ -94,7 +94,6 @@
*/
public class ISPNCacheWorkspaceStorageCache implements WorkspaceStorageCache, Backupable
{
-
private static final Log LOG =
ExoLogger.getLogger("exo.jcr.component.core.ISPNCacheWorkspaceStorageCache");
private final boolean enabled;
@@ -1016,6 +1015,14 @@
{
return true;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isChildNodesByPageSupported()
+ {
+ return true;
+ }
/**
* Internal put Item.
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2011-08-11
13:18:23 UTC (rev 4742)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2011-08-11
13:22:33 UTC (rev 4743)
@@ -1361,6 +1361,14 @@
{
return true;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isChildNodesByPageSupported()
+ {
+ return true;
+ }
// non-public members
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java 2011-08-11
13:18:23 UTC (rev 4742)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java 2011-08-11
13:22:33 UTC (rev 4743)
@@ -46,6 +46,8 @@
public static final int LAZY_NODE_ITERATOR_PAGE_SIZE_DEFAULT = 100;
+ public static final int LAZY_NODE_ITERATOR_PAGE_SIZE_MIN = 75;
+
public final static String CONTAINER_NAME = "containerName";
public final static String MAXBUFFERSIZE_PROP = "max-buffer-size";
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2011-08-11
13:18:23 UTC (rev 4742)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2011-08-11
13:22:33 UTC (rev 4743)
@@ -361,6 +361,14 @@
{
return false;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isChildNodesByPageSupported()
+ {
+ return false;
+ }
public List<PropertyData> listChildProperties(NodeData parentData)
{