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

[1/4] incubator-usergrid git commit: Updated NodeRegistry to use only tags instead of external simple db

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-252 1f75549e9 -> 91e25b5ec


Updated NodeRegistry to use only tags instead of external simple db

Upgraded AWS client

Removed unused registry list groovy script


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

Branch: refs/heads/USERGRID-252
Commit: b12130f06d503f8c5a3fc29d6049a4df89eb5a7e
Parents: 1f75549
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Nov 25 17:38:42 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Nov 25 17:38:42 2014 -0700

----------------------------------------------------------------------
 stack/awscluster/gatling-cluster-cf.json        |  86 +++++++---
 stack/awscluster/pom.xml                        |   2 +-
 .../src/main/groovy/NodeRegistry.groovy         | 165 ++++++++++++-------
 .../src/main/groovy/registry_list.groovy        |  36 ----
 4 files changed, 168 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b12130f0/stack/awscluster/gatling-cluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/gatling-cluster-cf.json b/stack/awscluster/gatling-cluster-cf.json
index ff41f14..b9f9752 100644
--- a/stack/awscluster/gatling-cluster-cf.json
+++ b/stack/awscluster/gatling-cluster-cf.json
@@ -1,53 +1,89 @@
 {
     "AWSTemplateFormatVersion" : "2010-09-09",
     "Description" : "Gatling cluster",
-
-    "Parameters" : {
+    "Parameters": {
         "InstanceCount": {
-            "Description" : "The number of gatling instances to create",
+            "Description": "The number of gatling instances to create",
             "Type": "Number",
             "Default": "1",
             "MinValue": "1"
         },
-
         "KeyName": {
-            "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
+            "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
             "Type": "AWS::EC2::KeyPair::KeyName",
-            "Default" : "jenkins-east",
-            "ConstraintDescription" : "must be the name of an existing EC2 KeyPair."
+            "Default": "jenkins-east",
+            "ConstraintDescription": "must be the name of an existing EC2 KeyPair."
         },
-
-        "InstanceType" : {
-            "Description" : "WebServer EC2 instance type",
-            "Type" : "String",
-            "Default" : "m1.xlarge",
-            "AllowedValues" : [ "t1.micro", "t2.micro", "t2.small", "t2.medium", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "c1.medium", "c1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "g2.2xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge", "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "cg1.4xlarge"]
-            ,
-            "ConstraintDescription" : "must be a valid EC2 instance type."
+        "InstanceType": {
+            "Description": "WebServer EC2 instance type",
+            "Type": "String",
+            "Default": "m1.xlarge",
+            "AllowedValues": [
+                "t1.micro",
+                "t2.micro",
+                "t2.small",
+                "t2.medium",
+                "m1.small",
+                "m1.medium",
+                "m1.large",
+                "m1.xlarge",
+                "m2.xlarge",
+                "m2.2xlarge",
+                "m2.4xlarge",
+                "m3.medium",
+                "m3.large",
+                "m3.xlarge",
+                "m3.2xlarge",
+                "c1.medium",
+                "c1.xlarge",
+                "c3.large",
+                "c3.xlarge",
+                "c3.2xlarge",
+                "c3.4xlarge",
+                "c3.8xlarge",
+                "g2.2xlarge",
+                "r3.large",
+                "r3.xlarge",
+                "r3.2xlarge",
+                "r3.4xlarge",
+                "r3.8xlarge",
+                "i2.xlarge",
+                "i2.2xlarge",
+                "i2.4xlarge",
+                "i2.8xlarge",
+                "hi1.4xlarge",
+                "hs1.8xlarge",
+                "cr1.8xlarge",
+                "cc2.8xlarge",
+                "cg1.4xlarge"
+            ],
+            "ConstraintDescription": "must be a valid EC2 instance type."
         },
-
         "OperatorEMail": {
             "Description": "EMail address to notify if there are any scaling operations",
             "Type": "String",
             "AllowedPattern": "([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)",
             "ConstraintDescription": "must be a valid email address.",
-            "Default":"rbridges@apigee.com"
+            "Default": "rbridges@apigee.com"
         },
-
         "ReleaseBucket": {
             "Description": "S3 Bucket where Usergrid assembly is to be found.",
             "Type": "String",
             "Default": "usergrid-jenkins-builds"
         },
-
-        "SSHLocation" : {
-            "Description" : "The IP address range that can be used to SSH to the EC2 instances",
+        "SSHLocation": {
+            "Description": "The IP address range that can be used to SSH to the EC2 instances",
             "Type": "String",
             "MinLength": "9",
             "MaxLength": "18",
             "Default": "0.0.0.0/0",
             "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})",
             "ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
+        },
+        "Branch": {
+            "Description": "The branch of usergrid to check out",
+            "Type": "String",
+            "Default": "two-dot-o"
         }
     },
 
@@ -231,15 +267,11 @@
                     "apt-add-repository ppa:awstools-dev/awstools --yes\n",
                     "apt-get update\n",
                     "echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections\n",
-                    "apt-get install oracle-java7-installer oracle-java7-set-default expect expect-dev git ec2-api-tools -y --force-yes\n",
+                    "apt-get install oracle-java7-installer oracle-java7-set-default expect expect-dev git ec2-api-tools maven -y --force-yes\n",
                     "update-java-alternatives -s java-7-oracle\n",
 
-                    "mkdir -p /usr/local/apache-maven\n",
-                    "cd /usr/local/apache-maven\n",
-                    "wget http://apache.mirrors.timporter.net/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz\n",
-                    "tar -xzvf apache-maven-3.1.1-bin.tar.gz\n",
                     "cd ~ubuntu\n",
-                    "git clone https://github.com/apache/incubator-usergrid.git usergrid\n",
+                    "git clone -b ",{ "Ref":"Branch" } , " https://github.com/apache/incubator-usergrid.git usergrid\n",
                     "chown -R ubuntu:ubuntu usergrid\n",
                     "ec2-create-tags $(curl -k http://169.254.169.254/latest/meta-data/instance-id)  --aws-access-key ",{ "Ref":"GatlingKey" }, " --aws-secret-key ", { "Fn::GetAtt":[ "GatlingKey", "SecretAccessKey" ] } ," --tag Name=", { "Ref":"AWS::StackName"  }, "-Gatling\n"
                 ]]}}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b12130f0/stack/awscluster/pom.xml
----------------------------------------------------------------------
diff --git a/stack/awscluster/pom.xml b/stack/awscluster/pom.xml
index 4a8f4d6..46157ab 100644
--- a/stack/awscluster/pom.xml
+++ b/stack/awscluster/pom.xml
@@ -215,7 +215,7 @@
     <dependency>
       <groupId>com.amazonaws</groupId>
       <artifactId>aws-java-sdk</artifactId>
-      <version>1.6.7</version>
+      <version>1.9.7</version>
     </dependency>
     <dependency>
       <artifactId>groovy-all</artifactId>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b12130f0/stack/awscluster/src/main/groovy/NodeRegistry.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/NodeRegistry.groovy b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
index 6291f93..277631b 100644
--- a/stack/awscluster/src/main/groovy/NodeRegistry.groovy
+++ b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
@@ -20,34 +20,64 @@
  * A utility class that search simple db for the node type provided and returns a list of hostnames as a string array
  */
 import com.amazonaws.auth.BasicAWSCredentials
-import com.amazonaws.services.simpledb.AmazonSimpleDBClient
-import com.amazonaws.services.simpledb.model.*
+import com.amazonaws.regions.Region
+import com.amazonaws.regions.Regions
+import com.amazonaws.services.ec2.model.DescribeInstancesRequest
+import com.amazonaws.services.ec2.model.DescribeInstancesResult
+import com.amazonaws.services.ec2.model.DescribeTagsRequest
+import com.amazonaws.services.ec2.AmazonEC2Client
+import com.amazonaws.services.ec2.model.CreateTagsRequest
+import com.amazonaws.services.ec2.model.Filter
+import com.amazonaws.services.ec2.model.Instance
+import com.amazonaws.services.ec2.model.Tag
 
 class NodeRegistry {
 
+
+    public static final String TAG_PREFIX = "tag:"
+    //taken from aws
+    public static final String STACK_NAME = "usergrid:stack-name";
+    public static final String NODE_TYPE = "usergrid:node_type";
+
     private String accessKey = (String) System.getenv().get("AWS_ACCESS_KEY")
     private String secretKey = (String) System.getenv().get("AWS_SECRET_KEY")
     private String stackName = (String) System.getenv().get("STACK_NAME")
-    private hostName = (String) System.getenv().get("PUBLIC_HOSTNAME")
+    private String instanceId = (String) System.getenv().get("EC2_INSTANCE_ID");
+    private String region = (String) System.getenv().get("EC2_REGION");
     private String domain = stackName
 
-    private def creds;
-    private def sdbClient;
+    private BasicAWSCredentials creds;
+    private AmazonEC2Client ec2Client;
 
 
     NodeRegistry() {
-        while ( true ) {
-            try {
-                // creates domain or no-op if it already exists
-                creds = new BasicAWSCredentials(accessKey, secretKey)
-                sdbClient = new AmazonSimpleDBClient(creds)
-                sdbClient.createDomain(new CreateDomainRequest(domain))
-
-            } catch ( Exception e ) {
-                continue
-            }
-            break
+
+        if (region == null) {
+            throw new IllegalArgumentException("EC2_REGION must be defined")
+        }
+
+        if (instanceId == null) {
+            throw new IllegalArgumentException("EC2_INSTANCE_ID must be defined")
+        }
+
+        if (stackName == null) {
+            throw new IllegalArgumentException("STACK_NAME must be defined")
+        }
+
+        if (accessKey == null) {
+            throw new IllegalArgumentException("AWS_ACCESS_KEY must be defined")
+        }
+
+        if (secretKey == null) {
+            throw new IllegalArgumentException("AWS_SECRET_KEY must be defined")
         }
+
+        creds = new BasicAWSCredentials(accessKey, secretKey)
+        ec2Client = new AmazonEC2Client(creds)
+        def regionEnum = Regions.fromName(region);
+        ec2Client.setRegion(Region.getRegion(regionEnum))
+
+
     }
 
     /**
@@ -55,64 +85,85 @@ class NodeRegistry {
      * @param defNodeType
      */
     def searchNode(def nodeType) {
-        //order by create time, if we have a conflict, then order by item name
-        def selectResult = sdbClient.select(new SelectRequest((String) \
-            "select * from `${domain}` where itemName() is not null AND createtime is not null AND nodetype = '${nodeType}'  order by createtime"))
-        def result = []
-
-        for (item in selectResult.getItems()) {
-            def hostname = item.getName()
-            result.add(hostname)
+
+        def stackNameFilter = new Filter(TAG_PREFIX+STACK_NAME).withValues(stackName);
+        def nodeTypeFilter = new Filter(TAG_PREFIX+NODE_TYPE).withValues(nodeType);
+
+        def describeRequest = new DescribeInstancesRequest().withFilters(stackNameFilter, nodeTypeFilter);
+
+
+        def nodes = ec2Client.describeInstances(describeRequest)
+
+        //sort by created date
+        def servers = [];
+
+        for(reservation in nodes.getReservations()){
+
+            //TODO, add these to a list then sort them by date, then name
+            for(instance in reservation.getInstances()){
+
+                servers.add(new ServerEntry(instance.launchTime, instance.publicDnsName))
+            }
+
         }
 
-        return result
 
+
+        return createResults(servers);
     }
 
-    /**
-     * Get the entire database back in raw form
-     * @return
-     */
-    def selectAll() {
-        def selectResult = sdbClient.select(new SelectRequest((String) "select * from `${domain}`")).getItems()
+    def createResults(def servers){
+
+
+        Collections.sort(servers);
+        def results = [];
 
-        return selectResult;
+        for(server in servers){
+            results.add(server.publicIp)
+        }
+
+        return results;
     }
 
+
+
     /**
      * Add the node to the database if it doesn't exist
      */
     def addNode(def nodeType) {
-        def gar = new GetAttributesRequest(domain, hostName);
-        def response = sdbClient.getAttributes(gar);
-        if (response.getAttributes().size() == 1) {
-            println "Already registered"
-            def attrs = response.getAttributes()
-            for (att in attrs) {
-                println("${hostName} -> ${att.getName()} : ${att.getValue()}")
-            }
 
-            return false;
-
-        } else {
-            println "Registering..."
-            def stackAtt = new ReplaceableAttribute("nodetype", nodeType, true)
-            def nowString = Calendar.getInstance(TimeZone.getTimeZone('UTC')).format("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
-            def createTime = new ReplaceableAttribute("createtime", nowString, true)
-            def attrs = new ArrayList()
-            attrs.add(stackAtt)
-            attrs.add(createTime)
-            def par = new PutAttributesRequest(domain, hostName, attrs)
-            sdbClient.putAttributes(par);
-            println "Registration done."
-            return true;
-        }
+        //add the node type
+        def tagRequest = new CreateTagsRequest().withTags(new Tag(NODE_TYPE, nodeType), new Tag(STACK_NAME, stackName)).withResources(instanceId)
+
+
+
+        ec2Client.createTags(tagRequest)
 
 
     }
 
-    def deleteRegistry(){
-        sdbClient.deleteDomain(new DeleteDomainRequest(domain))
+
+    class ServerEntry implements Comparable<ServerEntry>{
+        private final Date launchDate;
+        private final String publicIp;
+
+        ServerEntry(final Date launchDate, final String publicIp) {
+            this.launchDate = launchDate
+            this.publicIp = publicIp
+        }
+
+        @Override
+        int compareTo(final ServerEntry o) {
+            if(launchDate.before(o.launchDate)){
+                -1;
+            }else if (launchDate.after(o.launchDate)){
+                return 1;
+            }
+
+            return publicIp.compareTo(o.publicIp);
+
+
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b12130f0/stack/awscluster/src/main/groovy/registry_list.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/registry_list.groovy b/stack/awscluster/src/main/groovy/registry_list.groovy
deleted file mode 100644
index ca3bcda..0000000
--- a/stack/awscluster/src/main/groovy/registry_list.groovy
+++ /dev/null
@@ -1,36 +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.
- */
-
-
-// 
-// registry_list.groovy 
-// 
-// List contents of registry as debugging aid. Not used in any other scripts. 
-//
-NodeRegistry registry = new NodeRegistry();
-
-
-
-
-for (item in registry.selectAll()) {
-    for(att in item.getAttributes()){
-        println "${item.getName()} -> ${att.getName()} : ${att.getValue()}"
-    }
-
-    println "\n"
-}


[3/4] incubator-usergrid git commit: Fixes bug with gatling registration

Posted by to...@apache.org.
Fixes bug with gatling registration

Fixes bug with instance states and not running instances


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

Branch: refs/heads/USERGRID-252
Commit: fd5be56925885b74739c9f16b6d37bd5a8ab7abf
Parents: 65a018f
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Nov 26 16:32:50 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Nov 26 17:08:25 2014 -0700

----------------------------------------------------------------------
 stack/awscluster/gatling-cluster-cf.json        | 12 ++-
 .../src/main/groovy/NodeRegistry.groovy         | 81 +++++++++++++++-----
 2 files changed, 67 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fd5be569/stack/awscluster/gatling-cluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/gatling-cluster-cf.json b/stack/awscluster/gatling-cluster-cf.json
index 59090de..4345e1e 100644
--- a/stack/awscluster/gatling-cluster-cf.json
+++ b/stack/awscluster/gatling-cluster-cf.json
@@ -216,10 +216,10 @@
                             },
                             "/etc/profile.d/maven.sh" : {
                                 "content" : { "Fn::Join" : ["", [
-                                    "export M2_HOME=/usr/local/apache-maven/apache-maven-3.1.1\n",
-                                    "export M2=$M2_HOME/bin\n",
+                                    "export M3_HOME=/usr/local/apache-maven/apache-maven-3.1.1\n",
+                                    "export M3=$M3_HOME/bin\n",
                                     "export MAVEN_OPTS=\"-Xms256m -Xmx512m\"\n",
-                                    "export PATH=$M2:$PATH\n"
+                                    "export PATH=$M3:$PATH\n"
                                 ]]}
                             },
 
@@ -265,10 +265,8 @@
                     "git clone -b ",{ "Ref":"Branch" } , " https://github.com/apache/incubator-usergrid.git usergrid\n",
                     "chown -R ubuntu:ubuntu usergrid\n",
 
-
-                    "/usr/local/bin/cfn-signal --success true --stack ", { "Ref" : "AWS::StackName" }, " --resource GatlingServerGroup --region ", { "Ref" : "AWS::Region" }, "\n",
-
-                    "ec2-create-tags $(curl -k http://169.254.169.254/latest/meta-data/instance-id)  --aws-access-key ",{ "Ref":"GatlingKey" }, " --aws-secret-key ", { "Fn::GetAtt":[ "GatlingKey", "SecretAccessKey" ] } ," --tag Name=", { "Ref":"AWS::StackName"  }, "-Gatling\n"
+                    "ec2-create-tags $(curl -k http://169.254.169.254/latest/meta-data/instance-id)  --aws-access-key ",{ "Ref":"GatlingKey" }, " --aws-secret-key ", { "Fn::GetAtt":[ "GatlingKey", "SecretAccessKey" ] } ," --tag Name=", { "Ref":"AWS::StackName"  }, "-Gatling\n",
+                    "/usr/local/bin/cfn-signal --success true --stack ", { "Ref" : "AWS::StackName" }, " --resource GatlingServerGroup --region ", { "Ref" : "AWS::Region" }, "\n"
                 ]]}}
             }
         },

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fd5be569/stack/awscluster/src/main/groovy/NodeRegistry.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/NodeRegistry.groovy b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
index 277631b..80a20eb 100644
--- a/stack/awscluster/src/main/groovy/NodeRegistry.groovy
+++ b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
@@ -22,14 +22,8 @@
 import com.amazonaws.auth.BasicAWSCredentials
 import com.amazonaws.regions.Region
 import com.amazonaws.regions.Regions
-import com.amazonaws.services.ec2.model.DescribeInstancesRequest
-import com.amazonaws.services.ec2.model.DescribeInstancesResult
-import com.amazonaws.services.ec2.model.DescribeTagsRequest
 import com.amazonaws.services.ec2.AmazonEC2Client
-import com.amazonaws.services.ec2.model.CreateTagsRequest
-import com.amazonaws.services.ec2.model.Filter
-import com.amazonaws.services.ec2.model.Instance
-import com.amazonaws.services.ec2.model.Tag
+import com.amazonaws.services.ec2.model.*
 
 class NodeRegistry {
 
@@ -86,36 +80,66 @@ class NodeRegistry {
      */
     def searchNode(def nodeType) {
 
-        def stackNameFilter = new Filter(TAG_PREFIX+STACK_NAME).withValues(stackName);
-        def nodeTypeFilter = new Filter(TAG_PREFIX+NODE_TYPE).withValues(nodeType);
+        def stackNameFilter = new Filter(TAG_PREFIX+STACK_NAME).withValues(stackName)
+        def nodeTypeFilter = new Filter(TAG_PREFIX+NODE_TYPE).withValues(nodeType)
 
-        def describeRequest = new DescribeInstancesRequest().withFilters(stackNameFilter, nodeTypeFilter);
 
 
-        def nodes = ec2Client.describeInstances(describeRequest)
+         //sort by created date
+        def servers = new TreeSet<ServerEntry>();
 
-        //sort by created date
-        def servers = [];
 
-        for(reservation in nodes.getReservations()){
+        def token = null
 
-            //TODO, add these to a list then sort them by date, then name
-            for(instance in reservation.getInstances()){
 
-                servers.add(new ServerEntry(instance.launchTime, instance.publicDnsName))
+
+        while(true){
+
+            def describeRequest = new DescribeInstancesRequest().withFilters(stackNameFilter, nodeTypeFilter)
+
+            if(token != null){
+                describeRequest.withNextToken(token);
+            }
+
+
+            def nodes = ec2Client.describeInstances(describeRequest)
+
+            for (reservation in nodes.getReservations()) {
+
+                //TODO, add these to a list then sort them by date, then name
+                for (instance in reservation.getInstances()) {
+
+                    //ignore instances that aren't running
+                    if (instance.state.getName() == InstanceStateName.Running.toString()) {
+                        servers.add(new ServerEntry(instance.launchTime, instance.publicDnsName));
+                    }
+
+
+                }
+
             }
 
+            //nothing to do, exit the loop
+            if(nodes.nextToken != null){
+                token = nodes.nextToken;
+            }
+            else{
+                break;
+            }
+
+
+
+
         }
 
 
 
+
         return createResults(servers);
     }
 
     def createResults(def servers){
 
-
-        Collections.sort(servers);
         def results = [];
 
         for(server in servers){
@@ -164,6 +188,25 @@ class NodeRegistry {
 
 
         }
+
+        boolean equals(final o) {
+            if (this.is(o)) return true
+            if (getClass() != o.class) return false
+
+            final ServerEntry that = (ServerEntry) o
+
+            if (launchDate != that.launchDate) return false
+            if (publicIp != that.publicIp) return false
+
+            return true
+        }
+
+        int hashCode() {
+            int result
+            result = launchDate.hashCode()
+            result = 31 * result + publicIp.hashCode()
+            return result
+        }
     }
 
 }


[4/4] incubator-usergrid git commit: Updated NodeRegistry to only select running instances in describe

Posted by to...@apache.org.
Updated NodeRegistry to only select running instances in describe

Updated yourkit to the latest version


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

Branch: refs/heads/USERGRID-252
Commit: 91e25b5ecbccc205e97694851cf825994153e4f7
Parents: fd5be56
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Dec 1 09:49:51 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Dec 1 09:49:51 2014 -0700

----------------------------------------------------------------------
 .../main/dist/init_instance/install_yourkit.sh  |  6 +--
 .../src/main/groovy/NodeRegistry.groovy         | 45 ++++++++------------
 2 files changed, 21 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/91e25b5e/stack/awscluster/src/main/groovy/NodeRegistry.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/NodeRegistry.groovy b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
index 80a20eb..51aa8af 100644
--- a/stack/awscluster/src/main/groovy/NodeRegistry.groovy
+++ b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
@@ -32,6 +32,9 @@ class NodeRegistry {
     //taken from aws
     public static final String STACK_NAME = "usergrid:stack-name";
     public static final String NODE_TYPE = "usergrid:node_type";
+    public static final String SEARCH_INSTANCE_STATE = "instance-state-name";
+    public static final String SEARCH_STACK_NAME = TAG_PREFIX + STACK_NAME
+    public static final String SEARCH_NODE_TYPE = TAG_PREFIX + NODE_TYPE
 
     private String accessKey = (String) System.getenv().get("AWS_ACCESS_KEY")
     private String secretKey = (String) System.getenv().get("AWS_SECRET_KEY")
@@ -80,12 +83,12 @@ class NodeRegistry {
      */
     def searchNode(def nodeType) {
 
-        def stackNameFilter = new Filter(TAG_PREFIX+STACK_NAME).withValues(stackName)
-        def nodeTypeFilter = new Filter(TAG_PREFIX+NODE_TYPE).withValues(nodeType)
 
+        def stackNameFilter = new Filter(SEARCH_STACK_NAME).withValues(stackName)
+        def nodeTypeFilter = new Filter(SEARCH_NODE_TYPE).withValues(nodeType)
+        def instanceState = new Filter(SEARCH_INSTANCE_STATE).withValues(InstanceStateName.Running.toString());
 
-
-         //sort by created date
+        //sort by created date
         def servers = new TreeSet<ServerEntry>();
 
 
@@ -93,11 +96,11 @@ class NodeRegistry {
 
 
 
-        while(true){
+        while (true) {
 
-            def describeRequest = new DescribeInstancesRequest().withFilters(stackNameFilter, nodeTypeFilter)
+            def describeRequest = new DescribeInstancesRequest().withFilters(stackNameFilter, nodeTypeFilter, instanceState)
 
-            if(token != null){
+            if (token != null) {
                 describeRequest.withNextToken(token);
             }
 
@@ -108,27 +111,17 @@ class NodeRegistry {
 
                 //TODO, add these to a list then sort them by date, then name
                 for (instance in reservation.getInstances()) {
-
-                    //ignore instances that aren't running
-                    if (instance.state.getName() == InstanceStateName.Running.toString()) {
-                        servers.add(new ServerEntry(instance.launchTime, instance.publicDnsName));
-                    }
-
-
+                    servers.add(new ServerEntry(instance.launchTime, instance.publicIpAddress));
                 }
 
             }
 
             //nothing to do, exit the loop
-            if(nodes.nextToken != null){
-                token = nodes.nextToken;
-            }
-            else{
+            if (nodes.nextToken == null) {
                 break;
             }
 
-
-
+            token = nodes.nextToken;
 
         }
 
@@ -138,19 +131,17 @@ class NodeRegistry {
         return createResults(servers);
     }
 
-    def createResults(def servers){
+    def createResults(def servers) {
 
         def results = [];
 
-        for(server in servers){
+        for (server in servers) {
             results.add(server.publicIp)
         }
 
         return results;
     }
 
-
-
     /**
      * Add the node to the database if it doesn't exist
      */
@@ -167,7 +158,7 @@ class NodeRegistry {
     }
 
 
-    class ServerEntry implements Comparable<ServerEntry>{
+    class ServerEntry implements Comparable<ServerEntry> {
         private final Date launchDate;
         private final String publicIp;
 
@@ -178,9 +169,9 @@ class NodeRegistry {
 
         @Override
         int compareTo(final ServerEntry o) {
-            if(launchDate.before(o.launchDate)){
+            if (launchDate.before(o.launchDate)) {
                 -1;
-            }else if (launchDate.after(o.launchDate)){
+            } else if (launchDate.after(o.launchDate)) {
                 return 1;
             }
 


[2/4] incubator-usergrid git commit: Removed unused params in gatling cluster. Moved signal of success to last step

Posted by to...@apache.org.
Removed unused params in gatling cluster.  Moved signal of success to last step

Updated key selection to be a drop down of valid ssh keys


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

Branch: refs/heads/USERGRID-252
Commit: 65a018f8c06090d043d6016cc713941c1f30a91d
Parents: b12130f
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Nov 26 10:50:18 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Nov 26 10:50:18 2014 -0700

----------------------------------------------------------------------
 stack/awscluster/gatling-cluster-cf.json | 19 +++++++------------
 stack/awscluster/ugcluster-cf.json       |  7 ++++---
 2 files changed, 11 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/65a018f8/stack/awscluster/gatling-cluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/gatling-cluster-cf.json b/stack/awscluster/gatling-cluster-cf.json
index b9f9752..59090de 100644
--- a/stack/awscluster/gatling-cluster-cf.json
+++ b/stack/awscluster/gatling-cluster-cf.json
@@ -11,13 +11,13 @@
         "KeyName": {
             "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
             "Type": "AWS::EC2::KeyPair::KeyName",
-            "Default": "jenkins-east",
+            "Default": "ug-cloudformation",
             "ConstraintDescription": "must be the name of an existing EC2 KeyPair."
         },
         "InstanceType": {
             "Description": "WebServer EC2 instance type",
             "Type": "String",
-            "Default": "m1.xlarge",
+            "Default": "c3.xlarge",
             "AllowedValues": [
                 "t1.micro",
                 "t2.micro",
@@ -66,11 +66,6 @@
             "ConstraintDescription": "must be a valid email address.",
             "Default": "rbridges@apigee.com"
         },
-        "ReleaseBucket": {
-            "Description": "S3 Bucket where Usergrid assembly is to be found.",
-            "Type": "String",
-            "Default": "usergrid-jenkins-builds"
-        },
         "SSHLocation": {
             "Description": "The IP address range that can be used to SSH to the EC2 instances",
             "Type": "String",
@@ -253,15 +248,11 @@
                     "wget https://bootstrap.pypa.io/ez_setup.py -O - | python\n",
                     "easy_install  https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
                     "## These don't seem to work correctly and cause script to bail.  Temporarily removing \n",
-                    "#/usr/local/bin/cfn-init -v ",
+                    "/usr/local/bin/cfn-init -v ",
                     "         --stack ", { "Ref" : "AWS::StackName" },
                     "         --resource LaunchConfig ",
                     "         --region ", { "Ref" : "AWS::Region" }, "\n",
 
-                    "#/usr/local/bin/cfn-signal -e $? ",
-                    "         --stack ", { "Ref" : "AWS::StackName" },
-                    "         --resource GatlingServerGroup ",
-                    "         --region ", { "Ref" : "AWS::Region" }, "\n",
 
                     "add-apt-repository ppa:webupd8team/java --yes\n",
                     "apt-add-repository ppa:awstools-dev/awstools --yes\n",
@@ -273,6 +264,10 @@
                     "cd ~ubuntu\n",
                     "git clone -b ",{ "Ref":"Branch" } , " https://github.com/apache/incubator-usergrid.git usergrid\n",
                     "chown -R ubuntu:ubuntu usergrid\n",
+
+
+                    "/usr/local/bin/cfn-signal --success true --stack ", { "Ref" : "AWS::StackName" }, " --resource GatlingServerGroup --region ", { "Ref" : "AWS::Region" }, "\n",
+
                     "ec2-create-tags $(curl -k http://169.254.169.254/latest/meta-data/instance-id)  --aws-access-key ",{ "Ref":"GatlingKey" }, " --aws-secret-key ", { "Fn::GetAtt":[ "GatlingKey", "SecretAccessKey" ] } ," --tag Name=", { "Ref":"AWS::StackName"  }, "-Gatling\n"
                 ]]}}
             }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/65a018f8/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index 5b599ec..02058e5 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -47,9 +47,10 @@
             "ConstraintDescription": "must be valid instance type."
         },
         "KeyPair": {
-            "Description": "EC2 key pair to be use for SSH access",
-            "Type": "String",
-            "Default": "ug-cloudformation"
+          "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
+          "Type": "AWS::EC2::KeyPair::KeyName",
+          "Default": "ug-cloudformation",
+          "ConstraintDescription": "must be the name of an existing EC2 KeyPair."
         },
         "CassClusterName": {
             "Description": "Name to be used for Cassandra cluster.",