usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [7/9] git commit: Updated naming scheme so that we can efficiently seek meta data by connection or collection suffix in graph
Date Thu, 02 Oct 2014 07:31:52 GMT
Updated naming scheme so that we can efficiently seek meta data by connection or collection
suffix in graph


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0e18f57f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0e18f57f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0e18f57f

Branch: refs/heads/esbatching
Commit: 0e18f57f81c2bfdf1dccf9e0b2c19ea6c581ecdd
Parents: 93471f7
Author: Todd Nine <toddnine@apache.org>
Authored: Thu Oct 2 00:36:25 2014 -0600
Committer: Todd Nine <toddnine@apache.org>
Committed: Thu Oct 2 00:36:25 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        | 140 ++++---------------
 .../corepersistence/CpEntityManagerFactory.java |   5 +-
 .../usergrid/corepersistence/CpNamingUtils.java | 106 ++++++++++++++
 .../corepersistence/CpRelationManager.java      |  97 ++++++-------
 4 files changed, 184 insertions(+), 164 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0e18f57f/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 320d3fe..777b041 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -53,9 +53,6 @@ import me.prettyprint.hector.api.query.QueryResult;
 import me.prettyprint.hector.api.query.SliceCounterQuery;
 import static org.apache.commons.lang.StringUtils.capitalize;
 import static org.apache.commons.lang.StringUtils.isBlank;
-import static org.apache.usergrid.corepersistence.CpRelationManager.ALL_TYPES;
-import static org.apache.usergrid.corepersistence.CpRelationManager.EDGE_COLL_SUFFIX;
-import static org.apache.usergrid.corepersistence.CpRelationManager.EDGE_CONN_SUFFIX;
 import org.apache.usergrid.persistence.AggregateCounter;
 import org.apache.usergrid.persistence.AggregateCounterSet;
 import org.apache.usergrid.persistence.CollectionRef;
@@ -167,8 +164,6 @@ public class CpEntityManager implements EntityManager {
     public static final String APPLICATION_COLLECTION = "application.collection.";
     public static final String APPLICATION_ENTITIES = "application.entities";
     public static final long ONE_COUNT = 1L;
-    private static final String COLL_SUFFIX = "zzzcollzzz";
-    private static final String CONN_SUFFIX = "zzzconnzzz";
 
     private UUID applicationId;
     private Application application;
@@ -214,82 +209,6 @@ public class CpEntityManager implements EntityManager {
     }
 
 
-    static String getCollectionScopeNameFromEntityType( String type ) {
-        String csn = Schema.defaultCollectionName( type ) + COLL_SUFFIX;
-        return csn.toLowerCase();
-    }
-
-
-    static String getCollectionScopeNameFromCollectionName( String name ) {
-        String csn = name + COLL_SUFFIX;
-        return csn.toLowerCase();
-    }
-
-
-    static String getConnectionScopeName( String entityType, String connectionType ) {
-        String csn = connectionType + entityType + CONN_SUFFIX;
-        return csn.toLowerCase();
-    }
-
-    static boolean isCollectionEdgeType( String type )  {
-        return type.endsWith( EDGE_COLL_SUFFIX );
-    }
-    
-    static boolean isConnectionEdgeType( String type )  {
-        return type.endsWith( EDGE_CONN_SUFFIX );
-    }
-    
-    static public String getConnectionType( String edgeType ) {
-        String[] parts = edgeType.split("\\|");
-        return parts[0];
-    }
-
-    static public String getCollectionEntityType( String edgeType ) {
-        String[] parts = edgeType.split("\\|");
-        return parts[1];
-    }
-
-    static public String getCollectionName( String edgeType ) {
-        String[] parts = edgeType.split("\\|");
-        return parts[0];
-    }
-
-    static public String getConnectedEntityType( String edgeType ) {
-        String[] parts = edgeType.split("\\|");
-        return parts[1];
-    }
-
-    static String getEdgeTypeFromConnectionType( String connectionType, String targetEntityType
) {
-
-        if ( connectionType != null && targetEntityType != null ) {
-            String csn = connectionType + "|" + targetEntityType + "|" + EDGE_CONN_SUFFIX;
-            return csn;
-        }
-
-        if ( connectionType != null ) {
-            // no suffix, this must be a search
-            String csn = connectionType;
-            return csn;
-        } 
-
-        return null;
-    }
-
-    static String getEdgeTypeFromCollectionName( String collectionName, String targetEntityType
) {
-
-        if ( collectionName != null && targetEntityType != null ) {
-            String csn = collectionName + "|" + targetEntityType + "|" + EDGE_COLL_SUFFIX;
-            return csn;
-        }
-
-        if ( collectionName != null ) {
-            // no suffix, this must be a search
-            String csn = collectionName;
-            return csn;
-        } 
-
-        return null;
-    }
 
 
     @Override
@@ -380,7 +299,7 @@ public class CpEntityManager implements EntityManager {
         }
 
         Id id = new SimpleId( entityRef.getUuid(), entityRef.getType() );
-        String collectionName = getCollectionScopeNameFromEntityType( entityRef.getType()
);
+        String collectionName = CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType()
);
 
         CollectionScope collectionScope = new CollectionScopeImpl( 
                 applicationScope.getApplication(), applicationScope.getApplication(), collectionName
);
@@ -467,7 +386,7 @@ public class CpEntityManager implements EntityManager {
         String type = Schema.getDefaultSchema().getEntityType( entityClass );
 
         Id id = new SimpleId( entityId, type );
-        String collectionName = getCollectionScopeNameFromEntityType( type );
+        String collectionName = CpNamingUtils.getCollectionScopeNameFromEntityType( type
);
 
         CollectionScope collectionScope = new CollectionScopeImpl( 
                 applicationScope.getApplication(), applicationScope.getApplication(), collectionName
);
@@ -538,7 +457,7 @@ public class CpEntityManager implements EntityManager {
         CollectionScope collectionScope = new CollectionScopeImpl( 
             applicationScope.getApplication(), 
             applicationScope.getApplication(),
-            getCollectionScopeNameFromEntityType( entity.getType() ) );
+                CpNamingUtils.getCollectionScopeNameFromEntityType( entity.getType() ) );
         EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope
);
 
         Id entityId = new SimpleId( entity.getUuid(), entity.getType() );
@@ -558,8 +477,12 @@ public class CpEntityManager implements EntityManager {
 //                "Entity Id " + entityId.getType() + ":"+ entityId.getUuid() +" uuid not
time based");
 //        }
 
-        org.apache.usergrid.persistence.model.entity.Entity cpEntity =
-                ecm.load( entityId ).toBlockingObservable().last();
+//        org.apache.usergrid.persistence.model.entity.Entity cpEntity =
+//                ecm.load( entityId ).toBlockingObservable().last();
+
+
+        org.apache.usergrid.persistence.model.entity.Entity cpEntity = new org.apache.usergrid.persistence.model
+                .entity.Entity( entityId );
 
         cpEntity = CpEntityMapUtils.fromMap(
                 cpEntity, entity.getProperties(), entity.getType(), true );
@@ -569,7 +492,6 @@ public class CpEntityManager implements EntityManager {
                 cpEntity.getId().getType(), cpEntity.getId().getUuid(), cpEntity.getVersion()
});
 
             cpEntity = ecm.update( cpEntity ).toBlockingObservable().last();
-            refreshIndex();
             cpEntity = ecm.load( entityId ).toBlockingObservable().last();
 
             logger.debug("Wrote {}:{} version {}", new Object[] { 
@@ -603,7 +525,7 @@ public class CpEntityManager implements EntityManager {
         CollectionScope collectionScope = new CollectionScopeImpl( 
             applicationScope.getApplication(), 
             applicationScope.getApplication(),
-            getCollectionScopeNameFromEntityType( entityRef.getType() ) );
+                CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() )
);
 
         EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope
);
 
@@ -643,7 +565,7 @@ public class CpEntityManager implements EntityManager {
                         IndexScope indexScope = new IndexScopeImpl( 
                                 applicationScope.getApplication(), 
                                 new SimpleId( uuid, ownerType ), 
-                                CpEntityManager.getCollectionScopeNameFromCollectionName(coll)
);
+                                CpNamingUtils.getCollectionScopeNameFromCollectionName( coll
) );
 
 
                         batch.index( indexScope, entity );
@@ -657,14 +579,14 @@ public class CpEntityManager implements EntityManager {
             IndexScope defaultIndexScope = new IndexScopeImpl( 
                     applicationScope.getApplication(), 
                     applicationScope.getApplication(),
-                    getCollectionScopeNameFromEntityType( entityRef.getType() ) );
+                    CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType()
) );
 
             batch.deindex(defaultIndexScope,  entity );
 
             IndexScope allTypesIndexScope = new IndexScopeImpl( 
                 applicationScope.getApplication(), 
                 applicationScope.getApplication(), 
-                ALL_TYPES);
+                    CpNamingUtils.ALL_TYPES);
 
             batch.deindex( allTypesIndexScope,  entity );
 
@@ -1042,7 +964,7 @@ public class CpEntityManager implements EntityManager {
     @Override
     public void deleteProperty( EntityRef entityRef, String propertyName ) throws Exception
{
 
-        String collectionName = getCollectionScopeNameFromEntityType( entityRef.getType()
);
+        String collectionName = CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType()
);
 
         CollectionScope collectionScope = new CollectionScopeImpl( 
                 applicationScope.getApplication(), 
@@ -1052,7 +974,7 @@ public class CpEntityManager implements EntityManager {
         IndexScope defaultIndexScope = new IndexScopeImpl( 
                 applicationScope.getApplication(), 
                 applicationScope.getApplication(), 
-                getCollectionScopeNameFromEntityType( entityRef.getType()) );
+                CpNamingUtils.getCollectionScopeNameFromEntityType( entityRef.getType() )
);
 
         EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope
);
         EntityIndex ei = managerCache.getEntityIndex( applicationScope );
@@ -2570,7 +2492,7 @@ public class CpEntityManager implements EntityManager {
         CollectionScope collectionScope = new CollectionScopeImpl( 
                 applicationScope.getApplication(), 
                 applicationScope.getApplication(),
-                getCollectionScopeNameFromEntityType( eType ) );
+                CpNamingUtils.getCollectionScopeNameFromEntityType( eType ) );
         EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope
);
 
         if ( logger.isDebugEnabled() ) {
@@ -2911,15 +2833,15 @@ public class CpEntityManager implements EntityManager {
                     @Override
                     public void call( Edge edge ) {
 
-                        if ( isCollectionEdgeType( edge.getType() )) {
+                        if ( CpNamingUtils.isCollectionEdgeType( edge.getType() )) {
 
-                            String collName = getCollectionName(edgeType);
-                            String memberType = getCollectionEntityType(edgeType);
+                            String collName = CpNamingUtils.getCollectionName( edgeType );
+                            String memberType = edge.getTargetNode().getType();
 
                             CollectionScope collScope = new CollectionScopeImpl(
                                 applicationScope.getApplication(),
                                 applicationScope.getApplication(),
-                                CpEntityManager.getCollectionScopeNameFromEntityType(entity.getType()));
+                                    CpNamingUtils.getCollectionScopeNameFromEntityType( entity.getType()
));
                             EntityCollectionManager collMgr = 
                                 managerCache.getEntityCollectionManager(collScope);
 
@@ -2944,7 +2866,7 @@ public class CpEntityManager implements EntityManager {
                             CollectionScope memberScope = new CollectionScopeImpl(
                                 applicationScope.getApplication(),
                                 applicationScope.getApplication(),
-                                CpEntityManager.getCollectionScopeNameFromEntityType(memberType));
+                                    CpNamingUtils.getCollectionScopeNameFromEntityType( memberType
));
                             EntityCollectionManager memberMgr = 
                                 managerCache.getEntityCollectionManager(memberScope);
 
@@ -2976,16 +2898,16 @@ public class CpEntityManager implements EntityManager {
                             indexEntityConnectionsAndCollections( new SimpleEntityRef(
                                 memberEntity.getId().getType(), memberEntity.getId().getUuid()),po);
 
-                        } else if ( isConnectionEdgeType( edge.getType() )) {
+                        } else if ( CpNamingUtils.isConnectionEdgeType( edge.getType() ))
{
 
-                            String connType = getConnectionType(edgeType);
-                            String targetEntityType = getConnectedEntityType(edgeType);
+                            String connType = CpNamingUtils.getConnectionType( edgeType );
+                            String targetEntityType = edge.getTargetNode().getType();
                             String sourceEntityType = entity.getType();
 
                             CollectionScope sourceScope = new CollectionScopeImpl(
                                 applicationScope.getApplication(),
                                 applicationScope.getApplication(),
-                                CpEntityManager.getCollectionScopeNameFromEntityType(sourceEntityType));
+                                    CpNamingUtils.getCollectionScopeNameFromEntityType( sourceEntityType
));
                             EntityCollectionManager sourceEcm = 
                                 managerCache.getEntityCollectionManager(sourceScope);
 
@@ -2995,7 +2917,7 @@ public class CpEntityManager implements EntityManager {
                             CollectionScope targetScope = new CollectionScopeImpl(
                                 applicationScope.getApplication(),
                                 applicationScope.getApplication(),
-                                CpEntityManager.getCollectionScopeNameFromEntityType(targetEntityType));
+                                    CpNamingUtils.getCollectionScopeNameFromEntityType( targetEntityType
));
                             EntityCollectionManager targetEcm = 
                                 managerCache.getEntityCollectionManager(targetScope);
 
@@ -3071,14 +2993,14 @@ public class CpEntityManager implements EntityManager {
         IndexScope indexScope = new IndexScopeImpl(
                 applicationScope.getApplication(),
                 sourceEntity.getId(),
-                CpEntityManager.getConnectionScopeName(targetEntityType, connType));
+                CpNamingUtils.getConnectionScopeName( targetEntityType, connType ));
         batch.index(indexScope, targetEntity);
         
         // Index the new connection in app|scope|all-types context
         IndexScope allTypesIndexScope = new IndexScopeImpl(
                 applicationScope.getApplication(),
                 sourceEntity.getId(),
-                ALL_TYPES);
+                CpNamingUtils.ALL_TYPES);
 
         batch.index(allTypesIndexScope, targetEntity);
 
@@ -3098,7 +3020,7 @@ public class CpEntityManager implements EntityManager {
         IndexScope collectionIndexScope = new IndexScopeImpl(
                 applicationScope.getApplication(),
                 collectionEntity.getId(),
-                CpEntityManager.getCollectionScopeNameFromCollectionName(collName));
+                CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ));
 
         batch.index(collectionIndexScope, memberEntity);
         
@@ -3106,7 +3028,7 @@ public class CpEntityManager implements EntityManager {
         IndexScope entityAllTypesScope = new IndexScopeImpl(
                 applicationScope.getApplication(),
                 collectionEntity.getId(),
-                ALL_TYPES);
+                CpNamingUtils.ALL_TYPES);
 
         batch.index(entityAllTypesScope, memberEntity);
         
@@ -3114,7 +3036,7 @@ public class CpEntityManager implements EntityManager {
         IndexScope appAllTypesScope = new IndexScopeImpl(
                 applicationScope.getApplication(),
                 applicationScope.getApplication(),
-                ALL_TYPES);
+                CpNamingUtils.ALL_TYPES);
 
         batch.index(appAllTypesScope, memberEntity);
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0e18f57f/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 9a10afd..f24f26b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -51,7 +51,6 @@ import org.apache.usergrid.persistence.graph.GraphManager;
 import org.apache.usergrid.persistence.graph.GraphManagerFactory;
 import org.apache.usergrid.persistence.graph.SearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
-import org.apache.usergrid.persistence.index.EntityIndex;
 import org.apache.usergrid.persistence.index.EntityIndexFactory;
 import org.apache.usergrid.persistence.index.IndexScope;
 import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
@@ -349,7 +348,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         Application app = em.getApplication();
         Id fromEntityId = new SimpleId( app.getUuid(), app.getType() );
 
-        String edgeType = CpEntityManager.getEdgeTypeFromCollectionName("appinfos", "appinfo");
+        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( "appinfos" );
 
         logger.debug("getApplications(): Loading edges of edgeType {} from {}:{}", 
             new Object[] { edgeType, fromEntityId.getType(), fromEntityId.getUuid() } );
@@ -372,7 +371,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
             CollectionScope collScope = new CollectionScopeImpl(
                     appScope.getApplication(),
                     appScope.getApplication(),
-                    CpEntityManager.getCollectionScopeNameFromCollectionName("appinfos"));
+                    CpNamingUtils.getCollectionScopeNameFromCollectionName( "appinfos" ));
 
             org.apache.usergrid.persistence.model.entity.Entity e = 
                     managerCache.getEntityCollectionManager( collScope ).load( targetId )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0e18f57f/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpNamingUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpNamingUtils.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpNamingUtils.java
new file mode 100644
index 0000000..60cec72
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpNamingUtils.java
@@ -0,0 +1,106 @@
+package org.apache.usergrid.corepersistence;/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import org.apache.usergrid.persistence.Schema;
+
+
+/**
+ * Utilises for constructing standard naming conventions for collections and connections
+ */
+public class CpNamingUtils {
+
+    /**
+     * Edge types for all types
+     */
+    static final String ALL_TYPES = "zzzalltypeszzz";
+
+    /**
+     * Edge types for collection suffix
+     */
+    static final String EDGE_COLL_SUFFIX = "zzzcollzzz";
+
+    /**
+     * Edge types for connection suffix
+     */
+    static final String EDGE_CONN_SUFFIX = "zzzconnzzz";
+
+    static String getCollectionScopeNameFromEntityType( String type ) {
+          String csn = EDGE_COLL_SUFFIX + Schema.defaultCollectionName( type );
+          return csn.toLowerCase();
+      }
+
+
+      static String getCollectionScopeNameFromCollectionName( String name ) {
+          String csn = EDGE_COLL_SUFFIX + name ;
+          return csn.toLowerCase();
+      }
+
+
+      static String getConnectionScopeName( String entityType, String connectionType ) {
+          String csn = EDGE_CONN_SUFFIX + connectionType + entityType ;
+          return csn.toLowerCase();
+      }
+
+      static boolean isCollectionEdgeType( String type )  {
+          return type.startsWith( EDGE_COLL_SUFFIX );
+      }
+
+      static boolean isConnectionEdgeType( String type )  {
+          return type.startsWith( EDGE_CONN_SUFFIX );
+      }
+
+
+
+    static public String getConnectionType( String edgeType ) {
+        String[] parts = edgeType.split("\\|");
+        return parts[1];
+    }
+
+
+    static public String getCollectionName( String edgeType ) {
+        String[] parts = edgeType.split("\\|");
+        return parts[1];
+    }
+
+
+
+    static String getEdgeTypeFromConnectionType( String connectionType) {
+
+        if ( connectionType != null ) {
+            String csn = EDGE_CONN_SUFFIX + "|" + connectionType;
+            return csn;
+        }
+
+        return null;
+    }
+
+    static String getEdgeTypeFromCollectionName( String collectionName) {
+
+        if ( collectionName != null  ) {
+            String csn = EDGE_COLL_SUFFIX + "|" + collectionName;
+            return csn;
+        }
+
+
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0e18f57f/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 14f9359..ca01ddd 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -17,7 +17,7 @@
 package org.apache.usergrid.corepersistence;
 
 import static me.prettyprint.hector.api.factory.HFactory.createMutator;
-import static org.apache.usergrid.corepersistence.CpEntityManager.*;
+
 import com.yammer.metrics.annotation.Metered;
 import java.nio.ByteBuffer;
 import java.util.AbstractMap;
@@ -138,11 +138,7 @@ import org.apache.usergrid.utils.IndexUtils;
 import static org.apache.usergrid.utils.InflectionUtils.singularize;
 import org.apache.usergrid.utils.MapUtils;
 import static org.apache.usergrid.utils.MapUtils.addMapSet;
-import org.apache.usergrid.utils.UUIDUtils;
 import static org.apache.usergrid.utils.UUIDUtils.getTimestampInMicros;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.util.Assert;
 
 import me.prettyprint.hector.api.Keyspace;
 import me.prettyprint.hector.api.beans.DynamicComposite;
@@ -158,11 +154,7 @@ public class CpRelationManager implements RelationManager {
 
     private static final Logger logger = LoggerFactory.getLogger( CpRelationManager.class
);
 
-    static final String ALL_TYPES = "zzzalltypeszzz";
 
-    static final String EDGE_COLL_SUFFIX = "zzzcollzzz";
-
-    static final String EDGE_CONN_SUFFIX = "zzzconnzzz";
 
     private CpEntityManagerFactory emf;
     
@@ -218,7 +210,7 @@ public class CpRelationManager implements RelationManager {
         this.headEntityScope = new CollectionScopeImpl( 
             this.applicationScope.getApplication(), 
             this.applicationScope.getApplication(), 
-            CpEntityManager.getCollectionScopeNameFromEntityType( headEntity.getType()));
+                CpNamingUtils.getCollectionScopeNameFromEntityType( headEntity.getType()
));
 
         EntityCollectionManager ecm = managerCache.getEntityCollectionManager(headEntityScope);
         if ( logger.isDebugEnabled() ) {
@@ -248,7 +240,7 @@ public class CpRelationManager implements RelationManager {
 
         GraphManager gm = managerCache.getGraphManager(applicationScope);
 
-        String edgeTypePrefix = getEdgeTypeFromCollectionName( collectionName, null );
+        String edgeTypePrefix = CpNamingUtils.getEdgeTypeFromCollectionName( collectionName
);
 
         logger.debug("getCollectionIndexes(): Searching for edge type prefix {} to target
{}:{}", 
             new Object[] {
@@ -337,10 +329,10 @@ public class CpRelationManager implements RelationManager {
                     edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
 
                 String name = null;
-                if ( CpEntityManager.isConnectionEdgeType( edge.getType() )) {
-                    name = CpEntityManager.getConnectionType( edge.getType() );
+                if ( CpNamingUtils.isConnectionEdgeType( edge.getType() )) {
+                    name = CpNamingUtils.getConnectionType( edge.getType() );
                 } else {
-                    name = CpEntityManager.getCollectionName( edge.getType() );
+                    name = CpNamingUtils.getCollectionName( edge.getType() );
                 }
                 addMapSet( results, eref, name );
             }
@@ -400,21 +392,21 @@ public class CpRelationManager implements RelationManager {
                 // reindex the entity in the source entity's collection or connection index
 
                 IndexScope indexScope;
-                if ( CpEntityManager.isCollectionEdgeType( edge.getType() )) {
+                if ( CpNamingUtils.isCollectionEdgeType( edge.getType() )) {
 
-                    String collName = CpEntityManager.getCollectionName( edge.getType() );

+                    String collName = CpNamingUtils.getCollectionName( edge.getType() );
                     indexScope = new IndexScopeImpl(
                         applicationScope.getApplication(),
                         new SimpleId(sourceEntity.getUuid(), sourceEntity.getType()),
-                        CpEntityManager.getCollectionScopeNameFromCollectionName( collName
));
+                        CpNamingUtils.getCollectionScopeNameFromCollectionName( collName
));
 
                 } else {
 
-                    String connName = CpEntityManager.getCollectionName( edge.getType() );

+                    String connName = CpNamingUtils.getCollectionName( edge.getType() );
                     indexScope = new IndexScopeImpl(
                         applicationScope.getApplication(),
                         new SimpleId(sourceEntity.getUuid(), sourceEntity.getType()),
-                        CpEntityManager.getConnectionScopeName( cpHeadEntity.getId().getType(),
connName ));
+                        CpNamingUtils.getConnectionScopeName( cpHeadEntity.getId().getType(),
connName ));
                 }
 
                 entityIndexBatch.index(indexScope, cpEntity);
@@ -424,13 +416,16 @@ public class CpRelationManager implements RelationManager {
                 indexScope = new IndexScopeImpl(
                     applicationScope.getApplication(),
                     new SimpleId(sourceEntity.getUuid(), sourceEntity.getType()),
-                    ALL_TYPES);
+                        CpNamingUtils.ALL_TYPES);
 
                 entityIndexBatch.index(indexScope, cpEntity);
 
                 count++;
             }
         }
+
+        entityIndexBatch.execute();
+
         logger.debug("updateContainingCollectionsAndCollections() updated {} indexes", count);
         return results;
     }
@@ -441,7 +436,7 @@ public class CpRelationManager implements RelationManager {
 
         Id entityId = new SimpleId( entity.getUuid(), entity.getType() );
 
-        String edgeType = getEdgeTypeFromConnectionType( connectionType, entity.getType()
);  
+        String edgeType = CpNamingUtils.getEdgeTypeFromConnectionType( connectionType );
 
         logger.debug("isConnectionMember(): Checking for edge type {} from {}:{} to {}:{}",

             new Object[] { 
@@ -469,7 +464,7 @@ public class CpRelationManager implements RelationManager {
 
         Id entityId = new SimpleId( entity.getUuid(), entity.getType() );
 
-        String edgeType = getEdgeTypeFromCollectionName( collName, entity.getType() );  
+        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collName );
 
         logger.debug("isCollectionMember(): Checking for edge type {} from {}:{} to {}:{}",

             new Object[] { 
@@ -499,7 +494,7 @@ public class CpRelationManager implements RelationManager {
 
         Observable<Edge> edgesToTarget = gm.loadEdgesToTarget( new SimpleSearchByEdgeType(
             targetId,
-            CpEntityManager.getEdgeTypeFromConnectionType( connectionType, target.getType()
),
+            CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
             System.currentTimeMillis(), SearchByEdgeType.Order.DESCENDING,
             null)); // last
 
@@ -523,7 +518,7 @@ public class CpRelationManager implements RelationManager {
 
         Observable<Edge> edgesFromSource = gm.loadEdgesFromSource(new SimpleSearchByEdgeType(
             sourceId,
-            CpEntityManager.getEdgeTypeFromConnectionType( connectionType, null ),
+            CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
             System.currentTimeMillis(),SearchByEdgeType.Order.DESCENDING,
             null)); // last
 
@@ -546,7 +541,7 @@ public class CpRelationManager implements RelationManager {
         Iterator<String> iter = str.toBlockingObservable().getIterator();
         while ( iter.hasNext() ) {
             String edgeType = iter.next();
-            indexes.add( CpEntityManager.getCollectionName( edgeType ) );
+            indexes.add( CpNamingUtils.getCollectionName( edgeType ) );
         }
 
         return indexes;
@@ -611,8 +606,8 @@ public class CpRelationManager implements RelationManager {
         // load the new member entity to be added to the collection from its default scope
         CollectionScope memberScope = new CollectionScopeImpl( 
             applicationScope.getApplication(), 
-            applicationScope.getApplication(), 
-            CpEntityManager.getCollectionScopeNameFromEntityType( itemRef.getType()));
+            applicationScope.getApplication(),
+            CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ));
 
         EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager(memberScope);
 
@@ -637,7 +632,7 @@ public class CpRelationManager implements RelationManager {
             });
         }
 
-        String edgeType = getEdgeTypeFromCollectionName( collName, memberEntity.getId().getType()
);
+        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collName );
 
         UUID timeStampUuid =   memberEntity.getId().getUuid() != null 
                 &&  UUIDUtils.isTimeBased( memberEntity.getId().getUuid()) 
@@ -763,7 +758,7 @@ public class CpRelationManager implements RelationManager {
         CollectionScope memberScope = new CollectionScopeImpl( 
             this.applicationScope.getApplication(), 
             this.applicationScope.getApplication(), 
-            CpEntityManager.getCollectionScopeNameFromEntityType( itemRef.getType() ));
+            CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ));
         EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager(memberScope);
 
         if ( logger.isDebugEnabled() ) {
@@ -788,7 +783,7 @@ public class CpRelationManager implements RelationManager {
         IndexScope indexScope = new IndexScopeImpl(
             applicationScope.getApplication(), 
             cpHeadEntity.getId(), 
-            CpEntityManager.getCollectionScopeNameFromCollectionName( collName ));
+            CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ));
 
         batch.deindex(indexScope,  memberEntity );
 
@@ -796,8 +791,8 @@ public class CpRelationManager implements RelationManager {
         IndexScope itemScope = new IndexScopeImpl(
             applicationScope.getApplication(), 
             memberEntity.getId(), 
-            CpEntityManager.getCollectionScopeNameFromCollectionName( 
-                Schema.defaultCollectionName( cpHeadEntity.getId().getType() )));
+            CpNamingUtils.getCollectionScopeNameFromCollectionName(
+                    Schema.defaultCollectionName( cpHeadEntity.getId().getType() ) ));
 
 
         batch.deindex(itemScope,  cpHeadEntity );
@@ -808,7 +803,7 @@ public class CpRelationManager implements RelationManager {
         GraphManager gm = managerCache.getGraphManager(applicationScope);
         Edge collectionToItemEdge = new SimpleEdge( 
             cpHeadEntity.getId(),
-            getEdgeTypeFromCollectionName( collName, memberEntity.getId().getType() ), 
+             CpNamingUtils.getEdgeTypeFromCollectionName( collName),
             memberEntity.getId(), 
             memberEntity.getId().getUuid().timestamp() );
         gm.deleteEdge(collectionToItemEdge).toBlockingObservable().last();
@@ -816,9 +811,8 @@ public class CpRelationManager implements RelationManager {
         // remove edge from item to collection
         Edge itemToCollectionEdge = new SimpleEdge( 
             memberEntity.getId(), 
-            getEdgeTypeFromCollectionName( 
-                Schema.defaultCollectionName( cpHeadEntity.getId().getType() ), 
-                cpHeadEntity.getId().getType() ), 
+                CpNamingUtils
+                        .getEdgeTypeFromCollectionName( Schema.defaultCollectionName( cpHeadEntity.getId().getType()
)),
             cpHeadEntity.getId(),
             cpHeadEntity.getId().getUuid().timestamp() );
         gm.deleteEdge(itemToCollectionEdge).toBlockingObservable().last();
@@ -900,7 +894,7 @@ public class CpRelationManager implements RelationManager {
         IndexScope indexScope = new IndexScopeImpl(
             applicationScope.getApplication(), 
             cpHeadEntity.getId(), 
-            CpEntityManager.getCollectionScopeNameFromCollectionName( collName ));
+            CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ));
 
         EntityIndex ei = managerCache.getEntityIndex(applicationScope);
       
@@ -981,7 +975,7 @@ public class CpRelationManager implements RelationManager {
         CollectionScope targetScope = new CollectionScopeImpl( 
             applicationScope.getApplication(), 
             applicationScope.getApplication(), 
-            CpEntityManager.getCollectionScopeNameFromEntityType( connectedEntityRef.getType()
));
+            CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType()
));
 
         EntityCollectionManager targetEcm = managerCache.getEntityCollectionManager(targetScope);
 
@@ -1005,8 +999,8 @@ public class CpRelationManager implements RelationManager {
             new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ))
                 .toBlockingObservable().last();
 
-        String edgeType = CpEntityManager
-                .getEdgeTypeFromConnectionType( connectionType, connectedEntityRef.getType()
);
+        String edgeType = CpNamingUtils
+                .getEdgeTypeFromConnectionType( connectionType );
 
         // create graph edge connection from head entity to member entity
         Edge edge = new SimpleEdge( 
@@ -1024,7 +1018,7 @@ public class CpRelationManager implements RelationManager {
         IndexScope indexScope = new IndexScopeImpl(
             applicationScope.getApplication(), 
             cpHeadEntity.getId(), 
-            CpEntityManager.getConnectionScopeName( connectedEntityRef.getType(), connectionType
));
+            CpNamingUtils.getConnectionScopeName( connectedEntityRef.getType(), connectionType
));
 
         batch.index(indexScope, targetEntity );
 
@@ -1032,7 +1026,7 @@ public class CpRelationManager implements RelationManager {
         IndexScope allTypesIndexScope = new IndexScopeImpl(
             applicationScope.getApplication(), 
             cpHeadEntity.getId(), 
-            ALL_TYPES);
+                CpNamingUtils.ALL_TYPES);
         batch.index(allTypesIndexScope,  targetEntity );
 
 
@@ -1213,7 +1207,7 @@ public class CpRelationManager implements RelationManager {
         CollectionScope targetScope = new CollectionScopeImpl( 
             applicationScope.getApplication(), 
             applicationScope.getApplication(), 
-            CpEntityManager.getCollectionScopeNameFromEntityType( connectedEntityRef.getType()
));
+            CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType()
));
 
         EntityCollectionManager targetEcm = managerCache.getEntityCollectionManager(targetScope);
 
@@ -1248,14 +1242,14 @@ public class CpRelationManager implements RelationManager {
         IndexScope indexScope = new IndexScopeImpl(
             applicationScope.getApplication(), 
             new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
-            CpEntityManager.getConnectionScopeName( targetEntity.getId().getType(), connectionType
));
+            CpNamingUtils.getConnectionScopeName( targetEntity.getId().getType(), connectionType
));
         batch.deindex( indexScope , targetEntity );
 
         // Deindex the connection in app|source|type context
         IndexScope allTypesIndexScope = new IndexScopeImpl(
             applicationScope.getApplication(), 
             new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
-            ALL_TYPES);
+                CpNamingUtils.ALL_TYPES);
 
         batch.deindex( allTypesIndexScope,  targetEntity );
 
@@ -1306,9 +1300,9 @@ public class CpRelationManager implements RelationManager {
 
             String scopeName = null;
             if ( connectedEntityType != null ) {
-                scopeName = CpEntityManager.getConnectionScopeName( connectedEntityType,
connectionType );
+                scopeName = CpNamingUtils.getConnectionScopeName( connectedEntityType, connectionType
);
             } else {
-                scopeName = ALL_TYPES;
+                scopeName = CpNamingUtils.ALL_TYPES;
             }
 
             IndexScope indexScope = new IndexScopeImpl(
@@ -1375,7 +1369,7 @@ public class CpRelationManager implements RelationManager {
 
         // looking for edges to the head entity
         String edgeType = 
-                CpEntityManager.getEdgeTypeFromConnectionType( connType, headEntity.getType()
);
+                CpNamingUtils.getEdgeTypeFromConnectionType( connType );
 
         Map<EntityRef, Set<String>> containers = 
             getContainers( count, edgeType, fromEntityType );
@@ -1419,7 +1413,7 @@ public class CpRelationManager implements RelationManager {
             IndexScope indexScope = new IndexScopeImpl(
                 applicationScope.getApplication(), 
                 cpHeadEntity.getId(), 
-                ALL_TYPES);
+                    CpNamingUtils.ALL_TYPES);
 
             EntityIndex ei = managerCache.getEntityIndex(applicationScope);
         
@@ -1437,8 +1431,7 @@ public class CpRelationManager implements RelationManager {
         IndexScope indexScope = new IndexScopeImpl(
             applicationScope.getApplication(), 
             cpHeadEntity.getId(), 
-            CpEntityManager.getConnectionScopeName( 
-                    query.getEntityType(), query.getConnectionType() ));
+            CpNamingUtils.getConnectionScopeName( query.getEntityType(), query.getConnectionType()
));
         EntityIndex ei = managerCache.getEntityIndex(applicationScope);
     
         logger.debug("Searching connections from the '{}' scope {}:{}:{}", new String[] {

@@ -1618,7 +1611,7 @@ public class CpRelationManager implements RelationManager {
                 CollectionScope collScope = new CollectionScopeImpl( 
                     applicationScope.getApplication(), 
                     applicationScope.getApplication(), 
-                    CpEntityManager.getCollectionScopeNameFromEntityType( cr.getId().getType()
));
+                    CpNamingUtils.getCollectionScopeNameFromEntityType( cr.getId().getType()
));
                 EntityCollectionManager ecm = managerCache.getEntityCollectionManager(collScope);
 
                 if ( logger.isDebugEnabled() ) {


Mime
View raw message