Skip to content

Commit

Permalink
AMBARI-10370. Slider View: Support multiple versions of the same app …
Browse files Browse the repository at this point in the history
…(alexantonenko)
  • Loading branch information
hiveww committed Apr 6, 2015
1 parent 1afb7e6 commit 75c9df8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class SliderApp {
private String appVersion;
private String description;
private String type;
private String typeId;
private String user;
private String state;
private String diagnostics;
Expand Down Expand Up @@ -186,4 +187,12 @@ public Map<String, Object> getAlerts() {
public void setAlerts(Map<String, Object> alerts) {
this.alerts = alerts;
}

public String getTypeId() {
return typeId;
}

public void setTypeId(String typeId) {
this.typeId = typeId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,10 @@ private SliderApp createSliderAppObject(ApplicationReport yarnApp,
String value = tag.substring(index + 1).trim();
if ("name".equals(key)) {
app.setType(value);
app.setTypeId(value.toUpperCase() + "-" + app.getAppVersion());
} else if ("version".equals(key)) {
app.setAppVersion(value);
app.setTypeId(app.getType() + "-" + value);
} else if ("description".equals(key)) {
app.setDescription(value);
}
Expand All @@ -643,6 +645,7 @@ private SliderApp createSliderAppObject(ApplicationReport yarnApp,
&& (appType.getTypeVersion() != null && appType.getTypeVersion()
.equalsIgnoreCase(app.getAppVersion()))) {
matchedAppType = appType;
app.setTypeId(appType.getId());
break;
}
}
Expand Down Expand Up @@ -1040,7 +1043,7 @@ private List<SliderAppType> loadAppTypes() {
throw new IllegalStateException("Slider App package '" + appZip.getName() + "' does not contain 'resources-default.json' file");
}
SliderAppType appType = new SliderAppType();
appType.setId(application.getName());
appType.setId(application.getName() + "-" + application.getVersion());
appType.setTypeName(application.getName());
appType.setTypeDescription(application.getComment());
appType.setTypeVersion(application.getVersion());
Expand Down Expand Up @@ -1167,7 +1170,8 @@ public String createSliderApp(JsonObject json) throws IOException,
YarnException, InterruptedException {
if (json.has("name") && json.has("typeConfigs")
&& json.has("resources") && json.has("typeName")) {
final String appType = json.get("typeName").getAsString();
final String appTypeId = json.get("typeName").getAsString();
SliderAppType sliderAppType = getSliderAppType(appTypeId, null);
final String appName = json.get("name").getAsString();
final String queueName = json.has("queue") ? json.get("queue").getAsString() : null;
final boolean securityEnabled = Boolean.valueOf(getHadoopConfigs().get("security_enabled"));
Expand Down Expand Up @@ -1202,7 +1206,7 @@ public String createSliderApp(JsonObject json) throws IOException,
appCreateFolder.mkdirs();
File appConfigJsonFile = new File(appCreateFolder, "appConfig.json");
File resourcesJsonFile = new File(appCreateFolder, "resources.json");
saveAppConfigs(configs, componentsArray, appName, appType, securityEnabled, appConfigJsonFile);
saveAppConfigs(configs, componentsArray, appName, sliderAppType.getTypeName(), securityEnabled, appConfigJsonFile);
saveAppResources(resourcesObj, resourcesJsonFile);

final ActionCreateArgs createArgs = new ActionCreateArgs();
Expand All @@ -1213,15 +1217,14 @@ public String createSliderApp(JsonObject json) throws IOException,
}

final ActionInstallPackageArgs installArgs = new ActionInstallPackageArgs();
SliderAppType sliderAppType = getSliderAppType(appType, null);
String localAppPackageFileName = sliderAppType.getTypePackageFileName();
installArgs.name = appType;
installArgs.name = sliderAppType.getTypeName();
installArgs.packageURI = getAppsFolderPath() + "/" + localAppPackageFileName;
installArgs.replacePkg = true;

final List<ActionInstallKeytabArgs> installKeytabActions = new ArrayList<ActionInstallKeytabArgs>();
if (securityEnabled) {
for (String keytab : getUserToRunAsKeytabs(appType)) {
for (String keytab : getUserToRunAsKeytabs(sliderAppType.getTypeName())) {
ActionInstallKeytabArgs keytabArgs = new ActionInstallKeytabArgs();
keytabArgs.keytabUri = keytab;
keytabArgs.folder = appName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ App.ApplicationTypeMapper = App.Mapper.create({
map: {
id: 'id',
configs: 'typeConfigs',
displayName: 'typeName',
typeName: 'typeName',
typeVersion: 'typeVersion',
index: 'id',
description: 'typeDescription',
version: 'typeVersion',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, {
user: app.user,
started: app.startTime || 0,
ended: app.endTime || 0,
appType: app.type.toUpperCase(),
appType: app.typeId,
diagnostics: app.diagnostics || "-",
description: app.description || "-",
components: componentsId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ App.SliderAppType = DS.Model.extend({
/**
* @type {string}
*/
displayName: DS.attr('string'),
typeName: DS.attr('string'),

/**
* @type {string}
*/
typeVersion: DS.attr('string'),

/**
* @type {App.SliderAppTypeComponent[]}
Expand All @@ -46,8 +51,14 @@ App.SliderAppType = DS.Model.extend({
/**
* @type {object}
*/
configs: DS.attr('object')

configs: DS.attr('object'),

displayName : function() {
var typeName = this.get('typeName');
var typeVersion = this.get('typeVersion');
return (typeName == null ? '' : typeName) + " ("
+ (typeVersion == null ? '' : typeVersion) + ")"
}.property('typeName', 'typeVersion')
});

App.SliderAppType.FIXTURES = [];

0 comments on commit 75c9df8

Please sign in to comment.