[exo-jcr-commits] exo-jcr SVN: r785 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Nov 20 04:50:38 EST 2009
Author: pnedonosko
Date: 2009-11-20 04:50:37 -0500 (Fri, 20 Nov 2009)
New Revision: 785
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-203: Node.move re-view & commented the impl, TODO on the problem of cache reload;
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-20 09:48:12 UTC (rev 784)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-20 09:50:37 UTC (rev 785)
@@ -49,6 +49,8 @@
public static final String ITEM_DATA = "$data".intern();
public static final String ITEM_ID = "$id".intern();
+
+ public static final String INVALID_DATA = "$invalidData".intern();
@Deprecated
public static final String SESSION_ID = "$sessionId".intern();
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-20 09:48:12 UTC (rev 784)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-20 09:50:37 UTC (rev 785)
@@ -93,6 +93,54 @@
this.cache = cache;
}
+ // helpers
+ @Deprecated
+ protected NodeData getNodeData(Node<Serializable, Object> node)
+ {
+ Object data = node.get(ITEM_DATA);
+ if (data != null)
+ {
+ // check if invalid
+ if (data.equals(INVALID_DATA))
+ {
+ // evict to force read from DB
+ cache.evict(node.getFqn(), true);
+ Thread.yield();
+
+ // and ask again
+ Node<Serializable, Object> freshNode = cache.getNode(node.getFqn());
+ if (freshNode != null)
+ {
+ Object freshData = freshNode.get(ITEM_DATA);
+ if (freshData != null)
+ {
+ return (NodeData)freshData;
+ }
+ else
+ {
+ // TODO
+ return null;
+ }
+ }
+ else
+ {
+ // TODO
+ return null;
+ }
+ }
+ else
+ {
+ return (NodeData)data;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ // Connection API
+
/**
* {@inheritDoc}
*/
@@ -259,7 +307,7 @@
Node<Serializable, Object> parent = nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
if (parent == null)
{
- throw new RepositoryException("Property parent doesn't exist " + data.getQPath().getAsString());
+ throw new RepositoryException("Property's parent doesn't exist " + data.getQPath().getAsString());
}
if (data.getType() == PropertyType.REFERENCE)
@@ -339,8 +387,8 @@
Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeId));
if (node == null)
{
- throw new RepositoryException("FATAL Node record not found(" + nodeId + "), but listed in proprties of "
- + parent.getQPath().getAsString());
+ throw new RepositoryException("FATAL Node record not found(" + nodeId
+ + "), but listed in child nodes of " + parent.getQPath().getAsString());
}
NodeData nodeData = (NodeData)node.get(ITEM_DATA);
if (nodeData == null)
@@ -548,6 +596,7 @@
}
else
{
+ // TODO move usecase: re-load on demand, try cache.evict(node.getFqn());
throw new RepositoryException("FATAL NodeData empty " + identifier);
}
}
@@ -614,94 +663,88 @@
{
//TODO we expecting that on session.move() there will be only one rename() method call
- startBatch();
-
- String nodeUUID = data.getIdentifier();
-
- //1. Update renamed node and also get old nodeData
- Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeUUID));
- if (node == null)
- {
- throw new RepositoryException("FATAL renamed node is not exist" + data.getQPath().getAsString());
- }
-
- NodeData oldNodeData = (NodeData)node.put(ITEM_DATA, data);
- if (oldNodeData == null)
- {
- throw new RepositoryException("FATAL NodeData is empty " + data.getQPath().getAsString());
- }
-
- // 2. remove renamed node from child list of previous parent node
- // check if parent is cached
- Node<Serializable, Object> oldparent = nodesRoot.getChild(makeNodeFqn(oldNodeData.getParentIdentifier()));
- if (oldparent == null)
- {
- throw new RepositoryException("Nodes old parent doesn't exist " + data.getQPath().getAsString());
- }
-
- // remove node form old parent child list
- boolean removed =
- oldparent
- .removeChild(makeChildNodeFqn(oldNodeData.getQPath().getEntries()[oldNodeData.getQPath().getEntries().length - 1]));
- if (!removed)
- {
- throw new RepositoryException("Node was not removed from child list of old parent "
- + data.getQPath().getAsString());
- }
-
- // 3. add node to child list of new parent node
- if (data.getParentIdentifier() != null)
- {
- // check if parent is cached
- Node<Serializable, Object> newparent = nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
- if (newparent == null)
- {
- throw new RepositoryException("Nodes new parent doesn't exist " + data.getQPath().getAsString());
- }
-
- // add child to Parent
- Node<Serializable, Object> childNode =
- newparent.addChild(makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length - 1]));
-
- // set child id attr
- childNode.put(ITEM_ID, data.getIdentifier());
- }
-
- // 4. update all child nodes
- Set<Node<Serializable, Object>> childNodes = node.getChildren();
-
- for (Node<Serializable, Object> child : childNodes)
- {
- String childNodeId = (String)child.get(ITEM_ID);
- if (childNodeId == null)
- {
- throw new RepositoryException("FATAL Child Node Id key is null. Parent " + data.getQPath().getAsString());
- }
-
- // TODO NodeData or PropertyData? As ItemData check then and cast.
- Node<Serializable, Object> childnode = nodesRoot.getChild(makeNodeFqn(childNodeId));
- if (childnode == null)
- {
- throw new RepositoryException("FATAL Node record not found(" + childNodeId + "), but listed in childs of "
- + data.getQPath().getAsString());
- }
- NodeData nodeData = (NodeData)childnode.get(ITEM_DATA);
- if (nodeData == null)
- {
- // TODO should not occurs by contract
- throw new RepositoryException("Child node data is null. Parent " + data.getQPath().getAsString());
- }
-
- //repack child NodeData with new QPath
- //TODO check it
- QPath newPath = QPath.makeChildPath(data.getQPath(), nodeData.getQPath().getName());
- TransientNodeData newNodeData =
- new TransientNodeData(newPath, nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
- .getPrimaryTypeName(), nodeData.getMixinTypeNames(), nodeData.getOrderNumber(), nodeData
- .getParentIdentifier(), nodeData.getACL());
- childnode.put(ITEM_DATA, newNodeData);
- }
-
+// startBatch();
+//
+// String nodeId = data.getIdentifier();
+//
+// //1. Update renamed node and also get old nodeData
+// Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeId));
+// if (node == null)
+// {
+// throw new InvalidItemStateException("Renamed node is not exist" + data.getQPath().getAsString());
+// }
+//
+// NodeData prevData = (NodeData)node.put(ITEM_DATA, data);
+// if (prevData == null)
+// {
+// throw new RepositoryException("FATAL NodeData is empty " + data.getQPath().getAsString());
+// }
+//
+// // 2. remove renamed node from child list of previous parent node
+// // check if parent is cached
+// Node<Serializable, Object> prevParent = nodesRoot.getChild(makeNodeFqn(prevData.getParentIdentifier()));
+// if (prevParent == null)
+// {
+// throw new InvalidItemStateException("Node's previous parent doesn't exist "
+// + prevData.getQPath().getAsString() + ". Node " + data.getQPath().getAsString());
+// }
+//
+// // remove node form old parent child list
+// if (!prevParent
+// .removeChild(makeChildNodeFqn(prevData.getQPath().getEntries()[prevData.getQPath().getEntries().length - 1])))
+// {
+// throw new RepositoryException("FATAL Node doesn't listed in children nodes of previous parent "
+// + prevData.getQPath().getAsString() + ". Node " + data.getQPath().getAsString());
+// }
+//
+// // 3. add node to child list of new parent node
+// // check if parent is cached
+// Node<Serializable, Object> newParent = nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
+// if (newParent == null)
+// {
+// throw new InvalidItemStateException("Node's new parent doesn't exist " + data.getParentIdentifier()
+// + ". Node " + data.getQPath().getAsString());
+// }
+//
+// // add child to Parent
+// Node<Serializable, Object> childNode =
+// newParent.addChild(makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length - 1]));
+//
+// // set child id attr
+// childNode.put(ITEM_ID, data.getIdentifier());
+//
+// // 4. update all child nodes
+// for (Node<Serializable, Object> child : node.getChildren())
+// {
+// String childNodeId = (String)child.get(ITEM_ID);
+// if (childNodeId == null)
+// {
+// throw new RepositoryException("FATAL Child Node Id key is null. Parent " + data.getQPath().getAsString());
+// }
+//
+// // TODO NodeData or PropertyData? As ItemData check then and cast.
+// Node<Serializable, Object> childnode = nodesRoot.getChild(makeNodeFqn(childNodeId)); //cache.evict(fqn)
+// if (childnode == null)
+// {
+// throw new RepositoryException("FATAL Node record not found(" + childNodeId + "), but listed in childs of "
+// + data.getQPath().getAsString());
+// }
+// NodeData nodeData = (NodeData)childnode.get(ITEM_DATA);
+// if (nodeData == null)
+// {
+// // TODO should not occurs by contract
+// throw new RepositoryException("Child node data is null. Parent " + data.getQPath().getAsString());
+// }
+//
+// //repack child NodeData with new QPath
+// //TODO check it
+// QPath newPath = QPath.makeChildPath(data.getQPath(), nodeData.getQPath().getName());
+// TransientNodeData newNodeData =
+// new TransientNodeData(newPath, nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
+// .getPrimaryTypeName(), nodeData.getMixinTypeNames(), nodeData.getOrderNumber(), nodeData
+// .getParentIdentifier(), nodeData.getACL());
+// childnode.put(ITEM_DATA, newNodeData);
+// }
}
/**
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-11-20 09:48:12 UTC (rev 784)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-11-20 09:50:37 UTC (rev 785)
@@ -125,7 +125,6 @@
this.cache.addInterceptor(indexInterceptor, CacheStoreInterceptor.class);
Node<Serializable, Object> cacheRoot = cache.getRoot();
- //Node<Serializable, Object> wsRoot = cacheRoot.addChild(Fqn.fromElements(repositoryName, containerName));
// prepare cache structures
cache.startBatch();
@@ -138,25 +137,13 @@
public void start()
{
-
- // TODO started on init, due to RepositoryContainer logic
- // if (persistentContainer instanceof Startable)
- // {
- // ((Startable)persistentContainer).start();
- // }
- //
- // this.cache.start();
- //
- // Node<Serializable, Object> cacheRoot = cache.getRoot();
- // //Node<Serializable, Object> wsRoot = cacheRoot.addChild(Fqn.fromElements(repositoryName, containerName));
- //
- // // prepare cache structures
- // this.nodes = cacheRoot.addChild(Fqn.fromElements(JBossCacheStorage.NODES));
- // this.properties = cacheRoot.addChild(Fqn.fromElements(JBossCacheStorage.PROPS));
}
public void stop()
{
+ this.cache.stop();
+ this.cache.destroy();
+
if (persistentContainer instanceof Startable)
{
((Startable)persistentContainer).stop();
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-20 09:48:12 UTC (rev 784)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-20 09:50:37 UTC (rev 785)
@@ -113,7 +113,6 @@
LOG.warn("PUT_DATA_ERASE modification");
break;
case PUT_KEY_VALUE :
-
if (m.getFqn().size() == 2)
{
if (isUpdate(m, (JDBCStorageConnection)conn))
More information about the exo-jcr-commits
mailing list