You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2014/03/19 19:35:44 UTC
git commit: Added jobStats on old role page. Disabled job status
badge.
Repository: incubator-aurora
Updated Branches:
refs/heads/master 6c1d4027f -> c421e9969
Added jobStats on old role page. Disabled job status badge.
Added jobStats on role page.
We have stopped counting recently failed task count which is used to display the health badge.
Since this badge is being removed from the new UI, removed it from the old UI as well.
Testing Done:
./gradlew clean build
gradlew run
Bugs closed: AURORA-271
Reviewed at https://reviews.apache.org/r/19323/
Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/c421e996
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/c421e996
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/c421e996
Branch: refs/heads/master
Commit: c421e9969b147b3dd2005b7564e97851b5c7222f
Parents: 6c1d402
Author: Suman Karumuri <ma...@apache.org>
Authored: Wed Mar 19 11:32:47 2014 -0700
Committer: Suman Karumuri <sk...@twitter.com>
Committed: Wed Mar 19 11:32:47 2014 -0700
----------------------------------------------------------------------
build.gradle | 9 ++-
.../org/apache/aurora/scheduler/base/Jobs.java | 5 +-
.../aurora/scheduler/http/SchedulerzRole.java | 65 ++++++++++++++------
.../thrift/SchedulerThriftInterface.java | 2 +-
.../aurora/tools/java/thrift_wrapper_codegen.py | 10 +--
.../aurora/scheduler/http/schedulerzrole.st | 23 -------
.../apache/aurora/scheduler/base/JobsTest.java | 5 +-
7 files changed, 66 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c421e996/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index f38888b..c2a70b0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -257,9 +257,14 @@ 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'
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c421e996/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/c421e996/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..e2f9ed0 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;
@@ -206,25 +208,31 @@ public class SchedulerzRole extends JerseyTemplateServlet {
IJobKey jobKey = tasksByJobKey.getKey();
Collection<IScheduledTask> tasks = tasksByJobKey.getValue();
- Job job = new Job();
- job.environment = jobKey.getEnvironment();
- job.name = jobKey.getName();
-
// Pick the freshest task's config and associate it with the job.
ITaskConfig mostRecentTaskConfig =
getLatestActiveTask(tasks).getAssignedTask().getTask();
- job.production = mostRecentTaskConfig.isProduction();
+ JobType jobType;
// TODO(Suman Karumuri): Add a source/job type to TaskConfig and replace logic below
if (mostRecentTaskConfig.isIsService()) {
- job.type = JobType.SERVICE;
+ jobType = JobType.SERVICE;
} else if (cronJobs.containsKey(jobKey)) {
- job.type = JobType.CRON;
+ jobType = JobType.CRON;
} else {
- job.type = JobType.ADHOC;
+ jobType = JobType.ADHOC;
}
- return job;
+ IJobStats stats = Jobs.getJobStats(tasks);
+
+ return new Job(jobKey.getName(),
+ jobKey.getEnvironment(),
+ stats.getPendingTaskCount(),
+ stats.getActiveTaskCount(),
+ stats.getFinishedTaskCount(),
+ stats.getFailedTaskCount(),
+ 0,
+ mostRecentTaskConfig.isProduction(),
+ jobType);
}
};
@@ -246,15 +254,36 @@ public class SchedulerzRole extends JerseyTemplateServlet {
* Template object to represent a job.
*/
static class Job {
- private String name;
- private String environment;
- private int pendingTaskCount = 0;
- private int activeTaskCount = 0;
- private int finishedTaskCount = 0;
- private int failedTaskCount = 0;
- private int recentlyFailedTaskCount = 0;
- private boolean production = false;
- private JobType type;
+ private final String name;
+ private final String environment;
+ private final int pendingTaskCount;
+ private final int activeTaskCount;
+ private final int finishedTaskCount;
+ private final int failedTaskCount;
+ private final int recentlyFailedTaskCount;
+ private final boolean production;
+ private final JobType type;
+
+ Job(String name,
+ String environment,
+ int pendingTaskCount,
+ int activeTaskCount,
+ int finishedTaskCount,
+ int failedTaskCount,
+ int recentlyFailedTaskCount,
+ boolean production,
+ JobType type) {
+
+ this.name = name;
+ this.environment = environment;
+ this.pendingTaskCount = pendingTaskCount;
+ this.activeTaskCount = activeTaskCount;
+ this.finishedTaskCount = finishedTaskCount;
+ this.failedTaskCount = failedTaskCount;
+ this.recentlyFailedTaskCount = recentlyFailedTaskCount;
+ this.production = production;
+ this.type = type;
+ }
public String getName() {
return name;
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c421e996/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/c421e996/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)
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c421e996/src/main/resources/org/apache/aurora/scheduler/http/schedulerzrole.st
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/http/schedulerzrole.st b/src/main/resources/org/apache/aurora/scheduler/http/schedulerzrole.st
index 39c1d95..b53f352 100644
--- a/src/main/resources/org/apache/aurora/scheduler/http/schedulerzrole.st
+++ b/src/main/resources/org/apache/aurora/scheduler/http/schedulerzrole.st
@@ -220,33 +220,10 @@
function drawBadges() {
jQuery('#jobs-table>tbody').find('tr').each(function(){
var tr = jQuery(this);
- displayHealthBadge(tr);
displayProductionBadge(tr);
});
}
- function displayHealthBadge(tr) {
- var activeTasks = Number(tr.find('.active-tasks').val());
- var recentlyFailedTasks = Number(tr.find('.recently-failed-tasks').val());
- var pendingTasks = Number(tr.find('.pending-tasks').val());
- var finishedTasks = Number(tr.find('.finished-tasks').val());
- var totalTasks = pendingTasks + activeTasks + finishedTasks;
- var jobStatus = tr.find('.job-status');
-
- if (recentlyFailedTasks >= (totalTasks / 2)) {
- jobStatus.addClass('label-important').html('Unstable');
- jobStatus.attr('title', 'More than half of total tasks have failed in last 6 hours');
- } else if (recentlyFailedTasks > 0) {
- jobStatus.addClass('label-warning').html('Warning');
- jobStatus.attr('title', 'One or more tasks have failed in last 6 hours');
- } else {
- jobStatus.addClass('label-success').html('Stable');
- jobStatus.attr('title', 'No failed tasks in last 6 hours');
- }
-
- jobStatus.tooltip();
- }
-
function displayProductionBadge(tr) {
var productionBadgeElem = tr.find('.production-badge');
var production = tr.find('.production').val();
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/c421e996/src/test/java/org/apache/aurora/scheduler/base/JobsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/base/JobsTest.java b/src/test/java/org/apache/aurora/scheduler/base/JobsTest.java
index 6524e24..effe14b 100644
--- a/src/test/java/org/apache/aurora/scheduler/base/JobsTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/base/JobsTest.java
@@ -24,6 +24,7 @@ import com.google.common.collect.Sets;
import org.apache.aurora.gen.JobStats;
import org.apache.aurora.gen.ScheduleStatus;
+import org.apache.aurora.scheduler.storage.entities.IJobStats;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
import org.junit.Test;
@@ -44,11 +45,11 @@ public class JobsTest {
}
}).toList();
- JobStats expectedStats = new JobStats()
+ IJobStats expectedStats = IJobStats.build(new JobStats()
.setActiveTaskCount(7)
.setFailedTaskCount(3)
.setFinishedTaskCount(2)
- .setPendingTaskCount(3);
+ .setPendingTaskCount(3));
assertEquals(expectedStats, Jobs.getJobStats(tasks));
}