You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/10/17 18:34:48 UTC

[01/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o 9da529b98 -> 5a0410780


Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0


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

Branch: refs/heads/two-dot-o
Commit: aa2b1da34691525918dd45d3843ebf6d426b64f1
Parents: d1dc7cd b2b8886
Author: amuramoto <am...@apigee.com>
Authored: Wed Oct 1 23:53:26 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Wed Oct 1 23:53:26 2014 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        | 519 +++++++++++++++----
 .../corepersistence/CpEntityManagerFactory.java | 495 ++++++++----------
 .../corepersistence/CpRelationManager.java      | 356 +++++--------
 .../usergrid/corepersistence/CpSetup.java       |  55 +-
 .../HybridEntityManagerFactory.java             |  18 +-
 .../persistence/EntityManagerFactory.java       |  12 +-
 .../persistence/cassandra/CassandraService.java |   5 -
 .../cassandra/EntityManagerFactoryImpl.java     |  54 +-
 .../PerformanceEntityRebuildIndexTest.java      | 278 ++++++++++
 .../cassandra/EntityManagerFactoryImplIT.java   |  10 +-
 stack/core/src/test/resources/log4j.properties  |  13 +-
 .../usergrid/persistence/index/IndexFig.java    |   7 +
 .../index/impl/EsEntityIndexImpl.java           |  18 +
 .../persistence/index/impl/EsProvider.java      |  15 +
 .../org/apache/usergrid/tools/IndexRebuild.java |  63 ++-
 stack/tools/src/main/resources/log4j.properties |  18 +-
 16 files changed, 1206 insertions(+), 730 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/aa2b1da3/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------


[41/49] Fixed index refresh issue.

Posted by to...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c31c553f/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
index d491d3d..908e6bc 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
@@ -80,6 +80,7 @@ public class CpWalker {
                         applicationScope.getApplication().getUuid()
                 } );
 
+        //only search edge types that start with collections
         Observable<String> edgeTypes = gm.getEdgeTypesFromSource(
                 new SimpleSearchEdgeType( fromEntityId, CpNamingUtils.EDGE_COLL_SUFFIX, null ) );
 
@@ -100,16 +101,16 @@ public class CpWalker {
             @Override
             public void call( Edge edge ) {
 
-                EntityRef sourceEntityRef =
-                        new SimpleEntityRef( edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
+                EntityRef targetNodeEntityRef =
+                        new SimpleEntityRef( edge.getTargetNode().getType(), edge.getTargetNode().getUuid() );
 
                 Entity entity;
                 try {
-                    entity = em.get( sourceEntityRef );
+                    entity = em.get( targetNodeEntityRef );
                 }
                 catch ( Exception ex ) {
-                    logger.error( "Error getting sourceEntity {}:{}, continuing", sourceEntityRef.getType(),
-                            sourceEntityRef.getUuid() );
+                    logger.error( "Error getting sourceEntity {}:{}, continuing", targetNodeEntityRef.getType(),
+                            targetNodeEntityRef.getUuid() );
                     return;
                 }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c31c553f/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index d2f7fef..2ef65ef 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -213,6 +213,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 //            setup.getEmf().refreshIndex();
             setup.getEmf().rebuildAllIndexes( po );
 
+            reporter.report();
             registry.remove( meterName );
             logger.info("Rebuilt index");
 
@@ -236,7 +237,6 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
         Id appId = new SimpleId( appUuid, "application");
         ApplicationScope scope = new ApplicationScopeImpl( appId );
-        IndexScope is = new IndexScopeImpl( appId, "application");
         EntityIndex ei = eif.createEntityIndex(scope);
         EsEntityIndexImpl eeii = (EsEntityIndexImpl)ei;
 
@@ -247,6 +247,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
     private int readData( String collectionName, int expected ) throws Exception {
 
         EntityManager em = app.getEntityManager();
+        em.refreshIndex();
 
         Query q = Query.fromQL("select * where key1=1000");
         q.setLimit(40);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c31c553f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 9ea14a1..821f7b9 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -116,7 +116,7 @@ public class EsEntityIndexImpl implements EntityIndex {
 
             AdminClient admin = client.admin();
             CreateIndexResponse cir = admin.indices().prepareCreate( indexName ).execute().actionGet();
-            log.debug( "Created new Index Name [{}] ACK=[{}]", indexName, cir.isAcknowledged() );
+            log.info( "Created new Index Name [{}] ACK=[{}]", indexName, cir.isAcknowledged() );
 
             RefreshResponse response;
 
@@ -128,11 +128,11 @@ public class EsEntityIndexImpl implements EntityIndex {
             /**
              * Immediately refresh to ensure the entire cluster is ready to receive this write.  Occasionally we see
              * errors.  See this post.
-             * http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
+             * http://elasticsearch-users.115913.n3.nabble
+             * .com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
              *
              */
             refresh();
-
         }
         catch ( IndexAlreadyExistsException expected ) {
             // this is expected to happen if index already exists, it's a no-op and swallow
@@ -272,25 +272,33 @@ public class EsEntityIndexImpl implements EntityIndex {
 
     public void refresh() {
 
-            //now try to refresh, to ensure that it's recognized by everyone.  Occasionally we can get a success
-            //before we can write.
-            for(int i = 0 ; i < MAX_WAITS; i++ ){
-                try{
-                    client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
-                    break;
 
-                }catch(IndexMissingException e){
-                   log.error( "Unable to refresh index after create. Waiting before sleeping.", e );
-                }
+        log.info( "Refreshing Created new Index Name [{}]", indexName );
 
-                try {
-                    Thread.sleep( WAIT_TIME );
-                }
-                catch ( InterruptedException e ) {
-                    //swallow it
-                }
+        //now try to refresh, to ensure that it's recognized by everyone.  Occasionally we can get a success
+        //before we can write.
+        for ( int i = 0; i < MAX_WAITS; i++ ) {
+            try {
+                client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+                return;
+            }
+            catch ( IndexMissingException e ) {
+                log.error( "Unable to refresh index after create. Waiting before sleeping.", e );
             }
 
+            try {
+                Thread.sleep( WAIT_TIME );
+            }
+            catch ( InterruptedException e ) {
+                //swallow it
+            }
+        }
+
+        /**
+         * Try the refresh one last time if we get here
+         */
+        client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+
         log.debug( "Refreshed index: " + indexName );
     }
 


[15/49] git commit: more cloudformation updates

Posted by to...@apache.org.
more cloudformation updates


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

Branch: refs/heads/two-dot-o
Commit: f3fddfe98cee88a8c1f7ef0eb87a069b7de93954
Parents: 7f731fb
Author: amuramoto <am...@apigee.com>
Authored: Sat Oct 11 01:16:16 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Sat Oct 11 01:16:16 2014 -0700

----------------------------------------------------------------------
 stack/awscluster/pom.xml                        |  2 +-
 .../dist/init_instance/install_cassandra.sh     |  2 +-
 stack/awscluster/ugcluster-cf.json              | 56 ++++++++++++++++++++
 3 files changed, 58 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f3fddfe9/stack/awscluster/pom.xml
----------------------------------------------------------------------
diff --git a/stack/awscluster/pom.xml b/stack/awscluster/pom.xml
index 049415d..0c0bd46 100644
--- a/stack/awscluster/pom.xml
+++ b/stack/awscluster/pom.xml
@@ -30,7 +30,7 @@
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <aws.s3.release-bucket>ug-cloudformation</aws.s3.release-bucket>
+        <aws.s3.release-bucket>alex-cloudformation</aws.s3.release-bucket>
         <stack.war>../rest/target/ROOT.war</stack.war>
         <portal.dir>../../portal/dist/usergrid-portal</portal.dir>
     </properties>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f3fddfe9/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh b/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
index 9e74348..280ae40 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
@@ -28,7 +28,7 @@ deb http://www.apache.org/dist/cassandra/debian 12x main
 EOF
 
 apt-get update
-apt-get -y --force-yes install libcap2 cassandra=1.2.11
+apt-get -y --force-yes install libcap2 cassandra=1.2.19
 /etc/init.d/cassandra stop
 
 mkdir -p /mnt/data/cassandra

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f3fddfe9/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index 31950a2..197eb6c 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -1207,6 +1207,20 @@
                 }
             }
         },
+        "AllowRestToESOnAllPorts": {
+            "Type": "AWS::EC2::SecurityGroupIngress",
+            "Properties": {
+                "GroupName": {
+                    "Ref": "ESSecurityGroup"
+                },
+                "IpProtocol": "tcp",
+                "FromPort": "1",
+                "ToPort": "65535",
+                "SourceSecurityGroupName": {
+                    "Ref": "RestSecurityGroup"
+                }
+            }
+        },
         "CassSecurityGroup": {
             "Type": "AWS::EC2::SecurityGroup",
             "Properties": {
@@ -1235,6 +1249,34 @@
                 }
             }
         },
+        "AllowESToCassOnAllPorts": {
+            "Type": "AWS::EC2::SecurityGroupIngress",
+            "Properties": {
+                "GroupName": {
+                    "Ref": "CassSecurityGroup"
+                },
+                "IpProtocol": "tcp",
+                "FromPort": "1",
+                "ToPort": "65535",
+                "SourceSecurityGroupName": {
+                    "Ref": "ESSecurityGroup"
+                }
+            }
+        },
+        "AllowESToESOnAllPorts": {
+            "Type": "AWS::EC2::SecurityGroupIngress",
+            "Properties": {
+                "GroupName": {
+                    "Ref": "ESSecurityGroup"
+                },
+                "IpProtocol": "tcp",
+                "FromPort": "1",
+                "ToPort": "65535",
+                "SourceSecurityGroupName": {
+                    "Ref": "ESSecurityGroup"
+                }
+            }
+        },
         "AllowRestToCassOnAllPorts": {
             "Type": "AWS::EC2::SecurityGroupIngress",
             "Properties": {
@@ -1263,6 +1305,20 @@
                 }
             }
         },
+        "AllowESToRestOnAllPorts": {
+            "Type": "AWS::EC2::SecurityGroupIngress",
+            "Properties": {
+                "GroupName": {
+                    "Ref": "RestSecurityGroup"
+                },
+                "IpProtocol": "tcp",
+                "FromPort": "0",
+                "ToPort": "65535",
+                "SourceSecurityGroupName": {
+                    "Ref": "ESSecurityGroup"
+                }
+            }
+        },
         "AllowCassToCassOnAllPorts": {
             "Type": "AWS::EC2::SecurityGroupIngress",
             "Properties": {


[18/49] git commit: more cloudformation updates

Posted by to...@apache.org.
more cloudformation updates


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

Branch: refs/heads/two-dot-o
Commit: 60096b68604e1b7facd4ee3b20c755ad94854733
Parents: 59fed6a
Author: amuramoto <am...@apigee.com>
Authored: Sun Oct 12 03:49:14 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Sun Oct 12 03:49:14 2014 -0700

----------------------------------------------------------------------
 stack/awscluster/src/main/groovy/configure_elasticsearch.groovy | 4 ++--
 stack/awscluster/src/main/groovy/configure_usergrid.groovy      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/60096b68/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy b/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
index ce8e3c5..ceddcbe 100644
--- a/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
+++ b/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
@@ -30,13 +30,13 @@ import com.amazonaws.services.simpledb.*
 import com.amazonaws.services.simpledb.model.*
 
 String hostName  = (String)System.getenv().get("PUBLIC_HOSTNAME")
-def clusterName  = (String)System.getenv().get("CASSANDRA_CLUSTER_NAME")
+def clusterName  = (String)System.getenv().get("ES_CLUSTER_NAME")
 
 NodeRegistry registry = new NodeRegistry();
 
 // build seed list by listing all Cassandra nodes found in SimpleDB domain with our stackName
 // works because cassandra nodes are also elasticsearch nodes
-def selectResult = registry.searchNode('cassandra')
+def selectResult = registry.searchNode('elasticsearch')
 def esnodes = ""
 def sep = ""
 for (hostname in selectResult) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/60096b68/stack/awscluster/src/main/groovy/configure_usergrid.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_usergrid.groovy b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
index cdbbc77..a0a051c 100644
--- a/stack/awscluster/src/main/groovy/configure_usergrid.groovy
+++ b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
@@ -66,7 +66,7 @@ for (item in selectResult) {
 }
 
 // cassandra nodes are also our elasticsearch nodes
-selectResult = registry.searchNode('cassandra')
+selectResult = registry.searchNode('elasticsearch')
 def esnodes = ""
 sep = ""
 for (item in selectResult) {


[27/49] git commit: Added temporary tagging as instances start

Posted by to...@apache.org.
Added temporary tagging as instances start


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

Branch: refs/heads/two-dot-o
Commit: b0d1605409b714e13d06d9be1ccdd6dfa919e673
Parents: 6c632f8
Author: Todd Nine <to...@apache.org>
Authored: Wed Oct 15 11:08:32 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Wed Oct 15 11:09:50 2014 -0600

----------------------------------------------------------------------
 .../src/main/dist/init_instance/init_db_server.sh         |  7 +++++++
 .../src/main/dist/init_instance/init_es_server.sh         |  6 ++++++
 .../src/main/dist/init_instance/init_graphite_server.sh   |  6 ++++++
 .../src/main/dist/init_instance/init_rest_server.sh       |  9 ++++++++-
 stack/awscluster/src/main/groovy/tag_instance.groovy      | 10 +++++++++-
 5 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0d16054/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_db_server.sh b/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
index a37bb82..a46e7f9 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
@@ -18,6 +18,9 @@
 #  directory of this distribution.
 #
 
+
+
+
 echo "${HOSTNAME}" > /etc/hostname
 echo "127.0.0.1 ${HOSTNAME}" >> /etc/hosts
 hostname `cat /etc/hostname`
@@ -49,6 +52,10 @@ cp /usr/share/aws-java-sdk-*/lib/* /home/ubuntu/.groovy/lib
 rm /home/ubuntu/.groovy/lib/stax*
 ln -s /home/ubuntu/.groovy /root/.groovy
 
+# tag last so we can see in the console so that we know what's running
+cd /usr/share/usergrid/scripts
+groovy tag_instance.groovy BUILD-IN-PROGRESS
+
 cd /usr/share/usergrid/init_instance
 ./install_oraclejdk.sh 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0d16054/stack/awscluster/src/main/dist/init_instance/init_es_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_es_server.sh b/stack/awscluster/src/main/dist/init_instance/init_es_server.sh
index c187cb8..fbe41ab 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_es_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_es_server.sh
@@ -18,6 +18,8 @@
 #  directory of this distribution.
 #
 
+
+
 echo "${HOSTNAME}" > /etc/hostname
 echo "127.0.0.1 ${HOSTNAME}" >> /etc/hosts
 hostname `cat /etc/hostname`
@@ -49,6 +51,10 @@ cp /usr/share/aws-java-sdk-*/lib/* /home/ubuntu/.groovy/lib
 rm /home/ubuntu/.groovy/lib/stax*
 ln -s /home/ubuntu/.groovy /root/.groovy
 
+# tag last so we can see in the console so that we know what's running
+cd /usr/share/usergrid/scripts
+groovy tag_instance.groovy BUILD-IN-PROGRESS
+
 cd /usr/share/usergrid/init_instance
 ./install_oraclejdk.sh 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0d16054/stack/awscluster/src/main/dist/init_instance/init_graphite_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_graphite_server.sh b/stack/awscluster/src/main/dist/init_instance/init_graphite_server.sh
index a9d74c0..b095f2b 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_graphite_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_graphite_server.sh
@@ -18,6 +18,8 @@
 #  directory of this distribution.
 #
 
+
+
 echo "${HOSTNAME}" > /etc/hostname
 echo "127.0.0.1 ${HOSTNAME}" >> /etc/hosts
 hostname `cat /etc/hostname`
@@ -49,6 +51,10 @@ cp /usr/share/aws-java-sdk-*/lib/* /home/ubuntu/.groovy/lib
 rm /home/ubuntu/.groovy/lib/stax*
 ln -s /home/ubuntu/.groovy /root/.groovy
 
+# tag last so we can see in the console so that we know what's running
+cd /usr/share/usergrid/scripts
+groovy tag_instance.groovy BUILD-IN-PROGRESS
+
 cd /usr/share/usergrid/init_instance
 ./install_oraclejdk.sh
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0d16054/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
index 96da354..75edc16 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
@@ -18,6 +18,8 @@
 #  directory of this distribution.
 #
 
+
+
 echo "${HOSTNAME}" > /etc/hostname
 echo "127.0.0.1 ${HOSTNAME}" >> /etc/hosts
 hostname `cat /etc/hostname`
@@ -39,6 +41,11 @@ cp /usr/share/aws-java-sdk-*/third-party/*/*.jar /home/ubuntu/.groovy/lib
 cp /usr/share/aws-java-sdk-*/lib/* /home/ubuntu/.groovy/lib 
 ln -s /home/ubuntu/.groovy /root/.groovy
 
+# tag last so we can see in the console so that we know what's running
+cd /usr/share/usergrid/scripts
+groovy tag_instance.groovy BUILD-IN-PROGRESS
+
+
 # Build environment for Groovy scripts
 . /etc/profile.d/aws-credentials.sh
 . /etc/profile.d/usergrid-env.sh
@@ -145,4 +152,4 @@ sh /etc/init.d/tomcat7 start
 
 # tag last so we can see in the console that the script ran to completion
 cd /usr/share/usergrid/scripts
-groovy tag_instance.groovy
\ No newline at end of file
+groovy tag_instance.groovy

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b0d16054/stack/awscluster/src/main/groovy/tag_instance.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/tag_instance.groovy b/stack/awscluster/src/main/groovy/tag_instance.groovy
index 7e5ed84..99d3288 100644
--- a/stack/awscluster/src/main/groovy/tag_instance.groovy
+++ b/stack/awscluster/src/main/groovy/tag_instance.groovy
@@ -32,6 +32,14 @@ String secretKey  = (String)System.getenv().get("AWS_SECRET_KEY")
 String instanceId = (String)System.getenv().get("EC2_INSTANCE_ID")
 String stackName  = (String)System.getenv().get("STACK_NAME")
 
+
+String moreMetaData = ""
+
+if (args.size() == 1 )  {
+    moreMetaData = args[0]
+}
+
+
 def creds = new BasicAWSCredentials(accessKey, secretKey)
 def ec2Client = new AmazonEC2Client(creds)
 
@@ -39,7 +47,7 @@ def resources = new ArrayList()
 resources.add(instanceId)
 
 def tags = new ArrayList()
-def tag = "${stackName}-${type}-${instanceId}"
+def tag = "${stackName}-${type}-${instanceId}${moreMetaData}"
 tags.add(new Tag("Name", tag))
 
 ec2Client.createTags(new CreateTagsRequest(resources, tags))


[42/49] Fixed index refresh issue.

Posted by to...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c31c553f/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 2a790ab..96f0e1e 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
@@ -16,14 +16,10 @@
 
 package org.apache.usergrid.corepersistence;
 
-import static me.prettyprint.hector.api.factory.HFactory.createMutator;
 
-import com.clearspring.analytics.hash.MurmurHash;
-import com.yammer.metrics.annotation.Metered;
 import java.nio.ByteBuffer;
 import java.util.AbstractMap;
 import java.util.ArrayList;
-import static java.util.Arrays.asList;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -33,21 +29,18 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.Assert;
+
 import org.apache.usergrid.corepersistence.results.ResultsLoader;
 import org.apache.usergrid.corepersistence.results.ResultsLoaderFactory;
 import org.apache.usergrid.corepersistence.results.ResultsLoaderFactoryImpl;
 import org.apache.usergrid.corepersistence.util.CpEntityMapUtils;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.utils.UUIDUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.util.Assert;
-
 import org.apache.usergrid.persistence.ConnectedEntityRef;
 import org.apache.usergrid.persistence.ConnectionRef;
 import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.EntityFactory;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.EntityRef;
 import org.apache.usergrid.persistence.IndexBucketLocator;
@@ -56,43 +49,12 @@ import org.apache.usergrid.persistence.RelationManager;
 import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.persistence.RoleRef;
 import org.apache.usergrid.persistence.Schema;
-import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
-import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_ENTITIES;
-import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_TYPES;
-import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTING_ENTITIES;
-import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTING_TYPES;
-import static org.apache.usergrid.persistence.Schema.INDEX_CONNECTIONS;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_CREATED;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_INACTIVITY;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
-import static org.apache.usergrid.persistence.Schema.PROPERTY_TITLE;
-import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
-import static org.apache.usergrid.persistence.Schema.TYPE_ENTITY;
-import static org.apache.usergrid.persistence.Schema.TYPE_ROLE;
-import static org.apache.usergrid.persistence.Schema.getDefaultSchema;
 import org.apache.usergrid.persistence.SimpleEntityRef;
 import org.apache.usergrid.persistence.SimpleRoleRef;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_COMPOSITE_DICTIONARIES;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_DICTIONARIES;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_INDEX;
-import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_INDEX_ENTRIES;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addDeleteToMutator;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addInsertToMutator;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.batchExecute;
-import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
 import org.apache.usergrid.persistence.cassandra.CassandraService;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.INDEX_ENTRY_LIST_COUNT;
 import org.apache.usergrid.persistence.cassandra.ConnectionRefImpl;
-import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchDeleteLocationInConnectionsIndex;
-import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchRemoveLocationFromCollectionIndex;
-import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchStoreLocationInCollectionIndex;
-import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchStoreLocationInConnectionsIndex;
 import org.apache.usergrid.persistence.cassandra.IndexUpdate;
-import static org.apache.usergrid.persistence.cassandra.IndexUpdate.indexValueCode;
-import static org.apache.usergrid.persistence.cassandra.IndexUpdate.toIndexableValue;
-import static org.apache.usergrid.persistence.cassandra.IndexUpdate.validIndexableValue;
 import org.apache.usergrid.persistence.cassandra.QueryProcessorImpl;
-import static org.apache.usergrid.persistence.cassandra.Serializers.be;
 import org.apache.usergrid.persistence.cassandra.index.ConnectedIndexScanner;
 import org.apache.usergrid.persistence.cassandra.index.IndexBucketScanner;
 import org.apache.usergrid.persistence.cassandra.index.IndexScanner;
@@ -114,6 +76,7 @@ import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
 import org.apache.usergrid.persistence.index.EntityIndex;
+import org.apache.usergrid.persistence.index.EntityIndexBatch;
 import org.apache.usergrid.persistence.index.IndexScope;
 import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
 import org.apache.usergrid.persistence.index.query.CandidateResult;
@@ -138,19 +101,59 @@ import org.apache.usergrid.persistence.query.ir.result.GeoIterator;
 import org.apache.usergrid.persistence.query.ir.result.SliceIterator;
 import org.apache.usergrid.persistence.query.ir.result.StaticIdIterator;
 import org.apache.usergrid.persistence.schema.CollectionInfo;
-import static org.apache.usergrid.utils.ClassUtils.cast;
-import static org.apache.usergrid.utils.CompositeUtils.setGreaterThanEqualityFlag;
 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 static org.apache.usergrid.utils.UUIDUtils.getTimestampInMicros;
+import org.apache.usergrid.utils.UUIDUtils;
+
+import com.yammer.metrics.annotation.Metered;
 
 import me.prettyprint.hector.api.Keyspace;
 import me.prettyprint.hector.api.beans.DynamicComposite;
 import me.prettyprint.hector.api.beans.HColumn;
 import me.prettyprint.hector.api.mutation.Mutator;
 import rx.Observable;
+import rx.functions.Action1;
+import rx.functions.Func1;
+
+import static java.util.Arrays.asList;
+
+import static me.prettyprint.hector.api.factory.HFactory.createMutator;
+import static org.apache.usergrid.persistence.Schema.COLLECTION_ROLES;
+import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_ENTITIES;
+import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTED_TYPES;
+import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTING_ENTITIES;
+import static org.apache.usergrid.persistence.Schema.DICTIONARY_CONNECTING_TYPES;
+import static org.apache.usergrid.persistence.Schema.INDEX_CONNECTIONS;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_CREATED;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_INACTIVITY;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
+import static org.apache.usergrid.persistence.Schema.PROPERTY_TITLE;
+import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
+import static org.apache.usergrid.persistence.Schema.TYPE_ENTITY;
+import static org.apache.usergrid.persistence.Schema.TYPE_ROLE;
+import static org.apache.usergrid.persistence.Schema.getDefaultSchema;
+import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_COMPOSITE_DICTIONARIES;
+import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_DICTIONARIES;
+import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_INDEX;
+import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_INDEX_ENTRIES;
+import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addDeleteToMutator;
+import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addInsertToMutator;
+import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.batchExecute;
+import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.INDEX_ENTRY_LIST_COUNT;
+import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchDeleteLocationInConnectionsIndex;
+import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchRemoveLocationFromCollectionIndex;
+import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchStoreLocationInCollectionIndex;
+import static org.apache.usergrid.persistence.cassandra.GeoIndexManager.batchStoreLocationInConnectionsIndex;
+import static org.apache.usergrid.persistence.cassandra.IndexUpdate.indexValueCode;
+import static org.apache.usergrid.persistence.cassandra.IndexUpdate.toIndexableValue;
+import static org.apache.usergrid.persistence.cassandra.IndexUpdate.validIndexableValue;
+import static org.apache.usergrid.persistence.cassandra.Serializers.be;
+import static org.apache.usergrid.utils.ClassUtils.cast;
+import static org.apache.usergrid.utils.CompositeUtils.setGreaterThanEqualityFlag;
+import static org.apache.usergrid.utils.InflectionUtils.singularize;
+import static org.apache.usergrid.utils.MapUtils.addMapSet;
+import static org.apache.usergrid.utils.UUIDUtils.getTimestampInMicros;
 
 
 /**
@@ -161,9 +164,8 @@ public class CpRelationManager implements RelationManager {
     private static final Logger logger = LoggerFactory.getLogger( CpRelationManager.class );
 
 
-
     private CpEntityManagerFactory emf;
-    
+
     private CpManagerCache managerCache;
 
     private EntityManager em;
@@ -184,23 +186,18 @@ public class CpRelationManager implements RelationManager {
     private ResultsLoaderFactory resultsLoaderFactory;
 
 
-
     public CpRelationManager() {}
 
 
-    public CpRelationManager init( 
-        EntityManager em, 
-        CpEntityManagerFactory emf, 
-        UUID applicationId,
-        EntityRef headEntity, 
-        IndexBucketLocator indexBucketLocator ) {
+    public CpRelationManager init( EntityManager em, CpEntityManagerFactory emf, UUID applicationId,
+                                   EntityRef headEntity, IndexBucketLocator indexBucketLocator ) {
 
         Assert.notNull( em, "Entity manager cannot be null" );
         Assert.notNull( emf, "Entity manager factory cannot be null" );
         Assert.notNull( applicationId, "Application Id cannot be null" );
         Assert.notNull( headEntity, "Head entity cannot be null" );
         Assert.notNull( headEntity.getUuid(), "Head entity uuid cannot be null" );
-       
+
         // TODO: this assert should not be failing
         //Assert.notNull( indexBucketLocator, "indexBucketLocator cannot be null" );
 
@@ -209,31 +206,27 @@ public class CpRelationManager implements RelationManager {
         this.applicationId = applicationId;
         this.headEntity = headEntity;
         this.managerCache = emf.getManagerCache();
-        this.applicationScope = emf.getApplicationScope(applicationId);
+        this.applicationScope = emf.getApplicationScope( applicationId );
 
         this.cass = em.getCass(); // TODO: eliminate need for this via Core Persistence
         this.indexBucketLocator = indexBucketLocator; // TODO: this also
 
         // load the Core Persistence version of the head entity as well
-        this.headEntityScope = new CollectionScopeImpl( 
-            this.applicationScope.getApplication(), 
-            this.applicationScope.getApplication(), 
-                CpNamingUtils.getCollectionScopeNameFromEntityType( headEntity.getType() ));
+        this.headEntityScope =
+                new CollectionScopeImpl( this.applicationScope.getApplication(), this.applicationScope.getApplication(),
+                        CpNamingUtils.getCollectionScopeNameFromEntityType( headEntity.getType() ) );
 
-        EntityCollectionManager ecm = managerCache.getEntityCollectionManager(headEntityScope);
+        EntityCollectionManager ecm = managerCache.getEntityCollectionManager( headEntityScope );
         if ( logger.isDebugEnabled() ) {
-            logger.debug( "Loading head entity {}:{} from scope\n   app {}\n   owner {}\n   name {}", 
-                new Object[] {
-                    headEntity.getType(), 
-                    headEntity.getUuid(), 
-                    headEntityScope.getApplication(), 
-                    headEntityScope.getOwner(),
-                    headEntityScope.getName()
-            } );
+            logger.debug( "Loading head entity {}:{} from scope\n   app {}\n   owner {}\n   name {}", new Object[] {
+                            headEntity.getType(), headEntity.getUuid(), headEntityScope.getApplication(),
+                            headEntityScope.getOwner(), headEntityScope.getName()
+                    } );
         }
-        
-        this.cpHeadEntity = ecm.load( new SimpleId( 
-            headEntity.getUuid(), headEntity.getType() )).toBlocking().lastOrDefault(null);
+
+        //TODO PERFORMANCE why are we loading this again here?
+        this.cpHeadEntity = ecm.load( new SimpleId( headEntity.getUuid(), headEntity.getType() ) ).toBlocking()
+                               .lastOrDefault( null );
 
         // commented out because it is possible that CP entity has not been created yet
         Assert.notNull( cpHeadEntity, "cpHeadEntity cannot be null" );
@@ -243,22 +236,21 @@ public class CpRelationManager implements RelationManager {
         return this;
     }
 
-    
+
     @Override
     public Set<String> getCollectionIndexes( String collectionName ) throws Exception {
         final Set<String> indexes = new HashSet<String>();
 
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
 
         String edgeTypePrefix = CpNamingUtils.getEdgeTypeFromCollectionName( collectionName );
 
-        logger.debug("getCollectionIndexes(): Searching for edge type prefix {} to target {}:{}", 
-            new Object[] {
-                edgeTypePrefix, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid()
-        });
+        logger.debug( "getCollectionIndexes(): Searching for edge type prefix {} to target {}:{}", new Object[] {
+                        edgeTypePrefix, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid()
+                } );
 
-        Observable<String> types= gm.getEdgeTypesFromSource( 
-            new SimpleSearchEdgeType( cpHeadEntity.getId(), edgeTypePrefix,  null ));
+        Observable<String> types =
+                gm.getEdgeTypesFromSource( new SimpleSearchEdgeType( cpHeadEntity.getId(), edgeTypePrefix, null ) );
 
         Iterator<String> iter = types.toBlockingObservable().getIterator();
         while ( iter.hasNext() ) {
@@ -275,8 +267,7 @@ public class CpRelationManager implements RelationManager {
         //Map<EntityRef, Set<String>> containerEntities = getContainers(-1, "owns", null);
         Map<EntityRef, Set<String>> containerEntities = getContainers();
 
-        Map<String, Map<UUID, Set<String>>> owners = 
-                new LinkedHashMap<String, Map<UUID, Set<String>>>();
+        Map<String, Map<UUID, Set<String>>> owners = new LinkedHashMap<String, Map<UUID, Set<String>>>();
 
         for ( EntityRef owner : containerEntities.keySet() ) {
             Set<String> collections = containerEntities.get( owner );
@@ -296,6 +287,7 @@ public class CpRelationManager implements RelationManager {
 
     /**
      * Gets containing collections and/or connections depending on the edge type you pass in
+     *
      * @param limit Max number to return
      * @param edgeType Edge type, edge type prefix or null to allow any edge type
      * @param fromEntityType Only consider edges from entities of this type
@@ -304,44 +296,43 @@ public class CpRelationManager implements RelationManager {
 
         Map<EntityRef, Set<String>> results = new LinkedHashMap<EntityRef, Set<String>>();
 
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        Iterator<String> edgeTypes = gm.getEdgeTypesToTarget( new SimpleSearchEdgeType( 
-            cpHeadEntity.getId(), edgeType, null) ).toBlocking().getIterator();
+        Iterator<String> edgeTypes =
+                gm.getEdgeTypesToTarget( new SimpleSearchEdgeType( cpHeadEntity.getId(), edgeType, null ) ).toBlocking()
+                  .getIterator();
 
-        logger.debug("getContainers(): "
-                + "Searched for edges of type {}\n   to target {}:{}\n   in scope {}\n   found: {}", 
-            new Object[] {
-                edgeType,
-                cpHeadEntity.getId().getType(), 
-                cpHeadEntity.getId().getUuid(), 
-                applicationScope.getApplication(),
-                edgeTypes.hasNext()
-        });
+        logger.debug(
+                "getContainers(): " + "Searched for edges of type {}\n   to target {}:{}\n   in scope {}\n   found: {}",
+                new Object[] {
+                        edgeType, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid(),
+                        applicationScope.getApplication(), edgeTypes.hasNext()
+                } );
 
         while ( edgeTypes.hasNext() ) {
 
             String etype = edgeTypes.next();
 
-            Observable<Edge> edges = gm.loadEdgesToTarget( new SimpleSearchByEdgeType(
-                cpHeadEntity.getId(), etype, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null ));
+            Observable<Edge> edges = gm.loadEdgesToTarget(
+                    new SimpleSearchByEdgeType( cpHeadEntity.getId(), etype, Long.MAX_VALUE,
+                            SearchByEdgeType.Order.DESCENDING, null ) );
 
             Iterator<Edge> iter = edges.toBlockingObservable().getIterator();
             while ( iter.hasNext() ) {
                 Edge edge = iter.next();
 
-                if ( fromEntityType != null && !fromEntityType.equals( edge.getSourceNode().getType() )) {
-                    logger.debug("Ignoring edge from entity type {}", edge.getSourceNode().getType());
+                if ( fromEntityType != null && !fromEntityType.equals( edge.getSourceNode().getType() ) ) {
+                    logger.debug( "Ignoring edge from entity type {}", edge.getSourceNode().getType() );
                     continue;
                 }
 
-                EntityRef eref = new SimpleEntityRef( 
-                    edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
+                EntityRef eref = new SimpleEntityRef( edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
 
                 String name = null;
-                if ( CpNamingUtils.isConnectionEdgeType( edge.getType() )) {
+                if ( CpNamingUtils.isConnectionEdgeType( edge.getType() ) ) {
                     name = CpNamingUtils.getConnectionType( edge.getType() );
-                } else {
+                }
+                else {
                     name = CpNamingUtils.getCollectionName( edge.getType() );
                 }
                 addMapSet( results, eref, name );
@@ -356,183 +347,161 @@ public class CpRelationManager implements RelationManager {
     }
 
 
-    public List<String> updateContainingCollectionAndCollectionIndexes( 
-        Entity entity, org.apache.usergrid.persistence.model.entity.Entity cpEntity ) {
-
-        List<String> results = new ArrayList<String>();
+    public void updateContainingCollectionAndCollectionIndexes(
+            final org.apache.usergrid.persistence.model.entity.Entity cpEntity ) {
 
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
 
-        Iterator<String> edgeTypesToTarget = gm.getEdgeTypesToTarget( new SimpleSearchEdgeType( 
-            cpHeadEntity.getId(), null, null) ).toBlockingObservable().getIterator();
+        final GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        logger.debug("updateContainingCollectionsAndCollections(): "
-                + "Searched for edges to target {}:{}\n   in scope {}\n   found: {}", 
-            new Object[] {
-                cpHeadEntity.getId().getType(), 
-                cpHeadEntity.getId().getUuid(), 
-                applicationScope.getApplication(),
-                edgeTypesToTarget.hasNext()
-        });
+        logger.debug( "updateContainingCollectionsAndCollections(): "
+                        + "Searched for edges to target {}:{}\n   in scope {}\n   found: {}", new Object[] {
+                        cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid(),
+                        applicationScope.getApplication()
+                } );
 
         // loop through all types of edge to target
-        int count = 0;
+
 
         final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
 
         final EntityIndexBatch entityIndexBatch = ei.createBatch();
 
-        while ( edgeTypesToTarget.hasNext() ) {
-
-            // get all edges of the type
-            String etype = edgeTypesToTarget.next();
+        final int count = gm.getEdgeTypesToTarget(
+                new SimpleSearchEdgeType( cpHeadEntity.getId(), null, null ) )
+                //for each edge type, emit all the edges of that type
+                            .flatMap( new Func1<String, Observable<Edge>>() {
+                                @Override
+                                public Observable<Edge> call( final String etype ) {
+                                    return gm.loadEdgesToTarget(
+                                            new SimpleSearchByEdgeType( cpHeadEntity.getId(), etype, Long.MAX_VALUE,
+                                                    SearchByEdgeType.Order.DESCENDING, null ) );
+                                }
+                            } )
 
-            Observable<Edge> edges = gm.loadEdgesToTarget( new SimpleSearchByEdgeType(
-                cpHeadEntity.getId(), etype, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING,  null ));
+                            //for each edge we receive index and add to the batch
+                            .doOnNext( new Action1<Edge>() {
+                    @Override
+                    public void call( final Edge edge ) {
 
-            // loop through edges of that type
-            Iterator<Edge> iter = edges.toBlockingObservable().getIterator();
-            while ( iter.hasNext() ) {
 
-                Edge edge = iter.next();
+                        EntityRef sourceEntity =
+                                new SimpleEntityRef( edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
 
-                EntityRef sourceEntity = new SimpleEntityRef( 
-                    edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
+                        // reindex the entity in the source entity's collection or connection index
 
-                // reindex the entity in the source entity's collection or connection index
+                        IndexScope indexScope;
+                        if ( CpNamingUtils.isCollectionEdgeType( edge.getType() ) ) {
 
-                IndexScope indexScope;
-                if ( CpNamingUtils.isCollectionEdgeType( edge.getType() )) {
+                            String collName = CpNamingUtils.getCollectionName( edge.getType() );
+                            indexScope =
+                                    new IndexScopeImpl( new SimpleId( sourceEntity.getUuid(), sourceEntity.getType() ),
+                                            CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ) );
+                        }
+                        else {
 
-                    String collName = CpNamingUtils.getCollectionName( edge.getType() );
-                    indexScope = new IndexScopeImpl(
-                        new SimpleId(sourceEntity.getUuid(), sourceEntity.getType()),
-                        CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ));
+                            String connName = CpNamingUtils.getCollectionName( edge.getType() );
+                            indexScope =
+                                    new IndexScopeImpl( new SimpleId( sourceEntity.getUuid(), sourceEntity.getType() ),
+                                            CpNamingUtils.getConnectionScopeName( cpEntity.getId().getType(),
+                                                    connName ) );
+                        }
 
-                } else {
+                        entityIndexBatch.index( indexScope, cpEntity );
 
-                    String connName = CpNamingUtils.getCollectionName( edge.getType() );
-                    indexScope = new IndexScopeImpl(
-                        new SimpleId(sourceEntity.getUuid(), sourceEntity.getType()),
-                        CpNamingUtils.getConnectionScopeName( cpHeadEntity.getId().getType(), connName ));
-                }
+                        // reindex the entity in the source entity's all-types index
 
-                entityIndexBatch.index(indexScope, cpEntity);
+                        indexScope = new IndexScopeImpl( new SimpleId( sourceEntity.getUuid(), sourceEntity.getType() ),
+                                CpNamingUtils.ALL_TYPES );
 
-                // reindex the entity in the source entity's all-types index
-                
-                indexScope = new IndexScopeImpl(
-                    new SimpleId(sourceEntity.getUuid(), sourceEntity.getType()),
-                        CpNamingUtils.ALL_TYPES);
-
-                entityIndexBatch.index(indexScope, cpEntity);
+                        entityIndexBatch.index( indexScope, cpEntity );
+                    }
+                } ).count().toBlocking().lastOrDefault( 0 );
 
-                count++;
-            }
-        }
 
         entityIndexBatch.execute();
 
-        logger.debug("updateContainingCollectionsAndCollections() updated {} indexes", count);
-        return results;
+        logger.debug( "updateContainingCollectionsAndCollections() updated {} indexes", count );
     }
 
 
     @Override
-    public boolean isConnectionMember(String connectionType, EntityRef entity) throws Exception {
+    public boolean isConnectionMember( String connectionType, EntityRef entity ) throws Exception {
 
         Id entityId = new SimpleId( entity.getUuid(), entity.getType() );
 
         String edgeType = CpNamingUtils.getEdgeTypeFromConnectionType( connectionType );
 
-        logger.debug("isConnectionMember(): Checking for edge type {} from {}:{} to {}:{}", 
-            new Object[] { 
-                edgeType, 
-                headEntity.getType(), headEntity.getUuid(), 
-                entity.getType(), entity.getUuid() });
-
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
-        Observable<Edge> edges = gm.loadEdgeVersions( 
-            new SimpleSearchByEdge(
-                new SimpleId(headEntity.getUuid(), headEntity.getType()), 
-                edgeType,  
-                entityId, 
-                Long.MAX_VALUE,  SearchByEdgeType.Order.DESCENDING,
-                null));
-
-        return edges.toBlockingObservable().firstOrDefault(null) != null;
+        logger.debug( "isConnectionMember(): Checking for edge type {} from {}:{} to {}:{}", new Object[] {
+                        edgeType, headEntity.getType(), headEntity.getUuid(), entity.getType(), entity.getUuid()
+                } );
+
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
+        Observable<Edge> edges = gm.loadEdgeVersions(
+                new SimpleSearchByEdge( new SimpleId( headEntity.getUuid(), headEntity.getType() ), edgeType, entityId,
+                        Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null ) );
+
+        return edges.toBlockingObservable().firstOrDefault( null ) != null;
     }
 
 
-    @SuppressWarnings("unchecked")
-    @Metered(group = "core", name = "RelationManager_isOwner")
+    @SuppressWarnings( "unchecked" )
+    @Metered( group = "core", name = "RelationManager_isOwner" )
     @Override
-    public boolean isCollectionMember(String collName, EntityRef entity) throws Exception {
+    public boolean isCollectionMember( String collName, EntityRef entity ) throws Exception {
 
         Id entityId = new SimpleId( entity.getUuid(), entity.getType() );
 
         String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collName );
 
-        logger.debug("isCollectionMember(): Checking for edge type {} from {}:{} to {}:{}", 
-            new Object[] { 
-                edgeType, 
-                headEntity.getType(), headEntity.getUuid(), 
-                entity.getType(), entity.getUuid() });
-
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
-        Observable<Edge> edges = gm.loadEdgeVersions( 
-            new SimpleSearchByEdge(
-                new SimpleId(headEntity.getUuid(), headEntity.getType()), 
-                edgeType,  
-                entityId, 
-                Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING,
-                null));
-
-        return edges.toBlockingObservable().firstOrDefault(null) != null;
+        logger.debug( "isCollectionMember(): Checking for edge type {} from {}:{} to {}:{}", new Object[] {
+                        edgeType, headEntity.getType(), headEntity.getUuid(), entity.getType(), entity.getUuid()
+                } );
+
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
+        Observable<Edge> edges = gm.loadEdgeVersions(
+                new SimpleSearchByEdge( new SimpleId( headEntity.getUuid(), headEntity.getType() ), edgeType, entityId,
+                        Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null ) );
+
+        return edges.toBlockingObservable().firstOrDefault( null ) != null;
     }
 
 
-   private boolean moreThanOneInboundConnection( 
-           EntityRef target, String connectionType ) {
+    private boolean moreThanOneInboundConnection( EntityRef target, String connectionType ) {
 
         Id targetId = new SimpleId( target.getUuid(), target.getType() );
 
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        Observable<Edge> edgesToTarget = gm.loadEdgesToTarget( new SimpleSearchByEdgeType(
-            targetId,
-            CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
-            System.currentTimeMillis(), SearchByEdgeType.Order.DESCENDING,
-            null)); // last
+        Observable<Edge> edgesToTarget = gm.loadEdgesToTarget(
+                new SimpleSearchByEdgeType( targetId, CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
+                        System.currentTimeMillis(), SearchByEdgeType.Order.DESCENDING, null ) ); // last
 
         Iterator<Edge> iterator = edgesToTarget.toBlockingObservable().getIterator();
         int count = 0;
         while ( iterator.hasNext() ) {
             iterator.next();
-            if ( count++ > 1 ) { 
+            if ( count++ > 1 ) {
                 return true;
             }
-        } 
+        }
         return false;
-   } 
+    }
 
-   private boolean moreThanOneOutboundConnection( 
-           EntityRef source, String connectionType ) {
+
+    private boolean moreThanOneOutboundConnection( EntityRef source, String connectionType ) {
 
         Id sourceId = new SimpleId( source.getUuid(), source.getType() );
 
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        Observable<Edge> edgesFromSource = gm.loadEdgesFromSource(new SimpleSearchByEdgeType(
-            sourceId,
-            CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
-            System.currentTimeMillis(),SearchByEdgeType.Order.DESCENDING,
-            null)); // last
+        Observable<Edge> edgesFromSource = gm.loadEdgesFromSource(
+                new SimpleSearchByEdgeType( sourceId, CpNamingUtils.getEdgeTypeFromConnectionType( connectionType ),
+                        System.currentTimeMillis(), SearchByEdgeType.Order.DESCENDING, null ) ); // last
 
         int count = edgesFromSource.take( 2 ).count().toBlocking().last();
 
         return count > 1;
-   } 
+    }
 
 
     @Override
@@ -540,10 +509,10 @@ public class CpRelationManager implements RelationManager {
 
         final Set<String> indexes = new HashSet<String>();
 
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
 
-        Observable<String> str = gm.getEdgeTypesFromSource( 
-                new SimpleSearchEdgeType( cpHeadEntity.getId(), null , null ));
+        Observable<String> str =
+                gm.getEdgeTypesFromSource( new SimpleSearchEdgeType( cpHeadEntity.getId(), null, null ) );
 
         Iterator<String> iter = str.toBlockingObservable().getIterator();
         while ( iter.hasNext() ) {
@@ -552,52 +521,53 @@ public class CpRelationManager implements RelationManager {
         }
 
         return indexes;
-
     }
 
+
     @Override
-    public Results getCollection(String collectionName, UUID startResult, int count, 
-            Level resultsLevel, boolean reversed) throws Exception {
+    public Results getCollection( String collectionName, UUID startResult, int count, Level resultsLevel,
+                                  boolean reversed ) throws Exception {
 
-        Query query = Query.fromQL("select *");
-        query.setLimit(count);
-        query.setReversed(reversed);
+        Query query = Query.fromQL( "select *" );
+        query.setLimit( count );
+        query.setReversed( reversed );
 
         if ( startResult != null ) {
-            query.addGreaterThanEqualFilter("created", startResult.timestamp());
+            query.addGreaterThanEqualFilter( "created", startResult.timestamp() );
         }
 
-        return searchCollection(collectionName, query);
+        return searchCollection( collectionName, query );
     }
 
+
     @Override
-    public Results getCollection(
-            String collName, Query query, Level level) throws Exception {
+    public Results getCollection( String collName, Query query, Level level ) throws Exception {
 
-        return searchCollection(collName, query);
+        return searchCollection( collName, query );
     }
 
 
     // add to a named collection of the head entity
     @Override
-    public Entity addToCollection(String collName, EntityRef itemRef) throws Exception {
-       
+    public Entity addToCollection( String collName, EntityRef itemRef ) throws Exception {
+
         CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(), collName );
         if ( ( collection != null ) && !collection.getType().equals( itemRef.getType() ) ) {
             return null;
         }
 
-        return addToCollection( collName, itemRef, 
-                (collection != null && collection.getLinkedCollection() != null) );
+        return addToCollection( collName, itemRef, ( collection != null && collection.getLinkedCollection() != null ) );
     }
 
-    public Entity addToCollection(String collName, EntityRef itemRef, boolean connectBack ) throws Exception {
+
+    public Entity addToCollection( String collName, EntityRef itemRef, boolean connectBack ) throws Exception {
 
         // don't fetch entity if we've already got one
         final Entity itemEntity;
         if ( itemRef instanceof Entity ) {
-            itemEntity = (Entity)itemRef;
-        } else {
+            itemEntity = ( Entity ) itemRef;
+        }
+        else {
             itemEntity = em.get( itemRef );
         }
 
@@ -611,70 +581,61 @@ 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(),
-            CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ));
+        CollectionScope memberScope =
+                new CollectionScopeImpl( applicationScope.getApplication(), applicationScope.getApplication(),
+                        CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ) );
 
-        EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager(memberScope);
+        EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager( memberScope );
 
         //TODO, this double load should disappear once events are in
-        org.apache.usergrid.persistence.model.entity.Entity memberEntity = memberMgr.load(
-            new SimpleId( itemRef.getUuid(), itemRef.getType() )).toBlocking().last();
+        org.apache.usergrid.persistence.model.entity.Entity memberEntity =
+                memberMgr.load( new SimpleId( itemRef.getUuid(), itemRef.getType() ) ).toBlocking().last();
 
         if ( memberEntity == null ) {
-            throw new RuntimeException("Unable to load entity uuid=" 
-                + itemRef.getUuid() + " type=" + itemRef.getType());
+            throw new RuntimeException(
+                    "Unable to load entity uuid=" + itemRef.getUuid() + " type=" + itemRef.getType() );
         }
 
         if ( logger.isDebugEnabled() ) {
-            logger.debug("Loaded member entity {}:{} from scope\n   app {}\n   "
-                    + "owner {}\n   name {} data {}", 
-                new Object[] { 
-                    itemRef.getType(), 
-                    itemRef.getUuid(), 
-                    memberScope.getApplication(), 
-                    memberScope.getOwner(), 
-                    memberScope.getName(),
-                    CpEntityMapUtils.toMap( memberEntity )
-            });
+            logger.debug( "Loaded member entity {}:{} from scope\n   app {}\n   " + "owner {}\n   name {} data {}",
+                    new Object[] {
+                            itemRef.getType(), itemRef.getUuid(), memberScope.getApplication(), memberScope.getOwner(),
+                            memberScope.getName(), CpEntityMapUtils.toMap( memberEntity )
+                    } );
         }
 
         String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collName );
 
-        UUID timeStampUuid =   memberEntity.getId().getUuid() != null 
-                &&  UUIDUtils.isTimeBased( memberEntity.getId().getUuid()) 
-                ?  memberEntity.getId().getUuid() : UUIDUtils.newTimeUUID();
+        UUID timeStampUuid =
+                memberEntity.getId().getUuid() != null && UUIDUtils.isTimeBased( memberEntity.getId().getUuid() ) ?
+                memberEntity.getId().getUuid() : UUIDUtils.newTimeUUID();
 
-        long uuidHash =    UUIDUtils.getUUIDLong(timeStampUuid);
+        long uuidHash = UUIDUtils.getUUIDLong( timeStampUuid );
 
         // create graph edge connection from head entity to member entity
-        Edge edge = new SimpleEdge(
-            cpHeadEntity.getId(),
-            edgeType,
-            memberEntity.getId(),
-           uuidHash);
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
-        gm.writeEdge(edge).toBlockingObservable().last();
+        Edge edge = new SimpleEdge( cpHeadEntity.getId(), edgeType, memberEntity.getId(), uuidHash );
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
+        gm.writeEdge( edge ).toBlockingObservable().last();
 
-        logger.debug("Wrote edgeType {}\n   from {}:{}\n   to {}:{}\n   scope {}:{}", new Object[] { 
-            edgeType, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid(),
-            memberEntity.getId().getType(), memberEntity.getId().getUuid(),
-            applicationScope.getApplication().getType(), applicationScope.getApplication().getUuid()});  
+        logger.debug( "Wrote edgeType {}\n   from {}:{}\n   to {}:{}\n   scope {}:{}", new Object[] {
+                edgeType, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid(),
+                memberEntity.getId().getType(), memberEntity.getId().getUuid(),
+                applicationScope.getApplication().getType(), applicationScope.getApplication().getUuid()
+        } );
 
-        ((CpEntityManager)em).indexEntityIntoCollection( cpHeadEntity, memberEntity, collName );
+        ( ( CpEntityManager ) em ).indexEntityIntoCollection( cpHeadEntity, memberEntity, collName );
 
-        logger.debug("Added entity {}:{} to collection {}", new Object[] { 
-            itemRef.getUuid().toString(), itemRef.getType(), collName }); 
+        logger.debug( "Added entity {}:{} to collection {}", new Object[] {
+                itemRef.getUuid().toString(), itemRef.getType(), collName
+        } );
 
-//        logger.debug("With head entity scope is {}:{}:{}", new Object[] { 
-//            headEntityScope.getApplication().toString(), 
-//            headEntityScope.getOwner().toString(),
-//            headEntityScope.getName()}); 
+        //        logger.debug("With head entity scope is {}:{}:{}", new Object[] {
+        //            headEntityScope.getApplication().toString(),
+        //            headEntityScope.getOwner().toString(),
+        //            headEntityScope.getName()});
 
         if ( connectBack && collection != null && collection.getLinkedCollection() != null ) {
-            getRelationManager( itemEntity )
-                .addToCollection( collection.getLinkedCollection(), headEntity, false );
+            getRelationManager( itemEntity ).addToCollection( collection.getLinkedCollection(), headEntity, false );
         }
 
         return itemEntity;
@@ -682,11 +643,11 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public Entity addToCollections(List<EntityRef> owners, String collName) throws Exception {
+    public Entity addToCollections( List<EntityRef> owners, String collName ) throws Exception {
 
         // TODO: this addToCollections() implementation seems wrong.
         for ( EntityRef eref : owners ) {
-            addToCollection( collName, eref ); 
+            addToCollection( collName, eref );
         }
 
         return null;
@@ -694,9 +655,9 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    @Metered(group = "core", name = "RelationManager_createItemInCollection")
-    public Entity createItemInCollection(
-        String collName, String itemType, Map<String, Object> properties) throws Exception {
+    @Metered( group = "core", name = "RelationManager_createItemInCollection" )
+    public Entity createItemInCollection( String collName, String itemType, Map<String, Object> properties )
+            throws Exception {
 
         if ( headEntity.getUuid().equals( applicationId ) ) {
             if ( itemType.equals( TYPE_ENTITY ) ) {
@@ -714,14 +675,13 @@ public class CpRelationManager implements RelationManager {
             return em.create( itemType, properties );
         }
 
-        else if ( headEntity.getType().equals( Group.ENTITY_TYPE ) 
-                && ( collName.equals( COLLECTION_ROLES ) ) ) {
+        else if ( headEntity.getType().equals( Group.ENTITY_TYPE ) && ( collName.equals( COLLECTION_ROLES ) ) ) {
             UUID groupId = headEntity.getUuid();
             String roleName = ( String ) properties.get( PROPERTY_NAME );
             return em.createGroupRole( groupId, roleName, ( Long ) properties.get( PROPERTY_INACTIVITY ) );
         }
 
-        CollectionInfo collection = getDefaultSchema().getCollection(headEntity.getType(),collName);
+        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(), collName );
         if ( ( collection != null ) && !collection.getType().equals( itemType ) ) {
             return null;
         }
@@ -735,16 +695,16 @@ public class CpRelationManager implements RelationManager {
             addToCollection( collName, itemEntity );
 
             if ( collection != null && collection.getLinkedCollection() != null ) {
-                getRelationManager(  getHeadEntity() )
-                    .addToCollection( collection.getLinkedCollection(),itemEntity);
+                getRelationManager( getHeadEntity() ).addToCollection( collection.getLinkedCollection(), itemEntity );
             }
         }
 
-        return itemEntity;  
+        return itemEntity;
     }
 
+
     @Override
-    public void removeFromCollection(String collName, EntityRef itemRef) throws Exception {
+    public void removeFromCollection( String collName, EntityRef itemRef ) throws Exception {
 
         // special handling for roles collection of the application
         if ( headEntity.getUuid().equals( applicationId ) ) {
@@ -760,102 +720,86 @@ public class CpRelationManager implements RelationManager {
             }
             em.delete( itemRef );
             return;
-       }
+        }
 
         // load the entity to be removed to the collection
-        CollectionScope memberScope = new CollectionScopeImpl( 
-            this.applicationScope.getApplication(), 
-            this.applicationScope.getApplication(), 
-            CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ));
-        EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager(memberScope);
+        CollectionScope memberScope =
+                new CollectionScopeImpl( this.applicationScope.getApplication(), this.applicationScope.getApplication(),
+                        CpNamingUtils.getCollectionScopeNameFromEntityType( itemRef.getType() ) );
+        EntityCollectionManager memberMgr = managerCache.getEntityCollectionManager( memberScope );
 
         if ( logger.isDebugEnabled() ) {
-            logger.debug("Loading entity to remove from collection "
-                    + "{}:{} from scope\n   app {}\n   owner {}\n   name {}", 
-                new Object[] { 
-                    itemRef.getType(), 
-                    itemRef.getUuid(), 
-                    memberScope.getApplication(), 
-                    memberScope.getOwner(), 
-                    memberScope.getName() 
-            });
+            logger.debug( "Loading entity to remove from collection "
+                            + "{}:{} from scope\n   app {}\n   owner {}\n   name {}", new Object[] {
+                            itemRef.getType(), itemRef.getUuid(), memberScope.getApplication(), memberScope.getOwner(),
+                            memberScope.getName()
+                    } );
         }
 
-        org.apache.usergrid.persistence.model.entity.Entity memberEntity = memberMgr.load(
-            new SimpleId( itemRef.getUuid(), itemRef.getType() )).toBlockingObservable().last();
+        org.apache.usergrid.persistence.model.entity.Entity memberEntity =
+                memberMgr.load( new SimpleId( itemRef.getUuid(), itemRef.getType() ) ).toBlockingObservable().last();
 
-        final EntityIndex ei = managerCache.getEntityIndex(applicationScope);
+        final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
         final EntityIndexBatch batch = ei.createBatch();
 
         // remove item from collection index
-        IndexScope indexScope = new IndexScopeImpl(
-            cpHeadEntity.getId(), 
-            CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ));
+        IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(),
+                CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ) );
 
-        batch.deindex(indexScope,  memberEntity );
+        batch.deindex( indexScope, memberEntity );
 
         // remove collection from item index 
-        IndexScope itemScope = new IndexScopeImpl(
-            memberEntity.getId(), 
-            CpNamingUtils.getCollectionScopeNameFromCollectionName(
-                    Schema.defaultCollectionName( cpHeadEntity.getId().getType() ) ));
+        IndexScope itemScope = new IndexScopeImpl( memberEntity.getId(), CpNamingUtils
+                .getCollectionScopeNameFromCollectionName(
+                        Schema.defaultCollectionName( cpHeadEntity.getId().getType() ) ) );
 
 
-        batch.deindex(itemScope,  cpHeadEntity );
+        batch.deindex( itemScope, cpHeadEntity );
 
         batch.execute();
 
         // remove edge from collection to item 
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
-        Edge collectionToItemEdge = new SimpleEdge( 
-            cpHeadEntity.getId(),
-             CpNamingUtils.getEdgeTypeFromCollectionName( collName),
-            memberEntity.getId(),
-                UUIDUtils.getUUIDLong(memberEntity.getId().getUuid())
-            );
-        gm.deleteEdge(collectionToItemEdge).toBlockingObservable().last();
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
+        Edge collectionToItemEdge =
+                new SimpleEdge( cpHeadEntity.getId(), CpNamingUtils.getEdgeTypeFromCollectionName( collName ),
+                        memberEntity.getId(), UUIDUtils.getUUIDLong( memberEntity.getId().getUuid() ) );
+        gm.deleteEdge( collectionToItemEdge ).toBlockingObservable().last();
 
         // remove edge from item to collection
-        Edge itemToCollectionEdge = new SimpleEdge( 
-            memberEntity.getId(), 
-                CpNamingUtils
-                        .getEdgeTypeFromCollectionName( Schema.defaultCollectionName( cpHeadEntity.getId().getType() )),
-            cpHeadEntity.getId(),
-            UUIDUtils.getUUIDLong(cpHeadEntity.getId().getUuid()));
-        gm.deleteEdge(itemToCollectionEdge).toBlockingObservable().last();
+        Edge itemToCollectionEdge = new SimpleEdge( memberEntity.getId(), CpNamingUtils
+                .getEdgeTypeFromCollectionName( Schema.defaultCollectionName( cpHeadEntity.getId().getType() ) ),
+                cpHeadEntity.getId(), UUIDUtils.getUUIDLong( cpHeadEntity.getId().getUuid() ) );
+        gm.deleteEdge( itemToCollectionEdge ).toBlockingObservable().last();
 
         // special handling for roles collection of a group
         if ( headEntity.getType().equals( Group.ENTITY_TYPE ) ) {
 
             if ( collName.equals( COLLECTION_ROLES ) ) {
-                String path = (String)( (Entity)itemRef ).getMetadata( "path" );
+                String path = ( String ) ( ( Entity ) itemRef ).getMetadata( "path" );
 
                 if ( path.startsWith( "/roles/" ) ) {
 
-                    Entity itemEntity = em.get( new SimpleEntityRef( 
-                        memberEntity.getId().getType(), memberEntity.getId().getUuid() ) );
+                    Entity itemEntity = em.get( new SimpleEntityRef( memberEntity.getId().getType(),
+                            memberEntity.getId().getUuid() ) );
 
                     RoleRef roleRef = SimpleRoleRef.forRoleEntity( itemEntity );
                     em.deleteRole( roleRef.getApplicationRoleName() );
                 }
-
-            } 
+            }
         }
     }
 
 
     @Override
-    public void copyRelationships(String srcRelationName, EntityRef dstEntityRef, 
-            String dstRelationName) throws Exception {
+    public void copyRelationships( String srcRelationName, EntityRef dstEntityRef, String dstRelationName )
+            throws Exception {
 
         headEntity = em.validate( headEntity );
         dstEntityRef = em.validate( dstEntityRef );
 
-        CollectionInfo srcCollection = 
-                getDefaultSchema().getCollection( headEntity.getType(), srcRelationName );
+        CollectionInfo srcCollection = getDefaultSchema().getCollection( headEntity.getType(), srcRelationName );
 
-        CollectionInfo dstCollection = 
-                getDefaultSchema().getCollection( dstEntityRef.getType(), dstRelationName );
+        CollectionInfo dstCollection = getDefaultSchema().getCollection( dstEntityRef.getType(), dstRelationName );
 
         Results results = null;
         do {
@@ -881,8 +825,9 @@ public class CpRelationManager implements RelationManager {
         while ( ( results != null ) && ( results.hasMoreResults() ) );
     }
 
+
     @Override
-    public Results searchCollection(String collName, Query query) throws Exception {
+    public Results searchCollection( String collName, Query query ) throws Exception {
 
         if ( query == null ) {
             query = new Query();
@@ -890,24 +835,22 @@ public class CpRelationManager implements RelationManager {
 
         headEntity = em.validate( headEntity );
 
-        CollectionInfo collection = 
-            getDefaultSchema().getCollection( headEntity.getType(), collName );
+        CollectionInfo collection = getDefaultSchema().getCollection( headEntity.getType(), collName );
 
         if ( collection == null ) {
-            throw new RuntimeException("Cannot find collection-info for '"+collName
-                +"' of "+ headEntity.getType() +":"+headEntity.getUuid() );
+            throw new RuntimeException(
+                    "Cannot find collection-info for '" + collName + "' of " + headEntity.getType() + ":" + headEntity
+                            .getUuid() );
         }
 
-        IndexScope indexScope = new IndexScopeImpl(
-            cpHeadEntity.getId(), 
-            CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ));
+        IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(),
+                CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ) );
 
-        EntityIndex ei = managerCache.getEntityIndex(applicationScope);
-      
-        logger.debug("Searching scope {}:{}",
+        EntityIndex ei = managerCache.getEntityIndex( applicationScope );
 
-                indexScope.getOwner().toString(),
-                indexScope.getName() );
+        logger.debug( "Searching scope {}:{}",
+
+                indexScope.getOwner().toString(), indexScope.getName() );
 
         query.setEntityType( collection.getType() );
         query = adjustQuery( query );
@@ -929,22 +872,22 @@ public class CpRelationManager implements RelationManager {
             CandidateResults crs = ei.search( indexScope, query );
 
             if ( results == null ) {
-                logger.debug("Calling build results 1");
+                logger.debug( "Calling build results 1" );
                 results = buildResults( query, crs, collName );
-
-            } else {
-                logger.debug("Calling build results 2");
+            }
+            else {
+                logger.debug( "Calling build results 2" );
                 Results newResults = buildResults( query, crs, collName );
                 results.merge( newResults );
             }
 
             if ( crs.isEmpty() || !crs.hasCursor() ) { // no results, no cursor, can't get more
                 satisfied = true;
-
-            } else if ( results.size() == originalLimit )  { // got what we need
+            }
+            else if ( results.size() == originalLimit ) { // got what we need
                 satisfied = true;
-
-            } else if ( crs.hasCursor() ) {
+            }
+            else if ( crs.hasCursor() ) {
                 satisfied = false;
 
                 // need to query for more
@@ -952,10 +895,10 @@ public class CpRelationManager implements RelationManager {
                 query.setCursor( results.getCursor() );
                 query.setLimit( originalLimit - results.size() );
 
-                logger.warn("Satisfy query limit {}, new limit {} query count {}", new Object[] {
-                    originalLimit, query.getLimit(), queryCount 
-                });
-            } 
+                logger.warn( "Satisfy query limit {}, new limit {} query count {}", new Object[] {
+                        originalLimit, query.getLimit(), queryCount
+                } );
+            }
         }
 
         return results;
@@ -963,78 +906,60 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    @Metered(group = "core", name = "RelationManager_createConnection_connection_ref")
+    @Metered( group = "core", name = "RelationManager_createConnection_connection_ref" )
     public ConnectionRef createConnection( ConnectionRef connection ) throws Exception {
-        
+
         return createConnection( connection.getConnectionType(), connection.getConnectedEntity() );
     }
 
 
     @Override
-    @Metered(group = "core", name = "RelationManager_createConnection_connectionType")
-    public ConnectionRef createConnection( 
-            String connectionType, EntityRef connectedEntityRef ) throws Exception {
+    @Metered( group = "core", name = "RelationManager_createConnection_connectionType" )
+    public ConnectionRef createConnection( String connectionType, EntityRef connectedEntityRef ) throws Exception {
 
         headEntity = em.validate( headEntity );
         connectedEntityRef = em.validate( connectedEntityRef );
 
-        ConnectionRefImpl connection = new ConnectionRefImpl( 
-            headEntity, connectionType, connectedEntityRef );
+        ConnectionRefImpl connection = new ConnectionRefImpl( headEntity, connectionType, connectedEntityRef );
 
-        CollectionScope targetScope = new CollectionScopeImpl( 
-            applicationScope.getApplication(), 
-            applicationScope.getApplication(), 
-            CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType() ));
+        CollectionScope targetScope =
+                new CollectionScopeImpl( applicationScope.getApplication(), applicationScope.getApplication(),
+                        CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType() ) );
 
-        EntityCollectionManager targetEcm = managerCache.getEntityCollectionManager(targetScope);
+        EntityCollectionManager targetEcm = managerCache.getEntityCollectionManager( targetScope );
 
         if ( logger.isDebugEnabled() ) {
-            logger.debug("createConnection(): "
-                    + "Indexing connection type '{}'\n   from source {}:{}]\n"
-                    + "   to target {}:{}\n   from scope\n   app {}\n   owner {}\n   name {}", 
-                new Object[] { 
-                    connectionType,
-                    headEntity.getType(), 
-                    headEntity.getUuid(), 
-                    connectedEntityRef.getType(), 
-                    connectedEntityRef.getUuid(), 
-                    targetScope.getApplication(), 
-                    targetScope.getOwner(), 
-                    targetScope.getName() 
-            });
-        }
-
-        org.apache.usergrid.persistence.model.entity.Entity targetEntity = targetEcm.load(
-            new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ))
-                .toBlockingObservable().last();
-
-        String edgeType = CpNamingUtils
-                .getEdgeTypeFromConnectionType( connectionType );
+            logger.debug( "createConnection(): " + "Indexing connection type '{}'\n   from source {}:{}]\n"
+                            + "   to target {}:{}\n   from scope\n   app {}\n   owner {}\n   name {}", new Object[] {
+                            connectionType, headEntity.getType(), headEntity.getUuid(), connectedEntityRef.getType(),
+                            connectedEntityRef.getUuid(), targetScope.getApplication(), targetScope.getOwner(),
+                            targetScope.getName()
+                    } );
+        }
+
+        org.apache.usergrid.persistence.model.entity.Entity targetEntity =
+                targetEcm.load( new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ) )
+                         .toBlockingObservable().last();
+
+        String edgeType = CpNamingUtils.getEdgeTypeFromConnectionType( connectionType );
 
         // create graph edge connection from head entity to member entity
-        Edge edge = new SimpleEdge( 
-            cpHeadEntity.getId(), 
-            edgeType,
-            targetEntity.getId(), 
-            System.currentTimeMillis() );
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
-        gm.writeEdge(edge).toBlockingObservable().last();
-
-        EntityIndex ei = managerCache.getEntityIndex(applicationScope);
+        Edge edge = new SimpleEdge( cpHeadEntity.getId(), edgeType, targetEntity.getId(), System.currentTimeMillis() );
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
+        gm.writeEdge( edge ).toBlockingObservable().last();
+
+        EntityIndex ei = managerCache.getEntityIndex( applicationScope );
         EntityIndexBatch batch = ei.createBatch();
 
         // Index the new connection in app|source|type context
-        IndexScope indexScope = new IndexScopeImpl(
-            cpHeadEntity.getId(), 
-            CpNamingUtils.getConnectionScopeName( connectedEntityRef.getType(), connectionType ));
+        IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(),
+                CpNamingUtils.getConnectionScopeName( connectedEntityRef.getType(), connectionType ) );
 
-        batch.index(indexScope, targetEntity );
+        batch.index( indexScope, targetEntity );
 
         // Index the new connection in app|scope|all-types context
-        IndexScope allTypesIndexScope = new IndexScopeImpl(
-            cpHeadEntity.getId(), 
-                CpNamingUtils.ALL_TYPES);
-        batch.index(allTypesIndexScope,  targetEntity );
+        IndexScope allTypesIndexScope = new IndexScopeImpl( cpHeadEntity.getId(), CpNamingUtils.ALL_TYPES );
+        batch.index( allTypesIndexScope, targetEntity );
 
 
         batch.execute();
@@ -1047,16 +972,17 @@ public class CpRelationManager implements RelationManager {
         return connection;
     }
 
-    
-    @SuppressWarnings("unchecked")
-    @Metered(group = "core", name = "CpRelationManager_batchUpdateEntityConnection")
-    public Mutator<ByteBuffer> batchUpdateEntityConnection( Mutator<ByteBuffer> batch, 
-        boolean disconnect, ConnectionRefImpl connection, UUID timestampUuid ) throws Exception {
+
+    @SuppressWarnings( "unchecked" )
+    @Metered( group = "core", name = "CpRelationManager_batchUpdateEntityConnection" )
+    public Mutator<ByteBuffer> batchUpdateEntityConnection( Mutator<ByteBuffer> batch, boolean disconnect,
+                                                            ConnectionRefImpl connection, UUID timestampUuid )
+            throws Exception {
 
         long timestamp = getTimestampInMicros( timestampUuid );
 
-        Entity connectedEntity = em.get( new SimpleEntityRef( 
-                connection.getConnectedEntityType(), connection.getConnectedEntityId()) );
+        Entity connectedEntity =
+                em.get( new SimpleEntityRef( connection.getConnectedEntityType(), connection.getConnectedEntityId() ) );
 
         if ( connectedEntity == null ) {
             return batch;
@@ -1065,64 +991,60 @@ public class CpRelationManager implements RelationManager {
         // Create connection for requested params
 
         if ( disconnect ) {
-            
+
             addDeleteToMutator( batch, ENTITY_COMPOSITE_DICTIONARIES,
-                key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_ENTITIES,
-                    connection.getConnectionType() ),
-                asList( connection.getConnectedEntityId(), 
-                        connection.getConnectedEntityType() ), timestamp );
+                    key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_ENTITIES,
+                            connection.getConnectionType() ),
+                    asList( connection.getConnectedEntityId(), connection.getConnectedEntityType() ), timestamp );
 
             addDeleteToMutator( batch, ENTITY_COMPOSITE_DICTIONARIES,
-                key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_ENTITIES,
-                    connection.getConnectionType() ),
-                asList( connection.getConnectingEntityId(), 
-                        connection.getConnectingEntityType() ), timestamp );
+                    key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_ENTITIES,
+                            connection.getConnectionType() ),
+                    asList( connection.getConnectingEntityId(), connection.getConnectingEntityType() ), timestamp );
 
             // delete the connection path if there will be no connections left
 
             // check out outbound edges of the given type.  If we have more than the 1 specified,
             // we shouldn't delete the connection types from our outbound index
-            if ( !moreThanOneOutboundConnection( 
-                connection.getConnectingEntity(), connection.getConnectionType() ) ) {
+            if ( !moreThanOneOutboundConnection( connection.getConnectingEntity(), connection.getConnectionType() ) ) {
 
                 addDeleteToMutator( batch, ENTITY_DICTIONARIES,
-                    key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_TYPES ),
-                    connection.getConnectionType(), timestamp );
+                        key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_TYPES ),
+                        connection.getConnectionType(), timestamp );
             }
 
             //check out inbound edges of the given type.  If we have more than the 1 specified,
             // we shouldn't delete the connection types from our outbound index
-            if ( !moreThanOneInboundConnection( 
-               connection.getConnectingEntity(), connection.getConnectionType() ) ) {
+            if ( !moreThanOneInboundConnection( connection.getConnectingEntity(), connection.getConnectionType() ) ) {
 
                 addDeleteToMutator( batch, ENTITY_DICTIONARIES,
                         key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_TYPES ),
                         connection.getConnectionType(), timestamp );
             }
-
-        } else {
+        }
+        else {
 
             addInsertToMutator( batch, ENTITY_COMPOSITE_DICTIONARIES,
-                key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_ENTITIES,
-                    connection.getConnectionType() ),
-                asList( connection.getConnectedEntityId(), connection.getConnectedEntityType() ), 
-                    timestamp, timestamp );
+                    key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_ENTITIES,
+                            connection.getConnectionType() ),
+                    asList( connection.getConnectedEntityId(), connection.getConnectedEntityType() ), timestamp,
+                    timestamp );
 
             addInsertToMutator( batch, ENTITY_COMPOSITE_DICTIONARIES,
-                key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_ENTITIES,
-                    connection.getConnectionType() ),
-                asList( connection.getConnectingEntityId(), connection.getConnectingEntityType() ), 
-                    timestamp, timestamp );
+                    key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_ENTITIES,
+                            connection.getConnectionType() ),
+                    asList( connection.getConnectingEntityId(), connection.getConnectingEntityType() ), timestamp,
+                    timestamp );
 
             // Add connection type to connections set
             addInsertToMutator( batch, ENTITY_DICTIONARIES,
-                key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_TYPES ),
-                connection.getConnectionType(), null, timestamp );
+                    key( connection.getConnectingEntityId(), DICTIONARY_CONNECTED_TYPES ),
+                    connection.getConnectionType(), null, timestamp );
 
             // Add connection type to connections set
             addInsertToMutator( batch, ENTITY_DICTIONARIES,
-                key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_TYPES ),
-                connection.getConnectionType(), null, timestamp );
+                    key( connection.getConnectedEntityId(), DICTIONARY_CONNECTING_TYPES ),
+                    connection.getConnectionType(), null, timestamp );
         }
 
         // Add indexes for the connected entity's list properties
@@ -1137,15 +1059,15 @@ public class CpRelationManager implements RelationManager {
 
         for ( String dictionaryName : dictionaryNames ) {
             boolean has_dictionary = schema.hasDictionary( connectedEntity.getType(), dictionaryName );
-            boolean dictionary_indexed = schema.isDictionaryIndexedInConnections( 
-                connectedEntity.getType(), dictionaryName );
+            boolean dictionary_indexed =
+                    schema.isDictionaryIndexedInConnections( connectedEntity.getType(), dictionaryName );
 
             if ( dictionary_indexed || !has_dictionary ) {
                 Set<Object> elementValues = em.getDictionaryAsSet( connectedEntity, dictionaryName );
                 for ( Object elementValue : elementValues ) {
                     IndexUpdate indexUpdate =
-                        batchStartIndexUpdate( batch, connectedEntity, dictionaryName, 
-                            elementValue, timestampUuid, has_dictionary, true, disconnect, false );
+                            batchStartIndexUpdate( batch, connectedEntity, dictionaryName, elementValue, timestampUuid,
+                                    has_dictionary, true, disconnect, false );
                     batchUpdateConnectionIndex( indexUpdate, connection );
                 }
             }
@@ -1156,127 +1078,118 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    @Metered(group = "core", name = "RelationManager_createConnection_paired_connection_type")
-    public ConnectionRef createConnection( 
-            String pairedConnectionType, EntityRef pairedEntity, String connectionType,
-            EntityRef connectedEntityRef ) throws Exception {
-        
-        throw new UnsupportedOperationException("Paired connections not supported"); 
+    @Metered( group = "core", name = "RelationManager_createConnection_paired_connection_type" )
+    public ConnectionRef createConnection( String pairedConnectionType, EntityRef pairedEntity, String connectionType,
+                                           EntityRef connectedEntityRef ) throws Exception {
+
+        throw new UnsupportedOperationException( "Paired connections not supported" );
     }
 
 
     @Override
-    @Metered(group = "core", name = "RelationManager_createConnection_connected_entity_ref")
+    @Metered( group = "core", name = "RelationManager_createConnection_connected_entity_ref" )
     public ConnectionRef createConnection( ConnectedEntityRef... connections ) throws Exception {
 
-        throw new UnsupportedOperationException("Paired connections not supported"); 
+        throw new UnsupportedOperationException( "Paired connections not supported" );
     }
 
+
     @Override
-    public ConnectionRef connectionRef(
-            String connectionType, 
-            EntityRef connectedEntityRef) throws Exception {
+    public ConnectionRef connectionRef( String connectionType, EntityRef connectedEntityRef ) throws Exception {
 
-        ConnectionRef connection = new ConnectionRefImpl( 
-                headEntity, connectionType, connectedEntityRef );
+        ConnectionRef connection = new ConnectionRefImpl( headEntity, connectionType, connectedEntityRef );
 
         return connection;
     }
 
+
     @Override
-    public ConnectionRef connectionRef(String pairedConnectionType, EntityRef pairedEntity, 
-            String connectionType, EntityRef connectedEntityRef) throws Exception {
+    public ConnectionRef connectionRef( String pairedConnectionType, EntityRef pairedEntity, String connectionType,
+                                        EntityRef connectedEntityRef ) throws Exception {
 
-        throw new UnsupportedOperationException("Paired connections not supported"); 
+        throw new UnsupportedOperationException( "Paired connections not supported" );
     }
 
+
     @Override
-    public ConnectionRef connectionRef(ConnectedEntityRef... connections) {
+    public ConnectionRef connectionRef( ConnectedEntityRef... connections ) {
 
-        throw new UnsupportedOperationException("Paired connections not supported"); 
+        throw new UnsupportedOperationException( "Paired connections not supported" );
     }
 
+
     @Override
-    public void deleteConnection(ConnectionRef connectionRef) throws Exception {
-       
+    public void deleteConnection( ConnectionRef connectionRef ) throws Exception {
+
         // First, clean up the dictionary records of the connection
         Keyspace ko = cass.getApplicationKeyspace( applicationId );
         Mutator<ByteBuffer> m = createMutator( ko, be );
-        batchUpdateEntityConnection( 
-            m, true, (ConnectionRefImpl)connectionRef, UUIDGenerator.newTimeUUID() );
+        batchUpdateEntityConnection( m, true, ( ConnectionRefImpl ) connectionRef, UUIDGenerator.newTimeUUID() );
         batchExecute( m, CassandraService.RETRY_COUNT );
 
         EntityRef connectingEntityRef = connectionRef.getConnectingEntity();  // source
         EntityRef connectedEntityRef = connectionRef.getConnectedEntity();  // target
 
         String connectionType = connectionRef.getConnectedEntity().getConnectionType();
-        
-        CollectionScope targetScope = new CollectionScopeImpl( 
-            applicationScope.getApplication(), 
-            applicationScope.getApplication(), 
-            CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType() ));
 
-        EntityCollectionManager targetEcm = managerCache.getEntityCollectionManager(targetScope);
+        CollectionScope targetScope =
+                new CollectionScopeImpl( applicationScope.getApplication(), applicationScope.getApplication(),
+                        CpNamingUtils.getCollectionScopeNameFromEntityType( connectedEntityRef.getType() ) );
+
+        EntityCollectionManager targetEcm = managerCache.getEntityCollectionManager( targetScope );
 
         if ( logger.isDebugEnabled() ) {
-            logger.debug("Deleting connection '{}' from source {}:{} \n   to target {}:{}",
-                new Object[] { 
-                    connectionType,
-                    connectingEntityRef.getType(), 
-                    connectingEntityRef.getUuid(), 
-                    connectedEntityRef.getType(), 
-                    connectedEntityRef.getUuid()
-            });
+            logger.debug( "Deleting connection '{}' from source {}:{} \n   to target {}:{}", new Object[] {
+                            connectionType, connectingEntityRef.getType(), connectingEntityRef.getUuid(),
+                            connectedEntityRef.getType(), connectedEntityRef.getUuid()
+                    } );
         }
 
-        org.apache.usergrid.persistence.model.entity.Entity targetEntity = targetEcm.load(
-            new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ))
-                .toBlockingObservable().last();
+        org.apache.usergrid.persistence.model.entity.Entity targetEntity =
+                targetEcm.load( new SimpleId( connectedEntityRef.getUuid(), connectedEntityRef.getType() ) )
+                         .toBlockingObservable().last();
 
         // Delete graph edge connection from head entity to member entity
-        Edge edge = new SimpleEdge( 
-            new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
-            connectionType,
-            targetEntity.getId(), 
-            System.currentTimeMillis() );
-        GraphManager gm = managerCache.getGraphManager(applicationScope);
-        gm.deleteEdge(edge).toBlockingObservable().last();
-
-        final EntityIndex ei = managerCache.getEntityIndex( applicationScope )  ;
+        Edge edge = new SimpleEdge( new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
+                connectionType, targetEntity.getId(), System.currentTimeMillis() );
+        GraphManager gm = managerCache.getGraphManager( applicationScope );
+        gm.deleteEdge( edge ).toBlockingObservable().last();
+
+        final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
         final EntityIndexBatch batch = ei.createBatch();
 
         // Deindex the connection in app|source|type context
-        IndexScope indexScope = new IndexScopeImpl(
-            new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
-            CpNamingUtils.getConnectionScopeName( targetEntity.getId().getType(), connectionType ));
-        batch.deindex( indexScope , targetEntity );
+        IndexScope indexScope =
+                new IndexScopeImpl( new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
+                        CpNamingUtils.getConnectionScopeName( targetEntity.getId().getType(), connectionType ) );
+        batch.deindex( indexScope, targetEntity );
 
         // Deindex the connection in app|source|type context
-        IndexScope allTypesIndexScope = new IndexScopeImpl(
-            new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
-                CpNamingUtils.ALL_TYPES);
+        IndexScope allTypesIndexScope =
+                new IndexScopeImpl( new SimpleId( connectingEntityRef.getUuid(), connectingEntityRef.getType() ),
+                        CpNamingUtils.ALL_TYPES );
 
-        batch.deindex( allTypesIndexScope,  targetEntity );
+        batch.deindex( allTypesIndexScope, targetEntity );
 
         batch.execute();
-
     }
 
 
     @Override
-    public Set<String> getConnectionTypes(UUID connectedEntityId) throws Exception {
-        throw new UnsupportedOperationException("Cannot specify entity by UUID alone."); 
+    public Set<String> getConnectionTypes( UUID connectedEntityId ) throws Exception {
+        throw new UnsupportedOperationException( "Cannot specify entity by UUID alone." );
     }
 
+
     @Override
     public Set<String> getConnectionTypes() throws Exception {
         return getConnectionTypes( false );
     }
 
+
     @Override
-    public Set<String> getConnectionTypes(boolean filterConnection) throws Exception {
-        Set<String> connections = cast( 
-                em.getDictionaryAsSet( headEntity, Schema.DICTIONARY_CONNECTED_TYPES ) );
+    public Set<String> getConnectionTypes( boolean filterConnection ) throws Exception {
+        Set<String> connections = cast( em.getDictionaryAsSet( headEntity, Schema.DICTIONARY_CONNECTED_TYPES ) );
 
         if ( connections == null ) {
             return null;
@@ -1289,47 +1202,45 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public Results getConnectedEntities( 
-        String connectionType, String connectedEntityType, Level level) throws Exception {
+    public Results getConnectedEntities( String connectionType, String connectedEntityType, Level level )
+            throws Exception {
 
         Results raw = null;
 
         Query query = new Query();
-        query.setConnectionType(connectionType);
-        query.setEntityType(connectedEntityType);
+        query.setConnectionType( connectionType );
+        query.setEntityType( connectedEntityType );
 
         if ( connectionType == null ) {
             raw = searchConnectedEntities( query );
-
-        } else {
+        }
+        else {
 
             headEntity = em.validate( headEntity );
 
             String scopeName = null;
             if ( connectedEntityType != null ) {
                 scopeName = CpNamingUtils.getConnectionScopeName( connectedEntityType, connectionType );
-            } else {
+            }
+            else {
                 scopeName = CpNamingUtils.ALL_TYPES;
             }
 
-            IndexScope indexScope = new IndexScopeImpl(
-                cpHeadEntity.getId(), 
-                scopeName);
+            IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(), scopeName );
 
-            final EntityIndex ei = managerCache.getEntityIndex(applicationScope);
+            final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
 
-        
-            logger.debug("Searching connected entities from scope {}:{}",
-                indexScope.getOwner().toString(),
-                indexScope.getName());
+
+            logger.debug( "Searching connected entities from scope {}:{}", indexScope.getOwner().toString(),
+                    indexScope.getName() );
 
             query = adjustQuery( query );
             CandidateResults crs = ei.search( indexScope, query );
 
-            raw = buildResults( query , crs, query.getConnectionType() );
+            raw = buildResults( query, crs, query.getConnectionType() );
         }
 
-        if ( Level.ALL_PROPERTIES.equals(level ) ) {
+        if ( Level.ALL_PROPERTIES.equals( level ) ) {
             List<Entity> entities = new ArrayList<Entity>();
             for ( EntityRef ref : raw.getEntities() ) {
                 Entity entity = em.get( ref );
@@ -1349,29 +1260,28 @@ public class CpRelationManager implements RelationManager {
 
 
     @Override
-    public Results getConnectingEntities(
-            String connType, String fromEntityType, Level resultsLevel) throws Exception {
+    public Results getConnectingEntities( String connType, String fromEntityType, Level resultsLevel )
+            throws Exception {
 
         return getConnectingEntities( connType, fromEntityType, resultsLevel, -1 );
     }
 
+
     @Override
-    public Results getConnectingEntities(
-            String connType, String fromEntityType, Level level, int count) throws Exception {
+    public Results getConnectingEntities( String connType, String fromEntityType, Level level, int count )
+            throws Exception {
 
         // looking for edges to the head entity
-        String edgeType = 
-                CpNamingUtils.getEdgeTypeFromConnectionType( connType );
+        String edgeType = CpNamingUtils.getEdgeTypeFromConnectionType( connType );
 
-        Map<EntityRef, Set<String>> containers = 
-            getContainers( count, edgeType, fromEntityType );
+        Map<EntityRef, Set<String>> containers = getContainers( count, edgeType, fromEntityType );
 
-        if ( Level.REFS.equals(level ) ) {
+        if ( Level.REFS.equals( level ) ) {
             List<EntityRef> refList = new ArrayList<EntityRef>( containers.keySet() );
             return Results.fromRefList( refList );
-        } 
+        }
 
-        if ( Level.IDS.equals(level ) ) {
+        if ( Level.IDS.equals( level ) ) {
             // TODO: someday this should return a list of Core Persistence Ids
             List<UUID> idList = new ArrayList<UUID>();
             for ( EntityRef ref : containers.keySet() ) {
@@ -1383,7 +1293,7 @@ public class CpRelationManager implements RelationManager {
         List<Entity> entities = new ArrayList<Entity>();
         for ( EntityRef ref : containers.keySet() ) {
             Entity entity = em.get( ref );
-            logger.debug("   Found connecting entity: " + entity.getProperties());
+            logger.debug( "   Found connecting entity: " + entity.getProperties() );
             entities.add( entity );
         }
         return Results.fromEntities( entities );
@@ -1402,35 +1312,30 @@ public class CpRelationManager implements RelationManager {
         if ( query.getEntityType() == null ) {
 
             // search across all types of collections of the head-entity
-            IndexScope indexScope = new IndexScopeImpl(
-                cpHeadEntity.getId(), 
-                    CpNamingUtils.ALL_TYPES);
+            IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(), CpNamingUtils.ALL_TYPES );
+
+            EntityIndex ei = managerCache.getEntityIndex( applicationScope );
 
-            EntityIndex ei = managerCache.getEntityIndex(applicationScope);
-        
-            logger.debug("Searching connections from the all-types scope {}:{}",
-                indexScope.getOwner().toString(),
-                indexScope.getName());
+            logger.debug( "Searching connections from the all-types scope {}:{}", indexScope.getOwner().toString(),
+                    indexScope.getName() );
 
             query = adjustQuery( query );
-            CandidateResults crs = ei.search(indexScope,  query );
+            CandidateResults crs = ei.search( indexScope, query );
 
-            return buildConnectionResults(query , crs, query.getConnectionType() );
+            return buildConnectionResults( query, crs, query.getConnectionType() );
         }
 
-        IndexScope indexScope = new IndexScopeImpl(
-            cpHeadEntity.getId(), 
-            CpNamingUtils.getConnectionScopeName( query.getEntityType(), query.getConnectionType() ));
-        EntityIndex ei = managerCache.getEntityIndex(applicationScope);
-    
-        logger.debug("Searching connections from the scope {}:{}",
-            indexScope.getOwner().toString(),
-            indexScope.getName());
+        IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(),
+                CpNamingUtils.getConnectionScopeName( query.getEntityType(), query.getConnectionType() ) );
+        EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+
+        logger.debug( "Searching connections from the scope {}:{}", indexScope.getOwner().toString(),
+                indexScope.getName() );
 
         query = adjustQuery( query );
         CandidateResults crs = ei.search( indexScope, query );
 
-        return buildConnectionResults(query , crs, query.getConnectionType() );
+        return buildConnectionResults( query, crs, query.getConnectionType() );
     }
 
 
@@ -1448,47 +1353,44 @@ public class CpRelationManager implements RelationManager {
                 // This is fulgy to put here, but required.
                 if ( query.getEntityType().equals( User.ENTITY_TYPE ) && ident.isEmail() ) {
 
-                    Query newQuery = Query.fromQL(
-                        "select * where email='" + query.getSingleNameOrEmailIdentifier()+ "'");
+                    Query newQuery =
+                            Query.fromQL( "select * where email='" + query.getSingleNameOrEmailIdentifier() + "'" );
                     query.setRootOperand( newQuery.getRootOperand() );
                 }
 
                 // use the ident with the default alias. could be an email
                 else {
 
-                    Query newQuery = Query.fromQL(
-                        "select * where name='" + query.getSingleNameOrEmailIdentifier()+ "'");
+                    Query newQuery =
+                            Query.fromQL( "select * where name='" + query.getSingleNameOrEmailIdentifier() + "'" );
                     query.setRootOperand( newQuery.getRootOperand() );
                 }
+            }
+            else if ( query.containsSingleUuidIdentifier() ) {
 
-            } else if ( query.containsSingleUuidIdentifier() ) {
-
-                Query newQuery = Query.fromQL(
-                        "select * where uuid='" + query.getSingleUuidIdentifier() + "'");
+                Query newQuery = Query.fromQL( "select * where uuid='" + query.getSingleUuidIdentifier() + "'" );
                 query.setRootOperand( newQuery.getRootOperand() );
             }
         }
 
         if ( query.isReversed() ) {
 
-            Query.SortPredicate desc = new Query.SortPredicate( 
-                PROPERTY_CREATED, Query.SortDirection.DESCENDING );
+    

<TRUNCATED>

[08/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0


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

Branch: refs/heads/two-dot-o
Commit: 275f10a38d6604be3c321ddce0f8d6f627cc56f0
Parents: 7fc56f7 185ecef
Author: amuramoto <am...@apigee.com>
Authored: Wed Oct 8 19:58:56 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Wed Oct 8 19:58:56 2014 -0700

----------------------------------------------------------------------
 .../persistence/entities/Notification.java      |  13 ++
 .../corepersistence/StaleIndexCleanupTest.java  | 181 ++++++++++++++
 .../collection/EntityCollectionManager.java     |   5 +
 .../collection/guice/CollectionModule.java      |   5 +-
 .../impl/EntityCollectionManagerImpl.java       |  44 ++--
 .../mvcc/entity/MvccValidationUtils.java        |   3 +
 .../mvcc/event/PostProcessObserver.java         |  39 ----
 .../mvcc/stage/delete/MarkCommit.java           | 153 ++++++------
 .../mvcc/stage/write/EntityVersion.java         |  64 -----
 .../stage/write/EntityVersionSerializer.java    |  71 ------
 .../mvcc/stage/write/FieldSerializer.java       | 107 ---------
 .../mvcc/stage/write/RollbackAction.java        |   7 +-
 .../mvcc/stage/write/UniqueValue.java           |  39 ----
 .../mvcc/stage/write/UniqueValueImpl.java       | 124 ----------
 .../write/UniqueValueSerializationStrategy.java |  66 ------
 .../UniqueValueSerializationStrategyImpl.java   | 194 ---------------
 .../mvcc/stage/write/WriteCommit.java           |  12 +-
 .../mvcc/stage/write/WriteOptimisticVerify.java |  10 +-
 .../collection/mvcc/stage/write/WriteStart.java |   9 +-
 .../mvcc/stage/write/WriteUniqueVerify.java     | 207 ++++++++--------
 .../collection/serialization/UniqueValue.java   |  49 ++++
 .../UniqueValueSerializationStrategy.java       |  68 ++++++
 .../serialization/UniqueValueSet.java           |  32 +++
 .../serialization/impl/EntityVersion.java       |  64 +++++
 .../impl/EntityVersionSerializer.java           |  81 +++++++
 .../serialization/impl/FieldSerializer.java     | 117 ++++++++++
 .../MvccEntitySerializationStrategyImpl.java    |   9 +-
 .../serialization/impl/SerializationModule.java |   3 +-
 .../serialization/impl/UniqueValueImpl.java     | 114 +++++++++
 .../UniqueValueSerializationStrategyImpl.java   | 233 +++++++++++++++++++
 .../serialization/impl/UniqueValueSetImpl.java  |  85 +++++++
 .../persistence/collection/util/RepairUtil.java |  33 +--
 .../collection/EntityCollectionManagerIT.java   |  61 ++++-
 .../mvcc/stage/delete/MarkCommitTest.java       |  10 +-
 .../write/EntityVersionSerializerTest.java      |   2 +
 .../mvcc/stage/write/FieldSerializerTest.java   |   1 +
 ...niqueValueSerializationStrategyImplTest.java |  64 +++--
 .../mvcc/stage/write/WriteCommitTest.java       |   1 +
 .../stage/write/WriteOptimisticVerifyTest.java  |  31 +--
 .../stage/write/WriteUniqueVerifyStageTest.java |  48 ----
 .../mvcc/stage/write/WriteUniqueVerifyTest.java |  56 ++---
 .../persistence/model/field/AbstractField.java  |   4 +
 .../persistence/model/field/ArrayField.java     |   3 +
 .../persistence/model/field/BooleanField.java   |   6 +
 .../persistence/model/field/ByteArrayField.java |   6 +
 .../persistence/model/field/DoubleField.java    |   6 +
 .../model/field/EntityObjectField.java          |   6 +
 .../usergrid/persistence/model/field/Field.java |   8 +
 .../persistence/model/field/FieldTypeName.java  |  42 ++++
 .../persistence/model/field/FloatField.java     |   6 +
 .../persistence/model/field/IntegerField.java   |   6 +
 .../persistence/model/field/ListField.java      |   7 +
 .../persistence/model/field/LocationField.java  |   6 +
 .../persistence/model/field/LongField.java      |   6 +
 .../persistence/model/field/SetField.java       |   6 +
 .../persistence/model/field/StringField.java    |   6 +
 .../persistence/model/field/UUIDField.java      |   6 +
 stack/corepersistence/pom.xml                   |   4 +-
 .../persistence/index/EntityIndexBatch.java     |   3 +
 .../queue/impl/SQSQueueManagerImpl.java         |   2 +-
 .../notifications/ApplicationQueueManager.java  |  12 +-
 .../services/notifications/TaskManager.java     | 102 ++++----
 .../apns/NotificationsServiceIT.java            |  12 +
 .../gcm/NotificationsServiceIT.java             |  10 +
 64 files changed, 1643 insertions(+), 1147 deletions(-)
----------------------------------------------------------------------



[26/49] git commit: Updated to ensure yourkit installs correctly

Posted by to...@apache.org.
Updated to ensure yourkit installs correctly

Updated to fix opscenter installation

Updated to fix keyspace creation


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

Branch: refs/heads/two-dot-o
Commit: 6c632f8ae17968fa7acdf049aba77932933a62d5
Parents: 5773760
Author: Todd Nine <to...@apache.org>
Authored: Wed Oct 15 10:46:06 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Wed Oct 15 10:57:30 2014 -0600

----------------------------------------------------------------------
 stack/awscluster/pom.xml                        |   2 +-
 stack/awscluster/src/main/cql/create_locks.cql  |  24 +-
 .../awscluster/src/main/cql/create_usergrid.cql |  80 +---
 .../main/cql/create_usergrid_applications.cql   | 411 ++-----------------
 .../main/dist/init_instance/create_keyspaces.sh |  24 +-
 .../init_instance/install_opscenter_agent.sh    |   1 +
 .../main/dist/init_instance/install_yourkit.sh  |   6 +-
 .../src/main/groovy/configure_usergrid.groovy   |   4 +-
 8 files changed, 62 insertions(+), 490 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c632f8a/stack/awscluster/pom.xml
----------------------------------------------------------------------
diff --git a/stack/awscluster/pom.xml b/stack/awscluster/pom.xml
index 0c0bd46..84142d7 100644
--- a/stack/awscluster/pom.xml
+++ b/stack/awscluster/pom.xml
@@ -30,7 +30,7 @@
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <aws.s3.release-bucket>alex-cloudformation</aws.s3.release-bucket>
+        <aws.s3.release-bucket>todd-cloudformation</aws.s3.release-bucket>
         <stack.war>../rest/target/ROOT.war</stack.war>
         <portal.dir>../../portal/dist/usergrid-portal</portal.dir>
     </properties>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c632f8a/stack/awscluster/src/main/cql/create_locks.cql
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/cql/create_locks.cql b/stack/awscluster/src/main/cql/create_locks.cql
index a3eec9f..fc1de2a 100644
--- a/stack/awscluster/src/main/cql/create_locks.cql
+++ b/stack/awscluster/src/main/cql/create_locks.cql
@@ -18,27 +18,9 @@
 
 drop keyspace Locks;
 
-create keyspace Locks
-  with placement_strategy = 'NetworkTopologyStrategy'
-  and strategy_options = {us-east : 3}
-  and durable_writes = false;
+create keyspace Locks with placement_strategy = 'NetworkTopologyStrategy' and strategy_options = {KEYSPACE_REGION : 3} and durable_writes = false;
+update keyspace Locks with placement_strategy = 'NetworkTopologyStrategy' and strategy_options = {KEYSPACE_REGION : 3} and durable_writes = false;
 
 use Locks;
 
-create column family HLocks
-  with column_type = 'Standard'
-  and comparator = 'UTF8Type'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'UTF8Type'
-  and read_repair_chance = 0.0
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 60
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'ALL'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
+create column family HLocks with gc_grace=60 and caching=ALL and read_repair_chance=0.00 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c632f8a/stack/awscluster/src/main/cql/create_usergrid.cql
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/cql/create_usergrid.cql b/stack/awscluster/src/main/cql/create_usergrid.cql
index c33a81a..deae504 100644
--- a/stack/awscluster/src/main/cql/create_usergrid.cql
+++ b/stack/awscluster/src/main/cql/create_usergrid.cql
@@ -16,81 +16,13 @@
  * directory of this distribution.
  */
 
-create keyspace Usergrid
-  with placement_strategy = 'NetworkTopologyStrategy'
-  and strategy_options = {us-east : 3}
-  and durable_writes = true;
+create keyspace Usergrid with placement_strategy = 'NetworkTopologyStrategy' and strategy_options = {KEYSPACE_REGION : 3} and durable_writes = true;
+update keyspace Usergrid with placement_strategy = 'NetworkTopologyStrategy' and strategy_options = {KEYSPACE_REGION : 3} and durable_writes = true;
 
 use Usergrid;
 
-create column family Applications
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
+create column family Applications with caching=KEYS_ONLY and read_repair_chance=0.1  and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family PrincipalTokens with caching=KEYS_ONLY and read_repair_chance=0.1  and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Properties with caching=KEYS_ONLY and read_repair_chance=0.1  and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Tokens with caching=ALL and read_repair_chance=0.1  and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
 
-create column family PrincipalTokens
-  with column_type = 'Standard'
-  and comparator = 'UUIDType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Properties
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Tokens
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'ALL'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c632f8a/stack/awscluster/src/main/cql/create_usergrid_applications.cql
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/cql/create_usergrid_applications.cql b/stack/awscluster/src/main/cql/create_usergrid_applications.cql
index 3a80567..bb3d29a 100644
--- a/stack/awscluster/src/main/cql/create_usergrid_applications.cql
+++ b/stack/awscluster/src/main/cql/create_usergrid_applications.cql
@@ -16,393 +16,32 @@
  * directory of this distribution.
  */
 
-create keyspace Usergrid_Applications
-  with placement_strategy = 'NetworkTopologyStrategy'
-  and strategy_options = {us-east : 3}
-  and durable_writes = true;
+create keyspace Usergrid_Applications with placement_strategy = 'NetworkTopologyStrategy' and strategy_options = {KEYSPACE_REGION : 3} and durable_writes = true;
+update keyspace Usergrid_Applications with placement_strategy = 'NetworkTopologyStrategy' and strategy_options = {KEYSPACE_REGION : 3} and durable_writes = true;
 
 use Usergrid_Applications;
 
-create column family Application_Aggregate_Counters
-  with column_type = 'Standard'
-  and comparator = 'LongType'
-  and default_validation_class = 'CounterColumnType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
+create column family Application_Aggregate_Counters with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Application_Roles with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Applications with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Consumer_Queue_Messages_Properties with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Entity_Composite_Dictionaries with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Entity_Counters with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Entity_Dictionaries with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Entity_Id_Sets with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Entity_Index with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Entity_Index_Entries with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Entity_Metadata with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Entity_Properties with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Entity_Unique with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family MQ_Consumers with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family MQ_Consumers_Timeout with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family MQ_Counters with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family MQ_Property_Index with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family MQ_Property_Index_Entries with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Queue_Dictionaries with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Queue_Inbox with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Queue_Properties with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Queue_Subscribers with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
+create column family Queue_Subscriptions with caching=KEYS_ONLY and read_repair_chance=0.1 and compaction_strategy='LeveledCompactionStrategy' and bloom_filter_fp_chance=0.1 and compaction_strategy_options={sstable_size_in_mb:512};
 
-create column family Application_Roles
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Applications
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Consumer_Queue_Messages_Properties
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Entity_Composite_Dictionaries
-  with column_type = 'Standard'
-  and comparator = 'DynamicCompositeType(b=>org.apache.cassandra.db.marshal.BytesType,A=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.AsciiType),B=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.BytesType),a=>org.apache.cassandra.db.marshal.AsciiType,L=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LongType),l=>org.apache.cassandra.db.marshal.LongType,I=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.IntegerType),i=>org.apache.cassandra.db.marshal.IntegerType,U=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UUIDType),T=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType),u=>org.apache.cassandra.db.marshal.UUIDType,t=>org.apache.cassandra.db.marshal.TimeUUIDType,s=>org.apache.cassandra.db.marshal.UTF8Type,S=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UTF8Type),
 X=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LexicalUUIDType),x=>org.apache.cassandra.db.marshal.LexicalUUIDType)'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Entity_Counters
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'CounterColumnType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Entity_Dictionaries
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Entity_Id_Sets
-  with column_type = 'Standard'
-  and comparator = 'UUIDType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Entity_Index
-  with column_type = 'Standard'
-  and comparator = 'DynamicCompositeType(b=>org.apache.cassandra.db.marshal.BytesType,A=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.AsciiType),B=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.BytesType),a=>org.apache.cassandra.db.marshal.AsciiType,L=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LongType),l=>org.apache.cassandra.db.marshal.LongType,I=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.IntegerType),i=>org.apache.cassandra.db.marshal.IntegerType,U=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UUIDType),T=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType),u=>org.apache.cassandra.db.marshal.UUIDType,t=>org.apache.cassandra.db.marshal.TimeUUIDType,s=>org.apache.cassandra.db.marshal.UTF8Type,S=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UTF8Type),
 X=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LexicalUUIDType),x=>org.apache.cassandra.db.marshal.LexicalUUIDType)'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Entity_Index_Entries
-  with column_type = 'Standard'
-  and comparator = 'DynamicCompositeType(b=>org.apache.cassandra.db.marshal.BytesType,A=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.AsciiType),B=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.BytesType),a=>org.apache.cassandra.db.marshal.AsciiType,L=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LongType),l=>org.apache.cassandra.db.marshal.LongType,I=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.IntegerType),i=>org.apache.cassandra.db.marshal.IntegerType,U=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UUIDType),T=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType),u=>org.apache.cassandra.db.marshal.UUIDType,t=>org.apache.cassandra.db.marshal.TimeUUIDType,s=>org.apache.cassandra.db.marshal.UTF8Type,S=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UTF8Type),
 X=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LexicalUUIDType),x=>org.apache.cassandra.db.marshal.LexicalUUIDType)'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Entity_Metadata
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Entity_Properties
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Entity_Unique
-  with column_type = 'Standard'
-  and comparator = 'UUIDType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and bloom_filter_fp_chance = 0.1
-  and compaction_strategy_options = {'sstable_size_in_mb' : '512'}
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family MQ_Consumers
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family MQ_Consumers_Timeout
-  with column_type = 'Standard'
-  and comparator = 'UUIDType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family MQ_Counters
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'CounterColumnType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family MQ_Property_Index
-  with column_type = 'Standard'
-  and comparator = 'DynamicCompositeType(b=>org.apache.cassandra.db.marshal.BytesType,A=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.AsciiType),B=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.BytesType),a=>org.apache.cassandra.db.marshal.AsciiType,L=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LongType),l=>org.apache.cassandra.db.marshal.LongType,I=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.IntegerType),i=>org.apache.cassandra.db.marshal.IntegerType,U=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UUIDType),T=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType),u=>org.apache.cassandra.db.marshal.UUIDType,t=>org.apache.cassandra.db.marshal.TimeUUIDType,s=>org.apache.cassandra.db.marshal.UTF8Type,S=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UTF8Type),
 X=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LexicalUUIDType),x=>org.apache.cassandra.db.marshal.LexicalUUIDType)'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family MQ_Property_Index_Entries
-  with column_type = 'Standard'
-  and comparator = 'DynamicCompositeType(b=>org.apache.cassandra.db.marshal.BytesType,A=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.AsciiType),B=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.BytesType),a=>org.apache.cassandra.db.marshal.AsciiType,L=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LongType),l=>org.apache.cassandra.db.marshal.LongType,I=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.IntegerType),i=>org.apache.cassandra.db.marshal.IntegerType,U=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UUIDType),T=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType),u=>org.apache.cassandra.db.marshal.UUIDType,t=>org.apache.cassandra.db.marshal.TimeUUIDType,s=>org.apache.cassandra.db.marshal.UTF8Type,S=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.UTF8Type),
 X=>org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.LexicalUUIDType),x=>org.apache.cassandra.db.marshal.LexicalUUIDType)'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Queue_Dictionaries
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Queue_Inbox
-  with column_type = 'Standard'
-  and comparator = 'UUIDType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Queue_Properties
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Queue_Subscribers
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};
-
-create column family Queue_Subscriptions
-  with column_type = 'Standard'
-  and comparator = 'BytesType'
-  and default_validation_class = 'BytesType'
-  and key_validation_class = 'BytesType'
-  and read_repair_chance = 0.1
-  and dclocal_read_repair_chance = 0.0
-  and populate_io_cache_on_flush = false
-  and gc_grace = 864000
-  and min_compaction_threshold = 4
-  and max_compaction_threshold = 32
-  and replicate_on_write = true
-  and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
-  and caching = 'KEYS_ONLY'
-  and compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.SnappyCompressor'};

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c632f8a/stack/awscluster/src/main/dist/init_instance/create_keyspaces.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/create_keyspaces.sh b/stack/awscluster/src/main/dist/init_instance/create_keyspaces.sh
index 1151a9f..f2ebe8f 100644
--- a/stack/awscluster/src/main/dist/init_instance/create_keyspaces.sh
+++ b/stack/awscluster/src/main/dist/init_instance/create_keyspaces.sh
@@ -28,11 +28,27 @@ FIRSTHOST="$(groovy get_first_instance.groovy cassandra)"
 
 if [ "$FIRSTHOST"=="$PUBLIC_HOSTNAME" ]; then
 
-cd /usr/share/usergrid/cql
 
-/usr/bin/cassandra-cli -f  create_locks.cql
-/usr/bin/cassandra-cli -f  create_usergrid.cql
-/usr/bin/cassandra-cli -f  create_usergrid_applications.cql
+#Update the keyspace replication and run the cql
+sed -i.bak "s/KEYSPACE_REGION/${EC2_REGION}/g" /usr/share/usergrid/cql/create_locks.cql
+
+/usr/bin/cassandra-cli -f  /usr/share/usergrid/cql/create_locks.cql
+
+
+
+
+#Update the keyspace region and run the cql
+sed -i.bak "s/KEYSPACE_REGION/${EC2_REGION}/g" /usr/share/usergrid/cql/create_usergrid.cql
+
+/usr/bin/cassandra-cli -f  /usr/share/usergrid/cql/create_usergrid.cql
+
+
+
+
+#Update the keyspace region and run the cql
+sed -i.bak "s/KEYSPACE_REGION/${EC2_REGION}/g" /usr/share/usergrid/cql/create_usergrid_applications.cql
+
+/usr/bin/cassandra-cli -f  /usr/share/usergrid/cql/create_usergrid_applications.cql
 
 fi
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c632f8a/stack/awscluster/src/main/dist/init_instance/install_opscenter_agent.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_opscenter_agent.sh b/stack/awscluster/src/main/dist/init_instance/install_opscenter_agent.sh
index 447da6f..17ec780 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_opscenter_agent.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_opscenter_agent.sh
@@ -30,6 +30,7 @@ sudo apt-get update
 sudo apt-get install datastax-agent
 
 
+cd /usr/share/usergrid/scripts
 groovy configure_opscenter_agent.groovy > /var/lib/datastax-agent/conf/address.yaml
 
 sudo service datastax-agent start

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c632f8a/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh b/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
index 3812612..e117db7 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
@@ -25,15 +25,15 @@ if [[ $YOURKIT = "true" ]]; then
 
 mkdir -p /mnt/yourkit
 cd /mnt/yourkit
-s3cmd --config=/etc/s3cfg get s3://${RELEASE_BUCKET}/yjp-2014-build-14104.zip
-unzip /mnt/yourkit/yjp-2014-build-14104.zip
+s3cmd --config=/etc/s3cfg get s3://${RELEASE_BUCKET}/yjp-2014-build-14108.zip
+unzip /mnt/yourkit/yjp-2014-build-14108.zip
 
 mkdir -p /mnt/yourkitreports
 
 chown -R tomcat7.tomcat7 /mnt/yourkitreports
 
 cat >> /etc/default/tomcat7 << EOF
-JAVA_OPTS="${JAVA_OPTS} -agentpath:/mnt/yourkit/yjp-2014-build-14104/bin/linux-x86-64/libyjpagent.so=port=10001,logdir=/mnt/yourkitreports,dir=/mnt/yourkitreports,onexit=snapshot"
+JAVA_OPTS="${JAVA_OPTS} -agentpath:/mnt/yourkit/yjp-2014-build-14108/bin/linux-x86-64/libyjpagent.so=port=10001,logdir=/mnt/yourkitreports,dir=/mnt/yourkitreports,onexit=snapshot"
 EOF
 
 fi

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c632f8a/stack/awscluster/src/main/groovy/configure_usergrid.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_usergrid.groovy b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
index a0a051c..03b3077 100644
--- a/stack/awscluster/src/main/groovy/configure_usergrid.groovy
+++ b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
@@ -43,6 +43,8 @@ def testAdminUserEmail = System.getenv().get("TEST_ADMIN_USER_EMAIL")
 def cassThreads = System.getenv().get("TOMCAT_THREADS")
 def hystrixThreads = Integer.parseInt(cassThreads) / 100
 
+def ec2Region = System.getenv().get("EC2_REGION")
+
 
 NodeRegistry registry = new NodeRegistry();
 
@@ -81,7 +83,7 @@ def usergridConfig = """
 cassandra.url=${cassandras}
 cassandra.cluster=${clusterName}
 cassandra.keyspace.strategy=org.apache.cassandra.locator.SimpleStrategy
-cassandra.keyspace.replication=${replFactor}
+cassandra.keyspace.replication=${ec2Region}:${replFactor}
 
 cassandra.timeout=5000
 cassandra.connections=${cassThreads}


[16/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into cloudformation-update

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into cloudformation-update


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

Branch: refs/heads/two-dot-o
Commit: dd4f1177d7de5f5b48bb28dd71dc6db5186128c8
Parents: f3fddfe b866414
Author: amuramoto <am...@apigee.com>
Authored: Sun Oct 12 01:37:11 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Sun Oct 12 01:37:11 2014 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/usergrid/services/ServiceManager.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[38/49] git commit: Adds explicit refresh after create to ensure the index is actually ready to receive data.

Posted by to...@apache.org.
Adds explicit refresh after create to ensure the index is actually ready to receive data.


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

Branch: refs/heads/two-dot-o
Commit: 54b9a1197edc6498629f3bdb78f95408c24c566d
Parents: f24f3ea
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 15:11:45 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 15:11:45 2014 -0600

----------------------------------------------------------------------
 .../index/impl/EsEntityIndexImpl.java           | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/54b9a119/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index e55f7e0..495b9e1 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -87,6 +87,9 @@ public class EsEntityIndexImpl implements EntityIndex {
 
     private final IndexFig config;
 
+    private static final int MAX_WAITS = 10;
+    private static final int WAIT_TIME = 250;
+
 
     @Inject
     public EsEntityIndexImpl( @Assisted final ApplicationScope appScope, final IndexFig config,
@@ -120,6 +123,26 @@ public class EsEntityIndexImpl implements EntityIndex {
                 response = admin.indices().prepareRefresh( indexName ).execute().actionGet();
             }
             while ( response.getFailedShards() != 0 );
+
+            //now try to refresh, to ensure that it's recognized by everyone.  Occasionally we can get a success
+            //before we can write.
+            for(int i = 0 ; i < MAX_WAITS; i++ ){
+                try{
+                    refresh();
+                    break;
+
+                }catch(Exception e){
+                   log.error( "Unable to refresh index after create. Waiting before sleeping.", e );
+                }
+
+                try {
+                    Thread.sleep( WAIT_TIME );
+                }
+                catch ( InterruptedException e ) {
+                    //swallow it
+                }
+            }
+
             //
             //            response.getFailedShards();
             //


[34/49] git commit: Fixed incorrect strategy

Posted by to...@apache.org.
Fixed incorrect strategy


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

Branch: refs/heads/two-dot-o
Commit: 0ddecd1340e36e212ce8c89ab2990bc5dc163bd9
Parents: c920eca
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 09:44:57 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 09:44:57 2014 -0600

----------------------------------------------------------------------
 stack/awscluster/src/main/groovy/configure_usergrid.groovy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ddecd13/stack/awscluster/src/main/groovy/configure_usergrid.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_usergrid.groovy b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
index 35a0262..fc19b74 100644
--- a/stack/awscluster/src/main/groovy/configure_usergrid.groovy
+++ b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
@@ -83,7 +83,7 @@ def usergridConfig = """
 
 cassandra.url=${cassandras}
 cassandra.cluster=${clusterName}
-cassandra.keyspace.strategy=org.apache.cassandra.locator.SimpleStrategy
+cassandra.keyspace.strategy=org.apache.cassandra.locator.NetworkTopologyStrategy
 cassandra.keyspace.replication=${ec2Region}:${replFactor}
 
 cassandra.timeout=5000


[31/49] git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into cloudformation-update

Posted by to...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into cloudformation-update


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

Branch: refs/heads/two-dot-o
Commit: b84bbc16b0bea09a2bb55fd0b8166267691da24a
Parents: e8e6d1c d52ad4c
Author: Todd Nine <to...@apache.org>
Authored: Wed Oct 15 17:47:26 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Wed Oct 15 17:47:26 2014 -0600

----------------------------------------------------------------------
 .../notifications/apns/NotificationsServiceIT.java   | 12 ++++++------
 .../notifications/gcm/NotificationsServiceIT.java    | 15 +++++----------
 2 files changed, 11 insertions(+), 16 deletions(-)
----------------------------------------------------------------------



[30/49] git commit: Fixes issue with path escaping of options

Posted by to...@apache.org.
Fixes issue with path escaping of options


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

Branch: refs/heads/two-dot-o
Commit: e8e6d1c8bb6789c449e63df1d586c9595219c587
Parents: 52e10ee
Author: Todd Nine <to...@apache.org>
Authored: Wed Oct 15 15:10:14 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Wed Oct 15 15:10:14 2014 -0600

----------------------------------------------------------------------
 stack/awscluster/src/main/dist/init_instance/install_yourkit.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e8e6d1c8/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh b/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
index e117db7..2883dae 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_yourkit.sh
@@ -33,7 +33,7 @@ mkdir -p /mnt/yourkitreports
 chown -R tomcat7.tomcat7 /mnt/yourkitreports
 
 cat >> /etc/default/tomcat7 << EOF
-JAVA_OPTS="${JAVA_OPTS} -agentpath:/mnt/yourkit/yjp-2014-build-14108/bin/linux-x86-64/libyjpagent.so=port=10001,logdir=/mnt/yourkitreports,dir=/mnt/yourkitreports,onexit=snapshot"
+JAVA_OPTS="\${JAVA_OPTS} -agentpath:/mnt/yourkit/yjp-2014-build-14108/bin/linux-x86-64/libyjpagent.so=port=10001,logdir=/mnt/yourkitreports,dir=/mnt/yourkitreports,onexit=snapshot"
 EOF
 
 fi


[06/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0


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

Branch: refs/heads/two-dot-o
Commit: fc7140e4ac0f7dc2b91730a638c078dbcb604842
Parents: 519a6d8 bdb9795
Author: amuramoto <am...@apigee.com>
Authored: Tue Oct 7 10:03:45 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Tue Oct 7 10:03:45 2014 -0700

----------------------------------------------------------------------
 .../CpEntityIndexDeleteListener.java            |  23 +-
 .../corepersistence/CpEntityManager.java        |  45 +++-
 .../corepersistence/CpEntityManagerFactory.java |   5 +-
 .../corepersistence/CpManagerCache.java         |  29 ++-
 .../usergrid/corepersistence/GuiceModule.java   |  12 +-
 .../usergrid/persistence/map/MapManager.java    |   1 -
 .../persistence/map/MapManagerFactory.java      |   2 +-
 .../persistence/map/impl/MapManagerImpl.java    |  24 ---
 .../persistence/map/impl/MapScopeImpl.java      |   1 -
 .../map/impl/MapSerializationImpl.java          |  48 +++--
 .../persistence/map/MapManagerTest.java         |  21 +-
 .../index/impl/EsEntityIndexImpl.java           | 208 ++++++++++---------
 .../notifications/ApplicationQueueManager.java  |  11 +-
 .../notifications/NotificationsService.java     |   3 +-
 .../services/notifications/QueueListener.java   |   8 +-
 .../services/notifications/TaskManager.java     |  22 +-
 .../usergrid/services/TestQueueManager.java     |  67 ++++++
 .../AbstractServiceNotificationIT.java          |   1 -
 .../apns/NotificationsServiceIT.java            |   9 +-
 .../gcm/NotificationsServiceIT.java             |   7 +-
 20 files changed, 333 insertions(+), 214 deletions(-)
----------------------------------------------------------------------



[04/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0


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

Branch: refs/heads/two-dot-o
Commit: 30ba9ace6931d57e223a95740f52c15afb3c410c
Parents: 231b674 8930071
Author: amuramoto <am...@apigee.com>
Authored: Thu Oct 2 13:33:20 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Thu Oct 2 13:33:20 2014 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        | 106 ++++++++++++-------
 .../corepersistence/CpEntityManagerFactory.java |   2 -
 .../corepersistence/CpEntityMapUtils.java       |   2 +-
 .../org/apache/usergrid/persistence/GeoIT.java  |   2 +-
 .../persistence/model/field/value/Location.java |  12 ++-
 .../index/impl/EsEntityIndexBatchImpl.java      |   2 +-
 .../index/impl/EntityIndexMapUtils.java         |   2 +-
 .../apache/usergrid/rest/PartialUpdateTest.java |  18 +++-
 8 files changed, 95 insertions(+), 51 deletions(-)
----------------------------------------------------------------------



[46/49] git commit: Explicitly made node a client

Posted by to...@apache.org.
Explicitly made node a client


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

Branch: refs/heads/two-dot-o
Commit: bd00ee0012352b5cadecedbbccd92b8c5f2622dd
Parents: 722c43b
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 21:48:57 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 21:48:57 2014 -0600

----------------------------------------------------------------------
 .../java/org/apache/usergrid/persistence/index/impl/EsProvider.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bd00ee00/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
index a9228ee..aac9ff5 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
@@ -163,6 +163,7 @@ public class EsProvider {
                     .put("client.transport.ping_timeout", 2000) // milliseconds
                     .put("client.transport.nodes_sampler_interval", 100)
                     .put("network.tcp.blocking", true)
+                    .put("node.client", true)
                     .put("node.name",  nodeName )
 
                     .build();


[25/49] git commit: Changed default time of tomcat node

Posted by to...@apache.org.
Changed default time of tomcat node


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

Branch: refs/heads/two-dot-o
Commit: 57737600db6e56e4ada6ee26503fea0bac1c6b40
Parents: 6c8a7f5
Author: Todd Nine <to...@apache.org>
Authored: Wed Oct 15 07:58:34 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Wed Oct 15 07:58:34 2014 -0600

----------------------------------------------------------------------
 stack/awscluster/ugcluster-cf.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/57737600/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index 5b0a87d..efef0f9 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -32,7 +32,7 @@
         "RestInstanceType": {
             "Description": "Instance type for REST servers",
             "Type": "String",
-            "Default": "m3.large",
+            "Default": "c3.xlarge",
             "AllowedValues": [
                 "m1.small",
                 "m1.medium",
@@ -1434,4 +1434,4 @@
             }
         }
     }
-}
\ No newline at end of file
+}


[11/49] git commit: separated ES from C* in cloudformation template/scripts

Posted by to...@apache.org.
separated ES from C* in cloudformation template/scripts


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

Branch: refs/heads/two-dot-o
Commit: 112661a0799334c792641fa917b77d205ee8c9a6
Parents: 43acfad
Author: amuramoto <am...@apigee.com>
Authored: Fri Oct 10 12:35:45 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Fri Oct 10 12:35:45 2014 -0700

----------------------------------------------------------------------
 .../main/dist/init_instance/init_db_server.sh   |   4 -
 .../main/dist/init_instance/init_es_server.sh   |  61 +++++
 stack/awscluster/ugcluster-cf.json              | 243 ++++++++++++++++++-
 3 files changed, 303 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/112661a0/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_db_server.sh b/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
index b9c4f56..a37bb82 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
@@ -59,10 +59,6 @@ cd /usr/share/usergrid/init_instance
 cd /usr/share/usergrid/init_instance
 ./install_opscenter_agent.sh
 
-# Install and start ElasticSearch
-cd /usr/share/usergrid/init_instance
-./install_elasticsearch.sh
-
 # Use the CQL to crate the keyspaces
 cd /usr/share/usergrid/init_instance
 ./create_keyspaces.sh

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/112661a0/stack/awscluster/src/main/dist/init_instance/init_es_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_es_server.sh b/stack/awscluster/src/main/dist/init_instance/init_es_server.sh
new file mode 100644
index 0000000..c187cb8
--- /dev/null
+++ b/stack/awscluster/src/main/dist/init_instance/init_es_server.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+# 
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#   contributor license agreements.  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.  For additional information regarding
+#  copyright in this work, please see the NOTICE file in the top level
+#  directory of this distribution.
+#
+
+echo "${HOSTNAME}" > /etc/hostname
+echo "127.0.0.1 ${HOSTNAME}" >> /etc/hosts
+hostname `cat /etc/hostname`
+
+echo "US/Eastern" > /etc/timezone
+dpkg-reconfigure -f noninteractive tzdata
+
+# Build environment for scripts
+. /etc/profile.d/aws-credentials.sh
+. /etc/profile.d/usergrid-env.sh
+
+cd /usr/share/usergrid/init_instance
+./create_raid0.sh
+
+# Install the easy stuff
+PKGS="ntp unzip groovy curl"
+apt-get update
+apt-get -y --force-yes install ${PKGS}
+/etc/init.d/tomcat7 stop
+
+# Install AWS Java SDK and get it into the Groovy classpath
+curl http://sdk-for-java.amazonwebservices.com/latest/aws-java-sdk.zip > /tmp/aws-sdk-java.zip
+cd /usr/share/
+unzip /tmp/aws-sdk-java.zip 
+mkdir -p /home/ubuntu/.groovy/lib
+cp /usr/share/aws-java-sdk-*/third-party/*/*.jar /home/ubuntu/.groovy/lib
+cp /usr/share/aws-java-sdk-*/lib/* /home/ubuntu/.groovy/lib 
+# except for evil stax
+rm /home/ubuntu/.groovy/lib/stax*
+ln -s /home/ubuntu/.groovy /root/.groovy
+
+cd /usr/share/usergrid/init_instance
+./install_oraclejdk.sh 
+
+# Install and start ElasticSearch
+cd /usr/share/usergrid/init_instance
+./install_elasticsearch.sh
+
+# tag last so we can see in the console that the script ran to completion
+cd /usr/share/usergrid/scripts
+groovy tag_instance.groovy

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/112661a0/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index 67c081a..31950a2 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -84,6 +84,28 @@
             "Default": "3",
             "MinValue": "1"
         },
+        "ESNumServers": {
+            "Description": "Number of ES servers to start.",
+            "Type": "Number",
+            "Default": "3",
+            "MinValue": "1"
+        },
+        "ESInstanceType": {
+            "Description": "Instance type for ES servers",
+            "Type": "String",
+            "Default": "c3.2xlarge",
+            "AllowedValues": [
+                "m1.small",
+                "m1.medium",
+                "m1.large",
+                "m1.xlarge",
+                "m3.xlarge",
+                "m3.2xlarge",
+                "c3.2xlarge",
+                "c3.4xlarge"
+            ],
+            "ConstraintDescription": "must be valid instance type."
+        },
         "SuperUserEmail": {
             "Description": "Email for superuser user",
             "Type": "String",
@@ -429,6 +451,34 @@
                 }
             }
         },
+        "ESUser": {
+            "Type": "AWS::IAM::User",
+            "Properties": {
+                "Path": "/",
+                "Policies": [
+                    {
+                        "PolicyName": "root",
+                        "PolicyDocument": {
+                            "Statement": [
+                                {
+                                    "Effect": "Allow",
+                                    "Action": "*",
+                                    "Resource": "*"
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        },
+        "ESKey": {
+            "Type": "AWS::IAM::AccessKey",
+            "Properties": {
+                "UserName": {
+                    "Ref": "CassUser"
+                }
+            }
+        },
       "CassAutoScalingLaunchConfiguration":{
          "Type":"AWS::AutoScaling::LaunchConfiguration",
          "Properties":{
@@ -588,6 +638,155 @@
                 }
             }
         },
+      "ESAutoScalingLaunchConfiguration":{
+         "Type":"AWS::AutoScaling::LaunchConfiguration",
+         "Properties":{
+            "UserData":{
+               "Fn::Base64":{
+                  "Fn::Join":[
+                     "",
+                     [
+                        "#!/bin/bash -ex\n",
+                        "# ES NODE STARTUP \n",
+                        "exec >/var/log/usergrid-bootstrap.log 2>&1\n",
+                        "\n",
+                        "mkdir -p /usr/share/usergrid\n",
+                        "\n",
+                        "# create script that sets our environment variables\n",
+                        "cat >/etc/profile.d/usergrid-env.sh <<EOF\n",
+                        "alias sudo='sudo -E'\n", "\n",
+                        "export TYPE=es\n",
+                        "export STACK_NAME=", { "Ref":"AWS::StackName" }, "\n", "\n",
+                        "export PUBLIC_HOSTNAME=`(curl -s http://169.254.169.254/latest/meta-data/public-hostname)`\n",
+                        "export INTERNAL_HOSTNAME=`(curl http://169.254.169.254/latest/meta-data/local-ipv4)`\n", 
+                        "\n",
+                        "export EC2_INSTANCE_ID=`ec2metadata --instance-id`\n",
+                        "export EC2_REGION=", { "Ref":"AWS::Region" },
+                        "\n",
+                        "export EC2_URL=https://ec2.amazonaws.com/\n",
+                        "\n",
+                        "export ES_SECURITY_GROUP_NAME=", { "Ref":"ESSecurityGroup" }, "\n",
+                        "\n",
+                        "\n",
+                        "export ES_NUM_SERVERS=", { "Ref":"ESNumServers" }, "\n",
+                        "export GRAPHITE_NUM_SERVERS=", { "Ref":"GraphiteNumServers" }, "\n",
+                        "\n",
+                        "export RELEASE_BUCKET=", { "Ref":"ReleaseBucket" }, "\n",
+                        "\n",
+                        "EOF\n",
+                        "\n",
+                        "# put AWS creds in environment\n",
+                        "cat >/etc/profile.d/aws-credentials.sh <<EOF\n",
+                        "export AWS_ACCESS_KEY=", { "Ref":"ESKey" }, "\n",
+                        "export AWS_SECRET_KEY=", { "Fn::GetAtt":[ "ESKey", "SecretAccessKey" ] }, "\n",
+                        "EOF\n",
+                        "\n",
+                        "# setup s3cmd (will be installed by init script) \n",
+                        "cat >/etc/s3cfg <<EOF\n",
+                        "access_key=", { "Ref":"ESKey" }, "\n",
+                        "secret_key=", { "Fn::GetAtt":[ "ESKey", "SecretAccessKey" ] },
+                        "\n",
+                        "EOF\n",
+                        "chmod 644 /etc/s3cfg\n",
+                        "ln -s /etc/s3cfg ~ubuntu/.s3cfg\n",
+                        "ln -s /etc/s3cfg ~root/.s3cfg\n",
+                        "\n",
+                        "# download usergrid and init script bundle from S3\n",
+                        "wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | apt-key add -\n",
+                        "wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list\n",
+                        "apt-get update\n",
+                        "apt-get -y install s3cmd\n",
+                        "cd /usr/share/usergrid\n",
+                        "s3cmd --config=/etc/s3cfg get s3://", { "Ref":"ReleaseBucket" }, "/awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+                        "tar xvf awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+                        "rm -fr awscluster-1.0-SNAPSHOT-any.tar.gz\n",
+                        "chmod 755 ./init_instance/*.sh\n",
+                        "cd ./init_instance\n",
+                        "# init as an ES node \n",
+                        "sh ./init_es_server.sh\n"
+                     ]
+                  ]
+               }
+            },
+                "KeyName": {
+                    "Ref": "KeyPair"
+                },
+                "ImageId": {
+                    "Fn::FindInMap": [
+                        "AWSRegionArch2AMI",
+                        {
+                            "Ref": "AWS::Region"
+                        },
+                        {
+                            "Fn::FindInMap": [
+                                "AWSInstanceType2Arch",
+                                {
+                                    "Ref": "CassInstanceType"
+                                },
+                                "Arch"
+                            ]
+                        }
+                    ]
+                },
+                "InstanceType": {
+                    "Ref": "ESInstanceType"
+                },
+                "IamInstanceProfile": {
+                    "Ref": "RootInstanceProfile"
+                },
+                "SecurityGroups": [
+                    {
+                        "Ref": "ESSecurityGroup"
+                    }
+                ]
+            }
+      },
+        "ESAutoScalingGroup": {
+            "Type": "AWS::AutoScaling::AutoScalingGroup",
+            "Version": "2009-05-15",
+            "Properties": {
+                "AvailabilityZones": [
+                    {
+                        "Fn::FindInMap": [
+                            "TwoAZs",
+                            {
+                                "Ref": "AWS::Region"
+                            },
+                            "AZ1"
+                        ]
+                    },
+                    {
+                        "Fn::FindInMap": [
+                            "TwoAZs",
+                            {
+                                "Ref": "AWS::Region"
+                            },
+                            "AZ2"
+                        ]
+                    }
+                ],
+                "LaunchConfigurationName": {
+                    "Ref": "ESAutoScalingLaunchConfiguration"
+                },
+                "MinSize": {
+                    "Ref": "ESNumServers"
+                },
+                "MaxSize": {
+                    "Ref": "ESNumServers"
+                },
+                "NotificationConfiguration": {
+                    "TopicARN": {
+                        "Ref": "NotificationTopic"
+                    },
+                    "NotificationTypes": [
+                        "autoscaling:EC2_INSTANCE_LAUNCH",
+                        "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
+                        "autoscaling:EC2_INSTANCE_TERMINATE",
+                        "autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
+                    ]
+                }
+            }
+        },
       "RestAutoScalingLaunchConfiguration":{
          "Type":"AWS::AutoScaling::LaunchConfiguration",
          "Properties":{
@@ -980,6 +1179,34 @@
                 ]
             }
         },
+        "ESSecurityGroup": {
+            "Type": "AWS::EC2::SecurityGroup",
+            "Properties": {
+                "GroupDescription": "ElasticSearch Machines",
+                "SecurityGroupIngress": [
+                    {
+                        "IpProtocol": "tcp",
+                        "FromPort": "22",
+                        "ToPort": "22",
+                        "CidrIp": "0.0.0.0/0"
+                    }
+                ]
+            }
+        },
+        "AllowCassToESOnAllPorts": {
+            "Type": "AWS::EC2::SecurityGroupIngress",
+            "Properties": {
+                "GroupName": {
+                    "Ref": "ESSecurityGroup"
+                },
+                "IpProtocol": "tcp",
+                "FromPort": "1",
+                "ToPort": "65535",
+                "SourceSecurityGroupName": {
+                    "Ref": "CassSecurityGroup"
+                }
+            }
+        },
         "CassSecurityGroup": {
             "Type": "AWS::EC2::SecurityGroup",
             "Properties": {
@@ -993,7 +1220,7 @@
                     }
                 ]
             }
-        },
+        },        
         "AllowCassToCassOnAllPorts": {
             "Type": "AWS::EC2::SecurityGroupIngress",
             "Properties": {
@@ -1102,6 +1329,20 @@
                 ]
             }
         },
+        "AllowESToGraphiteAllPorts": {
+            "Type": "AWS::EC2::SecurityGroupIngress",
+            "Properties": {
+                "GroupName": {
+                    "Ref": "GraphiteSecurityGroup"
+                },
+                "IpProtocol": "tcp",
+                "FromPort": "0",
+                "ToPort": "65535",
+                "SourceSecurityGroupName": {
+                    "Ref": "ESSecurityGroup"
+                }
+            }
+        },
         "AllowCassToGraphiteAllPorts": {
             "Type": "AWS::EC2::SecurityGroupIngress",
             "Properties": {


[40/49] git commit: Explicitly catch IndexMissingException

Posted by to...@apache.org.
Explicitly catch IndexMissingException


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

Branch: refs/heads/two-dot-o
Commit: f807627b954b1554b0004c9e18555a867186657e
Parents: e5efa67
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 15:38:04 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 15:38:04 2014 -0600

----------------------------------------------------------------------
 .../apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f807627b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 6ed9b86..9ea14a1 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -38,6 +38,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
 import org.elasticsearch.index.query.FilterBuilder;
 import org.elasticsearch.index.query.QueryBuilder;
 import org.elasticsearch.indices.IndexAlreadyExistsException;
+import org.elasticsearch.indices.IndexMissingException;
 import org.elasticsearch.search.SearchHit;
 import org.elasticsearch.search.SearchHits;
 import org.elasticsearch.search.sort.FieldSortBuilder;
@@ -278,7 +279,7 @@ public class EsEntityIndexImpl implements EntityIndex {
                     client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
                     break;
 
-                }catch(Exception e){
+                }catch(IndexMissingException e){
                    log.error( "Unable to refresh index after create. Waiting before sleeping.", e );
                 }
 


[10/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0


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

Branch: refs/heads/two-dot-o
Commit: 43acfad8438b873ecf52384775f97e6052139150
Parents: c56c12c 389e766
Author: amuramoto <am...@apigee.com>
Authored: Fri Oct 10 11:26:01 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Fri Oct 10 11:26:01 2014 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityDeleteListener.java |   2 +-
 .../corepersistence/CpEntityManager.java        | 394 ++++++++-----------
 .../corepersistence/CpEntityManagerFactory.java | 217 +++++++---
 .../corepersistence/CpEntityMapUtils.java       | 323 ---------------
 .../corepersistence/CpManagerCache.java         |   2 +-
 .../usergrid/corepersistence/CpNamingUtils.java | 106 -----
 .../corepersistence/CpRelationManager.java      | 153 ++-----
 .../usergrid/corepersistence/CpVisitor.java     |  32 ++
 .../usergrid/corepersistence/CpWalker.java      | 238 +++++++++++
 .../HybridEntityManagerFactory.java             |  10 +
 .../corepersistence/results/EntityVerifier.java | 126 ++++++
 .../results/FilteringLoader.java                | 245 ++++++++++++
 .../corepersistence/results/IdsVerifier.java    |  46 +++
 .../corepersistence/results/RefsVerifier.java   |  42 ++
 .../corepersistence/results/ResultsLoader.java  |  43 ++
 .../results/ResultsLoaderFactory.java           |  39 ++
 .../results/ResultsLoaderFactoryImpl.java       |  67 ++++
 .../results/ResultsVerifier.java                |  54 +++
 .../results/VersionVerifier.java                |  82 ++++
 .../corepersistence/util/CpEntityMapUtils.java  | 323 +++++++++++++++
 .../corepersistence/util/CpNamingUtils.java     | 106 +++++
 .../usergrid/persistence/EntityManager.java     |  10 +
 .../persistence/EntityManagerFactory.java       |   4 +
 .../apache/usergrid/persistence/Results.java    |   6 +-
 .../cassandra/EntityManagerFactoryImpl.java     |  10 +
 .../cassandra/EntityManagerImpl.java            |  17 +
 .../org/apache/usergrid/CoreApplication.java    |   1 +
 .../CpEntityDeleteListenerTest.java             |   2 +-
 .../CpEntityIndexDeleteListenerTest.java        |   3 +-
 .../corepersistence/CpEntityMapUtilsTest.java   |   2 +
 .../corepersistence/StaleIndexCleanupTest.java  | 100 ++++-
 .../PerformanceEntityRepersistTest.java         | 236 +++++++++++
 .../collection/EntityCollectionManager.java     |  22 +-
 .../persistence/collection/EntitySet.java       |  47 +++
 .../persistence/collection/MvccEntity.java      |  68 ++++
 .../persistence/collection/MvccLogEntry.java    |  94 +++++
 .../persistence/collection/VersionSet.java      |  67 ++++
 .../exception/CollectionRuntimeException.java   |   2 +-
 .../exception/WriteCommitException.java         |   4 +-
 .../WriteOptimisticVerifyException.java         |   4 +-
 .../exception/WriteStartException.java          |   4 +-
 .../exception/WriteUniqueVerifyException.java   |   3 +-
 .../collection/guice/CollectionModule.java      |  14 +-
 .../impl/EntityCollectionManagerImpl.java       | 245 ++++++++----
 .../impl/EntityVersionCleanupTask.java          |   2 +-
 .../mvcc/MvccEntitySerializationStrategy.java   |  20 +-
 .../mvcc/MvccLogEntrySerializationStrategy.java |  17 +-
 .../collection/mvcc/changelog/ChangeLog.java    |  68 ++++
 .../mvcc/changelog/ChangeLogEntry.java          | 104 -----
 .../mvcc/changelog/ChangeLogGenerator.java      |  16 +-
 .../mvcc/changelog/ChangeLogGeneratorImpl.java  | 138 +++----
 .../mvcc/changelog/ChangeLogImpl.java           | 135 +++++++
 .../collection/mvcc/entity/MvccEntity.java      |  68 ----
 .../collection/mvcc/entity/MvccLogEntry.java    |  93 -----
 .../mvcc/entity/MvccValidationUtils.java        |   1 +
 .../mvcc/entity/impl/MvccEntityDeleteEvent.java |   2 +-
 .../mvcc/entity/impl/MvccEntityEvent.java       |   2 +-
 .../mvcc/entity/impl/MvccEntityImpl.java        |   2 +-
 .../mvcc/entity/impl/MvccEntityWriteEvent.java  |   3 +-
 .../mvcc/entity/impl/MvccLogEntryImpl.java      |   2 +-
 .../mvcc/stage/EntityUpdateEvent.java           |   1 -
 .../mvcc/stage/delete/MarkCommit.java           |   4 +-
 .../collection/mvcc/stage/delete/MarkStart.java |   4 +-
 .../collection/mvcc/stage/load/Load.java        |  98 -----
 .../mvcc/stage/write/RollbackAction.java        |   2 +-
 .../mvcc/stage/write/WriteCommit.java           |   4 +-
 .../mvcc/stage/write/WriteOptimisticVerify.java |  44 +--
 .../collection/mvcc/stage/write/WriteStart.java |   5 +-
 .../mvcc/stage/write/WriteUniqueVerify.java     |   2 +-
 .../collection/serialization/EntityRepair.java  |  38 ++
 .../serialization/OptimisticUpdate.java         |   2 +-
 .../serialization/SerializationFig.java         |  19 +
 .../serialization/impl/EntityRepairImpl.java    | 149 +++++++
 .../serialization/impl/EntitySetImpl.java       |  62 +++
 .../serialization/impl/LogEntryIterator.java    |   2 +-
 .../MvccEntitySerializationStrategyImpl.java    | 174 +++++---
 .../MvccLogEntrySerializationStrategyImpl.java  | 129 ++++--
 .../serialization/impl/VersionSetImpl.java      |  80 ++++
 .../persistence/collection/util/RepairUtil.java | 139 -------
 .../collection/EntityCollectionManagerIT.java   | 307 ++++++++++++---
 .../changelog/ChangeLogGeneratorImplTest.java   | 375 ++++++++++--------
 .../mvcc/entity/impl/MvccEntityImplTest.java    |   2 +-
 .../mvcc/entity/impl/MvccLogEntryImplTest.java  |   2 +-
 .../mvcc/stage/AbstractMvccEntityStageTest.java |   2 +-
 .../mvcc/stage/TestEntityGenerator.java         |   2 +-
 .../mvcc/stage/delete/MarkCommitTest.java       |   6 +-
 .../mvcc/stage/delete/MarkStartTest.java        |   4 +-
 .../collection/mvcc/stage/load/LoadTest.java    | 361 -----------------
 .../mvcc/stage/write/WriteCommitTest.java       |   4 +-
 .../stage/write/WriteOptimisticVerifyTest.java  |   4 +-
 .../mvcc/stage/write/WriteStartTest.java        |   4 +-
 .../mvcc/stage/write/WriteUniqueVerifyTest.java |   2 +-
 .../serialization/EntityRepairImplTest.java     | 147 +++++++
 .../impl/LogEntryIteratorTest.java              |   2 +-
 ...MvccEntitySerializationStrategyImplTest.java |  40 +-
 .../impl/MvccLESSTransientTest.java             |   7 +-
 ...ccLogEntrySerializationStrategyImplTest.java |  19 +-
 .../util/InvalidMvccEntityGenerator.java        |   2 +-
 .../util/InvalidValueGeneratorTest.java         |   2 +-
 .../collection/util/LogEntryMock.java           |   4 +-
 .../usergrid/persistence/index/EntityIndex.java |   6 +
 .../index/impl/EsEntityIndexBatchImpl.java      | 119 ++----
 .../index/impl/EsEntityIndexImpl.java           | 280 ++++++-------
 .../persistence/index/impl/IndexingUtils.java   |  66 ++++
 .../index/query/CandidateResult.java            |  30 ++
 .../persistence/index/impl/EntityIndexTest.java |   5 +
 .../cassandra/ManagementServiceImpl.java        |  38 +-
 .../org/apache/usergrid/tools/RepersistAll.java |  98 +++++
 108 files changed, 4611 insertions(+), 2575 deletions(-)
----------------------------------------------------------------------



[39/49] git commit: Changed refresh logic to catch an issue when the Index has not yet replicated across the cluster.

Posted by to...@apache.org.
Changed refresh logic to catch an issue when the Index has not yet replicated across the cluster.


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

Branch: refs/heads/two-dot-o
Commit: e5efa674bf71cda99d9958186962b0691ac4d6c2
Parents: 54b9a11
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 15:30:54 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 15:30:54 2014 -0600

----------------------------------------------------------------------
 .../index/impl/EsEntityIndexImpl.java           | 55 ++++++++++----------
 1 file changed, 27 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e5efa674/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 495b9e1..6ed9b86 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -124,34 +124,14 @@ public class EsEntityIndexImpl implements EntityIndex {
             }
             while ( response.getFailedShards() != 0 );
 
-            //now try to refresh, to ensure that it's recognized by everyone.  Occasionally we can get a success
-            //before we can write.
-            for(int i = 0 ; i < MAX_WAITS; i++ ){
-                try{
-                    refresh();
-                    break;
-
-                }catch(Exception e){
-                   log.error( "Unable to refresh index after create. Waiting before sleeping.", e );
-                }
+            /**
+             * Immediately refresh to ensure the entire cluster is ready to receive this write.  Occasionally we see
+             * errors.  See this post.
+             * http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
+             *
+             */
+            refresh();
 
-                try {
-                    Thread.sleep( WAIT_TIME );
-                }
-                catch ( InterruptedException e ) {
-                    //swallow it
-                }
-            }
-
-            //
-            //            response.getFailedShards();
-            //
-            //            try {
-            //                // TODO: figure out what refresh above is not enough to ensure index is ready
-            //                Thread.sleep( 500 );
-            //            }
-            //            catch ( InterruptedException ex ) {
-            //            }
         }
         catch ( IndexAlreadyExistsException expected ) {
             // this is expected to happen if index already exists, it's a no-op and swallow
@@ -290,7 +270,26 @@ public class EsEntityIndexImpl implements EntityIndex {
 
 
     public void refresh() {
-        client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+
+            //now try to refresh, to ensure that it's recognized by everyone.  Occasionally we can get a success
+            //before we can write.
+            for(int i = 0 ; i < MAX_WAITS; i++ ){
+                try{
+                    client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+                    break;
+
+                }catch(Exception e){
+                   log.error( "Unable to refresh index after create. Waiting before sleeping.", e );
+                }
+
+                try {
+                    Thread.sleep( WAIT_TIME );
+                }
+                catch ( InterruptedException e ) {
+                    //swallow it
+                }
+            }
+
         log.debug( "Refreshed index: " + indexName );
     }
 


[49/49] git commit: Fixes incorrect seek value on edge types

Posted by to...@apache.org.
Fixes incorrect seek value on edge types


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

Branch: refs/heads/two-dot-o
Commit: 5a0410780858836506207287ac984a7331f06aa6
Parents: 059a952
Author: Todd Nine <to...@apache.org>
Authored: Fri Oct 17 10:34:07 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Fri Oct 17 10:34:07 2014 -0600

----------------------------------------------------------------------
 .../main/java/org/apache/usergrid/corepersistence/CpWalker.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a041078/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
index 636cc91..ecf7787 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
@@ -81,7 +81,7 @@ public class CpWalker {
         //only search edge types that start with collections
 
         Observable<String> edgeTypes = gm.getEdgeTypesFromSource(
-                       new SimpleSearchEdgeType( applicationId, CpNamingUtils.EDGE_COLL_SUFFIX+"users", null ) );
+                       new SimpleSearchEdgeType( applicationId, CpNamingUtils.EDGE_COLL_SUFFIX, null ) );
 
         edgeTypes.flatMap( new Func1<String, Observable<Edge>>() {
             @Override


[07/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0


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

Branch: refs/heads/two-dot-o
Commit: 7fc56f7568c663741f7e94e9bd6f2b42394e8283
Parents: fc7140e 3547f2c
Author: amuramoto <am...@apigee.com>
Authored: Tue Oct 7 13:37:41 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Tue Oct 7 13:37:41 2014 -0700

----------------------------------------------------------------------
 .../core/util/AvailablePortFinder.java          | 188 -------------------
 .../queue/impl/SQSQueueManagerImpl.java         |  33 +++-
 .../notifications/ApplicationQueueManager.java  |  11 +-
 .../services/notifications/QueueListener.java   |  14 +-
 .../services/notifications/TaskManager.java     |  11 +-
 5 files changed, 47 insertions(+), 210 deletions(-)
----------------------------------------------------------------------



[20/49] git commit: more cloudoformation updates

Posted by to...@apache.org.
more cloudoformation updates


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

Branch: refs/heads/two-dot-o
Commit: ad45789b0b4847e19487db8ff85f71675db4239d
Parents: b33eccc
Author: amuramoto <am...@apigee.com>
Authored: Sun Oct 12 03:59:43 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Sun Oct 12 03:59:43 2014 -0700

----------------------------------------------------------------------
 stack/awscluster/ugcluster-cf.json | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ad45789b/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index 5688d6b..5b0a87d 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -84,6 +84,11 @@
             "Default": "3",
             "MinValue": "1"
         },
+        "ESClusterName": {
+            "Description": "Name to be used for Elasticsearch cluster.",
+            "Type": "String",
+            "Default": "usergrid"
+        },
         "ESNumServers": {
             "Description": "Number of ES servers to start.",
             "Type": "Number",


[05/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0


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

Branch: refs/heads/two-dot-o
Commit: 519a6d835f04aa043e43a56806eadd0f54864344
Parents: 30ba9ac c40aecb
Author: amuramoto <am...@apigee.com>
Authored: Mon Oct 6 15:40:54 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Mon Oct 6 15:40:54 2014 -0700

----------------------------------------------------------------------
 stack/core/pom.xml                              |  15 +
 .../usergrid/corepersistence/GuiceModule.java   |   4 +
 .../collection/event/EntityDeleted.java         |  17 +
 .../collection/event/EntityVersionCreated.java  |  17 +
 .../collection/event/EntityVersionDeleted.java  |  17 +
 stack/corepersistence/map/pom.xml               |  81 +++++
 .../usergrid/persistence/map/MapManager.java    |  69 ++++
 .../persistence/map/MapManagerFactory.java      |  30 ++
 .../usergrid/persistence/map/MapScope.java      |  40 +++
 .../persistence/map/guice/MapModule.java        |  61 ++++
 .../persistence/map/impl/MapManagerImpl.java    | 114 +++++++
 .../persistence/map/impl/MapScopeImpl.java      |  91 ++++++
 .../persistence/map/impl/MapSerialization.java  |  64 ++++
 .../map/impl/MapSerializationImpl.java          | 327 +++++++++++++++++++
 .../persistence/map/MapManagerTest.java         | 207 ++++++++++++
 .../persistence/map/guice/TestMapModule.java    |  16 +
 stack/corepersistence/pom.xml                   |  18 +
 stack/corepersistence/queue/pom.xml             |  92 ++++++
 .../usergrid/persistence/queue/Queue.java       |  31 ++
 .../usergrid/persistence/queue/QueueFig.java    |  16 +
 .../persistence/queue/QueueManager.java         |  64 ++++
 .../persistence/queue/QueueManagerFactory.java  |  23 ++
 .../persistence/queue/QueueMessage.java         |  42 +++
 .../usergrid/persistence/queue/QueueScope.java  |  31 ++
 .../persistence/queue/guice/QueueModule.java    |  51 +++
 .../persistence/queue/impl/QueueScopeImpl.java  |  87 +++++
 .../queue/impl/SQSQueueManagerImpl.java         | 234 +++++++++++++
 .../persistence/queue/QueueManagerTest.java     | 100 ++++++
 .../queue/guice/TestQueueModule.java            |  33 ++
 stack/pom.xml                                   |   8 +-
 .../apache/usergrid/rest/SystemResource.java    | 157 +++++++++
 .../notifications/ApplicationQueueManager.java  |  96 +++---
 .../notifications/ApplicationQueueMessage.java  |  67 ++--
 .../notifications/NotificationsService.java     |  15 +-
 .../services/notifications/QueueListener.java   |  69 ++--
 .../services/notifications/QueueManager.java    |  31 --
 .../services/notifications/TaskManager.java     |  54 +--
 .../apns/NotificationsServiceIT.java            |  47 ++-
 .../gcm/NotificationsServiceIT.java             |   2 +-
 stack/test-utils/pom.xml                        |  17 +-
 .../java/org/apache/usergrid/tools/ApiDoc.java  |   5 +-
 41 files changed, 2323 insertions(+), 237 deletions(-)
----------------------------------------------------------------------



[32/49] git commit: Fixes bug with us region naming

Posted by to...@apache.org.
Fixes bug with us region naming


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

Branch: refs/heads/two-dot-o
Commit: c9ac3e27a9b47dd47d411b54d931a95b02f79bed
Parents: b84bbc1
Author: Todd Nine <to...@apache.org>
Authored: Wed Oct 15 22:07:34 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Wed Oct 15 22:07:34 2014 -0600

----------------------------------------------------------------------
 stack/awscluster/src/main/groovy/configure_usergrid.groovy | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9ac3e27/stack/awscluster/src/main/groovy/configure_usergrid.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_usergrid.groovy b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
index 03b3077..35a0262 100644
--- a/stack/awscluster/src/main/groovy/configure_usergrid.groovy
+++ b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
@@ -43,7 +43,8 @@ def testAdminUserEmail = System.getenv().get("TEST_ADMIN_USER_EMAIL")
 def cassThreads = System.getenv().get("TOMCAT_THREADS")
 def hystrixThreads = Integer.parseInt(cassThreads) / 100
 
-def ec2Region = System.getenv().get("EC2_REGION")
+//if we end in -1, we remove it
+def ec2Region = System.getenv().get("EC2_REGION").replace("-1", "")
 
 
 NodeRegistry registry = new NodeRegistry();


[09/49] git commit: Updated pom.xml to properly include JSP servlet defs in web.xml on build

Posted by to...@apache.org.
Updated pom.xml to properly include JSP servlet defs in web.xml on build


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

Branch: refs/heads/two-dot-o
Commit: c56c12c212dad5779bdff949c5c95a8221968982
Parents: 275f10a
Author: amuramoto <am...@apigee.com>
Authored: Thu Oct 9 10:17:45 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Thu Oct 9 10:17:45 2014 -0700

----------------------------------------------------------------------
 stack/rest/pom.xml | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c56c12c2/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 4a99443..ef6cd26 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -140,17 +140,13 @@
             </plugin>
 
             <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-war-plugin</artifactId>
-                <version>2.3</version>
-            </plugin>
-
-            <plugin>
                 <groupId>org.jasig.mojo.jspc</groupId>
                 <artifactId>jspc-maven-plugin</artifactId>
                 <version>2.0.0</version>
                 <configuration>
-                    <includeInProject>false</includeInProject>
+                    <includeInProject>true</includeInProject>
+                    <inputWebXml>${basedir}/src/main/webapp/WEB-INF/web.xml</inputWebXml>
+                    <injectString>&lt;!--FRAGMENT--&gt;</injectString>
                     <webFragmentFile>${project.build.directory}/web-fragment.xml.txt</webFragmentFile>
                 </configuration>
                 <executions>
@@ -164,7 +160,7 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.jasig.mojo.jspc</groupId>
-                        <artifactId>jspc-compiler-tomcat6</artifactId>
+                        <artifactId>jspc-compiler-tomcat7</artifactId>
                         <version>2.0.0</version>
                     </dependency>
                 </dependencies>
@@ -172,6 +168,15 @@
 
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <configuration>
+                    <webXml>${project.build.directory}/jspweb.xml</webXml>
+                </configuration>
+                <version>2.3</version>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-jar-plugin</artifactId>
                 <version>2.3.2</version>
                 <configuration>


[48/49] git commit: Merge branch 'index-rebuild' into cloudformation-update

Posted by to...@apache.org.
Merge branch 'index-rebuild' into cloudformation-update


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

Branch: refs/heads/two-dot-o
Commit: 059a9523360eb543c3adfc42059a4c9e52e4efbb
Parents: 704c09d 8d9d4dc
Author: Todd Nine <to...@apache.org>
Authored: Fri Oct 17 08:57:14 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Fri Oct 17 08:57:14 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |  107 +-
 .../corepersistence/CpEntityManagerFactory.java |   40 +-
 .../corepersistence/CpRelationManager.java      | 1427 ++++++++----------
 .../usergrid/corepersistence/CpVisitor.java     |   11 +-
 .../usergrid/corepersistence/CpWalker.java      |  157 +-
 .../usergrid/persistence/EntityManager.java     |    2 +-
 .../persistence/EntityManagerFactory.java       |    8 +-
 .../org/apache/usergrid/CoreApplication.java    |    1 -
 .../PerformanceEntityRebuildIndexTest.java      |   23 +-
 .../index/impl/EsEntityIndexImpl.java           |  146 +-
 .../persistence/index/impl/EsProvider.java      |   21 +-
 .../apache/usergrid/rest/SystemResource.java    |   50 +-
 .../AbstractServiceNotificationIT.java          |    4 -
 13 files changed, 954 insertions(+), 1043 deletions(-)
----------------------------------------------------------------------



[47/49] git commit: Fixes migration bug

Posted by to...@apache.org.
Fixes migration bug


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

Branch: refs/heads/two-dot-o
Commit: 8d9d4dcf043240a9c53902b27e3daa23cd9987de
Parents: bd00ee0
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 23:24:50 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 23:24:50 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |  8 +++++++
 .../usergrid/corepersistence/CpWalker.java      | 15 ++++++-------
 .../PerformanceEntityRebuildIndexTest.java      |  2 +-
 .../persistence/index/impl/EsProvider.java      | 22 +++++++++++++-------
 .../apache/usergrid/rest/SystemResource.java    |  7 ++-----
 5 files changed, 33 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8d9d4dcf/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 e013957..bc45769 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
@@ -95,9 +95,15 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     public static final UUID SYSTEM_APP_ID =
             UUID.fromString("b6768a08-b5d5-11e3-a495-10ddb1de66c3");
 
+    /**
+     * App where we store management info
+     */
     public static final  UUID MANAGEMENT_APPLICATION_ID =
             UUID.fromString("b6768a08-b5d5-11e3-a495-11ddb1de66c8");
 
+    /**
+     * TODO Dave what is this?
+     */
     public static final  UUID DEFAULT_APPLICATION_ID =
             UUID.fromString("b6768a08-b5d5-11e3-a495-11ddb1de66c9");
 
@@ -679,6 +685,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     @Override
     public void rebuildInternalIndexes( ProgressObserver po ) throws Exception {
         rebuildApplicationIndexes(SYSTEM_APP_ID, po);
+        rebuildApplicationIndexes( MANAGEMENT_APPLICATION_ID, po );
+        rebuildApplicationIndexes( DEFAULT_APPLICATION_ID, po );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8d9d4dcf/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
index 908e6bc..636cc91 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
@@ -67,33 +67,32 @@ public class CpWalker {
     }
 
 
-    private void doWalkCollections( final CpEntityManager em, final Id start, final CpVisitor visitor ) {
-
-        final Id fromEntityId = new SimpleId( start.getUuid(), start.getType() );
+    private void doWalkCollections( final CpEntityManager em, final Id applicationId, final CpVisitor visitor ) {
 
         final ApplicationScope applicationScope = em.getApplicationScope();
 
         final GraphManager gm = em.getManagerCache().getGraphManager( applicationScope );
 
         logger.debug( "Loading edges types from {}:{}\n   scope {}:{}", new Object[] {
-                        start.getType(), start.getUuid(), applicationScope.getApplication().getType(),
+                applicationId.getType(), applicationId.getUuid(), applicationScope.getApplication().getType(),
                         applicationScope.getApplication().getUuid()
                 } );
 
         //only search edge types that start with collections
+
         Observable<String> edgeTypes = gm.getEdgeTypesFromSource(
-                new SimpleSearchEdgeType( fromEntityId, CpNamingUtils.EDGE_COLL_SUFFIX, null ) );
+                       new SimpleSearchEdgeType( applicationId, CpNamingUtils.EDGE_COLL_SUFFIX+"users", null ) );
 
         edgeTypes.flatMap( new Func1<String, Observable<Edge>>() {
             @Override
             public Observable<Edge> call( final String edgeType ) {
 
                 logger.debug( "Loading edges of edgeType {} from {}:{}\n   scope {}:{}", new Object[] {
-                        edgeType, start.getType(), start.getUuid(), applicationScope.getApplication().getType(),
+                        edgeType, applicationId.getType(), applicationId.getUuid(), applicationScope.getApplication().getType(),
                         applicationScope.getApplication().getUuid()
                 } );
 
-                return gm.loadEdgesFromSource( new SimpleSearchByEdgeType( fromEntityId, edgeType, Long.MAX_VALUE,
+                return gm.loadEdgesFromSource( new SimpleSearchByEdgeType( applicationId, edgeType, Long.MAX_VALUE,
                                 SearchByEdgeType.Order.DESCENDING, null ) );
             }
         } ).doOnNext( new Action1<Edge>() {
@@ -101,6 +100,8 @@ public class CpWalker {
             @Override
             public void call( Edge edge ) {
 
+                logger.info( "Re-indexing edge {}", edge );
+
                 EntityRef targetNodeEntityRef =
                         new SimpleEntityRef( edge.getTargetNode().getType(), edge.getTargetNode().getUuid() );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8d9d4dcf/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index 2ef65ef..ed3fd61 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -194,7 +194,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
                public void onProgress( final EntityRef entity ) {
 
                 meter.mark();
-                logger.debug("Indexing from {}:{}", entity.getType(), entity.getUuid());
+                logger.debug("Indexing {}:{}", entity.getType(), entity.getUuid());
                 if ( !logger.isDebugEnabled() && counter % 100 == 0 ) {
                     logger.info("Reindexed {} entities", counter );
                 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8d9d4dcf/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
index aac9ff5..9b37952 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
@@ -31,8 +31,10 @@ import org.apache.commons.lang.RandomStringUtils;
 import org.apache.usergrid.persistence.core.util.AvailablePortFinder;
 import org.apache.usergrid.persistence.index.IndexFig;
 import org.elasticsearch.client.Client;
+import org.elasticsearch.client.transport.TransportClient;
 import org.elasticsearch.common.settings.ImmutableSettings;
 import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.transport.InetSocketTransportAddress;
 import org.elasticsearch.node.Node;
 import org.elasticsearch.node.NodeBuilder;
 import org.slf4j.Logger;
@@ -152,24 +154,28 @@ public class EsProvider {
 
                 Settings settings = ImmutableSettings.settingsBuilder()
 
-                    .put("cluster.name", fig.getClusterName())
+                    .put( "cluster.name", fig.getClusterName() )
 
                     // this assumes that we're using zen for host discovery.  Putting an 
                     // explicit set of bootstrap hosts ensures we connect to a valid cluster.
-                    .put("discovery.zen.ping.unicast.hosts", allHosts)
-                    .put("discovery.zen.ping.multicast.enabled","false")
+                    .put( "discovery.zen.ping.unicast.hosts", allHosts )
+                    .put( "discovery.zen.ping.multicast.enabled", "false" )
                     .put("http.enabled", false) 
 
-                    .put("client.transport.ping_timeout", 2000) // milliseconds
-                    .put("client.transport.nodes_sampler_interval", 100)
-                    .put("network.tcp.blocking", true)
-                    .put("node.client", true)
-                    .put("node.name",  nodeName )
+                    .put( "client.transport.ping_timeout", 2000 ) // milliseconds
+                    .put( "client.transport.nodes_sampler_interval", 100 )
+                    .put( "network.tcp.blocking", true )
+                    .put( "node.client", true )
+                    .put( "node.name", nodeName )
 
                     .build();
 
                 log.debug("Creating ElasticSearch client with settings: " +  settings.getAsMap());
 
+                //use this client when connecting via socket only, such as ssh tunnel or other firewall issues
+//                newClient  = new TransportClient(settings).addTransportAddress( new InetSocketTransportAddress("localhost", 9300) );
+
+                //use this client for quick connectivity
                 Node node = NodeBuilder.nodeBuilder().settings(settings)
                     .client(true).node();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8d9d4dcf/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
index 28a7120..d068846 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
@@ -128,7 +128,7 @@ public class SystemResource extends AbstractContextResource {
 
             @Override
             public void onProgress( final EntityRef entity ) {
-                logger.info( "Indexing from {}:{} ", entity.getType(), entity.getUuid() );
+                logger.info( "Indexing entity {}:{} ", entity.getType(), entity.getUuid() );
             }
 
 
@@ -146,9 +146,6 @@ public class SystemResource extends AbstractContextResource {
                 logger.info( "Rebuilding all indexes" );
 
                 try {
-                    emf.rebuildInternalIndexes( po );
-                    emf.refreshIndex();
-
                     emf.rebuildAllIndexes( po );
                 }
                 catch ( Exception e ) {
@@ -252,7 +249,7 @@ public class SystemResource extends AbstractContextResource {
 
             @Override
             public void onProgress( final EntityRef entity ) {
-                logger.info( "Indexing from {}:{} to {}:{} edgeType {}", entity.getType(), entity.getUuid());
+                logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid());
             }
 
 


[13/49] git commit: more updates to cloudformation scripts

Posted by to...@apache.org.
more updates to cloudformation scripts


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

Branch: refs/heads/two-dot-o
Commit: 83fccdd35eaee23a769a77bf39071ae70e6f3470
Parents: e64e9c9
Author: amuramoto <am...@apigee.com>
Authored: Fri Oct 10 17:37:50 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Fri Oct 10 17:37:50 2014 -0700

----------------------------------------------------------------------
 stack/pom.xml      | 10 +++-------
 stack/rest/pom.xml | 21 ++++++++-------------
 2 files changed, 11 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/83fccdd3/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index b1bfe3c..c56942c 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -111,7 +111,7 @@
     <org.springframework.version>3.1.2.RELEASE</org.springframework.version>
     <shiro-version>1.2.0</shiro-version>
     <slf4j-version>1.6.1</slf4j-version>
-    <snakeyaml-version>1.6</snakeyaml-version>
+    <snakeyaml-version>1.8</snakeyaml-version>
     <tomcat-version>7.0.52</tomcat-version>
     <antlr.version>3.4</antlr.version>
     <tika.version>1.4</tika.version>
@@ -276,7 +276,7 @@
       <dependency>
         <groupId>org.apache.httpcomponents</groupId>
         <artifactId>httpclient</artifactId>
-        <version>4.2</version>
+        <version>4.1.3</version>
         <exclusions>
           <exclusion>
             <groupId>commons-codec</groupId>
@@ -457,10 +457,6 @@
         <version>${cassandra-version}</version>
         <exclusions>
           <exclusion>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-          </exclusion>
-          <exclusion>
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
           </exclusion>
@@ -1247,7 +1243,7 @@
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit-dep</artifactId>
-        <version>4.11</version>
+        <version>4.10</version>
       </dependency>
 
       <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/83fccdd3/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index ef6cd26..4a99443 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -140,13 +140,17 @@
             </plugin>
 
             <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>2.3</version>
+            </plugin>
+
+            <plugin>
                 <groupId>org.jasig.mojo.jspc</groupId>
                 <artifactId>jspc-maven-plugin</artifactId>
                 <version>2.0.0</version>
                 <configuration>
-                    <includeInProject>true</includeInProject>
-                    <inputWebXml>${basedir}/src/main/webapp/WEB-INF/web.xml</inputWebXml>
-                    <injectString>&lt;!--FRAGMENT--&gt;</injectString>
+                    <includeInProject>false</includeInProject>
                     <webFragmentFile>${project.build.directory}/web-fragment.xml.txt</webFragmentFile>
                 </configuration>
                 <executions>
@@ -160,7 +164,7 @@
                 <dependencies>
                     <dependency>
                         <groupId>org.jasig.mojo.jspc</groupId>
-                        <artifactId>jspc-compiler-tomcat7</artifactId>
+                        <artifactId>jspc-compiler-tomcat6</artifactId>
                         <version>2.0.0</version>
                     </dependency>
                 </dependencies>
@@ -168,15 +172,6 @@
 
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-war-plugin</artifactId>
-                <configuration>
-                    <webXml>${project.build.directory}/jspweb.xml</webXml>
-                </configuration>
-                <version>2.3</version>
-            </plugin>
-
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-jar-plugin</artifactId>
                 <version>2.3.2</version>
                 <configuration>


[19/49] git commit: more cloudformation updates

Posted by to...@apache.org.
more cloudformation updates


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

Branch: refs/heads/two-dot-o
Commit: b33ecccbb8415f3a9e3ba039692fbc57a4b68656
Parents: 60096b6
Author: amuramoto <am...@apigee.com>
Authored: Sun Oct 12 03:52:33 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Sun Oct 12 03:52:33 2014 -0700

----------------------------------------------------------------------
 stack/awscluster/ugcluster-cf.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b33ecccb/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index 93c7e86..5688d6b 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -668,7 +668,7 @@
                         "export ES_SECURITY_GROUP_NAME=", { "Ref":"ESSecurityGroup" }, "\n",
                         "\n",
                         "\n",
-                        "export ES_CLUSTER_NAME=", { "Ref":"CassClusterName" }, "\n",
+                        "export ES_CLUSTER_NAME=", { "Ref":"ESClusterName" }, "\n",
                         "export ES_NUM_SERVERS=", { "Ref":"ESNumServers" }, "\n",
                         "export GRAPHITE_NUM_SERVERS=", { "Ref":"GraphiteNumServers" }, "\n",
                         "\n",


[22/49] git commit: more cloudformation updates

Posted by to...@apache.org.
more cloudformation updates


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

Branch: refs/heads/two-dot-o
Commit: 4381884262c6e5f9ea98b2edc6980400e82cc821
Parents: 25770fe
Author: amuramoto <am...@apigee.com>
Authored: Mon Oct 13 13:56:36 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Mon Oct 13 13:56:36 2014 -0700

----------------------------------------------------------------------
 .../main/dist/init_instance/init_rest_server.sh  |  5 ++++-
 .../dist/init_instance/install_elasticsearch.sh  |  2 +-
 .../main/groovy/configure_elasticsearch.groovy   | 19 +++++++++++++++----
 3 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/43818842/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
index 5bb994c..96da354 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
@@ -123,6 +123,7 @@ EOF
 # wait for enough Cassandra nodes then delpoy and configure Usergrid 
 cd /usr/share/usergrid/scripts
 groovy wait_for_instances.groovy cassandra ${CASSANDRA_NUM_SERVERS}
+groovy wait_for_instances.groovy elasticsearch ${ES_NUM_SERVERS}
 groovy wait_for_instances.groovy graphite ${GRAPHITE_NUM_SERVERS}
 
 # link WAR and Portal into Tomcat's webapps dir
@@ -137,9 +138,11 @@ mkdir -p /usr/share/tomcat7/lib
 groovy configure_usergrid.groovy > /usr/share/tomcat7/lib/usergrid-deployment.properties 
 groovy configure_portal_new.groovy >> /var/lib/tomcat7/webapps/portal/config.js
 
+sudo sed -i '98i export CATALINA_OPTS=\"-DAWS_SECRET_KEY=${AWS_SECRET_KEY} -DAWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY} ${CATALINA_OPTS}\"' /usr/share/tomcat7/bin/catalina.sh
+
 # Go
 sh /etc/init.d/tomcat7 start
 
 # tag last so we can see in the console that the script ran to completion
 cd /usr/share/usergrid/scripts
-groovy tag_instance.groovy
+groovy tag_instance.groovy
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/43818842/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh b/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
index d6e4285..e5c6473 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
@@ -78,7 +78,7 @@ case `(curl http://169.254.169.254/latest/meta-data/instance-type)` in
 ;;
 'c3.4xlarge' )
     # total of 30g
-    export ES_HEAP_SIZE=15g
+    export ES_HEAP_SIZE=24g
 esac
 
 cat >> /etc/default/elasticsearch << EOF

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/43818842/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy b/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
index ceddcbe..549a23b 100644
--- a/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
+++ b/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
@@ -19,9 +19,9 @@
 
 
 // 
-// configure_cassandra.groovy 
+// configure_elasticsearch.groovy 
 // 
-// Emits Cassandra config file based on environment and Cassandra node 
+// Emits Elasticsearch config file based on environment and Elasticsearch node 
 // registry in SimpleDB
 //
 
@@ -34,8 +34,7 @@ def clusterName  = (String)System.getenv().get("ES_CLUSTER_NAME")
 
 NodeRegistry registry = new NodeRegistry();
 
-// build seed list by listing all Cassandra nodes found in SimpleDB domain with our stackName
-// works because cassandra nodes are also elasticsearch nodes
+// build seed list by listing all Elasticsearch nodes found in SimpleDB domain with our stackName
 def selectResult = registry.searchNode('elasticsearch')
 def esnodes = ""
 def sep = ""
@@ -46,6 +45,7 @@ for (hostname in selectResult) {
 
 def elasticSearchConfig = """
 cluster.name: ${clusterName}
+discovery.zen.minimum_master_nodes: 4
 discovery.zen.ping.multicast.enabled: false
 discovery.zen.ping.unicast.hosts: [${esnodes}]
 node:
@@ -55,6 +55,17 @@ network:
 path:
     logs: /mnt/log/elasticsearch
     data: /mnt/data/elasticsearch
+bootstrap.mlockall: true
+threadpool.index.type: fixed
+threadpool.index.size: 160
+threadpool.index.queue_size: 401
+threadpool.bulk.type: fixed
+threadpool.bulk.size: 160
+threadpool.bulk.queue_size: 800
+
+action.auto_create_index: false
+
+action.disable_delete_all_indices: true
 """
 
 println elasticSearchConfig


[37/49] git commit: Moved create index down to cache init. Not ideal, but lowest least called point in the code until setup is refactored.

Posted by to...@apache.org.
Moved create index down to cache init.  Not ideal, but lowest least called point in the code until setup is refactored.


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

Branch: refs/heads/two-dot-o
Commit: f24f3ea7cc70efa18de83308d4eb9011548517e4
Parents: 163fa9a
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 13:40:32 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 13:40:32 2014 -0600

----------------------------------------------------------------------
 .../apache/usergrid/corepersistence/CpEntityManagerFactory.java   | 3 +--
 stack/core/src/test/java/org/apache/usergrid/CoreApplication.java | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f24f3ea7/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 8ab0b7f..2514e20 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
@@ -146,7 +146,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
                 Map sysAppProps = new HashMap<String, Object>();
                 sysAppProps.put( PROPERTY_NAME, "systemapp");
                 em.create( SYSTEM_APP_ID, TYPE_APPLICATION, sysAppProps );
-                em.createIndex();
                 em.getApplication();
                 em.refreshIndex();
             }
@@ -287,7 +286,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         EntityManager appEm = getEntityManager( applicationId );
 
         //create our ES index since we're initializing this application
-        appEm.createIndex();
+//  TODO T.N, pushed this down into the cache load      appEm.createIndex();
 
         appEm.create( applicationId, TYPE_APPLICATION, properties );
         appEm.resetRoles();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f24f3ea7/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index 51e825b..fd8ca9b 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -150,9 +150,7 @@ public class CoreApplication implements Application, TestRule {
         id = setup.createApplication( orgName, appName );
         assertNotNull( id );
 
-        setup.getEmf().refreshIndex();
         em = setup.getEmf().getEntityManager( id );
-        em.createIndex();
         assertNotNull( em );
 
         LOG.info( "Created new application {} in organization {}", appName, orgName );


[36/49] git commit: Work in progress on refactoring visitor to only update entities since connections are handled internally

Posted by to...@apache.org.
Work in progress on refactoring visitor to only update entities since connections are handled internally


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

Branch: refs/heads/two-dot-o
Commit: 163fa9adf163226521d5724dce1cdac974de3b38
Parents: 9da529b
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 11:39:12 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 11:39:12 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |  83 ++--------
 .../corepersistence/CpEntityManagerFactory.java |  22 +--
 .../usergrid/corepersistence/CpVisitor.java     |  11 +-
 .../usergrid/corepersistence/CpWalker.java      | 155 +++++++------------
 .../persistence/EntityManagerFactory.java       |   8 +-
 .../org/apache/usergrid/CoreApplication.java    |   1 +
 .../PerformanceEntityRebuildIndexTest.java      |  20 ++-
 .../apache/usergrid/rest/SystemResource.java    |  47 +++---
 8 files changed, 135 insertions(+), 212 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/163fa9ad/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 8753670..4015014 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
@@ -109,6 +109,7 @@ import static org.apache.usergrid.persistence.cassandra.Serializers.ue;
 import org.apache.usergrid.persistence.cassandra.util.TraceParticipant;
 import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
+import org.apache.usergrid.persistence.collection.exception.WriteOptimisticVerifyException;
 import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
 import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
@@ -2869,94 +2870,32 @@ public class CpEntityManager implements EntityManager {
      */
     public void reindex( final EntityManagerFactory.ProgressObserver po ) throws Exception {
 
-        CpWalker walker = new CpWalker();
+        CpWalker walker = new CpWalker(po.getWriteDelayTime());
 
         walker.walkCollections( this, application, new CpVisitor() {
 
             @Override
             public void visitCollectionEntry(
-                    EntityManager em, String collName, Entity source, Entity target) {
+                    EntityManager em, String collName, Entity entity) {
 
                 try {
-                    em.update( target);
-                    po.onProgress(source, target, collName);
-
-                } catch (Exception ex) {
-                    logger.error("Error repersisting entity", ex);
+                    em.update( entity);
+                    po.onProgress(entity);
                 }
-            }
-
-            @Override
-            public void visitConnectionEntry(
-                    EntityManager em, String connType, Entity source, Entity target) {
-
-                try {
-                    em.update( target);
-                    po.onProgress(source, target, connType);
-
-                } catch (Exception ex) {
+                catch(WriteOptimisticVerifyException wo ){
+                    //swallow this, it just means this was already updated, which accomplishes our task.  Just ignore.
+                    logger.warn( "Someone beat us to updating entity {} in collection {}.  Ignoring.", entity.getName(), collName );
+                }
+                catch (Exception ex) {
                     logger.error("Error repersisting entity", ex);
                 }
             }
 
-        });
-    }
-
-
-    private void indexEntityIntoCollections( 
-            org.apache.usergrid.persistence.model.entity.Entity collectionEntity, 
-            org.apache.usergrid.persistence.model.entity.Entity memberEntity, 
-            String collName, 
-            boolean connectBack ) {
-
-        logger.debug("Indexing into collections {} {}:{} member {}:{}", new Object[] { 
-            collName, collectionEntity.getId().getType(), collectionEntity.getId().getUuid(),
-            memberEntity.getId().getType(), memberEntity.getId().getUuid() });
-
-        indexEntityIntoCollection( collectionEntity, memberEntity, collName);
 
-        CollectionInfo collection = getDefaultSchema()
-                .getCollection( memberEntity.getId().getType(), collName);
-
-        if (connectBack && collection != null && collection.getLinkedCollection() != null) {
-
-            logger.debug("Linking back from entity in collection {} to collection {}", 
-                collection.getName(), collection.getLinkedCollection());
-
-            indexEntityIntoCollections( 
-                memberEntity, collectionEntity, collection.getLinkedCollection(), false );
-        }
+        });
     }
 
 
-    void indexEntityIntoConnection(
-            org.apache.usergrid.persistence.model.entity.Entity sourceEntity,
-            org.apache.usergrid.persistence.model.entity.Entity targetEntity,
-            String connType) {
-
-        logger.debug("Indexing into connection {} source {}:{} target {}:{}", new Object[] { 
-            connType, sourceEntity.getId().getType(), sourceEntity.getId().getUuid(),
-            targetEntity.getId().getType(), targetEntity.getId().getUuid() });
-
-
-        final EntityIndex ei = getManagerCache().getEntityIndex(getApplicationScope());
-        final EntityIndexBatch batch = ei.createBatch();
-
-        // Index the new connection in app|source|type context
-        IndexScope indexScope = new IndexScopeImpl(
-                sourceEntity.getId(),
-                CpNamingUtils.getConnectionScopeName( targetEntity.getId().getType(), connType ));
-        batch.index(indexScope, targetEntity);
-        
-        // Index the new connection in app|scope|all-types context
-        IndexScope allTypesIndexScope = new IndexScopeImpl(
-                sourceEntity.getId(),
-                CpNamingUtils.ALL_TYPES);
-
-        batch.index(allTypesIndexScope, targetEntity);
-
-        batch.execute();
-    }
 
 
     void indexEntityIntoCollection(

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/163fa9ad/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 2abe83f..8ab0b7f 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
@@ -101,7 +101,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     public static final  UUID DEFAULT_APPLICATION_ID =
             UUID.fromString("b6768a08-b5d5-11e3-a495-11ddb1de66c9");
 
-    private static AtomicBoolean INIT_SYSTEM = new AtomicBoolean(  );
+    private AtomicBoolean init_indexes = new AtomicBoolean(  );
 
 
     // cache of already instantiated entity managers
@@ -201,6 +201,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     private EntityManager _getEntityManager( UUID applicationId ) {
         EntityManager em = new CpEntityManager();
         em.init( this, applicationId );
+        //TODO T.N. Can we remove this?  Seems like we should fix our lifecycle instead...
+        em.createIndex();
         return em;
     }
 
@@ -628,7 +630,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
     private void maybeCreateIndexes() {
         // system app
-        if ( INIT_SYSTEM.getAndSet( true ) ) {
+        if ( init_indexes.getAndSet( true ) ) {
             return;
         }
 
@@ -641,16 +643,16 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     private List<EntityIndex> getManagementIndexes() {
 
         return Arrays.asList(
-                getManagerCache().getEntityIndex( new ApplicationScopeImpl(
-                        new SimpleId( SYSTEM_APP_ID, "application" ) ) ),
+                getManagerCache().getEntityIndex(
+                        new ApplicationScopeImpl( new SimpleId( SYSTEM_APP_ID, "application" ) ) ),
 
                 // default app
-               getManagerCache().getEntityIndex( new ApplicationScopeImpl(
-                        new SimpleId( getManagementAppId(), "application" ) ) ),
+               getManagerCache().getEntityIndex(
+                       new ApplicationScopeImpl( new SimpleId( getManagementAppId(), "application" ) ) ),
 
                 // management app
-               getManagerCache().getEntityIndex( new ApplicationScopeImpl(
-                        new SimpleId( getDefaultAppId(), "application" ) ) ) );
+               getManagerCache().getEntityIndex(
+                       new ApplicationScopeImpl( new SimpleId( getDefaultAppId(), "application" ) ) ) );
     }
 
 
@@ -682,8 +684,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         EntityManager em = getEntityManager( appId );
         Application app = em.getApplication();
 
-        ((CpEntityManager)em).reindex( po );
-        em.refreshIndex();
+        em.reindex( po );
+//        em.refreshIndex();
 
         logger.info("\n\nRebuilt index for application {} id {}\n", app.getName(), appId );
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/163fa9ad/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpVisitor.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpVisitor.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpVisitor.java
index 5d32235..aa06744 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpVisitor.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpVisitor.java
@@ -24,9 +24,12 @@ import org.apache.usergrid.persistence.EntityManager;
  */
 public interface CpVisitor {
 
+    /**
+     * Visit the entity as we're walking the structure
+     * @param em
+     * @param collName
+     * @param visitedEntity
+     */
     public void visitCollectionEntry( 
-        EntityManager em, String collName, Entity sourceEntity, Entity targetEntity );
-
-    public void visitConnectionEntry( 
-        EntityManager em, String connType, Entity sourceEntity, Entity targetEntity );
+        EntityManager em, String collName, Entity visitedEntity );
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/163fa9ad/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
index b507edd..d491d3d 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
@@ -15,12 +15,15 @@
  */
 package org.apache.usergrid.corepersistence;
 
+
 import java.util.Stack;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityRef;
-import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
 import org.apache.usergrid.persistence.SimpleEntityRef;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.graph.Edge;
@@ -30,10 +33,12 @@ import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
 import rx.Observable;
 import rx.functions.Action1;
+import rx.functions.Func1;
+
+import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
 
 
 /**
@@ -43,125 +48,83 @@ public class CpWalker {
 
     private static final Logger logger = LoggerFactory.getLogger( CpWalker.class );
 
-    private long writeDelayMs = 100;
+    private final long writeDelayMs;
+
 
+    /**
+     * Wait the set amount of time between successive writes.
+     * @param writeDelayMs
+     */
+    public CpWalker(final long writeDelayMs){
+         this.writeDelayMs = writeDelayMs;
+    }
 
-    public void walkCollections( final CpEntityManager em, final EntityRef start, 
-            final CpVisitor visitor ) throws Exception {
 
-        Stack stack = new Stack();
-        Id appId = new SimpleId( em.getApplicationId(), TYPE_APPLICATION );
-        stack.push( appId );
+    public void walkCollections( final CpEntityManager em, final EntityRef start, final CpVisitor visitor )
+            throws Exception {
 
-        doWalkCollections(em, new SimpleId(start.getUuid(), start.getType()), visitor, new Stack());
+        doWalkCollections( em, new SimpleId( start.getUuid(), start.getType() ), visitor );
     }
 
 
-    private void doWalkCollections( final CpEntityManager em, final Id start, 
-            final CpVisitor visitor, final Stack stack ) {
+    private void doWalkCollections( final CpEntityManager em, final Id start, final CpVisitor visitor ) {
 
         final Id fromEntityId = new SimpleId( start.getUuid(), start.getType() );
 
         final ApplicationScope applicationScope = em.getApplicationScope();
 
-        final GraphManager gm = em.getManagerCache().getGraphManager(applicationScope);
-
-        logger.debug("Loading edges types from {}:{}\n   scope {}:{}",
-            new Object[] { start.getType(), start.getUuid(),
-                applicationScope.getApplication().getType(),
-                applicationScope.getApplication().getUuid()
-            });
+        final GraphManager gm = em.getManagerCache().getGraphManager( applicationScope );
 
-        Observable<String> edgeTypes = gm.getEdgeTypesFromSource( 
-                new SimpleSearchEdgeType( fromEntityId, null , null ));
+        logger.debug( "Loading edges types from {}:{}\n   scope {}:{}", new Object[] {
+                        start.getType(), start.getUuid(), applicationScope.getApplication().getType(),
+                        applicationScope.getApplication().getUuid()
+                } );
 
-        edgeTypes.forEach( new Action1<String>() {
+        Observable<String> edgeTypes = gm.getEdgeTypesFromSource(
+                new SimpleSearchEdgeType( fromEntityId, CpNamingUtils.EDGE_COLL_SUFFIX, null ) );
 
+        edgeTypes.flatMap( new Func1<String, Observable<Edge>>() {
             @Override
-            public void call( final String edgeType ) {
-
-                try {
-                    Thread.sleep( writeDelayMs );
-                } catch ( InterruptedException ignored ) {}
+            public Observable<Edge> call( final String edgeType ) {
 
-                logger.debug("Loading edges of edgeType {} from {}:{}\n   scope {}:{}",
-                    new Object[] { edgeType, start.getType(), start.getUuid(),
-                        applicationScope.getApplication().getType(),
+                logger.debug( "Loading edges of edgeType {} from {}:{}\n   scope {}:{}", new Object[] {
+                        edgeType, start.getType(), start.getUuid(), applicationScope.getApplication().getType(),
                         applicationScope.getApplication().getUuid()
-                });
+                } );
 
+                return gm.loadEdgesFromSource( new SimpleSearchByEdgeType( fromEntityId, edgeType, Long.MAX_VALUE,
+                                SearchByEdgeType.Order.DESCENDING, null ) );
+            }
+        } ).doOnNext( new Action1<Edge>() {
 
-                Observable<String> edgeTypes = gm.getEdgeTypesFromSource( new SimpleSearchEdgeType(fromEntityId, CpNamingUtils.EDGE_COLL_SUFFIX, null ));
-
-
-
-                Observable<Edge> edges = gm.loadEdgesFromSource( new SimpleSearchByEdgeType( 
-                        fromEntityId, edgeType, Long.MAX_VALUE, 
-                        SearchByEdgeType.Order.DESCENDING, null ));
-
-                edges.forEach( new Action1<Edge>() {
-
-                    @Override
-                    public void call( Edge edge ) {
-
-                        EntityRef sourceEntityRef = new SimpleEntityRef( 
-                            edge.getSourceNode().getType(), edge.getSourceNode().getUuid());
-                        Entity sourceEntity;
-                        try {
-                            sourceEntity = em.get( sourceEntityRef );
-                        } catch (Exception ex) {
-                            logger.error( "Error getting sourceEntity {}:{}, continuing", 
-                                    sourceEntityRef.getType(), sourceEntityRef.getUuid());
-                            return;
-                        }
-
-                        EntityRef targetEntityRef = new SimpleEntityRef( 
-                            edge.getTargetNode().getType(), edge.getTargetNode().getUuid());
-                        Entity targetEntity;
-                        try {
-                            targetEntity = em.get( targetEntityRef );
-                        } catch (Exception ex) {
-                            logger.error( "Error getting sourceEntity {}:{}, continuing", 
-                                    sourceEntityRef.getType(), sourceEntityRef.getUuid());
-                            return;
-                        }
-                            
-                        if ( CpNamingUtils.isCollectionEdgeType( edge.getType() )) {
-
-                            String collName = CpNamingUtils.getCollectionName( edgeType );
-
-                            visitor.visitCollectionEntry( 
-                                    em, collName, sourceEntity, targetEntity );
-
-                            // recursion
-                            if ( !stack.contains( targetEntity.getUuid() )) {
-                                stack.push( targetEntity.getUuid() );
-                                doWalkCollections( em, edge.getSourceNode(), visitor, stack );
-                                stack.pop(); 
-                            }
+            @Override
+            public void call( Edge edge ) {
 
-                        } else {
+                EntityRef sourceEntityRef =
+                        new SimpleEntityRef( edge.getSourceNode().getType(), edge.getSourceNode().getUuid() );
 
-                            String collName = CpNamingUtils.getConnectionType(edgeType);
+                Entity entity;
+                try {
+                    entity = em.get( sourceEntityRef );
+                }
+                catch ( Exception ex ) {
+                    logger.error( "Error getting sourceEntity {}:{}, continuing", sourceEntityRef.getType(),
+                            sourceEntityRef.getUuid() );
+                    return;
+                }
 
-                            visitor.visitConnectionEntry( 
-                                    em, collName, sourceEntity, targetEntity );
 
-                            // recursion
-                            if ( !stack.contains( targetEntity.getUuid() )) {
-                                stack.push( targetEntity.getUuid() );
-                                doWalkCollections( em, edge.getTargetNode(), visitor, stack );
-                                stack.pop(); 
-                            }
-                        }
-                    }
+                String collName = CpNamingUtils.getCollectionName( edge.getType() );
 
-                }); // end foreach on edges
+                visitor.visitCollectionEntry( em, collName, entity );
 
+                try {
+                    Thread.sleep( writeDelayMs );
+                }
+                catch ( InterruptedException e ) {
+                    throw new RuntimeException( "Unable to wait" );
+                }
             }
-
-        }); // end foreach on edgeTypes
-
+        } ).toBlocking().lastOrDefault( null ); // end foreach on edges
     }
-    
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/163fa9ad/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
index 06c3114..e57aa69 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
@@ -131,6 +131,12 @@ public interface EntityManagerFactory {
     public void rebuildCollectionIndex(UUID appId, String collection, ProgressObserver object);
 
     public interface ProgressObserver {
-        public void onProgress( EntityRef source, EntityRef target, String edgeType );
+        public void onProgress( EntityRef entity);
+
+        /**
+         * Get the write delay time from the progress observer.  Used to throttle writes
+         * @return
+         */
+        public long getWriteDelayTime();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/163fa9ad/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index c790f64..51e825b 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -150,6 +150,7 @@ public class CoreApplication implements Application, TestRule {
         id = setup.createApplication( orgName, appName );
         assertNotNull( id );
 
+        setup.getEmf().refreshIndex();
         em = setup.getEmf().getEntityManager( id );
         em.createIndex();
         assertNotNull( em );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/163fa9ad/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index 8de520a..d2f7fef 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -60,14 +60,13 @@ import static org.junit.Assert.fail;
 //@RunWith(JukitoRunner.class)
 //@UseModules({ GuiceModule.class })
 @Concurrent()
-@Ignore("Temporary ignore")
 public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
     private static final Logger logger = LoggerFactory.getLogger(PerformanceEntityRebuildIndexTest.class );
 
     private static final MetricRegistry registry = new MetricRegistry();
     private Slf4jReporter reporter;
 
-    private static final long RUNTIME = TimeUnit.MINUTES.toMillis( 1 );
+    private static final long RUNTIME = TimeUnit.SECONDS.toMillis( 5 );
 
     private static final long writeDelayMs = 100;
     //private static final long readDelayMs = 7;
@@ -192,18 +191,26 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
         EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
             int counter = 0;
             @Override
-            public void onProgress( EntityRef s, EntityRef t, String etype ) {
+               public void onProgress( final EntityRef entity ) {
+
                 meter.mark();
-                logger.debug("Indexing from {}:{} to {}:{} edgeType {}", new Object[] {
-                    s.getType(), s.getUuid(), t.getType(), t.getUuid(), etype });
+                logger.debug("Indexing from {}:{}", entity.getType(), entity.getUuid());
                 if ( !logger.isDebugEnabled() && counter % 100 == 0 ) {
                     logger.info("Reindexed {} entities", counter );
                 }
                 counter++;
             }
+
+
+
+            @Override
+            public long getWriteDelayTime() {
+                return 0;
+            }
         };
 
         try {
+//            setup.getEmf().refreshIndex();
             setup.getEmf().rebuildAllIndexes( po );
 
             registry.remove( meterName );
@@ -236,9 +243,6 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
         eeii.deleteIndex();
     }
 
-    private int readData( String collectionName ) throws Exception {
-        return readData( collectionName, -1 );
-    }
 
     private int readData( String collectionName, int expected ) throws Exception {
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/163fa9ad/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
index ceec656..28a7120 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
@@ -124,11 +124,17 @@ public class SystemResource extends AbstractContextResource {
 
 
         final ProgressObserver po = new ProgressObserver() {
+
+
+            @Override
+            public void onProgress( final EntityRef entity ) {
+                logger.info( "Indexing from {}:{} ", entity.getType(), entity.getUuid() );
+            }
+
+
             @Override
-            public void onProgress( EntityRef s, EntityRef t, String etype ) {
-                logger.info( "Indexing from {}:{} to {}:{} edgeType {}", new Object[] {
-                        s.getType(), s.getUuid(), t.getType(), t.getUuid(), etype
-                } );
+            public long getWriteDelayTime() {
+                return 0;
             }
         };
 
@@ -168,7 +174,8 @@ public class SystemResource extends AbstractContextResource {
     public JSONWithPadding rebuildIndexes( 
                 @Context UriInfo ui, 
                 @PathParam( "applicationId" ) String applicationIdStr,
-                @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+                @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
+                @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay)
 
             throws Exception {
 
@@ -177,14 +184,6 @@ public class SystemResource extends AbstractContextResource {
         response.setAction( "rebuild indexes" );
 
 
-        final ProgressObserver po = new ProgressObserver() {
-            @Override
-            public void onProgress( EntityRef s, EntityRef t, String etype ) {
-                logger.info( "Indexing from {}:{} to {}:{} edgeType {}", new Object[] {
-                        s.getType(), s.getUuid(), t.getType(), t.getUuid(), etype
-                } );
-            }
-        };
 
 
         final EntityManager em = emf.getEntityManager( appId );
@@ -199,7 +198,7 @@ public class SystemResource extends AbstractContextResource {
 
 
                 {
-                    rebuildCollection( appId, collectionName );
+                    rebuildCollection( appId, collectionName, delay );
                 }
             }
         };
@@ -221,7 +220,8 @@ public class SystemResource extends AbstractContextResource {
                 @Context UriInfo ui,
                 @PathParam( "applicationId" ) final String applicationIdStr,
                 @PathParam( "collectionName" ) final String collectionName,
-                @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+                @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
+                @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
             throws Exception {
 
         final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
@@ -232,7 +232,7 @@ public class SystemResource extends AbstractContextResource {
 
             public void run() {
 
-                rebuildCollection( appId, collectionName );
+                rebuildCollection( appId, collectionName, delay );
             }
         };
 
@@ -247,13 +247,18 @@ public class SystemResource extends AbstractContextResource {
     }
 
 
-    private void rebuildCollection( final UUID applicationId, final String collectionName ) {
+    private void rebuildCollection( final UUID applicationId, final String collectionName, final long delay ) {
         EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
+
+            @Override
+            public void onProgress( final EntityRef entity ) {
+                logger.info( "Indexing from {}:{} to {}:{} edgeType {}", entity.getType(), entity.getUuid());
+            }
+
+
             @Override
-            public void onProgress( EntityRef s, EntityRef t, String etype ) {
-                logger.info( "Indexing from {}:{} to {}:{} edgeType {}", new Object[] {
-                        s.getType(), s.getUuid(), t.getType(), t.getUuid(), etype
-                } );
+            public long getWriteDelayTime() {
+                return delay;
             }
         };
 


[03/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into 2.0


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

Branch: refs/heads/two-dot-o
Commit: 231b674ef2bb95ce2263b3e7c2e79a163f5712c2
Parents: 804e8be b644cc0
Author: amuramoto <am...@apigee.com>
Authored: Thu Oct 2 09:08:03 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Thu Oct 2 09:08:03 2014 -0700

----------------------------------------------------------------------
 .../CpEntityIndexDeleteListener.java            |  11 +-
 .../corepersistence/CpEntityManager.java        | 239 +++----
 .../corepersistence/CpEntityManagerFactory.java |  29 +-
 .../corepersistence/CpManagerCache.java         |  12 +-
 .../usergrid/corepersistence/CpNamingUtils.java | 106 ++++
 .../corepersistence/CpRelationManager.java      | 229 +++----
 .../CpEntityIndexDeleteListenerTest.java        |  18 +-
 .../PerformanceEntityRebuildIndexTest.java      |   7 +-
 .../collection/impl/CollectionScopeImpl.java    |   6 +-
 .../core/scope/ApplicationScopeImpl.java        |   6 +-
 .../serialization/EdgeSerializationTest.java    |   3 +
 .../usergrid/persistence/index/EntityIndex.java |  38 +-
 .../persistence/index/EntityIndexBatch.java     |  71 +++
 .../persistence/index/EntityIndexFactory.java   |   4 +-
 .../usergrid/persistence/index/IndexScope.java  |   2 +-
 .../index/impl/EsEntityIndexBatchImpl.java      | 396 ++++++++++++
 .../index/impl/EsEntityIndexImpl.java           | 628 ++++---------------
 .../persistence/index/impl/EsQueryVistor.java   |  35 +-
 .../persistence/index/impl/IndexScopeImpl.java  |   8 +-
 .../persistence/index/impl/IndexingUtils.java   | 107 ++++
 .../index/utils/IndexValidationUtils.java       |   3 +-
 .../index/impl/CorePerformanceIT.java           |  97 +--
 .../impl/EntityConnectionIndexImplTest.java     |  16 +-
 .../persistence/index/impl/EntityIndexTest.java | 144 +++--
 stack/pom.xml                                   |   2 +-
 .../apache/usergrid/rest/PartialUpdateTest.java |   9 +-
 26 files changed, 1259 insertions(+), 967 deletions(-)
----------------------------------------------------------------------



[02/49] git commit: Removed unnecessary refreshIndex from cpEntityManager.update()

Posted by to...@apache.org.
Removed unnecessary refreshIndex from cpEntityManager.update()


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

Branch: refs/heads/two-dot-o
Commit: 804e8be5a5f8b6223b24c524e6768edadc911750
Parents: aa2b1da
Author: amuramoto <am...@apigee.com>
Authored: Wed Oct 1 23:57:37 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Wed Oct 1 23:57:37 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/usergrid/corepersistence/CpEntityManager.java   | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/804e8be5/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 61e43e2..f24a9a9 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
@@ -568,7 +568,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[] { 


[17/49] git commit: more cloudformation updates

Posted by to...@apache.org.
more cloudformation updates


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

Branch: refs/heads/two-dot-o
Commit: 59fed6a1ac56f627c29eb54112649700124b523e
Parents: dd4f117
Author: amuramoto <am...@apigee.com>
Authored: Sun Oct 12 03:42:58 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Sun Oct 12 03:42:58 2014 -0700

----------------------------------------------------------------------
 .../src/main/dist/init_instance/install_elasticsearch.sh         | 4 ++--
 stack/awscluster/ugcluster-cf.json                               | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59fed6a1/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh b/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
index dc7ee8f..d6e4285 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
@@ -39,8 +39,8 @@ chown elasticsearch /mnt/log/elasticsearch
 cd /usr/share/usergrid/scripts
 
 # No need to do this, elasticsearch nodes are also cassandra nodes
-#groovy registry_register.groovy elasticsearch
-#groovy wait_for_instances.groovy elasticsearch ${CASSANDRA_NUM_SERVERS}
+groovy registry_register.groovy elasticsearch
+groovy wait_for_instances.groovy elasticsearch ${ES_NUM_SERVERS}
 
 # leave room for Cassandra: use about one half of RAM for heap
 case `(curl http://169.254.169.254/latest/meta-data/instance-type)` in

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/59fed6a1/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index 197eb6c..93c7e86 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -668,6 +668,7 @@
                         "export ES_SECURITY_GROUP_NAME=", { "Ref":"ESSecurityGroup" }, "\n",
                         "\n",
                         "\n",
+                        "export ES_CLUSTER_NAME=", { "Ref":"CassClusterName" }, "\n",
                         "export ES_NUM_SERVERS=", { "Ref":"ESNumServers" }, "\n",
                         "export GRAPHITE_NUM_SERVERS=", { "Ref":"GraphiteNumServers" }, "\n",
                         "\n",


[12/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into cloudformation-update

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into cloudformation-update


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

Branch: refs/heads/two-dot-o
Commit: e64e9c928da76d91cb320c3f820962f9cbd85f2f
Parents: 112661a 693cb2d
Author: amuramoto <am...@apigee.com>
Authored: Fri Oct 10 12:35:52 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Fri Oct 10 12:35:52 2014 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/usergrid/services/ServiceManager.java  | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[44/49] git commit: Added logging

Posted by to...@apache.org.
Added logging


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

Branch: refs/heads/two-dot-o
Commit: 83200bf52f276c89f4351cf6fc8988414646507a
Parents: c31c553
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 19:29:01 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 19:30:08 2014 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/index/impl/EsEntityIndexImpl.java      | 5 ++++-
 .../services/notifications/AbstractServiceNotificationIT.java   | 4 ----
 2 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/83200bf5/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 821f7b9..b562d8a 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -88,7 +88,9 @@ public class EsEntityIndexImpl implements EntityIndex {
 
     private final IndexFig config;
 
-    private static final int MAX_WAITS = 10;
+    //number of times to wait for the index to refresh propertly. Is an N+1, so 9 = 10
+    private static final int MAX_WAITS = 9;
+    //number of milliseconds to try again before sleeping
     private static final int WAIT_TIME = 250;
 
 
@@ -280,6 +282,7 @@ public class EsEntityIndexImpl implements EntityIndex {
         for ( int i = 0; i < MAX_WAITS; i++ ) {
             try {
                 client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+                log.debug( "Refreshed index: " + indexName );
                 return;
             }
             catch ( IndexMissingException e ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/83200bf5/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
index e16f111..a9ca955 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
@@ -41,11 +41,7 @@ import static org.junit.Assert.fail;
 
 public class AbstractServiceNotificationIT extends AbstractServiceIT {
     private NotificationsService ns;
-    @Autowired
-    private ServiceManagerFactory smf;
 
-    @Autowired
-    private EntityManagerFactory emf;
     @Rule
     public TestName name = new TestName();
 


[21/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into cloudformation-update

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into cloudformation-update


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

Branch: refs/heads/two-dot-o
Commit: 25770fee8b92e705a694548a2792256c72c29063
Parents: ad45789 c88282b
Author: amuramoto <am...@apigee.com>
Authored: Mon Oct 13 13:50:41 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Mon Oct 13 13:50:41 2014 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |  9 +++--
 .../corepersistence/CpEntityManagerFactory.java | 13 ++++---
 .../corepersistence/CpRelationManager.java      |  2 ++
 .../results/FilteringLoader.java                | 13 +++++--
 .../PerformanceEntityRebuildIndexTest.java      |  2 ++
 .../query/AbstractIteratingQueryIT.java         |  3 ++
 .../persistence/index/impl/IndexScopeImpl.java  | 37 ++++++++++++++++++++
 .../queue/impl/SQSQueueManagerImpl.java         | 12 +++++--
 .../usergrid/services/TestQueueManager.java     |  4 +--
 .../notifications/NotifiersServiceIT.java       |  1 +
 10 files changed, 82 insertions(+), 14 deletions(-)
----------------------------------------------------------------------



[45/49] git commit: Added verification to init to catch NPE issues

Posted by to...@apache.org.
Added verification to init to catch NPE issues

Updated index creation to write a document and delete to verify correct functionality


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

Branch: refs/heads/two-dot-o
Commit: 722c43b731a80c810916a09af8e50c19ac7c6891
Parents: 83200bf
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 20:53:59 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 20:53:59 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |  20 +--
 .../usergrid/persistence/EntityManager.java     |   2 +-
 .../index/impl/EsEntityIndexImpl.java           | 144 ++++++++++++++-----
 3 files changed, 121 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/722c43b7/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 2498dda..751b9e2 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
@@ -16,6 +16,7 @@
 package org.apache.usergrid.corepersistence;
 
 
+import com.google.common.base.Preconditions;
 import com.netflix.hystrix.exception.HystrixRuntimeException;
 import com.yammer.metrics.annotation.Metered;
 import static java.lang.String.CASE_INSENSITIVE_ORDER;
@@ -191,6 +192,9 @@ public class CpEntityManager implements EntityManager {
     @Override
     public void init( EntityManagerFactory emf, UUID applicationId ) {
 
+        Preconditions.checkNotNull(emf, "emf must not be null");
+        Preconditions.checkNotNull( applicationId, "applicationId must not be null"  );
+
         this.emf = ( CpEntityManagerFactory ) emf;
         this.managerCache = this.emf.getManagerCache();
         this.applicationId = applicationId;
@@ -202,9 +206,6 @@ public class CpEntityManager implements EntityManager {
 
         // set to false for now
         this.skipAggregateCounters = false;
-
-
-        applicationScope = this.emf.getApplicationScope( applicationId );
     }
 
 
@@ -643,11 +644,11 @@ public class CpEntityManager implements EntityManager {
         return getRelationManager( entityRef ).searchCollection( collectionName, query );
     }
 
-
-    @Override
-    public void setApplicationId( UUID applicationId ) {
-        this.applicationId = applicationId;
-    }
+//
+//    @Override
+//    public void setApplicationId( UUID applicationId ) {
+//        this.applicationId = applicationId;
+//    }
 
 
     @Override
@@ -2884,7 +2885,8 @@ public class CpEntityManager implements EntityManager {
                 }
                 catch(WriteOptimisticVerifyException wo ){
                     //swallow this, it just means this was already updated, which accomplishes our task.  Just ignore.
-                    logger.warn( "Someone beat us to updating entity {} in collection {}.  Ignoring.", entity.getName(), collName );
+                    logger.warn( "Someone beat us to updating entity {} in collection {}.  Ignoring.", entity.getName(),
+                            collName );
                 }
                 catch (Exception ex) {
                     logger.error("Error repersisting entity", ex);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/722c43b7/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
index 3684d7e..cd92729 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
@@ -41,7 +41,7 @@ import org.apache.usergrid.persistence.index.query.Query.Level;
  */
 public interface EntityManager {
 
-    public void setApplicationId( UUID applicationId );
+//    public void setApplicationId( UUID applicationId );
 
     public GeoIndexManager getGeoIndexManager();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/722c43b7/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index b562d8a..7584386 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -26,7 +26,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
 import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
-import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
 import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.elasticsearch.action.search.SearchResponse;
@@ -36,7 +35,9 @@ import org.elasticsearch.client.Client;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentFactory;
 import org.elasticsearch.index.query.FilterBuilder;
+import org.elasticsearch.index.query.MatchAllQueryBuilder;
 import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.indices.IndexAlreadyExistsException;
 import org.elasticsearch.indices.IndexMissingException;
 import org.elasticsearch.search.SearchHit;
@@ -58,7 +59,9 @@ import org.apache.usergrid.persistence.index.query.CandidateResults;
 import org.apache.usergrid.persistence.index.query.Query;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
+import com.google.common.collect.ImmutableMap;
 import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
 
@@ -88,11 +91,18 @@ public class EsEntityIndexImpl implements EntityIndex {
 
     private final IndexFig config;
 
-    //number of times to wait for the index to refresh propertly. Is an N+1, so 9 = 10
-    private static final int MAX_WAITS = 9;
+    //number of times to wait for the index to refresh properly.
+    private static final int MAX_WAITS = 10;
     //number of milliseconds to try again before sleeping
     private static final int WAIT_TIME = 250;
 
+    private static final String VERIFY_TYPE = "verification";
+
+    private static final ImmutableMap<String, Object> DEFAULT_PAYLOAD =
+            ImmutableMap.<String, Object>of( "field", "test" );
+
+    private static final MatchAllQueryBuilder MATCH_ALL_QUERY_BUILDER = QueryBuilders.matchAllQuery();
+
 
     @Inject
     public EsEntityIndexImpl( @Assisted final ApplicationScope appScope, final IndexFig config,
@@ -120,21 +130,16 @@ public class EsEntityIndexImpl implements EntityIndex {
             CreateIndexResponse cir = admin.indices().prepareCreate( indexName ).execute().actionGet();
             log.info( "Created new Index Name [{}] ACK=[{}]", indexName, cir.isAcknowledged() );
 
-            RefreshResponse response;
-
-            do {
-                response = admin.indices().prepareRefresh( indexName ).execute().actionGet();
-            }
-            while ( response.getFailedShards() != 0 );
 
+            //create the document, this ensures the index is ready
             /**
-             * Immediately refresh to ensure the entire cluster is ready to receive this write.  Occasionally we see
+             * Immediately create a document and remove it to ensure the entire cluster is ready to receive documents
+             * .  Occasionally we see
              * errors.  See this post.
-             * http://elasticsearch-users.115913.n3.nabble
-             * .com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
+             * http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
              *
              */
-            refresh();
+            testNewIndex();
         }
         catch ( IndexAlreadyExistsException expected ) {
             // this is expected to happen if index already exists, it's a no-op and swallow
@@ -146,6 +151,44 @@ public class EsEntityIndexImpl implements EntityIndex {
 
 
     /**
+     * Tests writing a document to a new index to ensure it's working correctly.  Comes from email
+     *
+     * http://elasticsearch-users.115913.n3.nabble
+     * .com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
+     */
+
+    private void testNewIndex() {
+
+
+        log.info( "Refreshing Created new Index Name [{}]", indexName );
+
+        final RetryOperation retryOperation = new RetryOperation() {
+            @Override
+            public boolean doOp() {
+                final String tempId = UUIDGenerator.newTimeUUID().toString();
+
+
+                client.prepareIndex( indexName, VERIFY_TYPE, tempId ).setSource( DEFAULT_PAYLOAD ).get();
+
+                log.info( "Successfully created new document with docId {} in index {} and type {}", tempId, indexName,
+                        VERIFY_TYPE );
+
+                //delete all types, this way if we miss one it will get cleaned up
+
+                client.prepareDeleteByQuery( indexName ).setTypes( VERIFY_TYPE ).setQuery( MATCH_ALL_QUERY_BUILDER )
+                      .get();
+
+                log.info( "Successfully deleted all documents in index {} and type {}", indexName, VERIFY_TYPE );
+
+                return true;
+            }
+        };
+
+        doInRetry( retryOperation );
+    }
+
+
+    /**
      * Setup ElasticSearch type mappings as a template that applies to all new indexes. Applies to all indexes that
      * start with our prefix.
      */
@@ -277,30 +320,22 @@ public class EsEntityIndexImpl implements EntityIndex {
 
         log.info( "Refreshing Created new Index Name [{}]", indexName );
 
-        //now try to refresh, to ensure that it's recognized by everyone.  Occasionally we can get a success
-        //before we can write.
-        for ( int i = 0; i < MAX_WAITS; i++ ) {
-            try {
-                client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
-                log.debug( "Refreshed index: " + indexName );
-                return;
-            }
-            catch ( IndexMissingException e ) {
-                log.error( "Unable to refresh index after create. Waiting before sleeping.", e );
-            }
-
-            try {
-                Thread.sleep( WAIT_TIME );
-            }
-            catch ( InterruptedException e ) {
-                //swallow it
+        final RetryOperation retryOperation = new RetryOperation() {
+            @Override
+            public boolean doOp() {
+                try {
+                    client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+                    log.debug( "Refreshed index: " + indexName );
+                    return true;
+                }
+                catch ( IndexMissingException e ) {
+                    log.error( "Unable to refresh index after create. Waiting before sleeping.", e );
+                    throw e;
+                }
             }
-        }
+        };
 
-        /**
-         * Try the refresh one last time if we get here
-         */
-        client.admin().indices().prepareRefresh( indexName ).execute().actionGet();
+        doInRetry( retryOperation );
 
         log.debug( "Refreshed index: " + indexName );
     }
@@ -328,4 +363,43 @@ public class EsEntityIndexImpl implements EntityIndex {
             log.info( "Failed to delete index " + indexName );
         }
     }
+
+
+    /**
+     * Do the retry operation
+     * @param operation
+     */
+    private void doInRetry( final RetryOperation operation ) {
+        for ( int i = 0; i < MAX_WAITS; i++ ) {
+
+            try {
+                if(operation.doOp()){
+                    return;
+                }
+            }
+            catch ( Exception e ) {
+                log.error( "Unable to execute operation, retrying", e );
+            }
+
+
+            try {
+                Thread.sleep( WAIT_TIME );
+            }
+            catch ( InterruptedException e ) {
+                //swallow it
+            }
+        }
+    }
+
+
+    /**
+     * Interface for operations
+     */
+    private static interface RetryOperation {
+
+        /**
+         * Return true if done, false if there should be a retry
+         */
+        public boolean doOp();
+    }
 }


[14/49] git commit: Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into cloudformation-update

Posted by to...@apache.org.
Merge branch 'two-dot-o' of github.com:apache/incubator-usergrid into cloudformation-update


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

Branch: refs/heads/two-dot-o
Commit: 7f731fb013864956259b6f01c353e8eea34fe35c
Parents: 83fccdd 5d0ad62
Author: amuramoto <am...@apigee.com>
Authored: Fri Oct 10 17:38:08 2014 -0700
Committer: amuramoto <am...@apigee.com>
Committed: Fri Oct 10 17:38:08 2014 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        | 121 +++-------
 .../corepersistence/CpEntityManagerFactory.java |  22 --
 .../corepersistence/CpRelationManager.java      |   3 +-
 .../usergrid/corepersistence/CpVisitor.java     |   8 +-
 .../usergrid/corepersistence/CpWalker.java      | 149 +++---------
 .../HybridEntityManagerFactory.java             |  10 -
 .../corepersistence/results/EntityVerifier.java |   3 +-
 .../results/FilteringLoader.java                |  23 +-
 .../results/VersionVerifier.java                |   5 +-
 .../usergrid/persistence/EntityManager.java     |   3 -
 .../persistence/EntityManagerFactory.java       |   4 -
 .../cassandra/EntityManagerFactoryImpl.java     |  10 -
 .../cassandra/EntityManagerImpl.java            |   7 +-
 .../usergrid/batch/job/SchedulerRuntime8IT.java |   3 +
 .../PerformanceEntityRepersistTest.java         | 236 -------------------
 .../impl/EntityCollectionManagerImpl.java       |  36 +--
 .../mvcc/stage/write/WriteCommit.java           |   2 +-
 .../collection/mvcc/stage/write/WriteStart.java |   7 +-
 .../serialization/impl/FieldSerializer.java     |   3 +-
 .../MvccEntitySerializationStrategyImpl.java    |   2 +-
 .../UniqueValueSerializationStrategyImpl.java   |   6 +-
 .../collection/EntityCollectionManagerIT.java   | 139 +++++++++--
 ...niqueValueSerializationStrategyImplTest.java |  63 ++++-
 .../index/impl/EsEntityIndexBatchImpl.java      |   2 +-
 stack/pom.xml                                   |   4 +-
 .../apache/usergrid/rest/SystemResource.java    |  30 ++-
 .../cassandra/ManagementServiceIT.java          |   2 +-
 .../src/test/resources/log4j.properties         |   4 +
 .../org/apache/usergrid/tools/RepersistAll.java |  98 --------
 29 files changed, 327 insertions(+), 678 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7f731fb0/stack/pom.xml
----------------------------------------------------------------------


[24/49] git commit: Removed unused script

Posted by to...@apache.org.
Removed unused script


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

Branch: refs/heads/two-dot-o
Commit: 6c8a7f558061398de3b7f8d91c0be94b6446d727
Parents: aca79b6
Author: Todd Nine <to...@apache.org>
Authored: Tue Oct 14 17:01:45 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Tue Oct 14 17:01:45 2014 -0600

----------------------------------------------------------------------
 .../src/main/dist/init_instance/init_cass.sh    | 70 --------------------
 1 file changed, 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6c8a7f55/stack/awscluster/src/main/dist/init_instance/init_cass.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_cass.sh b/stack/awscluster/src/main/dist/init_instance/init_cass.sh
deleted file mode 100644
index 9c6696a..0000000
--- a/stack/awscluster/src/main/dist/init_instance/init_cass.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/bash
-#
-#  Licensed to the Apache Software Foundation (ASF) under one or more
-#   contributor license agreements.  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.  For additional information regarding
-#  copyright in this work, please see the NOTICE file in the top level
-#  directory of this distribution.
-#
-
-echo "${HOSTNAME}" > /etc/hostname
-echo "127.0.0.1 ${HOSTNAME}" >> /etc/hosts
-hostname `cat /etc/hostname`
-
-echo "US/Eastern" > /etc/timezone
-dpkg-reconfigure -f noninteractive tzdata
-
-PKGS="openjdk-7-jdk s3cmd ntp unzip groovy"
-apt-get update
-apt-get -y install ${PKGS}
-
-# Install AWS Java SDK and get it into the Groovy classpath
-curl http://sdk-for-java.amazonwebservices.com/latest/aws-java-sdk.zip > /tmp/aws-sdk-java.zip
-cd /usr/share/
-unzip /tmp/aws-sdk-java.zip 
-mkdir -p /home/ubuntu/.groovy/lib
-cp /usr/share/aws-java-sdk-*/third-party/*/*.jar /home/ubuntu/.groovy/lib
-cp /usr/share/aws-java-sdk-*/lib/* /home/ubuntu/.groovy/lib 
-# except for evil stax
-rm /home/ubuntu/.groovy/lib/stax*
-ln -s /home/ubuntu/.groovy /root/.groovy
-
-# Build environment for Groovy scripts
-. /etc/profile.d/aws-credentials.sh
-. /etc/profile.d/usergrid-env.sh
-
-
-
-# Register as a Cassandra node and wait for enough other servers to join
-cd /usr/share/usergrid/scripts
-
-groovy registry_register.groovy
-groovy wait_for_cassandra.groovy
-
-# Install and stop Cassandra so we can configure it
-cd /etc/apt/sources.list.d
-cat >> cassandra.sources.list << EOF
-deb http://www.apache.org/dist/cassandra/debian 12x main
-EOF
-sudo apt-get update
-sudo apt-get -y install libcap2
-sudo apt-get --force-yes -y install cassandra
-/etc/init.d/cassandra stop
-
-cd /usr/share/usergrid/init_instance
-cd /usr/share/usergrid/scripts
-groovy configure_cassandra.groovy > /etc/cassandra/cassandra.yaml
-
-# Go
-/etc/init.d/cassandra start
-


[43/49] git commit: Fixed index refresh issue.

Posted by to...@apache.org.
Fixed index refresh issue.

Fixed source/target switch on entity rebuild

Added performance comments as encountered


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

Branch: refs/heads/two-dot-o
Commit: c31c553f9b3c16deda28fc0125d5b1a86a654d14
Parents: f807627
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 18:22:05 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 18:22:05 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |    6 +-
 .../corepersistence/CpEntityManagerFactory.java |   13 +-
 .../corepersistence/CpRelationManager.java      | 1427 ++++++++----------
 .../usergrid/corepersistence/CpWalker.java      |   11 +-
 .../PerformanceEntityRebuildIndexTest.java      |    3 +-
 .../index/impl/EsEntityIndexImpl.java           |   44 +-
 6 files changed, 692 insertions(+), 812 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c31c553f/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 4015014..2498dda 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
@@ -514,7 +514,7 @@ public class CpEntityManager implements EntityManager {
 
         // update in all containing collections and connection indexes
         CpRelationManager rm = (CpRelationManager)getRelationManager( entity );
-        rm.updateContainingCollectionAndCollectionIndexes( entity, cpEntity );
+        rm.updateContainingCollectionAndCollectionIndexes( cpEntity );
     }
 
 
@@ -995,7 +995,7 @@ public class CpEntityManager implements EntityManager {
 //        }
 
         org.apache.usergrid.persistence.model.entity.Entity cpEntity =
-                ecm.load( entityId ).toBlockingObservable().last();
+                ecm.load( entityId ).toBlocking().last();
 
         cpEntity.removeField( propertyName );
 
@@ -1012,7 +1012,7 @@ public class CpEntityManager implements EntityManager {
 
         // update in all containing collections and connection indexes
         CpRelationManager rm = (CpRelationManager)getRelationManager( entityRef );
-        rm.updateContainingCollectionAndCollectionIndexes( get( entityRef ), cpEntity );
+        rm.updateContainingCollectionAndCollectionIndexes( cpEntity );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c31c553f/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 2514e20..e013957 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
@@ -147,6 +147,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
                 sysAppProps.put( PROPERTY_NAME, "systemapp");
                 em.create( SYSTEM_APP_ID, TYPE_APPLICATION, sysAppProps );
                 em.getApplication();
+                em.createIndex();
                 em.refreshIndex();
             }
 
@@ -200,7 +201,10 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     private EntityManager _getEntityManager( UUID applicationId ) {
         EntityManager em = new CpEntityManager();
         em.init( this, applicationId );
-        //TODO T.N. Can we remove this?  Seems like we should fix our lifecycle instead...
+        //TODO PERFORMANCE  Can we remove this?  Seems like we should fix our lifecycle instead...
+        //if this is the first time we've loaded this entity manager in the JVM, create it's indexes, it may be new
+        //not sure how to handle other than this if the system dies after the application em has been created
+        //but before the create call can create the index
         em.createIndex();
         return em;
     }
@@ -286,7 +290,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         EntityManager appEm = getEntityManager( applicationId );
 
         //create our ES index since we're initializing this application
-//  TODO T.N, pushed this down into the cache load      appEm.createIndex();
+//  TODO PERFORMANCE  pushed this down into the cache load can we do this here?
+//        appEm.createIndex();
 
         appEm.create( applicationId, TYPE_APPLICATION, properties );
         appEm.resetRoles();
@@ -681,10 +686,12 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     public void rebuildApplicationIndexes( UUID appId, ProgressObserver po ) throws Exception {
 
         EntityManager em = getEntityManager( appId );
+
+        //explicitly invoke create index, we don't know if it exists or not in ES during a rebuild.
+        em.createIndex();
         Application app = em.getApplication();
 
         em.reindex( po );
-//        em.refreshIndex();
 
         logger.info("\n\nRebuilt index for application {} id {}\n", app.getName(), appId );
     }


[28/49] git commit: Fixes region string

Posted by to...@apache.org.
Fixes region string


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

Branch: refs/heads/two-dot-o
Commit: f98ed25366845432b29909c8af73d3dcca1c9b5e
Parents: b0d1605
Author: Todd Nine <to...@apache.org>
Authored: Wed Oct 15 13:32:19 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Wed Oct 15 13:32:19 2014 -0600

----------------------------------------------------------------------
 .../src/main/dist/init_instance/create_keyspaces.sh       | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f98ed253/stack/awscluster/src/main/dist/init_instance/create_keyspaces.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/create_keyspaces.sh b/stack/awscluster/src/main/dist/init_instance/create_keyspaces.sh
index f2ebe8f..5cf0f7f 100644
--- a/stack/awscluster/src/main/dist/init_instance/create_keyspaces.sh
+++ b/stack/awscluster/src/main/dist/init_instance/create_keyspaces.sh
@@ -29,8 +29,12 @@ FIRSTHOST="$(groovy get_first_instance.groovy cassandra)"
 if [ "$FIRSTHOST"=="$PUBLIC_HOSTNAME" ]; then
 
 
+#WE have to remove our -1 from the end, since us-east and us-west dont support -1 in cassandra
+CASS_REGION=${EC2_REGION%-1}
+
+
 #Update the keyspace replication and run the cql
-sed -i.bak "s/KEYSPACE_REGION/${EC2_REGION}/g" /usr/share/usergrid/cql/create_locks.cql
+sed -i.bak "s/KEYSPACE_REGION/${CASS_REGION}/g" /usr/share/usergrid/cql/create_locks.cql
 
 /usr/bin/cassandra-cli -f  /usr/share/usergrid/cql/create_locks.cql
 
@@ -38,7 +42,7 @@ sed -i.bak "s/KEYSPACE_REGION/${EC2_REGION}/g" /usr/share/usergrid/cql/create_lo
 
 
 #Update the keyspace region and run the cql
-sed -i.bak "s/KEYSPACE_REGION/${EC2_REGION}/g" /usr/share/usergrid/cql/create_usergrid.cql
+sed -i.bak "s/KEYSPACE_REGION/${CASS_REGION}/g" /usr/share/usergrid/cql/create_usergrid.cql
 
 /usr/bin/cassandra-cli -f  /usr/share/usergrid/cql/create_usergrid.cql
 
@@ -46,7 +50,7 @@ sed -i.bak "s/KEYSPACE_REGION/${EC2_REGION}/g" /usr/share/usergrid/cql/create_us
 
 
 #Update the keyspace region and run the cql
-sed -i.bak "s/KEYSPACE_REGION/${EC2_REGION}/g" /usr/share/usergrid/cql/create_usergrid_applications.cql
+sed -i.bak "s/KEYSPACE_REGION/${CASS_REGION}/g" /usr/share/usergrid/cql/create_usergrid_applications.cql
 
 /usr/bin/cassandra-cli -f  /usr/share/usergrid/cql/create_usergrid_applications.cql
 


[23/49] git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into cloudformation-update

Posted by to...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into cloudformation-update


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

Branch: refs/heads/two-dot-o
Commit: aca79b63f26ac6da13b9a64a7832f6ab2d264896
Parents: 4381884 27db106
Author: Todd Nine <to...@apache.org>
Authored: Tue Oct 14 15:00:11 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Tue Oct 14 15:00:11 2014 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/queue/impl/SQSQueueManagerImpl.java    | 2 +-
 .../services/notifications/ApplicationQueueManager.java         | 5 +++--
 .../usergrid/services/notifications/NotificationsService.java   | 2 +-
 .../apache/usergrid/services/notifications/QueueListener.java   | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[33/49] git commit: Merge branch 'two-dot-o' into cloudformation-update

Posted by to...@apache.org.
Merge branch 'two-dot-o' into cloudformation-update


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

Branch: refs/heads/two-dot-o
Commit: c920eca03621a7cf94d75d105be1e46418cd6464
Parents: c9ac3e2 dbdba30
Author: Todd Nine <to...@apache.org>
Authored: Wed Oct 15 22:30:48 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Wed Oct 15 22:30:48 2014 -0600

----------------------------------------------------------------------
 .../main/java/org/apache/usergrid/corepersistence/CpSetup.java    | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------



[35/49] git commit: Merge branch 'two-dot-o' into cloudformation-update

Posted by to...@apache.org.
Merge branch 'two-dot-o' into cloudformation-update


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

Branch: refs/heads/two-dot-o
Commit: 704c09d7865edfa7914e39a5a0324bca78803932
Parents: 0ddecd1 9da529b
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 09:50:47 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 09:50:47 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |  6 ++---
 .../services/devices/DevicesService.java        | 28 ++++++++++++--------
 .../services/users/devices/DevicesService.java  |  8 +++---
 .../apns/NotificationsServiceIT.java            |  5 +++-
 4 files changed, 28 insertions(+), 19 deletions(-)
----------------------------------------------------------------------



[29/49] git commit: Merge branch 'two-dot-o' into cloudformation-update

Posted by to...@apache.org.
Merge branch 'two-dot-o' into cloudformation-update


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

Branch: refs/heads/two-dot-o
Commit: 52e10ee3ec7f16263807e0da13f30f26a7648ff0
Parents: f98ed25 3b12766
Author: Todd Nine <to...@apache.org>
Authored: Wed Oct 15 13:51:21 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Wed Oct 15 13:51:21 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      |  10 +-
 .../services/devices/DevicesService.java        |  49 +++++-
 .../notifications/NotificationsService.java     |   5 +-
 .../services/users/devices/DevicesService.java  |  33 ++++
 .../AbstractServiceNotificationIT.java          |   6 +-
 .../apns/NotificationsServiceIT.java            | 169 ++++++++++---------
 .../gcm/NotificationsServiceIT.java             | 153 ++---------------
 7 files changed, 188 insertions(+), 237 deletions(-)
----------------------------------------------------------------------