aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject git commit: Fix task aggregate counts in roles page.
Date Mon, 17 Mar 2014 22:26:20 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/wfarner/fix_jobs_page fe6ab446a -> 2ce304215


Fix task aggregate counts in roles page.


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

Branch: refs/heads/wfarner/fix_jobs_page
Commit: 2ce304215b099687c3d2f89701a81707a11cca7f
Parents: fe6ab44
Author: Bill Farner <wfarner@apache.org>
Authored: Mon Mar 17 15:25:52 2014 -0700
Committer: Bill Farner <wfarner@apache.org>
Committed: Mon Mar 17 15:25:52 2014 -0700

----------------------------------------------------------------------
 build.gradle                                              | 10 ++++++++--
 src/main/java/org/apache/aurora/scheduler/base/Jobs.java  |  5 +++--
 .../org/apache/aurora/scheduler/http/SchedulerzRole.java  |  8 ++++++++
 .../aurora/scheduler/thrift/SchedulerThriftInterface.java |  2 +-
 .../apache/aurora/tools/java/thrift_wrapper_codegen.py    | 10 +++++-----
 5 files changed, 25 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2ce30421/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index f38888b..4d6784b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -257,13 +257,19 @@ task generateSources(dependsOn: 'bootstrapThrift') {
         args = ['--gen', 'java:hashcode', '--gen', 'js', '-o', outputDir, file]
       }
     }
-    // These are the 'root' structs, the tool recursively generates all composed structs.
     // TODO(wfarner): Change codegen tool to generate for all structs in a thrift file.
-    ['JobConfiguration', 'Lock', 'ResourceAggregate', 'ScheduledTask', 'ServerInfo'].each
{
+    def iStructs = ['JobConfiguration',
+                    'JobStats',
+                    'Lock',
+                    'ResourceAggregate',
+                    'ScheduledTask',
+                    'ServerInfo']
+    iStructs.each {
       def structName = it
       exec {
         executable = 'python'
         args = ['src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py',
+                '-v',
                 'src/main/thrift/org/apache/aurora/gen/api.thrift',
                 structName,
                 generatedJavaDir]

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2ce30421/src/main/java/org/apache/aurora/scheduler/base/Jobs.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/base/Jobs.java b/src/main/java/org/apache/aurora/scheduler/base/Jobs.java
index 3f02703..4ac218b 100644
--- a/src/main/java/org/apache/aurora/scheduler/base/Jobs.java
+++ b/src/main/java/org/apache/aurora/scheduler/base/Jobs.java
@@ -16,6 +16,7 @@
 package org.apache.aurora.scheduler.base;
 
 import org.apache.aurora.gen.JobStats;
+import org.apache.aurora.scheduler.storage.entities.IJobStats;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 
 /**
@@ -33,7 +34,7 @@ public final class Jobs {
    * @param tasks a collection of tasks for which statistics are sought
    * @return an JobStats object containing the statistics about the tasks.
    */
-  public static JobStats getJobStats(Iterable<IScheduledTask> tasks) {
+  public static IJobStats getJobStats(Iterable<IScheduledTask> tasks) {
     JobStats stats = new JobStats();
     for (IScheduledTask task : tasks) {
       switch (task.getStatus()) {
@@ -68,6 +69,6 @@ public final class Jobs {
           throw new IllegalArgumentException("Unsupported status: " + task.getStatus());
       }
     }
-    return stats;
+    return IJobStats.build(stats);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2ce30421/src/main/java/org/apache/aurora/scheduler/http/SchedulerzRole.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/SchedulerzRole.java b/src/main/java/org/apache/aurora/scheduler/http/SchedulerzRole.java
index b3f3124..2634fdc 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/SchedulerzRole.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/SchedulerzRole.java
@@ -41,6 +41,7 @@ import com.twitter.common.base.Closure;
 import org.antlr.stringtemplate.StringTemplate;
 import org.apache.aurora.gen.CronCollisionPolicy;
 import org.apache.aurora.scheduler.base.JobKeys;
+import org.apache.aurora.scheduler.base.Jobs;
 import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.cron.CronPredictor;
@@ -50,6 +51,7 @@ import org.apache.aurora.scheduler.state.CronJobManager;
 import org.apache.aurora.scheduler.storage.Storage;
 import org.apache.aurora.scheduler.storage.entities.IJobConfiguration;
 import org.apache.aurora.scheduler.storage.entities.IJobKey;
+import org.apache.aurora.scheduler.storage.entities.IJobStats;
 import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
 import org.apache.aurora.scheduler.storage.entities.IServerInfo;
 import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
@@ -224,6 +226,12 @@ public class SchedulerzRole extends JerseyTemplateServlet {
               job.type = JobType.ADHOC;
             }
 
+            IJobStats stats = Jobs.getJobStats(tasks);
+            job.pendingTaskCount = stats.getPendingTaskCount();
+            job.activeTaskCount = stats.getActiveTaskCount();
+            job.failedTaskCount = stats.getFailedTaskCount();
+            job.finishedTaskCount = stats.getFinishedTaskCount();
+
             return job;
           }
         };

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2ce30421/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index ee81b49..0d1e214 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -411,7 +411,7 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
       public JobSummary apply(IJobKey jobKey) {
         return new JobSummary()
             .setJob(jobs.get(jobKey).newBuilder())
-            .setStats(Jobs.getJobStats(tasks.get(jobKey)));
+            .setStats(Jobs.getJobStats(tasks.get(jobKey)).newBuilder());
       }
     };
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/2ce30421/src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py b/src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py
index 3143c6a..28b9984 100644
--- a/src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py
+++ b/src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py
@@ -445,9 +445,9 @@ if __name__ == '__main__':
     print('usage: %s thrift_file struct_name output_directory' % sys.argv[0])
     sys.exit(1)
 
-  thrift_file, struct_name, output_directory = sys.argv[1:]
-  log('Searching for %s in %s' % (sys.argv[2], sys.argv[1]))
-  with open(sys.argv[1]) as f:
+  thrift_file, struct_name, output_directory = args
+  log('Searching for %s in %s' % (struct_name, thrift_file))
+  with open(thrift_file) as f:
     # Load all structs found in the thrift file.
     structs = parse_structs(f.read())
 
@@ -483,7 +483,7 @@ if __name__ == '__main__':
       symbol_table[name] = symbol
       return symbol
 
-    find_symbol(sys.argv[2])
+    find_symbol(struct_name)
     log('Symbol table:')
     for _, symbol in symbol_table.items():
       log('    %s' % symbol)
@@ -493,7 +493,7 @@ if __name__ == '__main__':
         if symbol.kind == 'enum':
           log('Skipping code generation for %s, since it is immutable' % symbol.name)
         else:
-          package_dir = os.path.join(sys.argv[3], PACKAGE_NAME.replace('.', os.path.sep))
+          package_dir = os.path.join(output_directory, PACKAGE_NAME.replace('.', os.path.sep))
           if not os.path.isdir(package_dir):
             os.makedirs(package_dir)
           gen_file = os.path.join(package_dir, '%s.java' % symbol.codegen_name)


Mime
View raw message