[exo-jcr-commits] exo-jcr SVN: r927 - 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 Dec 4 11:15:15 EST 2009
Author: areshetnyak
Date: 2009-12-04 11:15:15 -0500 (Fri, 04 Dec 2009)
New Revision: 927
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.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/JDBCCacheLoader.java
Log:
EXOJCR-293 : The reuse tree algorithm for JbossCache nodes.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java 2009-12-04 14:08:54 UTC (rev 926)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java 2009-12-04 16:15:15 UTC (rev 927)
@@ -30,8 +30,10 @@
public class IdTreeHelper
{
- private final static int xLength = 8;
+ private final static int X_LENGTH = 8;
+ private final static int FQN_ID_LENGTH = X_LENGTH + 2;
+
/**
* Build path by UUID.
*
@@ -40,7 +42,7 @@
* @return String[]
* the tree id
*/
- public static String[] buildPath(String id)
+ /*public static String[] buildPath(String id)
{
String tree[] = new String[id.length()];
@@ -48,20 +50,20 @@
tree[i-1] = id.substring(i - 1, i);
return tree;
- }
+ }*/
- /*public static String[] buildPath(String id)
+ public static String[] buildPath(String id)
{
- String tree[] = new String[xLength +1];
+ String tree[] = new String[X_LENGTH +1];
char[] chs = id.toCharArray();
- for (int i = 0; i < xLength; i++)
+ for (int i = 0; i < X_LENGTH; i++)
tree[i] = String.valueOf(chs[i]);
- tree[xLength] = id.substring(xLength);
+ tree[X_LENGTH] = id.substring(X_LENGTH);
return tree;
- }*/
+ }
/**
* Create that transformation
@@ -78,7 +80,7 @@
* the tree Fqn
* @return Fqn
*/
- public static Fqn buildFqn(Fqn treeFqn)
+ /*public static Fqn buildFqn(Fqn treeFqn)
{
String id = treeFqn.getSubFqn(1, IdGenerator.IDENTIFIER_LENGTH + 1).toString();
@@ -97,27 +99,85 @@
}
return Fqn.fromElements(sArray);
- }
+ } */
/*public static Fqn buildFqn(Fqn treeFqn)
{
- String oldId = treeFqn.getSubFqn(1, xLength + 2).toString();
+ String id = "";
+
+ int index = 1;
+
+ for (;index < treeFqn.size(); index++)
+ {
+ if (((String) treeFqn.get(index)).length() == 1)
+ {
+ id += (String) treeFqn.get(index);
+ } else
+ {
+ break;
+ }
+ }
+
+ String[] sArray = new String[treeFqn.size() - (index - 2)];
+
+ sArray[0] = (String) treeFqn.get(0);
+ sArray[1] = id;
+
+ int sArrayIndex = 2;
+
+ for (int i=index; i < treeFqn.size(); i++)
+ {
+ sArray[sArrayIndex++] = (String) treeFqn.get(i);
+ }
+
+ return Fqn.fromElements(sArray);
+ }*/
+
+
+ public static Fqn buildFqn(Fqn treeFqn)
+ {
+ String oldId = treeFqn.getSubFqn(1, X_LENGTH + 2).toString();
String id = oldId.replaceAll(Fqn.SEPARATOR, "");
- String[] sArray = new String[treeFqn.size() - (xLength)];
+ String[] sArray = new String[treeFqn.size() - (X_LENGTH)];
sArray[0] = (String) treeFqn.get(0);
sArray[1] = id;
int sArrayIndex = 1;
- for (int i=(xLength + 2); i < treeFqn.size(); i++)
+ for (int i=(X_LENGTH + 2); i < treeFqn.size(); i++)
{
sArray[++sArrayIndex] = (String) treeFqn.get(i);
}
return Fqn.fromElements(sArray);
- }*/
+ }
+ /**
+ * Check the sub Fqn like /$LOCKs/2/5/6
+ * @return
+ */
+ public static boolean isSubFqn (Fqn fqn) {
+ if (FQN_ID_LENGTH - fqn.size() > 1)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+ public static void main(String[] args)
+ {
+ System.out.println(Fqn.fromElements(buildPath("00exo0jcr0root0uuid0000000000000")));
+ System.out.println(buildFqn(Fqn.fromString("/$NODES/0/0/e/x/o/0/j/c/r/0/r/o/o/t/0/u/u/i/d/0/0/0/0/0/0/0/0/0/0/0/0/0")));
+ System.out.println(buildFqn(Fqn.fromString("/$NODES/0/0/e/x/o/0/j/c/r/0/r/o/o/t/0/u/u/i/d/0/0/0/0/0/0/0/0/0/0/0/0/0/[]subNodeName:1")));
+ System.out.println(buildFqn(Fqn.fromString("/$NODES/f/a/l/s/e/[]dsds:1")));
+
+ }
+
}
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-12-04 14:08:54 UTC (rev 926)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-04 16:15:15 UTC (rev 927)
@@ -1311,7 +1311,7 @@
*/
public List<LockData> getLocksData() throws RepositoryException
{
- Set<Node<Serializable, Object>> lockSet = locksRoot.getChildren();
+ Set<Node<Serializable, Object>> lockSet = locksRoot.getChildren()/*getNodes(locksRoot)*/;
List<LockData> locksData = new ArrayList<LockData>();
for (Node<Serializable, Object> node : lockSet)
{
@@ -1326,8 +1326,39 @@
}
return locksData;
}
-
+
+
/**
+ * Traverse tree and getting all nodes without children.
+ *
+ * @param node
+ * @return
+ */
+ private Set<Node<Serializable, Object>> getNodes(Node<Serializable, Object> node) {
+ Set<Node<Serializable, Object>> lockSet = new HashSet<Node<Serializable,Object>>();
+
+ traverseTree(lockSet, node);
+
+ return lockSet;
+ }
+
+ private void traverseTree(Set<Node<Serializable, Object>> resultSet, Node<Serializable, Object> node) {
+ Set<Node<Serializable, Object>> childNodes = node.getChildren();
+
+ for (Node<Serializable, Object> childNode : childNodes)
+ {
+ if (childNode.getChildrenNames().size() == 0)
+ {
+ resultSet.add(childNode);
+ } else
+ {
+ traverseTree(resultSet, childNode);
+ }
+
+ }
+ }
+
+ /**
* @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#addLockData(org.exoplatform.services.jcr.impl.core.lock.LockData)
*/
public void addLockData(LockData lockData) throws RepositoryException
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-12-04 14:08:54 UTC (rev 926)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-04 16:15:15 UTC (rev 927)
@@ -595,6 +595,10 @@
{
// return child nodes names
+ //to sub Fqn (example /$LOCKS/5/4/3)
+ if (IdTreeHelper.isSubFqn(fqn))
+ return null;
+
Fqn name = ( fqn.size() >= 2 ? IdTreeHelper.buildFqn(fqn) : fqn);
JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
More information about the exo-jcr-commits
mailing list