You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2014/09/30 22:48:21 UTC
[15/35] git commit: AMBARI-7546. Slider View: Creating slider view
should use labels, queue and log aggregation settings (srimanth)
AMBARI-7546. Slider View: Creating slider view should use labels, queue and log aggregation settings (srimanth)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4d229c8d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4d229c8d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4d229c8d
Branch: refs/heads/branch-alerts-dev
Commit: 4d229c8db5b8df3302a04a0f1a17165ac79c3ce3
Parents: cc9adee
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Mon Sep 29 14:27:47 2014 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Mon Sep 29 15:42:56 2014 -0700
----------------------------------------------------------------------
.../slider-core/0.51.0/slider-core-0.51.0.jar | Bin 1146908 -> 1155217 bytes
.../slider/SliderAppsViewControllerImpl.java | 55 ++++++++++++-----
.../createAppWizard/step4_controller.js | 59 +++++++++++++++----
.../ui/app/templates/createAppWizard/step1.hbs | 2 +-
.../src/main/resources/ui/app/translations.js | 3 +-
5 files changed, 91 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4d229c8d/contrib/views/slider/lib/org/apache/slider/slider-core/0.51.0/slider-core-0.51.0.jar
----------------------------------------------------------------------
diff --git a/contrib/views/slider/lib/org/apache/slider/slider-core/0.51.0/slider-core-0.51.0.jar b/contrib/views/slider/lib/org/apache/slider/slider-core/0.51.0/slider-core-0.51.0.jar
index 2dfbb60..7c2e42f 100644
Binary files a/contrib/views/slider/lib/org/apache/slider/slider-core/0.51.0/slider-core-0.51.0.jar and b/contrib/views/slider/lib/org/apache/slider/slider-core/0.51.0/slider-core-0.51.0.jar differ
http://git-wip-us.apache.org/repos/asf/ambari/blob/4d229c8d/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java
index 552d06f..42e9316 100644
--- a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java
+++ b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/SliderAppsViewControllerImpl.java
@@ -73,6 +73,7 @@ import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -472,7 +473,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
yarnConfig.set("fs.defaultFS", hdfsPath);
yarnConfig.set("slider.zookeeper.quorum", zkQuorum.toString());
yarnConfig.set("yarn.application.classpath",
- "/etc/hadoop/conf,/usr/lib/hadoop/*,/usr/lib/hadoop/lib/*,/usr/lib/hadoop-hdfs/*,/usr/lib/hadoop-hdfs/lib/*,/usr/lib/hadoop-yarn/*,/usr/lib/hadoop-yarn/lib/*,/usr/lib/hadoop-mapreduce/*,/usr/lib/hadoop-mapreduce/lib/*");
+ "/etc/hadoop/conf,/usr/hdp/current/hadoop/*,/usr/hdp/current/hadoop/lib/*,/usr/hdp/current/hadoop-hdfs/*,/usr/hdp/current/hadoop-hdfs/lib/*,/usr/hdp/current/hadoop-yarn/*,/usr/hdp/current/hadoop-yarn/lib/*,/usr/hdp/current/hadoop-mapreduce/*,/usr/hdp/current/hadoop-mapreduce/lib/*");
if (securedCluster) {
String rmPrincipal = viewContext.getProperties().get(PROPERTY_YARN_RM_PRINCIPAL);
@@ -711,11 +712,13 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
public String createSliderApp(JsonObject json) throws IOException,
YarnException, InterruptedException {
if (json.has("name") && json.has("typeConfigs")
- && json.has("typeComponents") && json.has("typeName")) {
+ && json.has("resources") && json.has("typeName")) {
final String appType = json.get("typeName").getAsString();
final String appName = json.get("name").getAsString();
+ final String queueName = json.get("queue").getAsString();
JsonObject configs = json.get("typeConfigs").getAsJsonObject();
- JsonArray componentsArray = json.get("typeComponents").getAsJsonArray();
+ JsonObject resourcesObj = json.get("resources").getAsJsonObject();
+ JsonArray componentsArray = resourcesObj.get("components").getAsJsonArray();
String appsCreateFolderPath = getAppsCreateFolderPath();
File appsCreateFolder = new File(appsCreateFolderPath);
if (!appsCreateFolder.exists()) {
@@ -745,12 +748,15 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
File appConfigJsonFile = new File(appCreateFolder, "appConfig.json");
File resourcesJsonFile = new File(appCreateFolder, "resources.json");
saveAppConfigs(configs, componentsArray, appConfigJsonFile);
- saveAppResources(componentsArray, resourcesJsonFile);
+ saveAppResources(resourcesObj, resourcesJsonFile);
final ActionCreateArgs createArgs = new ActionCreateArgs();
createArgs.template = appConfigJsonFile;
createArgs.resources = resourcesJsonFile;
-
+ if (queueName != null && queueName.trim().length() > 0) {
+ createArgs.queue = queueName;
+ }
+
final ActionInstallPackageArgs installArgs = new ActionInstallPackageArgs();
SliderAppType sliderAppType = getSliderAppType(appType, null);
String localAppPackageFileName = sliderAppType.getTypePackageFileName();
@@ -774,30 +780,47 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
return null;
}
- private void saveAppResources(JsonArray componentsArray,
+ private void saveAppResources(JsonObject clientResourcesObj,
File resourcesJsonFile) throws IOException {
JsonObject resourcesObj = new JsonObject();
+ JsonArray clientComponentsArray = clientResourcesObj.get("components").getAsJsonArray();
resourcesObj.addProperty("schema",
"http://example.org/specification/v2.0.0");
resourcesObj.add("metadata", new JsonObject());
- resourcesObj.add("global", new JsonObject());
+ resourcesObj.add("global", clientResourcesObj.get("global").getAsJsonObject());
JsonObject componentsObj = new JsonObject();
- if (componentsArray != null) {
- for (int i = 0; i < componentsArray.size(); i++) {
- JsonObject inputComponent = componentsArray.get(i).getAsJsonObject();
+ if (clientComponentsArray != null) {
+ for (int i = 0; i < clientComponentsArray.size(); i++) {
+ JsonObject inputComponent = clientComponentsArray.get(i).getAsJsonObject();
if (inputComponent.has("id")) {
JsonObject componentValue = new JsonObject();
- componentValue.addProperty("yarn.role.priority",
- inputComponent.get("priority").getAsString());
- componentValue.addProperty("yarn.component.instances", inputComponent
- .get("instanceCount").getAsString());
+ if (inputComponent.has("priority")) {
+ componentValue.addProperty("yarn.role.priority", inputComponent
+ .get("priority").getAsString());
+ }
+ if (inputComponent.has("instanceCount")) {
+ componentValue.addProperty("yarn.component.instances",
+ inputComponent.get("instanceCount").getAsString());
+ }
+ if (inputComponent.has("yarnMemory")) {
+ componentValue.addProperty("yarn.memory",
+ inputComponent.get("yarnMemory").getAsString());
+ }
+ if (inputComponent.has("yarnCpuCores")) {
+ componentValue.addProperty("yarn.vcores",
+ inputComponent.get("yarnCpuCores").getAsString());
+ }
+ if (inputComponent.has("yarnLabel")) {
+ componentValue.addProperty("yarn.label.expression", inputComponent
+ .get("yarnLabel").getAsString());
+ }
componentsObj.add(inputComponent.get("id").getAsString(),
componentValue);
}
}
}
resourcesObj.add("components", componentsObj);
- String jsonString = new Gson().toJson(resourcesObj);
+ String jsonString = new GsonBuilder().setPrettyPrinting().create().toJson(resourcesObj);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(resourcesJsonFile);
@@ -826,7 +849,7 @@ public class SliderAppsViewControllerImpl implements SliderAppsViewController {
}
}
appConfigs.add("components", componentsObj);
- String jsonString = new Gson().toJson(appConfigs);
+ String jsonString = new GsonBuilder().setPrettyPrinting().create().toJson(appConfigs);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(appConfigJsonFile);
http://git-wip-us.apache.org/repos/asf/ambari/blob/4d229c8d/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js
index 6454938..b128c8f 100644
--- a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js
+++ b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js
@@ -47,16 +47,51 @@ App.CreateAppWizardStep4Controller = Ember.ObjectController.extend(App.AjaxError
* Return formatted object to send it in request to server
* @type {Object[]}
*/
- componentsFormatted: function () {
- return this.get('newApp.components').map(function (component) {
- return {
+ resourcesFormatted: function () {
+ var resources = {};
+ var newApp = this.get('newApp');
+ // Log Aggregation
+ var includeFilePatterns = newApp.get('includeFilePatterns');
+ var excludeFilePatterns = newApp.get('excludeFilePatterns');
+ var frequency = newApp.get('frequency');
+ if ((includeFilePatterns != null && includeFilePatterns.trim().length > 0)
+ || (excludeFilePatterns != null && excludeFilePatterns.trim().length > 0)
+ || (frequency != null && frequency.trim().length > 0)) {
+ resources.global = {
+ "yarn.log.include.patterns": includeFilePatterns,
+ "yarn.log.exclude.patterns": excludeFilePatterns,
+ "yarn.log.interval": frequency
+ };
+ }
+ // Components
+ resources.components = newApp.get('components').map(function (component) {
+ var componentObj = {
'id': component.get('name'),
'instanceCount': component.get('numInstances'),
'yarnMemory': component.get('yarnMemory'),
'yarnCpuCores': component.get('yarnCPU'),
'priority': component.get('priority')
};
+ if (component.get('yarnLabelChecked')) {
+ componentObj.yarnLabel = component.get('yarnLabel') == null ? ""
+ : component.get('yarnLabel').trim();
+ }
+ return componentObj;
});
+ // YARN Labels
+ var yarnLabelOption = newApp.get('selectedYarnLabel');
+ if (yarnLabelOption > 0) {
+ // 1=empty label. 2=specific label
+ var label = "";
+ if (yarnLabelOption == 2) {
+ label = newApp.get('specialLabel');
+ }
+ resources.components.push({
+ 'id': 'slider-appmaster',
+ 'yarn.label.expression': label
+ });
+ }
+ return resources;
}.property('newApp.components.@each'),
/**
@@ -83,17 +118,21 @@ App.CreateAppWizardStep4Controller = Ember.ObjectController.extend(App.AjaxError
*/
sendAppDataToServer: function () {
var app = this.get('newApp');
+ var dataObj = {
+ typeName: app.get('appType.index'),
+ typeVersion: app.get('appType.version'),
+ name: app.get('name'),
+ resources: this.get('resourcesFormatted'),
+ typeConfigs: app.get('configs')
+ };
+ if (app.queueName != null && app.queueName.trim().length > 0) {
+ dataObj.queue = app.queueName.trim();
+ }
return App.ajax.send({
name: 'createNewApp',
sender: this,
data: {
- data: {
- typeName: app.get('appType.index'),
- typeVersion: app.get('appType.version'),
- name: app.get('name'),
- typeComponents: this.get('componentsFormatted'),
- typeConfigs: app.get('configs')
- }
+ data: dataObj
},
success: 'sendAppDataToServerSuccessCallback'
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4d229c8d/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step1.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step1.hbs b/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step1.hbs
index 1448760..feec2ea 100644
--- a/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step1.hbs
+++ b/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step1.hbs
@@ -141,7 +141,7 @@
<div class="col-xs-7">
<div class="input-group">
{{input class="form-control" valueBinding="controller.newApp.frequency"}}
- <div class="input-group-addon">{{t common.minutes}}</div>
+ <div class="input-group-addon">{{t common.seconds}}</div>
</div>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/4d229c8d/contrib/views/slider/src/main/resources/ui/app/translations.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/translations.js b/contrib/views/slider/src/main/resources/ui/app/translations.js
index 38ce76d..acc1c9c 100644
--- a/contrib/views/slider/src/main/resources/ui/app/translations.js
+++ b/contrib/views/slider/src/main/resources/ui/app/translations.js
@@ -56,7 +56,8 @@ Em.I18n.translations = {
'error': 'Error',
'yarn.app.id': 'YARN Application ID',
'frequency': 'Frequency',
- 'minutes': 'Minutes'
+ 'minutes': 'Minutes',
+ 'seconds': 'Seconds'
},
'error.config_is_empty': 'Config <strong>{0}</strong> should not be empty',