usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [29/50] [abbrv] incubator-usergrid git commit: Fixes bug with gatling registration
Date Wed, 03 Dec 2014 19:59:39 GMT
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/two-dot-o-events
Commit: fd5be56925885b74739c9f16b6d37bd5a8ab7abf
Parents: 65a018f
Author: Todd Nine <tnine@apigee.com>
Authored: Wed Nov 26 16:32:50 2014 -0700
Committer: Todd Nine <tnine@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
+        }
     }
 
 }


Mime
View raw message