You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/03/15 17:20:45 UTC

[1/4] git commit: Adding support for REST instance.

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o 4ba3650c5 -> 6979ae6bf


Adding support for REST instance.


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

Branch: refs/heads/two-dot-o
Commit: 28bb791fc3eb3bd092546ea251e1777d3c4008c6
Parents: 4ba3650
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Mar 14 08:37:40 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Mar 14 08:37:40 2014 -0400

----------------------------------------------------------------------
 stack/awscluster/pom.xml                        |   6 +-
 .../main/dist/init_instance/init_db_server.sh   |  54 ++
 .../main/dist/init_instance/init_rest_server.sh |  41 ++
 .../dist/init_instance/install_cassandra.sh     |  63 +-
 stack/awscluster/src/main/dist/update.sh        |  16 +
 .../src/main/groovy/configure_cassandra.groovy  |   2 +-
 .../src/main/groovy/configure_portal_new.groovy |  17 +
 .../src/main/groovy/configure_usergrid.groovy   | 126 ++++
 stack/awscluster/ugcluster-cf.json              | 647 +++++++++++++++++++
 9 files changed, 938 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28bb791f/stack/awscluster/pom.xml
----------------------------------------------------------------------
diff --git a/stack/awscluster/pom.xml b/stack/awscluster/pom.xml
index 358f24e..9362f9f 100644
--- a/stack/awscluster/pom.xml
+++ b/stack/awscluster/pom.xml
@@ -2,16 +2,16 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>priamcluster</artifactId>
+    <artifactId>awscluster</artifactId>
     <groupId>org.usergrid</groupId>
     <version>1.0-SNAPSHOT</version>
 
-    <name>priamcluster</name>
+    <name>awscluster</name>
     <description>Creates bundle for initializing a Cassandra and Priam cluster via CloudFormation</description>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <aws.s3.release-bucket>ug-cloudformation-priam</aws.s3.release-bucket>
+        <aws.s3.release-bucket>ug-cloudformation</aws.s3.release-bucket>
     </properties>
 
     <build>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28bb791f/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
new file mode 100644
index 0000000..4c2e8c6
--- /dev/null
+++ b/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+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 tomcat7 curl"
+apt-get update
+apt-get -y 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 stop Cassandra 
+cd /usr/share/usergrid/init_instance
+./install_cassandra.sh
+
+# Install and start ElasticSearch
+cd /usr/share/usergrid/init_instance
+./install_elasticsearch.sh
+/etc/init.d/elasticsearch start
+
+# Starting Tomcat starts Priam which starts Priam
+#/etc/init.d/tomcat7 restart
+
+# Priam consistently craps out on first run
+# making this ugly kludge necessary
+#sleep 90
+#/etc/init.d/tomcat7 restart
+
+cd /usr/share/usergrid/scripts
+groovy tag_instance.groovy

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28bb791f/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
new file mode 100644
index 0000000..3eaf58c
--- /dev/null
+++ b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+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 tomcat7 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
+
+# Wait for enough Cassandra nodes then deploy and restart Tomcat 
+cd /usr/share/usergrid/scripts
+groovy wait_for_cassandra.groovy
+
+mkdir -p /usr/share/tomcat7/lib 
+groovy configure_usergrid.groovy > /usr/share/tomcat7/lib/usergrid-deployment.properties 
+
+rm -rf /var/lib/tomcat7/webapps/*
+cp -r /usr/share/usergrid/webapps/* /var/lib/tomcat7/webapps
+groovy configure_portal_new.groovy > /var/lib/tomcat7/webapps/portal/config.js 
+
+# Go
+/etc/init.d/tomcat7 restart
+groovy tag_instance.groovy

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28bb791f/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 5bf7d04..0467753 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
@@ -19,38 +19,41 @@ cd /usr/share/usergrid/scripts
 groovy registry_register.groovy
 groovy wait_for_instances.groovy
 
-# Configure Priam
 cd /usr/share/usergrid/scripts
 groovy configure_cassandra.groovy > /etc/cassandra/cassandra.yaml
-groovy configure_priam.groovy
-
-# Copy Priam extension into Cassandra and Priam WAR into Tomcat
-rm -rf /var/lib/tomcat7/webapps/*
-mkdir -p /usr/share/cassandra/lib 
-cp /usr/share/usergrid/lib/priam-cass-extensions-1.2.24.jar /usr/share/cassandra/lib 
-cp /usr/share/usergrid/webapps/priam-web-1.2.24.war /var/lib/tomcat7/webapps/Priam.war
-
-# Make sure Priam via Tomcat can write to /etc/cassandra
-# TODO: do this without 777
-chmod -R 777 /etc/cassandra
-chmod 777 /etc/init.d/cassandra
-
-# Configure sudo for no passwords to please Priam
-cat >> /tmp/sudoers.new << EOF
-Defaults    env_reset
-Defaults    mail_badpass
-Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-root    ALL=(ALL:ALL) ALL
-%admin  ALL=(ALL) ALL
-%sudo   ALL=(ALL:ALL) NOPASSWD:ALL
-EOF
-visudo -c -f /tmp/sudoers.new
-if [ "$?" -eq "0" ]; then
-    cp /tmp/sudoers.new /etc/sudoers
-fi
-# Add tomat user to sudoers to please Priam
-adduser tomcat7 sudo
-/etc/init.d/sudo restart
+
+/etc/init.d/cassandra start
+
+## Configure Priam
+#groovy configure_priam.groovy
+#
+## Copy Priam extension into Cassandra and Priam WAR into Tomcat
+#rm -rf /var/lib/tomcat7/webapps/*
+#mkdir -p /usr/share/cassandra/lib 
+#cp /usr/share/usergrid/lib/priam-cass-extensions-1.2.24.jar /usr/share/cassandra/lib 
+#cp /usr/share/usergrid/webapps/priam-web-1.2.24.war /var/lib/tomcat7/webapps/Priam.war
+#
+## Make sure Priam via Tomcat can write to /etc/cassandra
+## TODO: do this without 777
+#chmod -R 777 /etc/cassandra
+#chmod 777 /etc/init.d/cassandra
+#
+## Configure sudo for no passwords to please Priam
+#cat >> /tmp/sudoers.new << EOF
+#Defaults    env_reset
+#Defaults    mail_badpass
+#Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+#root    ALL=(ALL:ALL) ALL
+#%admin  ALL=(ALL) ALL
+#%sudo   ALL=(ALL:ALL) NOPASSWD:ALL
+#EOF
+#visudo -c -f /tmp/sudoers.new
+#if [ "$?" -eq "0" ]; then
+#    cp /tmp/sudoers.new /etc/sudoers
+#fi
+## Add tomat user to sudoers to please Priam
+#adduser tomcat7 sudo
+#/etc/init.d/sudo restart
 
 popd
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28bb791f/stack/awscluster/src/main/dist/update.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/update.sh b/stack/awscluster/src/main/dist/update.sh
new file mode 100644
index 0000000..a908d55
--- /dev/null
+++ b/stack/awscluster/src/main/dist/update.sh
@@ -0,0 +1,16 @@
+sudo mkdir __tmpupdate__
+pushd __tmpupdate__
+
+    sudo s3cmd --config=/etc/s3cfg get s3://${RELEASE_BUCKET}/usergrid-cloudformation-1.0-SNAPSHOT-any.tar.gz
+    sudo tar xzvf usergrid-cloudformation-1.0-SNAPSHOT-any.tar.gz 
+    sudo /etc/init.d/tomcat7 stop
+    sudo cp -r webapps/* /var/lib/tomcat7/webapps
+
+    pushd /usr/share/usergrid/scripts
+        sudo groovy configure_portal_new.groovy > /var/lib/tomcat7/webapps/portal/config.js 
+    popd
+
+    sudo /etc/init.d/tomcat7 start
+
+popd 
+sudo rm -rf __tmpupdate__

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28bb791f/stack/awscluster/src/main/groovy/configure_cassandra.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_cassandra.groovy b/stack/awscluster/src/main/groovy/configure_cassandra.groovy
index a71e071..7edccbe 100644
--- a/stack/awscluster/src/main/groovy/configure_cassandra.groovy
+++ b/stack/awscluster/src/main/groovy/configure_cassandra.groovy
@@ -37,7 +37,7 @@ seed_provider:
     - class_name: org.apache.cassandra.locator.SimpleSeedProvider
       parameters:
           - seeds: "${seeds}"
-auto_bootstrap: true
+auto_bootstrap: false 
 initial_token:
 hinted_handoff_enabled: true
 hinted_handoff_throttle_in_kb: 1024

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28bb791f/stack/awscluster/src/main/groovy/configure_portal_new.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_portal_new.groovy b/stack/awscluster/src/main/groovy/configure_portal_new.groovy
new file mode 100644
index 0000000..2f15223
--- /dev/null
+++ b/stack/awscluster/src/main/groovy/configure_portal_new.groovy
@@ -0,0 +1,17 @@
+//
+// Emits dash/app/config.js file 
+//
+def baseUrl = "http://${System.getenv().get("DNS_NAME")}.${System.getenv().get("DNS_DOMAIN")}"
+config = """
+var VERSION = 'R-2013-07-02-02';
+var Usergrid = Usergrid || {};
+Usergrid.showNotifcations = true;
+
+// used only if hostname does not match a real server name
+Usergrid.overrideUrl = '${baseUrl}';
+
+Usergrid.settings = {
+  hasMonitoring:true //change to false to remove monitoring
+};
+"""
+println config

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28bb791f/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
new file mode 100644
index 0000000..a3e710b
--- /dev/null
+++ b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
@@ -0,0 +1,126 @@
+// 
+// configure_usergrid.groovy 
+// 
+// Emits usergrid properties file based on environment and Cassandra node registry in SimpleDB
+//
+import com.amazonaws.auth.*
+import com.amazonaws.services.simpledb.*
+import com.amazonaws.services.simpledb.model.*
+
+String domain = "UGCloudFormation"
+
+String accessKey = (String)System.getenv().get("AWS_ACCESS_KEY")
+String secretKey = (String)System.getenv().get("AWS_SECRET_KEY")
+
+def baseUrl      = "http://${System.getenv().get("DNS_NAME")}.${System.getenv().get("DNS_DOMAIN")}"
+String stackName = (String)System.getenv().get("STACK_NAME")
+String hostName  = (String)System.getenv().get("PUBLIC_HOSTNAME")
+def replFactor   = System.getenv().get("CASSANDRA_REPLICATION_FACTOR")
+def clusterName  = System.getenv().get("CASSANDRA_CLUSTER_NAME")
+
+def superUserEmail     = System.getenv().get("SUPER_USER_EMAIL")
+def testAdminUserEmail = System.getenv().get("TEST_ADMIN_USER_EMAIL")
+
+// build seed list by listing all Cassandra nodes found in SimpleDB domain with our stackName
+def creds = new BasicAWSCredentials(accessKey, secretKey)
+def sdbClient = new AmazonSimpleDBClient(creds)
+def selectResult = sdbClient.select(new SelectRequest((String)"select * from ${domain}"))
+def seeds = ""
+def sep = ""
+for (item in selectResult.getItems()) {
+    def att = item.getAttributes().get(0)
+    if (att.getValue().equals(stackName)) {
+        seeds = "${seeds}${sep}${item.getName()}:9160"
+        sep = ","
+    }
+}
+
+def usergridConfig = """
+######################################################
+# Minimal Usergrid configuration properties for local Tomcat and Cassandra 
+#
+
+cassandra.url=${seeds}
+cassanrda.cluster=${clusterName}
+cassandra.keyspace.strategy.options.replication_factor=${replFactor}
+cassandra.keyspace.strategy.options.us-west=${replFactor}
+cassandra.keyspace.strategy.options.us-west=${replFactor}
+cassandra.keyspace.strategy=org.apache.cassandra.locator.SimpleStrategy
+
+# These settings seem to cause problems at startup time
+#cassandra.keyspace.strategy=org.apache.cassandra.locator.NetworkTopologyStrategy
+#cassandra.writecl=LOCAL_QUORUM
+#cassandra.readcl=LOCAL_QUORUM
+
+
+######################################################
+# Custom mail transport 
+
+mail.transport.protocol=smtps
+mail.smtps.host=smtp.gmail.com
+mail.smtps.port=465
+mail.smtps.auth=true
+mail.smtps.quitwait=false
+
+# CAUTION: THERE IS A PASSWORD HERE!
+mail.smtps.username=usergridtest@gmail.com
+mail.smtps.password=shy-rtol
+
+######################################################
+# Admin and test user setup
+
+usergrid.sysadmin.login.allowed=true
+usergrid.sysadmin.login.name=superuser
+usergrid.sysadmin.login.password=test
+usergrid.sysadmin.login.email=${superUserEmail}
+
+usergrid.sysadmin.email=${superUserEmail}
+usergrid.sysadmin.approve.users=true
+usergrid.sysadmin.approve.organizations=true
+
+# Base mailer account - default for all outgoing messages
+usergrid.management.mailer=Admin <${superUserEmail}>
+
+usergrid.setup-test-account=true
+
+usergrid.test-account.app=test-app
+usergrid.test-account.organization=test-organization
+usergrid.test-account.admin-user.username=test
+usergrid.test-account.admin-user.name=Test User
+usergrid.test-account.admin-user.email=${testAdminUserEmail}
+usergrid.test-account.admin-user.password=test
+
+######################################################
+# Auto-confirm and sign-up notifications settings
+
+usergrid.management.admin_users_require_confirmation=false
+usergrid.management.admin_users_require_activation=false
+
+usergrid.management.organizations_require_activation=false
+usergrid.management.notify_sysadmin_of_new_organizations=true
+usergrid.management.notify_sysadmin_of_new_admin_users=true
+
+######################################################
+# URLs
+
+# Redirect path when request come in for TLD
+usergrid.redirect_root=${baseUrl}/status
+
+usergrid.view.management.organizations.organization.activate=${baseUrl}/accounts/welcome
+usergrid.view.management.organizations.organization.confirm=${baseUrl}/accounts/welcome
+\n\
+usergrid.view.management.users.user.activate=${baseUrl}/accounts/welcome
+usergrid.view.management.users.user.confirm=${baseUrl}/accounts/welcome
+
+usergrid.admin.confirmation.url=${baseUrl}/management/users/%s/confirm
+usergrid.user.confirmation.url=${baseUrl}/%s/%s/users/%s/confirm\n\\n\
+
+usergrid.organization.activation.url=${baseUrl}/management/organizations/%s/activate\n\
+usergrid.admin.activation.url=${baseUrl}/management/users/%s/activate
+usergrid.user.activation.url=${baseUrl}%s/%s/users/%s/activate
+
+usergrid.admin.resetpw.url=${baseUrl}/management/users/%s/resetpw
+usergrid.user.resetpw.url=${baseUrl}/%s/%s/users/%s/resetpw
+"""
+
+println usergridConfig 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/28bb791f/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
new file mode 100644
index 0000000..a1c79aa
--- /dev/null
+++ b/stack/awscluster/ugcluster-cf.json
@@ -0,0 +1,647 @@
+{
+    "AWSTemplateFormatVersion": "2010-09-09",
+    "Description": "Usergrid AWS Cluster",
+    "Parameters": {
+        "DnsSubDomain": {
+            "Description": "DNS name for stack, must not already exist in Route53.",
+            "Type": "String",
+            "Default": "ugtest"
+        },
+        "DnsDomain": {
+            "Description": "DNS domain for stack, must already exist in Route53",
+            "Type": "String",
+            "Default": "usergrid.com"
+        },
+        "ReleaseBucket": {
+            "Description": "S3 Bucket where Usergrid assembly is to be found.",
+            "Type": "String",
+            "Default": "ug-cloudformation"
+        },
+        "RestMinServers": {
+            "Description": "Minimum number of REST servers.",
+            "Type": "Number",
+            "Default": "1",
+            "MinValue": "1"
+        },
+        "RestMaxServers": {
+            "Description": "Maximum number REST servers.",
+            "Type": "Number",
+            "Default": "1",
+            "MinValue": "1"
+        },
+        "RestInstanceType": {
+            "Description": "Instance type for REST servers",
+            "Type": "String",
+            "Default": "m1.small",
+            "AllowedValues": ["m1.small", "m1.medium", "m1.large", "m1.xlarge", "m3.xlarge", "m3.2xlarge"],
+            "ConstraintDescription": "must be valid instance type."
+        },
+        "KeyPair": {
+            "Description": "EC2 key pair to be use for SSH access",
+            "Type": "String",
+            "Default": "ug-cloudformation"
+        },
+        "CassClusterName": {
+            "Description": "Name to be used for Cassandra cluster.",
+            "Type": "String",
+            "Default": "usergrid"
+        },
+        "CassNumServers": {
+            "Description": "Number of Cass servers to start.",
+            "Type": "Number",
+            "Default": "3",
+            "MinValue": "3"
+        },
+        "CassInstanceType": {
+            "Description": "Instance type for Cass servers",
+            "Type": "String",
+            "Default": "m1.xlarge",
+            "AllowedValues": ["m1.small", "m1.medium", "m1.large", "m1.xlarge", "m3.xlarge", "m3.2xlarge"],
+            "ConstraintDescription": "must be valid instance type."
+        },
+        "CassReplicationFactor": {
+            "Description": "Cassandra replication factor",
+            "Type": "Number",
+            "Default": "2",
+            "MinValue": "1"
+        },
+        "SuperUserEmail": {
+            "Description": "Email for superuser user",
+            "Type": "String",
+            "Default": "dmjohnson+super@apigee.com"
+        },
+        "TestAdminUserEmail": {
+            "Description": "Email for test admin user",
+            "Type": "String",
+            "Default": "dmjohnson+admin@apigee.com"
+        },
+        "NotificationEmail": {
+            "Description": "Email for notifications",
+            "Type": "String",
+            "Default": "dmjohnson+super@apigee.com"
+        }
+    },
+    "Mappings": {
+        "AWSInstanceType2Arch": {
+            "m1.small": {"Arch": "64"},
+            "m1.medium": {"Arch": "64"},
+            "m1.large": {"Arch": "64"},
+            "m1.xlarge": {"Arch": "64"}
+        },
+        "AWSRegionArch2AMI": {
+            "ap-southeast-2": {"64": "ami-db8611e1"},
+            "us-east-1": {"64": "ami-e864da81"},
+            "us-west-2": {"64": "ami-50f97060"}
+        },
+        "TwoAZs": {
+            "ap-southeast-2": {"AZ1": "ap-southeast-2a", "AZ2": "ap-southeast-2b"},
+            "us-east-1": {"AZ1": "us-east-1a", "AZ2": "us-east-1b"},
+            "us-west-2": {"AZ1": "us-west-2a", "AZ2": "us-west-2b"}
+        }
+    },
+    "Resources": {
+                "RestUser": {
+            "Type": "AWS::IAM::User",
+            "Properties": {
+                "Path": "/",
+                "Policies": [{
+                        "PolicyName": "root",
+                        "PolicyDocument": {"Statement": [{
+                                    "Effect": "Allow",
+                                    "Action": "*",
+                                    "Resource": "*"
+                                }]}
+                    }]
+            }
+        },
+        "RestKey": {
+            "Type": "AWS::IAM::AccessKey",
+            "Properties": {
+                "UserName": {"Ref": "RestUser"}
+            }
+        },
+        "CassUser": {
+            "Type": "AWS::IAM::User",
+            "Properties": {
+                "Path": "/",
+                "Policies": [{
+                        "PolicyName": "root",
+                        "PolicyDocument": {"Statement": [{
+                                    "Effect": "Allow",
+                                    "Action": "*",
+                                    "Resource": "*"
+                                }]}
+                    }]
+            }
+        },
+        "CassKey": {
+            "Type": "AWS::IAM::AccessKey",
+            "Properties": {
+                "UserName": {"Ref": "CassUser"}
+            }
+        },
+        "CassAutoScalingLaunchConfiguration": {
+            "Type": "AWS::AutoScaling::LaunchConfiguration",
+            "Properties": {
+                "UserData": {
+                    "Fn::Base64": {"Fn::Join": ["", [
+
+                                "#!/bin/bash -ex\n",
+
+                                "# CASSANDRA 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=cass\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 CASS_SECURITY_GROUP_NAME=", {"Ref": "CassSecurityGroup"}, "\n",
+                                    "\n",
+                                    "#export JVM_EXTRA_OPTS=-javaagent:/usr/share/cassandra/lib/priam-cass-extensions-1.2.24.jar", "\n",
+                                    "\n",
+                                    "export CASSANDRA_CLUSTER_NAME=", {"Ref": "CassClusterName"}, "\n",
+                                    "export CASSANDRA_NUM_SERVERS=", {"Ref": "CassNumServers"}, "\n",
+                                    "export CASSANDRA_KEYSPACE_NAME=usergrid", "\n",
+                                    "export CASSANDRA_REPLICATION_FACTOR=", {"Ref": "CassReplicationFactor"}, "\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": "CassKey"}, "\n",
+                                "export AWS_SECRET_KEY=", {"Fn::GetAtt": ["CassKey", "SecretAccessKey"]}, "\n",
+                                "EOF\n",
+                                "\n",
+
+                                "# put AWS creds Priam's config file\n",
+                                "cat >/etc/awscredential.properties <<EOF\n",
+                                "AWSACCESSID=", {"Ref": "CassKey"}, "\n",
+                                "AWSKEY=", {"Fn::GetAtt": ["CassKey", "SecretAccessKey"]}, "\n",
+                                "EOF\n",
+                                "\n",
+
+                                "# setup s3cmd (will be installed by init script) \n",
+                                "cat >/etc/s3cfg <<EOF\n",
+                                "access_key=", {"Ref": "CassKey"}, "\n",
+                                "secret_key=", {"Fn::GetAtt": ["CassKey", "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",
+                                "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 a Cassandra node \n",
+                                "sh ./init_db_server.sh\n"
+
+                            ]]}
+                },
+                "KeyName": {"Ref": "KeyPair"},
+                "ImageId": {
+                    "Fn::FindInMap": [
+                        "AWSRegionArch2AMI",
+                        {
+                            "Ref": "AWS::Region"
+                        },
+                        {
+                            "Fn::FindInMap": [
+                                "AWSInstanceType2Arch",
+                                {
+                                    "Ref": "CassInstanceType"
+                                },
+                                "Arch"
+                            ]
+                        }
+                    ]
+                },
+                "InstanceType": {
+                    "Ref": "CassInstanceType"
+                },
+                "IamInstanceProfile": {
+                    "Ref": "RootInstanceProfile"
+                },
+                "SecurityGroups": [{"Ref": "CassSecurityGroup"}]
+            }
+        },
+        "CassAutoScalingGroup": {
+            "Type": "AWS::AutoScaling::AutoScalingGroup",
+            "Version": "2009-05-15",
+            "Properties": {
+                "AvailabilityZones": {
+                    "Fn::GetAZs": ""
+                },
+                "LaunchConfigurationName": {
+                    "Ref": "CassAutoScalingLaunchConfiguration"
+                },
+                "MinSize": {"Ref": "CassNumServers"},
+                "MaxSize": {"Ref": "CassNumServers"},
+                "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": {
+                "UserData": {
+                    "Fn::Base64": {"Fn::Join": ["", [
+
+                                "#!/bin/bash -ex\n",
+
+                                "# REST SERVER 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=rest\n",
+                                    "export STACK_NAME=", {"Ref": "AWS::StackName"}, "\n",
+                                    "\n",
+                                    "export DNS_NAME=", {"Ref": "DnsSubDomain"}, "\n",
+                                    "export DNS_DOMAIN=", {"Ref": "DnsDomain"}, "\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",
+                                    "export ELB_NAME=", {"Ref": "RestElasticLoadBalancer"}, "\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 REST_SECURITY_GROUP_NAME=", {"Ref": "RestSecurityGroup"}, "\n",
+                                    "export DB_SECURITY_GROUP_NAME=", {"Ref": "CassSecurityGroup"}, "\n",
+                                    "\n",
+                                    "export CASSANDRA_CLUSTER_NAME=", {"Ref": "CassClusterName"}, "\n",
+                                    "export CASSANDRA_KEYSPACE_NAME=usergrid", "\n",
+                                    "export CASSANDRA_REPLICATION_FACTOR=", {"Ref": "CassReplicationFactor"}, "\n",
+                                    "\n",
+                                    "export RELEASE_BUCKET=", {"Ref": "ReleaseBucket"}, "\n",
+                                    "\n",
+                                    "export SUPER_USER_EMAIL=", {"Ref": "SuperUserEmail"}, "\n",
+                                    "export TEST_ADMIN_USER_EMAIL=", {"Ref": "TestAdminUserEmail"}, "\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": "RestKey"}, "\n",
+                                "export AWS_SECRET_KEY=", {"Fn::GetAtt": ["RestKey", "SecretAccessKey"]}, "\n",
+                                "EOF\n",
+                                "\n",
+
+                                "# setup s3cmd (will be installed by init script) \n",
+                                "cat >/etc/s3cfg <<EOF\n",
+                                "access_key=", {"Ref": "RestKey"}, "\n",
+                                "secret_key=", {"Fn::GetAtt": ["RestKey", "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",
+                                "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 a REST intance \n",
+                                "sh ./init_rest_server.sh\n"
+
+                            ]]}
+                },
+                "KeyName": {"Ref": "KeyPair"},
+                "ImageId": {
+                    "Fn::FindInMap": [
+                        "AWSRegionArch2AMI",
+                        {
+                            "Ref": "AWS::Region"
+                        },
+                        {
+                            "Fn::FindInMap": [
+                                "AWSInstanceType2Arch",
+                                {
+                                    "Ref": "RestInstanceType"
+                                },
+                                "Arch"
+                            ]
+                        }
+                    ]
+                },
+                "InstanceType": {
+                    "Ref": "RestInstanceType"
+                },
+                "IamInstanceProfile": {
+                    "Ref": "RootInstanceProfile"
+                },
+                "SecurityGroups": [{"Ref": "RestSecurityGroup"}]
+            }
+        },
+        "RestAutoScalingGroup": {
+            "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": "RestAutoScalingLaunchConfiguration"
+                },
+                "MinSize": {"Ref": "RestMinServers"},
+                "MaxSize": {"Ref": "RestMaxServers"},
+                "HealthCheckType": "ELB",
+                "HealthCheckGracePeriod": "1800",
+                "LoadBalancerNames": [{"Ref": "RestElasticLoadBalancer"}],
+                "NotificationConfiguration": {
+                    "TopicARN": {"Ref": "NotificationTopic"},
+                    "NotificationTypes": [
+                        "autoscaling:EC2_INSTANCE_LAUNCH",
+                        "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
+                        "autoscaling:EC2_INSTANCE_TERMINATE",
+                        "autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
+                    ]
+                }
+            }
+        },
+        "RestServerScaleUpPolicy": {
+            "Type": "AWS::AutoScaling::ScalingPolicy",
+            "Properties": {
+                "AdjustmentType": "ChangeInCapacity",
+                "AutoScalingGroupName": {
+                    "Ref": "RestAutoScalingGroup"
+                },
+                "Cooldown": "60",
+                "ScalingAdjustment": "1"
+            }
+        },
+        "RestServerScaleDownPolicy": {
+            "Type": "AWS::AutoScaling::ScalingPolicy",
+            "Properties": {
+                "AdjustmentType": "ChangeInCapacity",
+                "AutoScalingGroupName": {
+                    "Ref": "RestAutoScalingGroup"
+                },
+                "Cooldown": "60",
+                "ScalingAdjustment": "-1"
+            }
+        },
+        "CPUAlarmHigh": {
+            "Type": "AWS::CloudWatch::Alarm",
+            "Properties": {
+                "AlarmDescription": "Scale-up if CPU > 60% for 10 minutes",
+                "MetricName": "CPUUtilization",
+                "Namespace": "AWS/EC2",
+                "Statistic": "Average",
+                "Period": "600",
+                "EvaluationPeriods": "2",
+                "Threshold": "60",
+                "AlarmActions": [{
+                        "Ref": "RestServerScaleUpPolicy"
+                    }],
+                "Dimensions": [
+                    {
+                        "Name": "AutoScalingGroupName",
+                        "Value": {
+                            "Ref": "RestAutoScalingGroup"
+                        }
+                    }],
+                "ComparisonOperator": "GreaterThanThreshold"
+            }
+        },
+        "CPUAlarmLow": {
+            "Type": "AWS::CloudWatch::Alarm",
+            "Properties": {
+                "AlarmDescription": "Scale-down if CPU < 10% for 10 minutes",
+                "MetricName": "CPUUtilization",
+                "Namespace": "AWS/EC2",
+                "Statistic": "Average",
+                "Period": "600",
+                "EvaluationPeriods": "2",
+                "Threshold": "10",
+                "AlarmActions": [{
+                        "Ref": "RestServerScaleDownPolicy"
+                    }],
+                "Dimensions": [
+                    {
+                        "Name": "AutoScalingGroupName",
+                        "Value": {
+                            "Ref": "RestAutoScalingGroup"
+                        }
+                    }],
+                "ComparisonOperator": "LessThanThreshold"
+            }
+        },
+        "RestElasticLoadBalancer": {
+            "Type": "AWS::ElasticLoadBalancing::LoadBalancer",
+            "Properties": {
+                "AvailabilityZones": [
+                    {"Fn::FindInMap": ["TwoAZs", {"Ref": "AWS::Region"}, "AZ1"]},
+                    {"Fn::FindInMap": ["TwoAZs", {"Ref": "AWS::Region"}, "AZ2"]}
+                ],
+                "Listeners": [{
+                        "LoadBalancerPort": "80",
+                        "InstancePort": "8080",
+                        "Protocol": "HTTP"
+                    }],
+                "HealthCheck": {
+                    "Target": "HTTP:8080/status",
+                    "HealthyThreshold": "2",
+                    "UnhealthyThreshold": "4",
+                    "Interval": "30",
+                    "Timeout": "5"
+                }
+            }
+        },
+        "NotificationTopic": {
+            "Type": "AWS::SNS::Topic",
+            "Properties": {
+                "Subscription": [{
+                        "Endpoint": {"Ref": "NotificationEmail"},
+                        "Protocol": "email"
+                    }]
+            }
+        },
+        "DnsRecord": {
+            "Type": "AWS::Route53::RecordSetGroup",
+            "Properties": {
+                "HostedZoneName": {"Fn::Join": [".", [{"Ref": "DnsDomain"}, ""]]},
+                "RecordSets": [{
+                        "Name": {"Fn::Join": [".", [{"Ref": "DnsSubDomain"}, {"Ref": "DnsDomain"}]]},
+                        "Type": "A",
+                        "AliasTarget": {
+                            "HostedZoneId": {"Fn::GetAtt": ["RestElasticLoadBalancer", "CanonicalHostedZoneNameID"]},
+                            "DNSName": {"Fn::GetAtt": ["RestElasticLoadBalancer", "CanonicalHostedZoneName"]}
+                        }
+                    }]
+            }
+        },
+
+        "RootRole": {
+            "Type": "AWS::IAM::Role",
+            "Properties": {
+                "AssumeRolePolicyDocument": {
+                    "Statement": [
+                        {
+                            "Effect": "Allow",
+                            "Principal": {
+                                "Service": [
+                                    "ec2.amazonaws.com"
+                                ]
+                            },
+                            "Action": [
+                                "sts:AssumeRole"
+                            ]
+                        }
+                    ]
+                },
+                "Path": "/"
+            }
+        },
+        "RolePolicies": {
+            "Type": "AWS::IAM::Policy",
+            "Properties": {
+                "PolicyName": "root",
+                "PolicyDocument": {
+                    "Statement": [
+                        {
+                            "Effect": "Allow",
+                            "Action": "*",
+                            "Resource": "*"
+                        }
+                    ]
+                },
+                "Roles": [
+                    {
+                        "Ref": "RootRole"
+                    }
+                ]
+            }
+        },
+        "RootInstanceProfile": {
+            "Type": "AWS::IAM::InstanceProfile",
+            "Properties": {
+                "Path": "/",
+                "Roles": [
+                    {
+                        "Ref": "RootRole"
+                    }
+                ]
+            }
+        },
+        "CassSecurityGroup": {
+            "Type": "AWS::EC2::SecurityGroup",
+            "Properties": {
+                "GroupDescription": "Database Machines",
+                "SecurityGroupIngress": [{
+                        "IpProtocol": "tcp",
+                        "FromPort": "22",
+                        "ToPort": "22",
+                        "CidrIp": "0.0.0.0/0"
+                    }]
+            }
+        },
+        "CassSecurityGroupPort7000": {
+            "Type": "AWS::EC2::SecurityGroupIngress",
+            "Properties": {
+                "GroupName": {"Ref": "CassSecurityGroup"},
+                "IpProtocol": "tcp",
+                "FromPort": "7000",
+                "ToPort": "7000",
+                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
+            }
+        },
+        "CassSecurityGroupPort9160": {
+            "Type": "AWS::EC2::SecurityGroupIngress",
+            "Properties": {
+                "GroupName": {"Ref": "CassSecurityGroup"},
+                "IpProtocol": "tcp",
+                "FromPort": "9160",
+                "ToPort": "9160",
+                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
+            }
+        },
+        "CassSecurityGroupPort9200": {
+            "Type": "AWS::EC2::SecurityGroupIngress",
+            "Properties": {
+                "GroupName": {"Ref": "CassSecurityGroup"},
+                "IpProtocol": "tcp",
+                "FromPort": "9200",
+                "ToPort": "9200",
+                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
+            }
+        },
+        "CassSecurityGroupPort9300": {
+            "Type": "AWS::EC2::SecurityGroupIngress",
+            "Properties": {
+                "GroupName": {"Ref": "CassSecurityGroup"},
+                "IpProtocol": "tcp",
+                "FromPort": "9300",
+                "ToPort": "9300",
+                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
+            }
+        },
+        "RestSecurityGroup": {
+            "Type": "AWS::EC2::SecurityGroup",
+            "Properties": {
+                "GroupDescription": "REST Machines",
+                "SecurityGroupIngress": [{
+                        "IpProtocol": "tcp",
+                        "FromPort": "22",
+                        "ToPort": "22",
+                        "CidrIp": "0.0.0.0/0"
+                    }, {
+                        "IpProtocol": "tcp",
+                        "FromPort": "8080",
+                        "ToPort": "8080",
+                        "CidrIp": "0.0.0.0/0"
+                    }]
+            }
+        }
+    }
+
+
+
+}


[4/4] git commit: Changes to get non-embedded ElasticSearch working.

Posted by sn...@apache.org.
Changes to get non-embedded ElasticSearch working.


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

Branch: refs/heads/two-dot-o
Commit: 6979ae6bfc0acbbc936abfd0c7a8bed657e75948
Parents: 3e6e7e8
Author: Dave Johnson <dm...@apigee.com>
Authored: Sat Mar 15 11:34:04 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Sat Mar 15 11:34:04 2014 -0400

----------------------------------------------------------------------
 .../serialization/SerializationFig.java         |  5 ++
 .../usergrid/persistence/index/IndexFig.java    |  8 +--
 .../index/impl/EsEntityCollectionIndex.java     |  3 +-
 .../persistence/index/impl/EsProvider.java      | 53 +++++++++++---------
 .../index/legacy/EntityManagerFacade.java       |  1 -
 .../src/test/resources/dynamic-test.properties  |  2 +-
 .../src/test/resources/usergrid-CHOP.properties |  5 +-
 .../src/test/resources/usergrid-UNIT.properties |  2 +-
 8 files changed, 44 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6979ae6b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
index e24d6a9..d2793e4 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/SerializationFig.java
@@ -12,6 +12,11 @@ import org.safehaus.guicyfig.Key;
  */
 @FigSingleton
 public interface SerializationFig extends GuicyFig {
+
+    /**
+     * Time to live timeout in seconds.
+     * @return Timeout in seconds.
+     */
     @Key( "collection.stage.transient.timeout" )
     @Default( "60" )
     int getTimeout();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6979ae6b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
index 7b6f318..5fb11e6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
@@ -31,13 +31,13 @@ public interface IndexFig extends GuicyFig {
 
     public static final String ELASTICSEARCH_PORT = "elasticsearch.port";
 
-    public static final String ELASTICSEARCH_INDEXNAME = "elasticsearch.indexname";
+    public static final String ELASTICSEARCH_INDEXNAME = "elasticsearch.index_name";
 
     public static final String ELASTICSEARCH_EMBEDDED = "elasticsearch.embedded";
 
-    public static final String QUERY_CURSOR_TIMEOUT_MINUTES = "elasticsearch.cursor-timeout.minutes";
+    public static final String QUERY_CURSOR_TIMEOUT_MINUTES = "elasticsearch.cursor_timeout.minutes";
 
-    public static final String ELASTICSEARCH_FORCE_REFRESH = "elasticsearch.force-refresh";
+    public static final String ELASTICSEARCH_FORCE_REFRESH = "elasticsearch.force_refresh";
 
     public static final String QUERY_LIMIT_DEFAULT = "index.query.limit.default";
     
@@ -57,7 +57,7 @@ public interface IndexFig extends GuicyFig {
     @Key( QUERY_CURSOR_TIMEOUT_MINUTES )
     int getQueryCursorTimeout();
 
-    @Default( "true" )
+    @Default( "false" )
     @Key( ELASTICSEARCH_EMBEDDED )
     boolean isEmbedded();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6979ae6b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
index 2de269d..4d750a7 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
@@ -69,6 +69,7 @@ import org.elasticsearch.search.sort.SortOrder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+
 /**
  * Implements index using ElasticSearch Java API and Core Persistence Collections.
  */
@@ -361,7 +362,7 @@ public class EsEntityCollectionIndex implements EntityCollectionIndex {
                 LocationField locField = (LocationField) f;
                 Map<String, Object> locMap = new HashMap<String, Object>();
 
-                // field names lat and lon triggerl ElasticSearch geo location 
+                // field names lat and lon trigger ElasticSearch geo location 
                 locMap.put("lat", locField.getValue().getLatitude());
                 locMap.put("lon", locField.getValue().getLongtitude());
                 entityMap.put(field.getName() + GEO_SUFFIX, locMap);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6979ae6b/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 5e5ba44..2393b36 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
@@ -32,65 +32,68 @@ import org.elasticsearch.node.NodeBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
  * Provides access to ElasticSearch client.
  */
 @Singleton
 public class EsProvider {
-    private static final Logger log = LoggerFactory.getLogger( EsProvider.class ); 
+
+    private static final Logger log = LoggerFactory.getLogger(EsProvider.class);
 
     private final IndexFig indexFig;
     private static Client client;
 
     @Inject
-    public EsProvider( IndexFig fig ) {
+    public EsProvider(IndexFig fig) {
         this.indexFig = fig;
     }
 
     public synchronized Client getClient() {
-       if ( client == null ) {
-           client = getClient( indexFig );
-       }
-       return client;
+        if (client == null) {
+            client = getClient(indexFig);
+        }
+        return client;
     }
 
-    public static synchronized Client getClient( IndexFig fig ) {
+    public static synchronized Client getClient(IndexFig fig) {
 
-        if ( client == null ) {
+        if (client == null) {
 
             Client newClient = null;
 
-            if ( fig.isEmbedded() ) {
+            if (fig.isEmbedded()) {
 
                 log.info("--------------------------------");
                 log.info("Starting embedded ElasticSearch");
                 log.info("--------------------------------");
 
-                int port = AvailablePortFinder.getNextAvailable( 2000 );
+                int port = AvailablePortFinder.getNextAvailable(2000);
                 Settings settings = ImmutableSettings.settingsBuilder()
-                        .put( "node.http.enabled", true )
-                        .put( "transport.tcp.port", port )
-                        .put( "path.logs", "target/elasticsearch/logs_" + port )
-                        .put( "path.data", "target/elasticsearch/data_" + port )
-                        .put( "gateway.type", "none" )
-                        .put( "index.store.type", "memory" )
-                        .put( "index.number_of_shards", 1 )
-                        .put( "index.number_of_replicas", 1 ).build();
-
-                Node node = NodeBuilder.nodeBuilder().local( true ).settings( settings ).node();
+                        .put("node.http.enabled", true)
+                        .put("transport.tcp.port", port)
+                        .put("path.logs", "target/elasticsearch/logs_" + port)
+                        .put("path.data", "target/elasticsearch/data_" + port)
+                        .put("gateway.type", "none")
+                        .put("index.store.type", "memory")
+                        .put("index.number_of_shards", 1)
+                        .put("index.number_of_replicas", 1).build();
+
+                Node node = NodeBuilder.nodeBuilder().local(true).settings(settings).node();
                 newClient = node.client();
-            
+
             } else { // build client that connects to all hosts
 
                 log.info("--------------------------------");
                 log.info("Creating ElasticSearch client");
                 log.info("--------------------------------");
 
-                TransportClient transportClient = new TransportClient();
-                for ( String host : fig.getHosts().split(",") ) {
+                Settings settings = ImmutableSettings.settingsBuilder()
+                        .put("cluster.name", fig.getIndexName() ).build();
+
+                TransportClient transportClient = new TransportClient(settings);
+                for (String host : fig.getHosts().split(",")) {
                     transportClient.addTransportAddress(
-                            new InetSocketTransportAddress( host, fig.getPort() ));
+                            new InetSocketTransportAddress(host.trim(), fig.getPort()));
                 }
                 newClient = transportClient;
             }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6979ae6b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
index de1b9b6..5e57ace 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
@@ -15,7 +15,6 @@
  * copyright in this work, please see the NOTICE file in the top level
  * directory of this distribution.
  */
-
 package org.apache.usergrid.persistence.index.legacy;
 
 import org.apache.usergrid.utils.EntityBuilder;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6979ae6b/stack/corepersistence/queryindex/src/test/resources/dynamic-test.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/dynamic-test.properties b/stack/corepersistence/queryindex/src/test/resources/dynamic-test.properties
index 8d3ee42..1f8cb99 100644
--- a/stack/corepersistence/queryindex/src/test/resources/dynamic-test.properties
+++ b/stack/corepersistence/queryindex/src/test/resources/dynamic-test.properties
@@ -11,6 +11,6 @@ cassandra.timeout=5000
 index.query.limit.default=10
 elasticsearch.indexname=Usergrid
 elasticsearch.embedded=true
-elasticsearch.force-refresh=true
+elasticsearch.force-refresh=false
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6979ae6b/stack/corepersistence/queryindex/src/test/resources/usergrid-CHOP.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/usergrid-CHOP.properties b/stack/corepersistence/queryindex/src/test/resources/usergrid-CHOP.properties
index f25632e..7c3e0c9 100644
--- a/stack/corepersistence/queryindex/src/test/resources/usergrid-CHOP.properties
+++ b/stack/corepersistence/queryindex/src/test/resources/usergrid-CHOP.properties
@@ -11,6 +11,7 @@ collections.keyspace=Usergrid_Collections
 cassandra.timeout=5000
 
 index.query.limit.default=10
+
 elasticsearch.indexname=usergrid
-elasticsearch.embedded=true
-elasticsearch.force-refresh=true
+elasticsearch.embedded=false
+elasticsearch.force_refresh=false

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6979ae6b/stack/corepersistence/queryindex/src/test/resources/usergrid-UNIT.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/usergrid-UNIT.properties b/stack/corepersistence/queryindex/src/test/resources/usergrid-UNIT.properties
index 34e5f62..828dca7 100644
--- a/stack/corepersistence/queryindex/src/test/resources/usergrid-UNIT.properties
+++ b/stack/corepersistence/queryindex/src/test/resources/usergrid-UNIT.properties
@@ -14,5 +14,5 @@ collection.stage.transient.timeout=60
 collections.keyspace.strategy.class=org.apache.cassandra.locator.SimpleStrategy
 
 index.query.limit.default=1000
-elasticsearch.indexname=usergrid
+elasticsearch.index_name=usergrid
 elasticsearch.embedded=true


[2/4] git commit: Adding support for REST instance.

Posted by sn...@apache.org.
Adding support for REST instance.


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

Branch: refs/heads/two-dot-o
Commit: 904713f3a2a509ee845410a4333e6a852e4bfb91
Parents: 28bb791
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Mar 14 08:37:53 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Mar 14 08:37:53 2014 -0400

----------------------------------------------------------------------
 stack/awscluster/cassandra-cf.json              | 315 -------------------
 .../main/dist/init_instance/init_instance.sh    |  54 ----
 2 files changed, 369 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/904713f3/stack/awscluster/cassandra-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/cassandra-cf.json b/stack/awscluster/cassandra-cf.json
deleted file mode 100644
index a28cf48..0000000
--- a/stack/awscluster/cassandra-cf.json
+++ /dev/null
@@ -1,315 +0,0 @@
-{
-    "AWSTemplateFormatVersion": "2010-09-09",
-    "Description": "Cassandra Test Stack",
-    "Parameters": {
-        "ReleaseBucket": {
-            "Description": "S3 Bucket where Priam-Cluster assembly is to be found.",
-            "Type": "String",
-            "Default": "ug-cloudformation-priam"
-        },
-        "KeyPair": {
-            "Description": "EC2 key pair to be use for SSH access",
-            "Type": "String",
-            "Default": "ug-cloudformation"
-        },
-        "CassClusterName": {
-            "Description": "Name to be used for Cassandra cluster.",
-            "Type": "String",
-            "Default": "usergrid"
-        },
-        "CassNumServers": {
-            "Description": "Number of Cass servers to start.",
-            "Type": "Number",
-            "Default": "3",
-            "MinValue": "3"
-        },
-        "CassInstanceType": {
-            "Description": "Instance type for Cass servers",
-            "Type": "String",
-            "Default": "m1.xlarge",
-            "AllowedValues": ["m1.small", "m1.medium", "m1.large", "m1.xlarge", "m3.xlarge", "m3.2xlarge"],
-            "ConstraintDescription": "must be valid instance type."
-        },
-        "CassReplicationFactor": {
-            "Description": "Cassandra replication factor",
-            "Type": "Number",
-            "Default": "2",
-            "MinValue": "1"
-        },
-        "NotificationEmail": {
-            "Description": "Email for notifications",
-            "Type": "String",
-            "Default": "dmjohnson+cf@apigee.com"
-        }
-    },
-    "Mappings": {
-        "AWSInstanceType2Arch": {
-            "m1.small": {"Arch": "64"},
-            "m1.medium": {"Arch": "64"},
-            "m1.large": {"Arch": "64"},
-            "m1.xlarge": {"Arch": "64"}
-        },
-        "AWSRegionArch2AMI": {
-            "ap-southeast-2": {"64": "ami-db8611e1"},
-            "us-east-1": {"64": "ami-e864da81"},
-            "us-west-2": {"64": "ami-50f97060"}
-        }
-    },
-    "Resources": {
-        "CassUser": {
-            "Type": "AWS::IAM::User",
-            "Properties": {
-                "Path": "/",
-                "Policies": [{
-                        "PolicyName": "root",
-                        "PolicyDocument": {"Statement": [{
-                                    "Effect": "Allow",
-                                    "Action": "*",
-                                    "Resource": "*"
-                                }]}
-                    }]
-            }
-        },
-        "CassKey": {
-            "Type": "AWS::IAM::AccessKey",
-            "Properties": {
-                "UserName": {"Ref": "CassUser"}
-            }
-        },
-        "CassAutoScalingLaunchConfiguration": {
-            "Type": "AWS::AutoScaling::LaunchConfiguration",
-            "Properties": {
-                "UserData": {
-                    "Fn::Base64": {"Fn::Join": ["", [
-
-                                "#!/bin/bash -ex\n",
-
-                                "# CASSANDRA 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=cass\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 CASS_SECURITY_GROUP_NAME=", {"Ref": "CassSecurityGroup"}, "\n",
-                                    "\n",
-                                    "export JVM_EXTRA_OPTS=-javaagent:/usr/share/cassandra/lib/priam-cass-extensions-1.2.24.jar", "\n",
-                                    "\n",
-                                    "export CASSANDRA_CLUSTER_NAME=", {"Ref": "CassClusterName"}, "\n",
-                                    "export CASSANDRA_NUM_SERVERS=", {"Ref": "CassNumServers"}, "\n",
-                                    "export CASSANDRA_KEYSPACE_NAME=usergrid", "\n",
-                                    "export CASSANDRA_REPLICATION_FACTOR=", {"Ref": "CassReplicationFactor"}, "\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": "CassKey"}, "\n",
-                                "export AWS_SECRET_KEY=", {"Fn::GetAtt": ["CassKey", "SecretAccessKey"]}, "\n",
-                                "EOF\n",
-                                "\n",
-
-                                "# put AWS creds Priam's config file\n",
-                                "cat >/etc/awscredential.properties <<EOF\n",
-                                "AWSACCESSID=", {"Ref": "CassKey"}, "\n",
-                                "AWSKEY=", {"Fn::GetAtt": ["CassKey", "SecretAccessKey"]}, "\n",
-                                "EOF\n",
-                                "\n",
-
-                                "# setup s3cmd (will be installed by init script) \n",
-                                "cat >/etc/s3cfg <<EOF\n",
-                                "access_key=", {"Ref": "CassKey"}, "\n",
-                                "secret_key=", {"Fn::GetAtt": ["CassKey", "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",
-                                "apt-get update\n",
-                                "apt-get -y install s3cmd\n",
-                                "cd /usr/share/usergrid\n",
-                                "s3cmd --config=/etc/s3cfg get s3://", {"Ref": "ReleaseBucket"}, "/priamcluster-1.0-SNAPSHOT-any.tar.gz\n",
-                                "tar xvf priamcluster-1.0-SNAPSHOT-any.tar.gz\n",
-                                "rm -fr priamcluster-1.0-SNAPSHOT-any.tar.gz\n",
-                                "chmod 755 ./init_instance/*.sh\n",
-                                "cd ./init_instance\n",
-
-                                "# init as a Cassandra node \n",
-                                "sh ./init_instance.sh\n"
-
-                            ]]}
-                },
-                "KeyName": {"Ref": "KeyPair"},
-                "ImageId": {
-                    "Fn::FindInMap": [
-                        "AWSRegionArch2AMI",
-                        {
-                            "Ref": "AWS::Region"
-                        },
-                        {
-                            "Fn::FindInMap": [
-                                "AWSInstanceType2Arch",
-                                {
-                                    "Ref": "CassInstanceType"
-                                },
-                                "Arch"
-                            ]
-                        }
-                    ]
-                },
-                "InstanceType": {
-                    "Ref": "CassInstanceType"
-                },
-                "IamInstanceProfile": {
-                    "Ref": "RootInstanceProfile"
-                },
-                "SecurityGroups": [{"Ref": "CassSecurityGroup"}]
-            }
-        },
-        "CassAutoScalingGroup": {
-            "Type": "AWS::AutoScaling::AutoScalingGroup",
-            "Version": "2009-05-15",
-            "Properties": {
-                "AvailabilityZones": {
-                    "Fn::GetAZs": ""
-                },
-                "LaunchConfigurationName": {
-                    "Ref": "CassAutoScalingLaunchConfiguration"
-                },
-                "MinSize": {"Ref": "CassNumServers"},
-                "MaxSize": {"Ref": "CassNumServers"},
-                "NotificationConfiguration": {
-                    "TopicARN": {"Ref": "NotificationTopic"},
-                    "NotificationTypes": [
-                        "autoscaling:EC2_INSTANCE_LAUNCH",
-                        "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
-                        "autoscaling:EC2_INSTANCE_TERMINATE",
-                        "autoscaling:EC2_INSTANCE_TERMINATE_ERROR"
-                    ]
-                }
-            }
-        },
-        "NotificationTopic": {
-            "Type": "AWS::SNS::Topic",
-            "Properties": {
-                "Subscription": [{
-                        "Endpoint": {"Ref": "NotificationEmail"},
-                        "Protocol": "email"
-                    }]
-            }
-        },
-        "RootRole": {
-            "Type": "AWS::IAM::Role",
-            "Properties": {
-                "AssumeRolePolicyDocument": {
-                    "Statement": [
-                        {
-                            "Effect": "Allow",
-                            "Principal": {
-                                "Service": [
-                                    "ec2.amazonaws.com"
-                                ]
-                            },
-                            "Action": [
-                                "sts:AssumeRole"
-                            ]
-                        }
-                    ]
-                },
-                "Path": "/"
-            }
-        },
-        "RolePolicies": {
-            "Type": "AWS::IAM::Policy",
-            "Properties": {
-                "PolicyName": "root",
-                "PolicyDocument": {
-                    "Statement": [
-                        {
-                            "Effect": "Allow",
-                            "Action": "*",
-                            "Resource": "*"
-                        }
-                    ]
-                },
-                "Roles": [
-                    {
-                        "Ref": "RootRole"
-                    }
-                ]
-            }
-        },
-        "RootInstanceProfile": {
-            "Type": "AWS::IAM::InstanceProfile",
-            "Properties": {
-                "Path": "/",
-                "Roles": [
-                    {
-                        "Ref": "RootRole"
-                    }
-                ]
-            }
-        },
-        "CassSecurityGroup": {
-            "Type": "AWS::EC2::SecurityGroup",
-            "Properties": {
-                "GroupDescription": "Database Machines",
-                "SecurityGroupIngress": [{
-                        "IpProtocol": "tcp",
-                        "FromPort": "22",
-                        "ToPort": "22",
-                        "CidrIp": "0.0.0.0/0"
-                    }]
-            }
-        },
-        "CassSecurityGroupPort7000": {
-            "Type": "AWS::EC2::SecurityGroupIngress",
-            "Properties": {
-                "GroupName": {"Ref": "CassSecurityGroup"},
-                "IpProtocol": "tcp",
-                "FromPort": "7000",
-                "ToPort": "7000",
-                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
-            }
-        },
-        "CassSecurityGroupPort9160": {
-            "Type": "AWS::EC2::SecurityGroupIngress",
-            "Properties": {
-                "GroupName": {"Ref": "CassSecurityGroup"},
-                "IpProtocol": "tcp",
-                "FromPort": "9160",
-                "ToPort": "9160",
-                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
-            }
-        },
-        "CassSecurityGroupPort9200": {
-            "Type": "AWS::EC2::SecurityGroupIngress",
-            "Properties": {
-                "GroupName": {"Ref": "CassSecurityGroup"},
-                "IpProtocol": "tcp",
-                "FromPort": "9200",
-                "ToPort": "9200",
-                "SourceSecurityGroupName": {"Ref": "CassSecurityGroup"}
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/904713f3/stack/awscluster/src/main/dist/init_instance/init_instance.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_instance.sh b/stack/awscluster/src/main/dist/init_instance/init_instance.sh
deleted file mode 100644
index 552df78..0000000
--- a/stack/awscluster/src/main/dist/init_instance/init_instance.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/bash
-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 tomcat7 curl"
-apt-get update
-apt-get -y 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 stop Cassandra 
-cd /usr/share/usergrid/init_instance
-./install_cassandra.sh
-
-# Install and start ElasticSearch
-cd /usr/share/usergrid/init_instance
-./install_elasticsearch.sh
-/etc/init.d/elasticsearch start
-
-# Starting Tomcat starts Priam which starts Priam
-/etc/init.d/tomcat7 restart
-
-# Priam consistently craps out on first run
-# making this ugly kludge necessary
-sleep 90
-/etc/init.d/tomcat7 restart
-
-cd /usr/share/usergrid/scripts
-groovy tag_instance.groovy


[3/4] git commit: Minor refactoring to allow legacy EntityManager to be used outside of tests.

Posted by sn...@apache.org.
Minor refactoring to allow legacy EntityManager to be used outside of tests.


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

Branch: refs/heads/two-dot-o
Commit: 3e6e7e82fbf9db14fb730e6aef65e331f9b7d11c
Parents: 904713f
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Mar 14 08:38:23 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Mar 14 08:38:23 2014 -0400

----------------------------------------------------------------------
 .../index/legacy/EntityManagerFacade.java       | 201 +++++++++++++++++++
 .../apache/usergrid/utils/EntityBuilder.java    | 177 ++++++++++++++++
 .../index/impl/EntityCollectionIndexTest.java   |   2 +-
 .../persistence/index/legacy/EntityBuilder.java | 177 ----------------
 .../index/legacy/EntityManagerFacade.java       | 200 ------------------
 5 files changed, 379 insertions(+), 378 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e6e7e82/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
new file mode 100644
index 0000000..de1b9b6
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
@@ -0,0 +1,201 @@
+/*
+ * 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.
+ */
+
+package org.apache.usergrid.persistence.index.legacy;
+
+import org.apache.usergrid.utils.EntityBuilder;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.EntityCollectionManager;
+import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
+import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
+import org.apache.usergrid.persistence.index.EntityCollectionIndex;
+import org.apache.usergrid.persistence.index.EntityCollectionIndexFactory;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.field.LocationField;
+import org.apache.usergrid.persistence.model.field.LongField;
+import org.apache.usergrid.persistence.model.field.value.Location;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.apache.usergrid.persistence.query.EntityRef;
+import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.query.Results;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/** 
+ * Implements just enough of the old EntityManager interface to get old tests imported from the
+ * Usergrid 1.0 Core module working against the new Core Persistence index & query system.
+ */
+public class EntityManagerFacade {
+    private static final Logger logger = LoggerFactory.getLogger( EntityManagerFacade.class );
+
+    private final Id orgId;
+    private final Id appId;
+    private final EntityCollectionManagerFactory ecmf;
+    private final EntityCollectionIndexFactory ecif;
+    private final Map<String, String> typesByCollectionNames = new HashMap<String, String>();
+
+    private final Map<CollectionScope, EntityCollectionManager> managers = new HashMap<>();
+    private final Map<CollectionScope, EntityCollectionIndex> indexes = new HashMap<>();
+    
+    public EntityManagerFacade( 
+        Id orgId, 
+        Id appId, 
+        EntityCollectionManagerFactory ecmf, 
+        EntityCollectionIndexFactory ecif ) {
+
+        this.appId = appId;
+        this.orgId = orgId;
+        this.ecmf = ecmf;
+        this.ecif = ecif;
+    }
+
+    private EntityCollectionIndex getIndex( CollectionScope scope ) { 
+        EntityCollectionIndex eci = indexes.get( scope );
+        if ( eci == null ) {
+            eci = ecif.createCollectionIndex( scope );
+            indexes.put( scope, eci );
+        }
+        return eci;
+    }
+
+    private EntityCollectionManager getManager( CollectionScope scope ) { 
+        EntityCollectionManager ecm = managers.get( scope );
+        if ( ecm == null ) {
+            ecm = ecmf.createCollectionManager( scope );
+            managers.put( scope, ecm);
+        }
+        return ecm;
+    }
+
+    public Entity create( String type, Map<String, Object> properties ) {
+
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
+        EntityCollectionManager ecm = getManager( scope );
+        EntityCollectionIndex eci = getIndex( scope );
+
+        final String collectionName;
+        if ( type.endsWith("y") ) {
+            collectionName = type.substring( 0, type.length() - 1) + "ies";
+        } else {
+            collectionName = type + "s";
+        }
+        typesByCollectionNames.put( collectionName, type );
+
+        Entity entity = new Entity(new SimpleId(UUIDGenerator.newTimeUUID(), type ));
+        entity = EntityBuilder.fromMap( scope.getName(), entity, properties );
+        entity.setField(new LongField("created", entity.getId().getUuid().timestamp()) );
+        entity.setField(new LongField("modified", entity.getId().getUuid().timestamp()) );
+        entity = ecm.write( entity ).toBlockingObservable().last();
+
+        eci.index( entity );
+        return entity;
+    }
+
+    public Results searchCollection( Entity user, String collectionName, Query query ) {
+
+        String type = typesByCollectionNames.get( collectionName );
+		if ( type == null ) {
+			throw new RuntimeException( 
+					"No type found for collection name: " + collectionName);
+		}
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
+
+        EntityCollectionIndex eci = getIndex( scope );
+        Results results = eci.execute( query );
+        return results;
+    }
+
+    public Entity get( Id id ) {
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, id.getType() );
+        EntityCollectionManager ecm = getManager( scope );
+        return ecm.load( id ).toBlockingObservable().last();
+    }
+
+    public void addToCollection( Entity user, String collectionName, Entity entity ) {
+        // basically a no-op except that can now map Entity type to collection name
+        typesByCollectionNames.put( collectionName, entity.getId().getType() );
+    }
+
+    public Entity getApplicationRef() {
+        return new Entity();
+    }
+
+    public void update( Entity entity ) {
+
+        String type = entity.getId().getType();
+
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
+        EntityCollectionManager ecm = getManager( scope );
+        EntityCollectionIndex eci = getIndex( scope );
+
+        final String collectionName;
+        if ( type.endsWith("y") ) {
+            collectionName = type.substring( 0, type.length() - 1) + "ies";
+        } else {
+            collectionName = type + "s";
+        }
+        typesByCollectionNames.put( collectionName, type );
+        
+        entity = ecm.write( entity ).toBlockingObservable().last();
+
+        eci.index( entity );
+    }
+
+	
+	public void delete( Entity entity ) {
+
+        String type = entity.getId().getType();
+
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
+        EntityCollectionManager ecm = getManager( scope );
+        EntityCollectionIndex eci = getIndex( scope );
+
+		eci.deindex( entity );
+		ecm.delete( entity.getId() );
+	}
+
+
+	public void setProperty( EntityRef entityRef, String fieldName, double lat, double lon ) {
+
+        String type = entityRef.getId().getType();
+
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
+        EntityCollectionManager ecm = getManager( scope );
+        EntityCollectionIndex eci = getIndex( scope );
+
+		Entity entity = ecm.load( entityRef.getId() ).toBlockingObservable().last();
+		entity.setField( new LocationField( fieldName, new Location( lat, lon )));
+
+        entity = ecm.write(entity).toBlockingObservable().last();
+        eci.index(entity);
+	}
+
+
+    public void refreshIndex() {
+        CollectionScope scope = new CollectionScopeImpl( appId, orgId, "dummy" );
+        EntityCollectionManager ecm = getManager( scope );
+        EntityCollectionIndex eci = getIndex( scope );
+		eci.refresh();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e6e7e82/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java
new file mode 100644
index 0000000..c9e1c84
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java
@@ -0,0 +1,177 @@
+/*
+ * 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.
+ */
+
+
+package org.apache.usergrid.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.field.BooleanField;
+import org.apache.usergrid.persistence.model.field.DoubleField;
+import org.apache.usergrid.persistence.model.field.EntityObjectField;
+import org.apache.usergrid.persistence.model.field.Field;
+import org.apache.usergrid.persistence.model.field.FloatField;
+import org.apache.usergrid.persistence.model.field.IntegerField;
+import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.LocationField;
+import org.apache.usergrid.persistence.model.field.LongField;
+import org.apache.usergrid.persistence.model.field.StringField;
+import org.apache.usergrid.persistence.model.field.value.Location;
+
+
+public class EntityBuilder {
+
+    public static Entity fromMap( String scope, Map<String, Object> item ) {
+        return fromMap( scope, null, item );
+    }
+
+    public static Entity fromMap( String scope, Entity entity, Map<String, Object> map ) {
+
+        if ( entity == null ) {
+            entity = new Entity();
+        }
+
+        for ( String fieldName : map.keySet() ) {
+
+            Object value = map.get( fieldName );
+
+            if ( value instanceof String ) {
+                entity.setField( new StringField( fieldName, (String)value ));
+
+            } else if ( value instanceof Boolean ) {
+                entity.setField( new BooleanField( fieldName, (Boolean)value ));
+                        
+            } else if ( value instanceof Integer ) {
+                entity.setField( new IntegerField( fieldName, (Integer)value ));
+
+            } else if ( value instanceof Double ) {
+                entity.setField( new DoubleField( fieldName, (Double)value ));
+
+		    } else if ( value instanceof Float ) {
+                entity.setField( new FloatField( fieldName, (Float)value ));
+				
+            } else if ( value instanceof Long ) {
+                entity.setField( new LongField( fieldName, (Long)value ));
+
+            } else if ( value instanceof List) {
+                entity.setField( listToListField( scope, fieldName, (List)value ));
+
+            } else if ( value instanceof Map ) {
+
+				Field field = null;
+
+				// is the map really a location element?
+				Map<String, Object> m = (Map<String, Object>)value;
+				if ( m.size() == 2) {
+					Double lat = null;
+					Double lon = null;
+					try {
+						if ( m.get("latitude") != null && m.get("longitude") != null ) {
+							lat = Double.parseDouble( m.get("latitude").toString() );
+							lon = Double.parseDouble( m.get("longitude").toString() );
+
+						} else if ( m.get("lat") != null && m.get("lon") != null ) { 
+							lat = Double.parseDouble( m.get("lat").toString() );
+							lon = Double.parseDouble( m.get("lon").toString() );
+						}
+					} catch ( NumberFormatException ignored ) {}
+
+					if ( lat != null && lon != null ) {
+						field = new LocationField( fieldName, new Location( lat, lon ));
+					}
+				}
+
+				if ( field == null ) { 
+
+					// not a location element, process it as map
+					entity.setField( new EntityObjectField( fieldName, 
+						fromMap( scope, (Map<String, Object>)value ))); // recursion
+
+				} else {
+					entity.setField( field );
+				}
+	
+			} else {
+                throw new RuntimeException("Unknown type " + value.getClass().getName());
+            }
+        }
+
+        return entity;
+    }
+
+    
+    private static ListField listToListField( String scope, String fieldName, List list ) {
+
+        if (list.isEmpty()) {
+            return new ListField( fieldName );
+        }
+
+        Object sample = list.get(0);
+
+        if ( sample instanceof Map ) {
+            return new ListField<Entity>( fieldName, processListForField( scope, list ));
+
+        } else if ( sample instanceof List ) {
+            return new ListField<List>( fieldName, processListForField( scope, list ));
+            
+        } else if ( sample instanceof String ) {
+            return new ListField<String>( fieldName, (List<String>)list );
+                    
+        } else if ( sample instanceof Boolean ) {
+            return new ListField<Boolean>( fieldName, (List<Boolean>)list );
+                    
+        } else if ( sample instanceof Integer ) {
+            return new ListField<Integer>( fieldName, (List<Integer>)list );
+
+        } else if ( sample instanceof Double ) {
+            return new ListField<Double>( fieldName, (List<Double>)list );
+
+        } else if ( sample instanceof Long ) {
+            return new ListField<Long>( fieldName, (List<Long>)list );
+
+        } else {
+            throw new RuntimeException("Unknown type " + sample.getClass().getName());
+        }
+    }
+
+    
+    private static List processListForField( String scope, List list ) {
+        if ( list.isEmpty() ) {
+            return list;
+        }
+        Object sample = list.get(0);
+
+        if ( sample instanceof Map ) {
+            List<Entity> newList = new ArrayList<Entity>();
+            for ( Map<String, Object> map : (List<Map<String, Object>>)list ) {
+                newList.add( fromMap( scope, map ) );
+            }
+            return newList;
+
+        } else if ( sample instanceof List ) {
+            return processListForField( scope, list ); // recursion
+            
+        } else { 
+            return list;
+        } 
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e6e7e82/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
index e951098..423780c 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
@@ -43,7 +43,7 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.persistence.query.Query;
 import org.apache.usergrid.persistence.query.Results;
-import org.apache.usergrid.persistence.index.legacy.EntityBuilder;
+import org.apache.usergrid.utils.EntityBuilder;
 import org.jukito.JukitoRunner;
 import org.jukito.UseModules;
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e6e7e82/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityBuilder.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityBuilder.java
deleted file mode 100644
index fefb8fb..0000000
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityBuilder.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * 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.
- */
-
-
-package org.apache.usergrid.persistence.index.legacy;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.field.BooleanField;
-import org.apache.usergrid.persistence.model.field.DoubleField;
-import org.apache.usergrid.persistence.model.field.EntityObjectField;
-import org.apache.usergrid.persistence.model.field.Field;
-import org.apache.usergrid.persistence.model.field.FloatField;
-import org.apache.usergrid.persistence.model.field.IntegerField;
-import org.apache.usergrid.persistence.model.field.ListField;
-import org.apache.usergrid.persistence.model.field.LocationField;
-import org.apache.usergrid.persistence.model.field.LongField;
-import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.persistence.model.field.value.Location;
-
-
-public class EntityBuilder {
-
-    public static Entity fromMap( String scope, Map<String, Object> item ) {
-        return fromMap( scope, null, item );
-    }
-
-    public static Entity fromMap( String scope, Entity entity, Map<String, Object> map ) {
-
-        if ( entity == null ) {
-            entity = new Entity();
-        }
-
-        for ( String fieldName : map.keySet() ) {
-
-            Object value = map.get( fieldName );
-
-            if ( value instanceof String ) {
-                entity.setField( new StringField( fieldName, (String)value ));
-
-            } else if ( value instanceof Boolean ) {
-                entity.setField( new BooleanField( fieldName, (Boolean)value ));
-                        
-            } else if ( value instanceof Integer ) {
-                entity.setField( new IntegerField( fieldName, (Integer)value ));
-
-            } else if ( value instanceof Double ) {
-                entity.setField( new DoubleField( fieldName, (Double)value ));
-
-		    } else if ( value instanceof Float ) {
-                entity.setField( new FloatField( fieldName, (Float)value ));
-				
-            } else if ( value instanceof Long ) {
-                entity.setField( new LongField( fieldName, (Long)value ));
-
-            } else if ( value instanceof List) {
-                entity.setField( listToListField( scope, fieldName, (List)value ));
-
-            } else if ( value instanceof Map ) {
-
-				Field field = null;
-
-				// is the map really a location element?
-				Map<String, Object> m = (Map<String, Object>)value;
-				if ( m.size() == 2) {
-					Double lat = null;
-					Double lon = null;
-					try {
-						if ( m.get("latitude") != null && m.get("longitude") != null ) {
-							lat = Double.parseDouble( m.get("latitude").toString() );
-							lon = Double.parseDouble( m.get("longitude").toString() );
-
-						} else if ( m.get("lat") != null && m.get("lon") != null ) { 
-							lat = Double.parseDouble( m.get("lat").toString() );
-							lon = Double.parseDouble( m.get("lon").toString() );
-						}
-					} catch ( NumberFormatException ignored ) {}
-
-					if ( lat != null && lon != null ) {
-						field = new LocationField( fieldName, new Location( lat, lon ));
-					}
-				}
-
-				if ( field == null ) { 
-
-					// not a location element, process it as map
-					entity.setField( new EntityObjectField( fieldName, 
-						fromMap( scope, (Map<String, Object>)value ))); // recursion
-
-				} else {
-					entity.setField( field );
-				}
-	
-			} else {
-                throw new RuntimeException("Unknown type " + value.getClass().getName());
-            }
-        }
-
-        return entity;
-    }
-
-    
-    private static ListField listToListField( String scope, String fieldName, List list ) {
-
-        if (list.isEmpty()) {
-            return new ListField( fieldName );
-        }
-
-        Object sample = list.get(0);
-
-        if ( sample instanceof Map ) {
-            return new ListField<Entity>( fieldName, processListForField( scope, list ));
-
-        } else if ( sample instanceof List ) {
-            return new ListField<List>( fieldName, processListForField( scope, list ));
-            
-        } else if ( sample instanceof String ) {
-            return new ListField<String>( fieldName, (List<String>)list );
-                    
-        } else if ( sample instanceof Boolean ) {
-            return new ListField<Boolean>( fieldName, (List<Boolean>)list );
-                    
-        } else if ( sample instanceof Integer ) {
-            return new ListField<Integer>( fieldName, (List<Integer>)list );
-
-        } else if ( sample instanceof Double ) {
-            return new ListField<Double>( fieldName, (List<Double>)list );
-
-        } else if ( sample instanceof Long ) {
-            return new ListField<Long>( fieldName, (List<Long>)list );
-
-        } else {
-            throw new RuntimeException("Unknown type " + sample.getClass().getName());
-        }
-    }
-
-    
-    private static List processListForField( String scope, List list ) {
-        if ( list.isEmpty() ) {
-            return list;
-        }
-        Object sample = list.get(0);
-
-        if ( sample instanceof Map ) {
-            List<Entity> newList = new ArrayList<Entity>();
-            for ( Map<String, Object> map : (List<Map<String, Object>>)list ) {
-                newList.add( fromMap( scope, map ) );
-            }
-            return newList;
-
-        } else if ( sample instanceof List ) {
-            return processListForField( scope, list ); // recursion
-            
-        } else { 
-            return list;
-        } 
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3e6e7e82/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
deleted file mode 100644
index e8eb5e1..0000000
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.usergrid.persistence.index.legacy;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.EntityCollectionManager;
-import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
-import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
-import org.apache.usergrid.persistence.index.EntityCollectionIndex;
-import org.apache.usergrid.persistence.index.EntityCollectionIndexFactory;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.model.field.LocationField;
-import org.apache.usergrid.persistence.model.field.LongField;
-import org.apache.usergrid.persistence.model.field.value.Location;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.query.EntityRef;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/** 
- * Implements just enough of the old EntityManager interface to get old tests imported from the
- * Usergrid 1.0 Core module working against the new Core Persistence index & query system.
- */
-public class EntityManagerFacade {
-    private static final Logger logger = LoggerFactory.getLogger( EntityManagerFacade.class );
-
-    private final Id orgId;
-    private final Id appId;
-    private final EntityCollectionManagerFactory ecmf;
-    private final EntityCollectionIndexFactory ecif;
-    private final Map<String, String> typesByCollectionNames = new HashMap<String, String>();
-
-    private final Map<CollectionScope, EntityCollectionManager> managers = new HashMap<>();
-    private final Map<CollectionScope, EntityCollectionIndex> indexes = new HashMap<>();
-    
-    public EntityManagerFacade( 
-        Id orgId, 
-        Id appId, 
-        EntityCollectionManagerFactory ecmf, 
-        EntityCollectionIndexFactory ecif ) {
-
-        this.appId = appId;
-        this.orgId = orgId;
-        this.ecmf = ecmf;
-        this.ecif = ecif;
-    }
-
-    private EntityCollectionIndex getIndex( CollectionScope scope ) { 
-        EntityCollectionIndex eci = indexes.get( scope );
-        if ( eci == null ) {
-            eci = ecif.createCollectionIndex( scope );
-            indexes.put( scope, eci );
-        }
-        return eci;
-    }
-
-    private EntityCollectionManager getManager( CollectionScope scope ) { 
-        EntityCollectionManager ecm = managers.get( scope );
-        if ( ecm == null ) {
-            ecm = ecmf.createCollectionManager( scope );
-            managers.put( scope, ecm);
-        }
-        return ecm;
-    }
-
-    public Entity create( String type, Map<String, Object> properties ) {
-
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
-        EntityCollectionManager ecm = getManager( scope );
-        EntityCollectionIndex eci = getIndex( scope );
-
-        final String collectionName;
-        if ( type.endsWith("y") ) {
-            collectionName = type.substring( 0, type.length() - 1) + "ies";
-        } else {
-            collectionName = type + "s";
-        }
-        typesByCollectionNames.put( collectionName, type );
-
-        Entity entity = new Entity(new SimpleId(UUIDGenerator.newTimeUUID(), type ));
-        entity = EntityBuilder.fromMap( scope.getName(), entity, properties );
-        entity.setField(new LongField("created", entity.getId().getUuid().timestamp()) );
-        entity.setField(new LongField("modified", entity.getId().getUuid().timestamp()) );
-        entity = ecm.write( entity ).toBlockingObservable().last();
-
-        eci.index( entity );
-        return entity;
-    }
-
-    public Results searchCollection( Entity user, String collectionName, Query query ) {
-
-        String type = typesByCollectionNames.get( collectionName );
-		if ( type == null ) {
-			throw new RuntimeException( 
-					"No type found for collection name: " + collectionName);
-		}
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
-
-        EntityCollectionIndex eci = getIndex( scope );
-        Results results = eci.execute( query );
-        return results;
-    }
-
-    public Entity get( Id id ) {
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, id.getType() );
-        EntityCollectionManager ecm = getManager( scope );
-        return ecm.load( id ).toBlockingObservable().last();
-    }
-
-    public void addToCollection( Entity user, String collectionName, Entity entity ) {
-        // basically a no-op except that can now map Entity type to collection name
-        typesByCollectionNames.put( collectionName, entity.getId().getType() );
-    }
-
-    public Entity getApplicationRef() {
-        return new Entity();
-    }
-
-    public void update( Entity entity ) {
-
-        String type = entity.getId().getType();
-
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
-        EntityCollectionManager ecm = getManager( scope );
-        EntityCollectionIndex eci = getIndex( scope );
-
-        final String collectionName;
-        if ( type.endsWith("y") ) {
-            collectionName = type.substring( 0, type.length() - 1) + "ies";
-        } else {
-            collectionName = type + "s";
-        }
-        typesByCollectionNames.put( collectionName, type );
-        
-        entity = ecm.write( entity ).toBlockingObservable().last();
-
-        eci.index( entity );
-    }
-
-	
-	public void delete( Entity entity ) {
-
-        String type = entity.getId().getType();
-
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
-        EntityCollectionManager ecm = getManager( scope );
-        EntityCollectionIndex eci = getIndex( scope );
-
-		eci.deindex( entity );
-		ecm.delete( entity.getId() );
-	}
-
-
-	public void setProperty( EntityRef entityRef, String fieldName, double lat, double lon ) {
-
-        String type = entityRef.getId().getType();
-
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, type );
-        EntityCollectionManager ecm = getManager( scope );
-        EntityCollectionIndex eci = getIndex( scope );
-
-		Entity entity = ecm.load( entityRef.getId() ).toBlockingObservable().last();
-		entity.setField( new LocationField( fieldName, new Location( lat, lon )));
-
-        entity = ecm.write(entity).toBlockingObservable().last();
-        eci.index(entity);
-	}
-
-
-    public void refreshIndex() {
-        CollectionScope scope = new CollectionScopeImpl( appId, orgId, "dummy" );
-        EntityCollectionManager ecm = getManager( scope );
-        EntityCollectionIndex eci = getIndex( scope );
-		eci.refresh();
-    }
-
-}