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/07 00:47:43 UTC
git commit: Added cluster name to page title.
Repository: incubator-aurora
Updated Branches:
refs/heads/master b49a2ab42 -> 6e4fe853e
Added cluster name to page title.
Added a ServerInfo struct to each thrift response.
Testing Done:
gradle clean build.
gradle run.
Bugs closed: AURORA-120
Reviewed at https://reviews.apache.org/r/17562/
Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/6e4fe853
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/6e4fe853
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/6e4fe853
Branch: refs/heads/master
Commit: 6e4fe853e8807d1403229b58c05a533e440fc116
Parents: b49a2ab
Author: Suman Karumuri <ma...@apache.org>
Authored: Thu Mar 6 15:44:41 2014 -0800
Committer: Suman Karumuri <sk...@twitter.com>
Committed: Thu Mar 6 15:44:41 2014 -0800
----------------------------------------------------------------------
build.gradle | 2 +-
.../apache/aurora/scheduler/app/AppModule.java | 12 ++-
.../aurora/scheduler/http/ClusterName.java | 33 ------
.../aurora/scheduler/http/SchedulerzJob.java | 8 +-
.../aurora/scheduler/http/SchedulerzRole.java | 5 +-
.../aurora/scheduler/http/ServletModule.java | 3 +-
.../apache/aurora/scheduler/http/Slaves.java | 7 +-
.../aurora/scheduler/http/Utilization.java | 5 +-
.../thrift/aop/APIVersionInterceptor.java | 34 ------
.../aurora/scheduler/thrift/aop/AopModule.java | 2 +-
.../thrift/aop/ServerInfoInterceptor.java | 39 +++++++
.../aurora/scheduler/http/ui/js/controllers.js | 85 ++++++++-------
.../aurora/scheduler/http/ui/js/services.js | 36 +++++--
.../thrift/org/apache/aurora/gen/api.thrift | 17 ++-
.../thrift/SchedulerThriftInterfaceTest.java | 4 +
.../aurora/scheduler/thrift/ThriftIT.java | 3 +
.../thrift/aop/APIVersionInterceptorTest.java | 93 ----------------
.../scheduler/thrift/aop/AopModuleTest.java | 3 +
.../thrift/aop/ServerInfoInterceptorTest.java | 105 +++++++++++++++++++
.../org/apache/aurora/gen/api.thrift.md5 | 2 +-
20 files changed, 268 insertions(+), 230 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index ba83b91..265f385 100644
--- a/build.gradle
+++ b/build.gradle
@@ -235,7 +235,7 @@ task generateSources(dependsOn: 'bootstrapThrift') {
}
// 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'].each {
+ ['JobConfiguration', 'Lock', 'ResourceAggregate', 'ScheduledTask', 'ServerInfo'].each {
def structName = it
exec {
executable = 'python'
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/java/org/apache/aurora/scheduler/app/AppModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/app/AppModule.java b/src/main/java/org/apache/aurora/scheduler/app/AppModule.java
index 296bc1f..eeafc78 100644
--- a/src/main/java/org/apache/aurora/scheduler/app/AppModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/app/AppModule.java
@@ -26,7 +26,6 @@ import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import com.google.inject.AbstractModule;
-import com.google.inject.Key;
import com.google.inject.Provides;
import com.twitter.common.application.ShutdownRegistry;
import com.twitter.common.application.modules.LifecycleModule;
@@ -46,22 +45,25 @@ import com.twitter.common.zookeeper.guice.client.ZooKeeperClientModule.ClientCon
import com.twitter.thrift.ServiceInstance;
import org.apache.aurora.GuiceUtils;
+import org.apache.aurora.gen.ServerInfo;
import org.apache.aurora.scheduler.SchedulerModule;
import org.apache.aurora.scheduler.async.AsyncModule;
import org.apache.aurora.scheduler.events.PubsubEventModule;
import org.apache.aurora.scheduler.filter.SchedulingFilterImpl;
-import org.apache.aurora.scheduler.http.ClusterName;
import org.apache.aurora.scheduler.http.ServletModule;
import org.apache.aurora.scheduler.metadata.MetadataModule;
import org.apache.aurora.scheduler.quota.QuotaModule;
import org.apache.aurora.scheduler.state.StateModule;
import org.apache.aurora.scheduler.stats.AsyncStatsModule;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
import org.apache.mesos.Scheduler;
import org.apache.zookeeper.data.ACL;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.twitter.common.base.MorePreconditions.checkNotBlank;
+import static org.apache.aurora.gen.apiConstants.THRIFT_API_VERSION;
+
/**
* Binding module for the aurora scheduler application.
*/
@@ -87,7 +89,11 @@ class AppModule extends AbstractModule {
bind(Clock.class).toInstance(Clock.SYSTEM_CLOCK);
- bind(Key.get(String.class, ClusterName.class)).toInstance(clusterName);
+ bind(IServerInfo.class).toInstance(
+ IServerInfo.build(
+ new ServerInfo()
+ .setClusterName(clusterName)
+ .setThriftAPIVersion(THRIFT_API_VERSION)));
// Filter layering: notifier filter -> base impl
PubsubEventModule.bind(binder(), SchedulingFilterImpl.class);
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/java/org/apache/aurora/scheduler/http/ClusterName.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/ClusterName.java b/src/main/java/org/apache/aurora/scheduler/http/ClusterName.java
deleted file mode 100644
index ac77f6a..0000000
--- a/src/main/java/org/apache/aurora/scheduler/http/ClusterName.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2013 Apache Software Foundation
- *
- * Licensed 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.
- */
-package org.apache.aurora.scheduler.http;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import com.google.inject.BindingAnnotation;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Binding annotation for the cluster name.
- */
-@BindingAnnotation
-@Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
-public @interface ClusterName { }
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/java/org/apache/aurora/scheduler/http/SchedulerzJob.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/SchedulerzJob.java b/src/main/java/org/apache/aurora/scheduler/http/SchedulerzJob.java
index 3686a66..c14e195 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/SchedulerzJob.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/SchedulerzJob.java
@@ -62,6 +62,7 @@ import org.apache.aurora.scheduler.storage.entities.IAssignedTask;
import org.apache.aurora.scheduler.storage.entities.IConstraint;
import org.apache.aurora.scheduler.storage.entities.IJobKey;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
import org.apache.aurora.scheduler.storage.entities.ITaskConstraint;
@@ -191,19 +192,18 @@ public class SchedulerzJob extends JerseyTemplateServlet {
/**
* Creates a new job servlet.
*
- * @param storage Backing store to fetch tasks from.
- * @param clusterName Name of the serving cluster.
+ * @param storage a reference to scheduler storage.
*/
@Inject
public SchedulerzJob(
Storage storage,
CronJobManager cronJobManager,
- @ClusterName String clusterName,
+ IServerInfo serverInfo,
NearestFit nearestFit) {
super("schedulerzjob");
this.storage = checkNotNull(storage);
- this.clusterName = checkNotBlank(clusterName);
+ this.clusterName = checkNotBlank(serverInfo.getClusterName());
this.nearestFit = checkNotNull(nearestFit);
this.cronJobManager = checkNotNull(cronJobManager);
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/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 25ba7da..60b2259 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/SchedulerzRole.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/SchedulerzRole.java
@@ -64,6 +64,7 @@ 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.IScheduledTask;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -104,14 +105,14 @@ public class SchedulerzRole extends JerseyTemplateServlet {
Storage storage,
CronJobManager cronJobManager,
CronPredictor cronPredictor,
- @ClusterName String clusterName,
+ IServerInfo serverInfo,
QuotaManager quotaManager) {
super("schedulerzrole");
this.storage = checkNotNull(storage);
this.cronJobManager = checkNotNull(cronJobManager);
this.cronPredictor = checkNotNull(cronPredictor);
- this.clusterName = checkNotBlank(clusterName);
+ this.clusterName = checkNotBlank(serverInfo.getClusterName());
this.quotaManager = checkNotNull(quotaManager);
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java b/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java
index 36aa425..e3ff257 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java
@@ -42,6 +42,7 @@ import com.twitter.thrift.ServiceInstance;
import org.apache.aurora.scheduler.quota.QuotaManager;
import org.apache.aurora.scheduler.state.CronJobManager;
import org.apache.aurora.scheduler.state.SchedulerCore;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
import static com.sun.jersey.api.core.ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS;
import static com.sun.jersey.api.core.ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS;
@@ -61,7 +62,7 @@ public class ServletModule extends AbstractModule {
protected void configure() {
requireBinding(SchedulerCore.class);
requireBinding(CronJobManager.class);
- requireBinding(Key.get(String.class, ClusterName.class));
+ requireBinding(IServerInfo.class);
requireBinding(QuotaManager.class);
// Bindings required for the leader redirector.
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/java/org/apache/aurora/scheduler/http/Slaves.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/Slaves.java b/src/main/java/org/apache/aurora/scheduler/http/Slaves.java
index cc8971c..9fa9818 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/Slaves.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/Slaves.java
@@ -34,6 +34,7 @@ import org.apache.aurora.gen.Attribute;
import org.apache.aurora.gen.HostAttributes;
import org.apache.aurora.gen.MaintenanceMode;
import org.apache.aurora.scheduler.storage.Storage;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.twitter.common.base.MorePreconditions.checkNotBlank;
@@ -52,13 +53,13 @@ public class Slaves extends JerseyTemplateServlet {
/**
* Injected constructor.
*
- * @param clusterName cluster name
+ * @param serverInfo server meta-data that contains the cluster name
* @param storage store to fetch the host attributes from
*/
@Inject
- public Slaves(@ClusterName String clusterName, Storage storage) {
+ public Slaves(IServerInfo serverInfo, Storage storage) {
super("slaves");
- this.clusterName = checkNotBlank(clusterName);
+ this.clusterName = checkNotBlank(serverInfo.getClusterName());
this.storage = checkNotNull(storage);
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/java/org/apache/aurora/scheduler/http/Utilization.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/http/Utilization.java b/src/main/java/org/apache/aurora/scheduler/http/Utilization.java
index 0cbdeea..1296bc7 100644
--- a/src/main/java/org/apache/aurora/scheduler/http/Utilization.java
+++ b/src/main/java/org/apache/aurora/scheduler/http/Utilization.java
@@ -45,6 +45,7 @@ import org.apache.aurora.scheduler.stats.ResourceCounter;
import org.apache.aurora.scheduler.stats.ResourceCounter.GlobalMetric;
import org.apache.aurora.scheduler.stats.ResourceCounter.Metric;
import org.apache.aurora.scheduler.stats.ResourceCounter.MetricType;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
/**
@@ -58,10 +59,10 @@ public class Utilization {
private final StringTemplateHelper templateHelper;
@Inject
- Utilization(ResourceCounter counter, @ClusterName String clusterName) {
+ Utilization(ResourceCounter counter, IServerInfo serverInfo) {
templateHelper = new StringTemplateHelper(getClass(), "utilization", true);
this.counter = Preconditions.checkNotNull(counter);
- this.clusterName = MorePreconditions.checkNotBlank(clusterName);
+ this.clusterName = MorePreconditions.checkNotBlank(serverInfo.getClusterName());
}
private String fillTemplate(Map<Display, Metric> metrics) {
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/java/org/apache/aurora/scheduler/thrift/aop/APIVersionInterceptor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/aop/APIVersionInterceptor.java b/src/main/java/org/apache/aurora/scheduler/thrift/aop/APIVersionInterceptor.java
deleted file mode 100644
index e3e050e..0000000
--- a/src/main/java/org/apache/aurora/scheduler/thrift/aop/APIVersionInterceptor.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2013 Apache Software Foundation
- *
- * Licensed 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.
- */
-package org.apache.aurora.scheduler.thrift.aop;
-
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
-import org.apache.aurora.gen.Response;
-
-import static org.apache.aurora.gen.apiConstants.CURRENT_API_VERSION;
-
-class APIVersionInterceptor implements MethodInterceptor {
-
- @Override
- public Object invoke(MethodInvocation invocation) throws Throwable {
- Response resp = (Response) invocation.proceed();
- if (resp.version == null) {
- resp.setVersion(CURRENT_API_VERSION);
- }
- return resp;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/java/org/apache/aurora/scheduler/thrift/aop/AopModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/aop/AopModule.java b/src/main/java/org/apache/aurora/scheduler/thrift/aop/AopModule.java
index c68977a..9c2a74a 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/aop/AopModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/aop/AopModule.java
@@ -128,7 +128,7 @@ public class AopModule extends AbstractModule {
});
bindThriftDecorator(new FeatureToggleInterceptor());
bindThriftDecorator(new ThriftStatsExporterInterceptor());
- bindThriftDecorator(new APIVersionInterceptor());
+ bindThriftDecorator(new ServerInfoInterceptor());
}
private void bindThriftDecorator(MethodInterceptor interceptor) {
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/java/org/apache/aurora/scheduler/thrift/aop/ServerInfoInterceptor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/aop/ServerInfoInterceptor.java b/src/main/java/org/apache/aurora/scheduler/thrift/aop/ServerInfoInterceptor.java
new file mode 100644
index 0000000..e34eef9
--- /dev/null
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/aop/ServerInfoInterceptor.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2013 Apache Software Foundation
+ *
+ * Licensed 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.
+ */
+package org.apache.aurora.scheduler.thrift.aop;
+
+import javax.inject.Inject;
+
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+import org.apache.aurora.gen.Response;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
+
+import static org.apache.aurora.gen.apiConstants.CURRENT_API_VERSION;
+
+class ServerInfoInterceptor implements MethodInterceptor {
+
+ @Inject
+ private IServerInfo serverInfo;
+
+ @Override
+ public Object invoke(MethodInvocation invocation) throws Throwable {
+ Response resp = (Response) invocation.proceed();
+ resp.setDEPRECATEDversion(CURRENT_API_VERSION);
+ resp.setServerInfo(serverInfo.newBuilder());
+ return resp;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
index 1916ff9..7cd5344 100644
--- a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
+++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
@@ -2,43 +2,48 @@
/* Controllers */
-angular.module('auroraUI.controllers', []).
- controller('JobSummaryController',
- function ($scope, $window, auroraClient) {
- $scope.title = 'Scheduled Jobs Summary';
-
- $scope.error = false;
- $scope.reloadMsg = "An error occurred when querying the server. Please reload this page.";
- $scope.errorMsg = "";
-
- $scope.columnCollection = [
- {label : 'Role', map: 'role', cellTemplateUrl: 'roleLink.html'},
- {label : 'Jobs', map: 'jobCount'},
- {label : 'Cron Jobs', map: 'cronJobCount'}
- ];
-
- $scope.rowCollection = parseResponse(auroraClient.getJobSummary());
-
- function parseResponse(response) {
- $scope.error = response.error;
- $scope.errorMsg = response.errorMsg;
- // TODO(Suman Karumuri): Replace sort with defaultSortColumn once it lands
- // https://github.com/lorenzofox3/Smart-Table/pull/61
- return response.summaries.sort(function (a, b) {
- if (a.role.toLowerCase() > b.role.toLowerCase()) {
- return 1;
- }
- if (a.role.toLowerCase() < b.role.toLowerCase()) {
- return -1;
- }
- return 0;
- });
- }
-
- $scope.globalConfig = {
- isGlobalSearchActivated: true,
- isPaginationEnabled: true,
- itemsByPage: 25,
- maxSize: 8
- };
- });
+var auroraUIControllers = angular.module('auroraUI.controllers', []);
+
+auroraUIControllers.controller('JobSummaryController',
+ function ($scope, $window, auroraClient) {
+ $scope.title = 'Scheduled Jobs Summary';
+
+ $scope.error = false;
+ $scope.reloadMsg = "An error occurred when querying the server. Please reload this page.";
+ $scope.errorMsg = "";
+
+ $scope.columnCollection = [
+ {label: 'Role', map: 'role', cellTemplateUrl: 'roleLink.html'},
+ {label: 'Jobs', map: 'jobCount'},
+ {label: 'Cron Jobs', map: 'cronJobCount'}
+ ];
+
+ $scope.rowCollection = parseResponse(auroraClient.getRoleSummary());
+
+ function parseResponse(response) {
+ $scope.error = response.error;
+ $scope.errorMsg = response.errorMsg;
+
+ // Not the best way to set the page title, but this works on all browsers.
+ $window.document.title = response.pageTitle;
+
+ // TODO(Suman Karumuri): Replace sort with defaultSortColumn once it lands
+ // https://github.com/lorenzofox3/Smart-Table/pull/61
+ return response.summaries.sort(function (a, b) {
+ if (a.role.toLowerCase() > b.role.toLowerCase()) {
+ return 1;
+ }
+ if (a.role.toLowerCase() < b.role.toLowerCase()) {
+ return -1;
+ }
+ return 0;
+ });
+ }
+
+ $scope.globalConfig = {
+ isGlobalSearchActivated: true,
+ isPaginationEnabled: true,
+ itemsByPage: 25,
+ maxSize: 8
+ };
+ });
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js
index 9418964..81cd12c 100644
--- a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js
+++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/services.js
@@ -4,19 +4,35 @@ auroraUI.factory(
'auroraClient',
function () {
return {
- getJobSummary: function () {
- var response = this.makeSchedulerClient().getRoleSummary();
+ getRoleSummary: function () {
+ var response = this.getSchedulerClient().getRoleSummary();
return {
- error : response.responseCode !== 1,
- errorMsg : response.message,
- summaries : response.result !== null ? response.result.roleSummaryResult.summaries : []
+ error: response.responseCode !== 1,
+ errorMsg: response.message,
+ summaries: response.result !== null ? response.result.roleSummaryResult.summaries : [],
+ pageTitle: this.getPageTitle(response.serverInfo)
}
- },
+ },
- makeSchedulerClient: function () {
- var transport = new Thrift.Transport("/api/");
- var protocol = new Thrift.Protocol(transport);
- return new ReadOnlySchedulerClient(protocol);
+ // TODO(Suman Karumuri): Make schedulerClient a service
+ schedulerClient: null,
+
+ getSchedulerClient: function () {
+ if (!this.schedulerClient) {
+ var transport = new Thrift.Transport("/api/");
+ var protocol = new Thrift.Protocol(transport);
+ this.schedulerClient = new ReadOnlySchedulerClient(protocol);
+ return this.schedulerClient;
+ } else {
+ return this.schedulerClient;
+ }
+ },
+
+ getPageTitle: function (info) {
+ var title = "Aurora UI";
+ return info.error || typeof info.clusterName === "undefined"
+ ? title
+ : info.clusterName + " " + title;
}
};
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/main/thrift/org/apache/aurora/gen/api.thrift
----------------------------------------------------------------------
diff --git a/src/main/thrift/org/apache/aurora/gen/api.thrift b/src/main/thrift/org/apache/aurora/gen/api.thrift
index 2afbb4c..159bdaa 100644
--- a/src/main/thrift/org/apache/aurora/gen/api.thrift
+++ b/src/main/thrift/org/apache/aurora/gen/api.thrift
@@ -28,12 +28,14 @@ enum ResponseCode {
LOCK_ERROR = 5 // Raised when a Lock-protected operation failed due to lock validation.
}
+const i32 THRIFT_API_VERSION = 3
+
struct APIVersion {
1: required i32 major
}
// Scheduler Thrift API Version. Increment this when breaking backwards compatibility.
-const APIVersion CURRENT_API_VERSION = {'major': 3}
+const APIVersion CURRENT_API_VERSION = {'major': THRIFT_API_VERSION}
// Aurora executor framework name.
const string AURORA_EXECUTOR_NAME = 'AuroraExecutor'
@@ -407,6 +409,12 @@ struct RoleSummaryResult {
1: set<RoleSummary> summaries
}
+// meta-data about the thrift server that is wrapped around every thrift response
+struct ServerInfo {
+ 1: string clusterName
+ 2: i32 thriftAPIVersion
+}
+
union Result {
1: PopulateJobResult populateJobResult
3: ScheduleStatusResult scheduleStatusResult
@@ -426,7 +434,10 @@ union Result {
struct Response {
1: ResponseCode responseCode
2: string message
- 4: APIVersion version
+ // TODO(Suman Karumuri): Remove version field
+ // version field is deprecated.
+ 4: APIVersion DEPRECATEDversion
+ 5: ServerInfo serverInfo
3: optional Result result
}
@@ -445,6 +456,8 @@ service ReadOnlyScheduler {
// Fetches the quota allocated for a user.
Response getQuota(1: string ownerRole)
+ // TODO(Suman Karumuri): Delete this API once it is no longer used.
+ // NOTE: This API is deprecated.
// Returns the current version of the API implementation
Response getVersion()
}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index cd532bd..9712f30 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -59,6 +59,7 @@ import org.apache.aurora.gen.RoleSummary;
import org.apache.aurora.gen.RoleSummaryResult;
import org.apache.aurora.gen.ScheduleStatus;
import org.apache.aurora.gen.ScheduledTask;
+import org.apache.aurora.gen.ServerInfo;
import org.apache.aurora.gen.SessionKey;
import org.apache.aurora.gen.TaskConfig;
import org.apache.aurora.gen.TaskConstraint;
@@ -86,6 +87,7 @@ import org.apache.aurora.scheduler.storage.entities.ILock;
import org.apache.aurora.scheduler.storage.entities.ILockKey;
import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
import org.apache.aurora.scheduler.storage.entities.IScheduledTask;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
import org.apache.aurora.scheduler.storage.entities.ITaskConfig;
import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
import org.apache.aurora.scheduler.thrift.aop.AopModule;
@@ -176,6 +178,8 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
bind(CronJobManager.class).toInstance(cronJobManager);
bind(QuotaManager.class).toInstance(quotaManager);
bind(AuroraAdmin.Iface.class).to(SchedulerThriftInterface.class);
+ bind(IServerInfo.class).toInstance(IServerInfo.build(
+ new ServerInfo().setClusterName("test").setThriftAPIVersion(1)));
}
};
Injector injector = Guice.createInjector(testModule, new AopModule());
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java b/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
index f5effe7..e78ee7b 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/ThriftIT.java
@@ -32,6 +32,7 @@ import org.apache.aurora.auth.CapabilityValidator.Capability;
import org.apache.aurora.auth.SessionValidator;
import org.apache.aurora.gen.AuroraAdmin;
import org.apache.aurora.gen.ResourceAggregate;
+import org.apache.aurora.gen.ServerInfo;
import org.apache.aurora.gen.SessionKey;
import org.apache.aurora.scheduler.cron.CronScheduler;
import org.apache.aurora.scheduler.quota.QuotaManager;
@@ -44,6 +45,7 @@ import org.apache.aurora.scheduler.storage.Storage.NonVolatileStorage;
import org.apache.aurora.scheduler.storage.backup.Recovery;
import org.apache.aurora.scheduler.storage.backup.StorageBackup;
import org.apache.aurora.scheduler.storage.entities.IResourceAggregate;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
import org.apache.aurora.scheduler.storage.testing.StorageTestUtil;
import org.apache.aurora.scheduler.thrift.auth.ThriftAuthModule;
import org.junit.Before;
@@ -161,6 +163,7 @@ public class ThriftIT extends EasyMockTest {
bind(QuotaManager.class).toInstance(quotaManager);
bind(SessionValidator.class).toInstance(validator);
bind(CapabilityValidator.class).toInstance(new CapabilityValidatorFake(validator));
+ bind(IServerInfo.class).toInstance(IServerInfo.build(new ServerInfo()));
}
}
);
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/test/java/org/apache/aurora/scheduler/thrift/aop/APIVersionInterceptorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/aop/APIVersionInterceptorTest.java b/src/test/java/org/apache/aurora/scheduler/thrift/aop/APIVersionInterceptorTest.java
deleted file mode 100644
index 2f0b671..0000000
--- a/src/test/java/org/apache/aurora/scheduler/thrift/aop/APIVersionInterceptorTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * Copyright 2013 Apache Software Foundation
- *
- * Licensed 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.
- */
-package org.apache.aurora.scheduler.thrift.aop;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.matcher.Matchers;
-import com.twitter.common.testing.easymock.EasyMockTest;
-
-import org.apache.aurora.gen.APIVersion;
-import org.apache.aurora.gen.AuroraAdmin;
-import org.apache.aurora.gen.GetJobsResult;
-import org.apache.aurora.gen.JobConfiguration;
-import org.apache.aurora.gen.Response;
-import org.apache.aurora.gen.Result;
-import org.apache.aurora.scheduler.thrift.auth.DecoratedThrift;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.apache.aurora.gen.ResponseCode.OK;
-import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class APIVersionInterceptorTest extends EasyMockTest {
-
- private static final String ROLE = "bob";
-
- private AuroraAdmin.Iface realThrift;
- private AuroraAdmin.Iface decoratedThrift;
-
- private APIVersionInterceptor interceptor;
-
- @Before
- public void setUp() {
- interceptor = new APIVersionInterceptor();
- realThrift = createMock(AuroraAdmin.Iface.class);
- Injector injector = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- MockDecoratedThrift.bindForwardedMock(binder(), realThrift);
- AopModule.bindThriftDecorator(
- binder(),
- Matchers.annotatedWith(DecoratedThrift.class),
- interceptor);
- }
- });
- decoratedThrift = injector.getInstance(AuroraAdmin.Iface.class);
- }
-
- @Test
- public void testVersionIsSet() throws Exception {
- Response response = new Response().setResponseCode(OK)
- .setResult(Result.getJobsResult(new GetJobsResult()
- .setConfigs(ImmutableSet.<JobConfiguration>of())));
-
- expect(realThrift.getJobs(ROLE)).andReturn(response);
- control.replay();
-
- assertNotNull(decoratedThrift.getJobs(ROLE).version);
- }
-
- @Test
- public void testExistingVersion() throws Exception {
- Response response = new Response().setResponseCode(OK)
- .setResult(Result.getJobsResult(new GetJobsResult()
- .setConfigs(ImmutableSet.<JobConfiguration>of())))
- .setVersion(new APIVersion().setMajor(1));
-
- expect(realThrift.getJobs(ROLE)).andReturn(response);
- control.replay();
-
- Response decoratedResponse = decoratedThrift.getJobs(ROLE);
- assertNotNull(decoratedResponse.version);
- assertEquals(decoratedResponse.version.getMajor(), 1);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/test/java/org/apache/aurora/scheduler/thrift/aop/AopModuleTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/aop/AopModuleTest.java b/src/test/java/org/apache/aurora/scheduler/thrift/aop/AopModuleTest.java
index d93ac53..0d8c733 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/aop/AopModuleTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/aop/AopModuleTest.java
@@ -29,7 +29,9 @@ import org.apache.aurora.gen.AuroraAdmin.Iface;
import org.apache.aurora.gen.JobConfiguration;
import org.apache.aurora.gen.Response;
import org.apache.aurora.gen.ResponseCode;
+import org.apache.aurora.gen.ServerInfo;
import org.apache.aurora.gen.SessionKey;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
import org.junit.Before;
import org.junit.Test;
@@ -59,6 +61,7 @@ public class AopModuleTest extends EasyMockTest {
@Override
protected void configure() {
bind(CapabilityValidator.class).toInstance(capabilityValidator);
+ bind(IServerInfo.class).toInstance(IServerInfo.build(new ServerInfo()));
MockDecoratedThrift.bindForwardedMock(binder(), mockThrift);
}
},
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/test/java/org/apache/aurora/scheduler/thrift/aop/ServerInfoInterceptorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/aop/ServerInfoInterceptorTest.java b/src/test/java/org/apache/aurora/scheduler/thrift/aop/ServerInfoInterceptorTest.java
new file mode 100644
index 0000000..dd991fb
--- /dev/null
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/aop/ServerInfoInterceptorTest.java
@@ -0,0 +1,105 @@
+/**
+ * Copyright 2013 Apache Software Foundation
+ *
+ * Licensed 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.
+ */
+package org.apache.aurora.scheduler.thrift.aop;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.matcher.Matchers;
+import com.twitter.common.testing.easymock.EasyMockTest;
+
+import org.apache.aurora.gen.AuroraAdmin;
+import org.apache.aurora.gen.GetJobsResult;
+import org.apache.aurora.gen.JobConfiguration;
+import org.apache.aurora.gen.Response;
+import org.apache.aurora.gen.Result;
+import org.apache.aurora.gen.ServerInfo;
+import org.apache.aurora.scheduler.storage.entities.IServerInfo;
+import org.apache.aurora.scheduler.thrift.auth.DecoratedThrift;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.apache.aurora.gen.ResponseCode.OK;
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class ServerInfoInterceptorTest extends EasyMockTest {
+
+ private static final String ROLE = "bob";
+
+ private AuroraAdmin.Iface realThrift;
+ private AuroraAdmin.Iface decoratedThrift;
+
+ private static final IServerInfo SERVER_INFO =
+ IServerInfo.build(new ServerInfo().setClusterName("test").setThriftAPIVersion(1));
+
+ private ServerInfoInterceptor interceptor;
+
+ @Before
+ public void setUp() {
+ interceptor = new ServerInfoInterceptor();
+ realThrift = createMock(AuroraAdmin.Iface.class);
+ Injector injector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ MockDecoratedThrift.bindForwardedMock(binder(), realThrift);
+ bind(IServerInfo.class).toInstance(SERVER_INFO);
+ AopModule.bindThriftDecorator(
+ binder(),
+ Matchers.annotatedWith(DecoratedThrift.class),
+ interceptor);
+ }
+ });
+ decoratedThrift = injector.getInstance(AuroraAdmin.Iface.class);
+ }
+
+ @Test
+ public void testVersionIsSet() throws Exception {
+ Response response = okResponse(
+ Result.getJobsResult(
+ new GetJobsResult().setConfigs(ImmutableSet.<JobConfiguration>of())));
+
+ expect(realThrift.getJobs(ROLE)).andReturn(response);
+ control.replay();
+
+ assertNotNull(decoratedThrift.getJobs(ROLE).DEPRECATEDversion);
+ }
+
+ @Test
+ public void testServerInfoIsSet() throws Exception {
+ ServerInfo previousServerInfo =
+ new ServerInfo().setClusterName("FAKECLUSTER").setThriftAPIVersion(100000);
+
+ Response response = okResponse(
+ Result.getJobsResult(
+ new GetJobsResult().setConfigs(ImmutableSet.<JobConfiguration>of())))
+ .setServerInfo(previousServerInfo);
+
+ expect(realThrift.getJobs(ROLE)).andReturn(response);
+
+ control.replay();
+
+ assertEquals(SERVER_INFO.newBuilder(), decoratedThrift.getJobs(ROLE).serverInfo);
+ }
+
+ private static Response okResponse(Result result) {
+ return new Response()
+ .setResponseCode(OK)
+ .setResult(result);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/6e4fe853/src/test/resources/org/apache/aurora/gen/api.thrift.md5
----------------------------------------------------------------------
diff --git a/src/test/resources/org/apache/aurora/gen/api.thrift.md5 b/src/test/resources/org/apache/aurora/gen/api.thrift.md5
index 5cfa330..593d154 100644
--- a/src/test/resources/org/apache/aurora/gen/api.thrift.md5
+++ b/src/test/resources/org/apache/aurora/gen/api.thrift.md5
@@ -1 +1 @@
-48965974ea35ab83fc54651c4f13f604
+5132f760c254dd05a9e7bdd57a5684cc