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:18 UTC

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

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;
             }