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/08/18 15:47:56 UTC
[1/5] git commit: AMBARI-6883. Add service wizard does not select 1
client host by default when all hosts has master components. (jaimin)
Repository: ambari
Updated Branches:
refs/heads/branch-alerts-dev 157df3883 -> 26b162af8
AMBARI-6883. Add service wizard does not select 1 client host by default when all hosts has master components. (jaimin)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/00a45acb
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/00a45acb
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/00a45acb
Branch: refs/heads/branch-alerts-dev
Commit: 00a45acb38aca0d5a9529cd366d5e33ad987bcf0
Parents: 157df38
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Fri Aug 15 14:42:02 2014 -0700
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Aug 18 09:47:44 2014 -0400
----------------------------------------------------------------------
.../app/controllers/wizard/step6_controller.js | 53 +++++++++++---------
1 file changed, 29 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/00a45acb/ambari-web/app/controllers/wizard/step6_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step6_controller.js b/ambari-web/app/controllers/wizard/step6_controller.js
index ce4e496..a3e97ce 100644
--- a/ambari-web/app/controllers/wizard/step6_controller.js
+++ b/ambari-web/app/controllers/wizard/step6_controller.js
@@ -252,7 +252,7 @@ App.WizardStep6Controller = Em.Controller.extend({
allChecked: false,
isRequired: serviceComponent.get('isRequired'),
noChecked: true,
- isDisabled: installedServices.someProperty('serviceName',stackService.get('serviceName')) && this.get('isAddServiceWizard')
+ isDisabled: installedServices.someProperty('serviceName', stackService.get('serviceName')) && this.get('isAddServiceWizard')
}));
}
}, this);
@@ -425,13 +425,12 @@ App.WizardStep6Controller = Em.Controller.extend({
* @param hostsObj
*/
selectClientHost: function (hostsObj) {
- var nonMasterHost = hostsObj.findProperty('hasMaster',false);
- if (nonMasterHost) {
- var clientCheckBox = nonMasterHost.get('checkboxes').findProperty('name','CLIENT');
- if (clientCheckBox) {
- clientCheckBox.set('checked',true);
- }
- }
+ var nonMasterHost = hostsObj.findProperty('hasMaster', false);
+ var clientHost = !!nonMasterHost ? nonMasterHost : hostsObj[hostsObj.length - 1]; // last host
+ var clientCheckBox = clientHost.get('checkboxes').findProperty('component', 'CLIENT');
+ if (clientCheckBox) {
+ clientCheckBox.set('checked', true);
+ }
},
/**
@@ -469,7 +468,7 @@ App.WizardStep6Controller = Em.Controller.extend({
return this.get('content.masterComponentHosts').filterProperty('hostName', hostName).mapProperty('component');
},
- callValidation: function(successCallback) {
+ callValidation: function (successCallback) {
var self = this;
if (App.supports.serverRecommendValidate) {
self.callServerSideValidation(successCallback);
@@ -510,7 +509,7 @@ App.WizardStep6Controller = Em.Controller.extend({
}
var selectedClientComponents = self.get('content.clients').mapProperty('component_name');
- var alreadyInstalledClients = App.get('components.clients').reject(function(c) {
+ var alreadyInstalledClients = App.get('components.clients').reject(function (c) {
return selectedClientComponents.contains(c);
});
@@ -540,7 +539,7 @@ App.WizardStep6Controller = Em.Controller.extend({
times: App.maxRetries,
timeout: App.timeout
}).
- then(function() {
+ then(function () {
if (!self.get('submitDisabled') && successCallback) {
successCallback();
}
@@ -567,7 +566,7 @@ App.WizardStep6Controller = Em.Controller.extend({
this.get('hosts').setEach('warnMessages', []);
this.get('hosts').setEach('errorMessages', []);
this.get('hosts').setEach('anyMessage', false);
- this.get('hosts').forEach(function(host) {
+ this.get('hosts').forEach(function (host) {
host.checkboxes.setEach('hasWarnMessage', false);
host.checkboxes.setEach('hasErrorMessage', false);
});
@@ -575,11 +574,11 @@ App.WizardStep6Controller = Em.Controller.extend({
var anyGeneralClientErrors = false; // any error/warning for any client component (under "CLIENT" alias)
var validationData = validationUtils.filterNotInstalledComponents(data);
- validationData.filterProperty('type', 'host-component').forEach(function(item) {
+ validationData.filterProperty('type', 'host-component').forEach(function (item) {
var checkboxWithIssue = null;
var isGeneralClientValidationItem = clientComponents.contains(item['component-name']); // it is an error/warning for any client component (under "CLIENT" alias)
- var host = self.get('hosts').find(function(h) {
- return h.hostName === item.host && h.checkboxes.some(function(checkbox) {
+ var host = self.get('hosts').find(function (h) {
+ return h.hostName === item.host && h.checkboxes.some(function (checkbox) {
var isClientComponent = checkbox.component === "CLIENT" && isGeneralClientValidationItem;
if (checkbox.component === item['component-name'] || isClientComponent) {
checkboxWithIssue = checkbox;
@@ -636,7 +635,7 @@ App.WizardStep6Controller = Em.Controller.extend({
/**
* Composes selected values of comboboxes into blueprint format
*/
- getCurrentBlueprint: function() {
+ getCurrentBlueprint: function () {
var self = this;
var res = {
@@ -648,15 +647,15 @@ App.WizardStep6Controller = Em.Controller.extend({
var mapping = self.get('hosts');
var i = 0;
- mapping.forEach(function(item) {
+ mapping.forEach(function (item) {
i += 1;
var group_name = 'host-group-' + i;
var host_group = {
name: group_name,
- components: item.checkboxes.filterProperty('checked', true).map(function(checkbox) {
+ components: item.checkboxes.filterProperty('checked', true).map(function (checkbox) {
if (checkbox.component === "CLIENT") {
- return clientComponents.map(function(client) {
+ return clientComponents.map(function (client) {
return { name: client };
});
} else {
@@ -669,7 +668,9 @@ App.WizardStep6Controller = Em.Controller.extend({
var binding = {
name: group_name,
- hosts: [ { fqdn: item.hostName } ]
+ hosts: [
+ { fqdn: item.hostName }
+ ]
}
res.blueprint.host_groups.push(host_group);
@@ -679,7 +680,7 @@ App.WizardStep6Controller = Em.Controller.extend({
return res;
},
- getMasterSlaveBlueprintForAddHostWizard: function() {
+ getMasterSlaveBlueprintForAddHostWizard: function () {
var components = App.HostComponent.find();
var hosts = components.mapProperty("hostName").uniq();
@@ -689,18 +690,22 @@ App.WizardStep6Controller = Em.Controller.extend({
};
var i = 0;
- hosts.forEach(function(host) {
+ hosts.forEach(function (host) {
i += 1;
var group_name = 'host-group-' + i;
res.blueprint.host_groups.push({
name: group_name,
- components: components.filterProperty("hostName", host).mapProperty("componentName").map(function(c) { return { name: c }; })
+ components: components.filterProperty("hostName", host).mapProperty("componentName").map(function (c) {
+ return { name: c };
+ })
});
res.blueprint_cluster_binding.host_groups.push({
name: group_name,
- hosts: [ { fqdn: host } ]
+ hosts: [
+ { fqdn: host }
+ ]
});
});
return res;
[5/5] git commit: AMBARI-6882. Views : Admin - Support Upgrade
Scenario.
Posted by jo...@apache.org.
AMBARI-6882. Views : Admin - Support Upgrade Scenario.
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ace4a3e6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ace4a3e6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ace4a3e6
Branch: refs/heads/branch-alerts-dev
Commit: ace4a3e639ee4341647457593bad6ecd723f339d
Parents: 00a45ac
Author: Siddharth Wagle <sw...@hortonworks.com>
Authored: Fri Aug 15 14:47:58 2014 -0700
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Aug 18 09:47:45 2014 -0400
----------------------------------------------------------------------
.../AmbariManagementControllerImpl.java | 25 ---
.../ambari/server/controller/UserRequest.java | 27 +--
.../ambari/server/controller/UserResponse.java | 9 -
.../internal/UserResourceProvider.java | 14 --
.../ambari/server/orm/dao/PermissionDAO.java | 18 ++
.../server/upgrade/UpgradeCatalog170.java | 181 ++++++++++++++++++-
.../src/main/resources/properties.json | 1 -
.../AmbariManagementControllerTest.java | 8 -
.../controller/internal/RequestImplTest.java | 1 -
.../server/upgrade/UpgradeCatalog170Test.java | 91 +++++++++-
10 files changed, 276 insertions(+), 99 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/ace4a3e6/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index c749a26..3b80515 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -718,17 +718,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
users.createUser(request.getUsername(), request.getPassword(), request.isActive(), request.isAdmin());
- if (0 != request.getRoles().size()) {
- user = users.getAnyUser(request.getUsername());
- if (null != user) {
- for (String role : request.getRoles()) {
- if (!user.getRoles().contains(role)) {
- users.addRoleToUser(user, role);
- }
- }
- }
- }
-
if (null != request.isActive() && null != user) {
users.setUserActive(user, request.isActive());
}
@@ -2420,18 +2409,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
request.getPassword());
}
- Set<String> roolesToDelete = new HashSet<String>(u.getRoles());
- Set<String> roolesToAdd = request.getRoles();
- roolesToDelete.removeAll(request.getRoles());
- for (String role : roolesToDelete) {
- users.removeRoleFromUser(u, role);
- u.getRoles().remove(role);
- }
- roolesToAdd.removeAll(u.getRoles());
- for (String role : roolesToAdd) {
- users.addRoleToUser(u, role);
- }
-
if (null != request.isActive()) {
users.setUserActive(u, request.isActive());
}
@@ -2786,7 +2763,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
if (null == r.getUsername()) {
for (User u : users.getAllUsers()) {
UserResponse resp = new UserResponse(u.getUserName(), u.isLdapUser(), u.isActive(), u.isAdmin());
- resp.setRoles(new HashSet<String>(u.getRoles()));
resp.setGroups(new HashSet<String>(u.getGroups()));
responses.add(resp);
}
@@ -2802,7 +2778,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
} else {
UserResponse resp = new UserResponse(u.getUserName(), u.isLdapUser(), u.isActive(), u.isAdmin());
- resp.setRoles(new HashSet<String>(u.getRoles()));
resp.setGroups(new HashSet<String>(u.getGroups()));
responses.add(resp);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ace4a3e6/ambari-server/src/main/java/org/apache/ambari/server/controller/UserRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/UserRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/UserRequest.java
index 6e4c7fe..282131a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/UserRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/UserRequest.java
@@ -17,9 +17,6 @@
*/
package org.apache.ambari.server.controller;
-import java.util.HashSet;
-import java.util.Set;
-
/**
* Represents a user maintenance request.
*/
@@ -28,7 +25,6 @@ public class UserRequest {
private String password;
private String oldPassword;
private Boolean active;
- private Set<String> roles = new HashSet<String>();
private Boolean admin;
public UserRequest(String name) {
@@ -39,14 +35,6 @@ public class UserRequest {
return userName;
}
- public Set<String> getRoles() {
- return roles;
- }
-
- public void setRoles(Set<String> userRoles) {
- roles = userRoles;
- }
-
public String getPassword() {
return password;
}
@@ -82,20 +70,7 @@ public class UserRequest {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("User"
- + ", username=" + userName
- + ", roles=[ ");
- if (roles != null && !roles.isEmpty()) {
- boolean first = true;
- for (String role : roles) {
- if (!first) {
- sb.append(",");
- }
- first = false;
- sb.append(role);
- }
- }
- sb.append(" ]");
+ sb.append("User, username=" + userName);
return sb.toString();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ace4a3e6/ambari-server/src/main/java/org/apache/ambari/server/controller/UserResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/UserResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/UserResponse.java
index b42b667..868635c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/UserResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/UserResponse.java
@@ -25,7 +25,6 @@ import java.util.Set;
*/
public class UserResponse {
- private Set<String> roles = Collections.emptySet();
private final String userName;
private final boolean isLdapUser;
private final boolean isActive;
@@ -43,14 +42,6 @@ public class UserResponse {
return userName;
}
- public Set<String> getRoles() {
- return roles;
- }
-
- public void setRoles(Set<String> userRoles) {
- roles = userRoles;
- }
-
public Set<String> getGroups() {
return groups;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ace4a3e6/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
index 2e0a659..35f9db5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
@@ -25,7 +25,6 @@ import org.apache.ambari.server.controller.spi.*;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -39,7 +38,6 @@ class UserResourceProvider extends AbstractControllerResourceProvider {
// Users
protected static final String USER_USERNAME_PROPERTY_ID = PropertyHelper.getPropertyId("Users", "user_name");
- protected static final String USER_ROLES_PROPERTY_ID = PropertyHelper.getPropertyId("Users", "roles");
protected static final String USER_PASSWORD_PROPERTY_ID = PropertyHelper.getPropertyId("Users", "password");
protected static final String USER_OLD_PASSWORD_PROPERTY_ID = PropertyHelper.getPropertyId("Users", "old_password");
protected static final String USER_LDAP_USER_PROPERTY_ID = PropertyHelper.getPropertyId("Users", "ldap_user");
@@ -118,9 +116,6 @@ class UserResourceProvider extends AbstractControllerResourceProvider {
setResourceProperty(resource, USER_USERNAME_PROPERTY_ID,
userResponse.getUsername(), requestedIds);
- setResourceProperty(resource, USER_ROLES_PROPERTY_ID,
- userResponse.getRoles(), requestedIds);
-
setResourceProperty(resource, USER_LDAP_USER_PROPERTY_ID,
userResponse.isLdapUser(), requestedIds);
@@ -198,15 +193,6 @@ class UserResourceProvider extends AbstractControllerResourceProvider {
request.setPassword((String) properties.get(USER_PASSWORD_PROPERTY_ID));
request.setOldPassword((String) properties.get(USER_OLD_PASSWORD_PROPERTY_ID));
- // TODO - support array/sets directly out of the request
- if (null != properties.get(USER_ROLES_PROPERTY_ID)) {
- HashSet<String> roles = new HashSet<String>();
-
- Collections.addAll(roles, ((String) properties.get(USER_ROLES_PROPERTY_ID)).split(","));
-
- request.setRoles(roles);
- }
-
if (null != properties.get(USER_ACTIVE_PROPERTY_ID)) {
request.setActive(Boolean.valueOf(properties.get(USER_ACTIVE_PROPERTY_ID).toString()));
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ace4a3e6/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/PermissionDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/PermissionDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/PermissionDAO.java
index 0c44006..faa6b8c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/PermissionDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/PermissionDAO.java
@@ -100,4 +100,22 @@ public class PermissionDAO {
public PermissionEntity findViewUsePermission() {
return findById(PermissionEntity.VIEW_USE_PERMISSION);
}
+
+ /**
+ * Find CLUSTER.OPERATE permission.
+ *
+ * @return a matching permission entity or null
+ */
+ public PermissionEntity findClusterOperatePermission() {
+ return findById(PermissionEntity.CLUSTER_OPERATE_PERMISSION);
+ }
+
+ /**
+ * Find CLUSTER.READ permission.
+ *
+ * @return a matching permission entity or null
+ */
+ public PermissionEntity findClusterReadPermission() {
+ return findById(PermissionEntity.CLUSTER_READ_PERMISSION);
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ace4a3e6/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
index d5781f6..10e760b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
@@ -43,10 +43,31 @@ import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.orm.DBAccessor.DBColumnInfo;
+import org.apache.ambari.server.orm.dao.ClusterDAO;
import org.apache.ambari.server.orm.dao.DaoUtils;
import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
+import org.apache.ambari.server.orm.dao.PermissionDAO;
+import org.apache.ambari.server.orm.dao.PrincipalDAO;
+import org.apache.ambari.server.orm.dao.PrincipalTypeDAO;
+import org.apache.ambari.server.orm.dao.PrivilegeDAO;
+import org.apache.ambari.server.orm.dao.ResourceDAO;
+import org.apache.ambari.server.orm.dao.ResourceTypeDAO;
+import org.apache.ambari.server.orm.dao.UserDAO;
+import org.apache.ambari.server.orm.dao.ViewDAO;
+import org.apache.ambari.server.orm.dao.ViewInstanceDAO;
+import org.apache.ambari.server.orm.entities.ClusterEntity;
import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
import org.apache.ambari.server.orm.entities.HostRoleCommandEntity_;
+import org.apache.ambari.server.orm.entities.PermissionEntity;
+import org.apache.ambari.server.orm.entities.PrincipalEntity;
+import org.apache.ambari.server.orm.entities.PrincipalTypeEntity;
+import org.apache.ambari.server.orm.entities.PrivilegeEntity;
+import org.apache.ambari.server.orm.entities.ResourceEntity;
+import org.apache.ambari.server.orm.entities.ResourceTypeEntity;
+import org.apache.ambari.server.orm.entities.RoleEntity;
+import org.apache.ambari.server.orm.entities.UserEntity;
+import org.apache.ambari.server.orm.entities.ViewEntity;
+import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
@@ -108,6 +129,20 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
List<DBColumnInfo> columns;
String dbType = getDbType();
+ // add group and members tables
+ columns = new ArrayList<DBColumnInfo>();
+ columns.add(new DBColumnInfo("group_id", Integer.class, 1, null, false));
+ columns.add(new DBColumnInfo("principal_id", Integer.class, 1, null, false));
+ columns.add(new DBColumnInfo("group_name", String.class, 1, null, false));
+ columns.add(new DBColumnInfo("ldap_group", Integer.class, 1, 0, false));
+ dbAccessor.createTable("groups", columns, "group_id");
+
+ columns = new ArrayList<DBColumnInfo>();
+ columns.add(new DBColumnInfo("member_id", Integer.class, 1, null, false));
+ columns.add(new DBColumnInfo("group_id", Integer.class, 1, null, false));
+ columns.add(new DBColumnInfo("user_id", Integer.class, 1, null, false));
+ dbAccessor.createTable("members", columns, "member_id");
+
// add admin tables and initial values prior to adding referencing columns on existing tables
columns = new ArrayList<DBColumnInfo>();
columns.add(new DBColumnInfo("principal_type_id", Integer.class, 1, null,
@@ -161,8 +196,8 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
dbAccessor.insertRow("adminpermission", new String[]{"permission_id", "permission_name", "resource_type_id"}, new String[]{"1", "'AMBARI.ADMIN'", "1"}, true);
dbAccessor.insertRow("adminpermission", new String[]{"permission_id", "permission_name", "resource_type_id"}, new String[]{"2", "'CLUSTER.READ'", "2"}, true);
- dbAccessor.insertRow("adminpermission", new String[]{"permission_id", "permission_name", "resource_type_id"}, new String[]{"3", "'CLUSTER.OPERATE'", "3"}, true);
- dbAccessor.insertRow("adminpermission", new String[]{"permission_id", "permission_name", "resource_type_id"}, new String[]{"4", "'VIEW.USE'", "4"}, true);
+ dbAccessor.insertRow("adminpermission", new String[]{"permission_id", "permission_name", "resource_type_id"}, new String[]{"3", "'CLUSTER.OPERATE'", "2"}, true);
+ dbAccessor.insertRow("adminpermission", new String[]{"permission_id", "permission_name", "resource_type_id"}, new String[]{"4", "'VIEW.USE'", "3"}, true);
columns = new ArrayList<DBColumnInfo>();
columns.add(new DBColumnInfo("privilege_id", Long.class, null, null, false));
@@ -334,6 +369,22 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ valueColumnName + ") " + "VALUES('config_id_seq', " + count + ")", false);
+ dbAccessor.addFKConstraint("users", "FK_users_principal_id", "principal_id", "adminprincipal", "principal_id", true);
+ dbAccessor.addFKConstraint("clusters", "FK_clusters_resource_id", "resource_id", "adminresource", "resource_id", true);
+ dbAccessor.addFKConstraint("viewinstance", "FK_viewinstance_resource_id", "resource_id", "adminresource", "resource_id", true);
+ dbAccessor.addFKConstraint("adminresource", "FK_resource_resource_type_id", "resource_type_id", "adminresourcetype", "resource_type_id", true);
+ dbAccessor.addFKConstraint("adminprincipal", "FK_principal_principal_type_id", "principal_type_id", "adminprincipaltype", "principal_type_id", true);
+ dbAccessor.addFKConstraint("adminpermission", "FK_permission_resource_type_id", "resource_type_id", "adminresourcetype", "resource_type_id", true);
+ dbAccessor.addFKConstraint("adminprivilege", "FK_privilege_permission_id", "permission_id", "adminpermission", "permission_id", true);
+ dbAccessor.addFKConstraint("adminprivilege", "FK_privilege_resource_id", "resource_id", "adminresource", "resource_id", true);
+
+ dbAccessor.addFKConstraint("groups", "FK_groups_principal_id", "principal_id", "adminprincipal", "principal_id", true);
+ dbAccessor.addFKConstraint("members", "FK_members_user_id", "user_id", "users", "user_id", true);
+ dbAccessor.addFKConstraint("members", "FK_members_group_id", "group_id", "groups", "group_id", true);
+
+ dbAccessor.executeQuery("ALTER TABLE groups ADD CONSTRAINT UNQ_groups_0 UNIQUE (group_name, ldap_group)");
+ dbAccessor.executeQuery("ALTER TABLE members ADD CONSTRAINT UNQ_members_0 UNIQUE (group_id, user_id)");
+ dbAccessor.executeQuery("ALTER TABLE adminpermission ADD CONSTRAINT UQ_perm_name_resource_type_id UNIQUE (permission_name, resource_type_id)");
}
private void populateConfigVersions() throws SQLException {
@@ -404,9 +455,6 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
@Override
protected void executeDMLUpdates() throws AmbariException, SQLException {
- // !!! TODO: create admin principals for existing users and groups.
- // !!! TODO: create admin resources for existing clusters and view instances
-
String dbType = getDbType();
// add new sequences for view entity
@@ -435,6 +483,35 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ valueColumnName + ") " + "VALUES('alert_current_id_seq', 0)", false);
+ dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ + valueColumnName + ") " + "VALUES('group_id_seq', 1)", false);
+
+ dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ + valueColumnName + ") " + "VALUES('member_id_seq', 1)", false);
+
+ dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ + valueColumnName + ") " + "VALUES('resource_type_id_seq', 4)", false);
+
+ dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ + valueColumnName + ") " + "VALUES('resource_id_seq', 2)", false);
+
+ dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ + valueColumnName + ") " + "VALUES('principal_type_id_seq', 3)", false);
+
+ dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ + valueColumnName + ") " + "VALUES('principal_id_seq', 2)", false);
+
+ dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ + valueColumnName + ") " + "VALUES('permission_id_seq', 5)", false);
+
+ dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ + valueColumnName + ") " + "VALUES('privilege_id_seq', 1)", false);
+
+ dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ + valueColumnName + ") " + "VALUES('service_config_id_seq', 1)", false);
+
+ dbAccessor.executeQuery("INSERT INTO ambari_sequences(sequence_name, "
+ + valueColumnName + ") " + "VALUES('config_id_seq', 1)", false);
// Update historic records with the log paths, but only enough so as to not prolong the upgrade process
executeInTransaction(new Runnable() {
@@ -496,6 +573,7 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
moveGlobalsToEnv();
addEnvContentFields();
addMissingConfigs();
+ upgradePermissionModel();
}
/**
@@ -790,4 +868,97 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
return result;
}
+
+ private void upgradePermissionModel() {
+ final UserDAO userDAO = injector.getInstance(UserDAO.class);
+ final PrincipalDAO principalDAO = injector.getInstance(PrincipalDAO.class);
+ final PrincipalTypeDAO principalTypeDAO = injector.getInstance(PrincipalTypeDAO.class);
+ final ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
+ final ResourceTypeDAO resourceTypeDAO = injector.getInstance(ResourceTypeDAO.class);
+ final ResourceDAO resourceDAO = injector.getInstance(ResourceDAO.class);
+ final ViewDAO viewDAO = injector.getInstance(ViewDAO.class);
+ final ViewInstanceDAO viewInstanceDAO = injector.getInstance(ViewInstanceDAO.class);
+ final PermissionDAO permissionDAO = injector.getInstance(PermissionDAO.class);
+ final PrivilegeDAO privilegeDAO = injector.getInstance(PrivilegeDAO.class);
+
+ final PrincipalTypeEntity userPrincipalType = principalTypeDAO.findById(PrincipalTypeEntity.USER_PRINCIPAL_TYPE);
+ for (UserEntity user: userDAO.findAll()) {
+ final PrincipalEntity principalEntity = new PrincipalEntity();
+ principalEntity.setPrincipalType(userPrincipalType);
+ principalDAO.create(principalEntity);
+ user.setPrincipal(principalEntity);
+ userDAO.merge(user);
+ }
+
+ final ResourceTypeEntity clusterResourceType = resourceTypeDAO.findById(ResourceTypeEntity.CLUSTER_RESOURCE_TYPE);
+ for (ClusterEntity cluster: clusterDAO.findAll()) {
+ final ResourceEntity resourceEntity = new ResourceEntity();
+ resourceEntity.setResourceType(clusterResourceType);
+ resourceDAO.create(resourceEntity);
+ cluster.setResource(resourceEntity);
+ clusterDAO.merge(cluster);
+ }
+
+ for (ViewEntity view: viewDAO.findAll()) {
+ final ResourceTypeEntity resourceType = new ResourceTypeEntity();
+ resourceType.setName(ViewEntity.getViewName(view.getCommonName(), view.getVersion()));
+ resourceTypeDAO.create(resourceType);
+ }
+
+ for (ViewInstanceEntity viewInstance: viewInstanceDAO.findAll()) {
+ final ResourceEntity resourceEntity = new ResourceEntity();
+ viewInstance.getViewEntity();
+ resourceEntity.setResourceType(resourceTypeDAO.findByName(
+ ViewEntity.getViewName(
+ viewInstance.getViewEntity().getCommonName(),
+ viewInstance.getViewEntity().getVersion())));
+ viewInstance.setResource(resourceEntity);
+ resourceDAO.create(resourceEntity);
+ viewInstanceDAO.merge(viewInstance);
+ }
+
+ final PermissionEntity adminPermission = permissionDAO.findAmbariAdminPermission();
+ final PermissionEntity clusterOperatePermission = permissionDAO.findClusterOperatePermission();
+ final PermissionEntity clusterReadPermission = permissionDAO.findClusterReadPermission();
+ final ResourceEntity ambariResource = resourceDAO.findAmbariResource();
+ for (UserEntity user: userDAO.findAll()) {
+ boolean hasAdminRole = false;
+ boolean hasUserRole = false;
+ for (RoleEntity role: user.getRoleEntities()) {
+ if (role.getRoleName().equals("admin")) {
+ hasAdminRole = true;
+ }
+ if (role.getRoleName().equals("user")) {
+ hasUserRole = true;
+ }
+ if (hasAdminRole) {
+ final PrivilegeEntity privilege = new PrivilegeEntity();
+ privilege.setPermission(adminPermission);
+ privilege.setPrincipal(user.getPrincipal());
+ privilege.setResource(ambariResource);
+ user.getPrincipal().getPrivileges().add(privilege);
+ privilegeDAO.create(privilege);
+ for (ClusterEntity cluster: clusterDAO.findAll()) {
+ final PrivilegeEntity clusterPrivilege = new PrivilegeEntity();
+ clusterPrivilege.setPermission(clusterOperatePermission);
+ clusterPrivilege.setPrincipal(user.getPrincipal());
+ clusterPrivilege.setResource(cluster.getResource());
+ privilegeDAO.create(clusterPrivilege);
+ user.getPrincipal().getPrivileges().add(clusterPrivilege);
+ }
+ userDAO.merge(user);
+ } else if (hasUserRole) {
+ for (ClusterEntity cluster: clusterDAO.findAll()) {
+ final PrivilegeEntity privilege = new PrivilegeEntity();
+ privilege.setPermission(clusterReadPermission);
+ privilege.setPrincipal(user.getPrincipal());
+ privilege.setResource(cluster.getResource());
+ privilegeDAO.create(privilege);
+ user.getPrincipal().getPrivileges().add(privilege);
+ }
+ userDAO.merge(user);
+ }
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ace4a3e6/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index 8db8662..55b451e 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -170,7 +170,6 @@
],
"User":[
"Users/user_name",
- "Users/roles",
"Users/password",
"Users/old_password",
"Users/ldap_user",
http://git-wip-us.apache.org/repos/asf/ambari/blob/ace4a3e6/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 4e9a0f9..9ca5348 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -4596,10 +4596,6 @@ public class AmbariManagementControllerTest {
users.createDefaultRoles();
UserRequest request = new UserRequest("user1");
- request.setRoles(new HashSet<String>(){{
- add("user");
- add("admin");
- }});
controller.updateUsers(Collections.singleton(request));
}
@@ -4613,10 +4609,6 @@ public class AmbariManagementControllerTest {
users.createDefaultRoles();
UserRequest request = new UserRequest("user1");
- request.setRoles(new HashSet<String>(){{
- add("user");
- add("admin");
- }});
controller.updateUsers(Collections.singleton(request));
request = new UserRequest("user1");
http://git-wip-us.apache.org/repos/asf/ambari/blob/ace4a3e6/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
index 01d76af..91adc9b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
@@ -189,7 +189,6 @@ public class RequestImplTest {
//User resource properties
Assert.assertFalse(validPropertyIds.contains("Users/unsupported_property_id"));
Assert.assertTrue(validPropertyIds.contains("Users/user_name"));
- Assert.assertTrue(validPropertyIds.contains("Users/roles"));
Assert.assertTrue(validPropertyIds.contains("Users/password"));
Assert.assertTrue(validPropertyIds.contains("Users/old_password"));
Assert.assertTrue(validPropertyIds.contains("Users/ldap_user"));
http://git-wip-us.apache.org/repos/asf/ambari/blob/ace4a3e6/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
index 19f37ad..ac1bd25 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
@@ -21,19 +21,60 @@ package org.apache.ambari.server.upgrade;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMockBuilder;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Order;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import javax.persistence.metamodel.SingularAttribute;
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.orm.DBAccessor;
-import org.apache.ambari.server.orm.dao.DaoUtils;
+import org.apache.ambari.server.orm.dao.ClusterDAO;
+import org.apache.ambari.server.orm.dao.PermissionDAO;
+import org.apache.ambari.server.orm.dao.PrincipalDAO;
+import org.apache.ambari.server.orm.dao.PrincipalTypeDAO;
+import org.apache.ambari.server.orm.dao.PrivilegeDAO;
+import org.apache.ambari.server.orm.dao.ResourceDAO;
+import org.apache.ambari.server.orm.dao.ResourceTypeDAO;
+import org.apache.ambari.server.orm.dao.UserDAO;
+import org.apache.ambari.server.orm.dao.ViewDAO;
+import org.apache.ambari.server.orm.dao.ViewInstanceDAO;
+import org.apache.ambari.server.orm.entities.ClusterEntity;
import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
+import org.apache.ambari.server.orm.entities.UserEntity;
+import org.apache.ambari.server.orm.entities.ViewEntity;
+import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
@@ -44,12 +85,11 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import com.google.inject.*;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityTransaction;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.*;
-import javax.persistence.metamodel.SingularAttribute;
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.Provider;
/**
* UpgradeCatalog170 unit tests.
@@ -167,10 +207,21 @@ public class UpgradeCatalog170Test {
Clusters clusters = createStrictMock(Clusters.class);
Config config = createStrictMock(Config.class);
+ UserDAO userDAO = createNiceMock(UserDAO.class);
+ PrincipalDAO principalDAO = createNiceMock(PrincipalDAO.class);
+ PrincipalTypeDAO principalTypeDAO = createNiceMock(PrincipalTypeDAO.class);
+ ClusterDAO clusterDAO = createNiceMock(ClusterDAO.class);
+ ResourceTypeDAO resourceTypeDAO = createNiceMock(ResourceTypeDAO.class);
+ ResourceDAO resourceDAO = createNiceMock(ResourceDAO.class);
+ ViewDAO viewDAO = createNiceMock(ViewDAO.class);
+ ViewInstanceDAO viewInstanceDAO = createNiceMock(ViewInstanceDAO.class);
+ PermissionDAO permissionDAO = createNiceMock(PermissionDAO.class);
+ PrivilegeDAO privilegeDAO = createNiceMock(PrivilegeDAO.class);
+
EntityTransaction trans = createNiceMock(EntityTransaction.class);
CriteriaBuilder cb = createNiceMock(CriteriaBuilder.class);
CriteriaQuery<HostRoleCommandEntity> cq = createNiceMock(CriteriaQuery.class);
- Root<HostRoleCommandEntity> hrc = (Root<HostRoleCommandEntity>) createNiceMock(Root.class);
+ Root<HostRoleCommandEntity> hrc = createNiceMock(Root.class);
Path<Long> taskId = null;
Path<String> outputLog = null;
Path<String> errorLog = null;
@@ -244,8 +295,28 @@ public class UpgradeCatalog170Test {
expect(configHelper.findConfigTypesByPropertyName(new StackId("HDP", "2.1"), "content")).andReturn(envDicts).once();
expect(configHelper.getPropertyValueFromStackDefenitions(cluster, "hadoop-env", "content")).andReturn("env file contents").once();
+ expect(injector.getInstance(UserDAO.class)).andReturn(userDAO).once();
+ expect(injector.getInstance(PrincipalDAO.class)).andReturn(principalDAO).once();
+ expect(injector.getInstance(PrincipalTypeDAO.class)).andReturn(principalTypeDAO).once();
+ expect(injector.getInstance(ClusterDAO.class)).andReturn(clusterDAO).once();
+ expect(injector.getInstance(ResourceTypeDAO.class)).andReturn(resourceTypeDAO).once();
+ expect(injector.getInstance(ResourceDAO.class)).andReturn(resourceDAO).once();
+ expect(injector.getInstance(ViewDAO.class)).andReturn(viewDAO).once();
+ expect(injector.getInstance(ViewInstanceDAO.class)).andReturn(viewInstanceDAO).once();
+ expect(injector.getInstance(PermissionDAO.class)).andReturn(permissionDAO).once();
+ expect(injector.getInstance(PrivilegeDAO.class)).andReturn(privilegeDAO).once();
+
+ expect(userDAO.findAll()).andReturn(Collections.<UserEntity> emptyList()).anyTimes();
+ expect(clusterDAO.findAll()).andReturn(Collections.<ClusterEntity> emptyList()).anyTimes();
+ expect(viewDAO.findAll()).andReturn(Collections.<ViewEntity> emptyList()).anyTimes();
+ expect(viewInstanceDAO.findAll()).andReturn(Collections.<ViewInstanceEntity> emptyList()).anyTimes();
+ expect(permissionDAO.findAmbariAdminPermission()).andReturn(null);
+ expect(permissionDAO.findClusterOperatePermission()).andReturn(null);
+ expect(permissionDAO.findClusterReadPermission()).andReturn(null);
+
replay(entityManager, trans, upgradeCatalog, cb, cq, hrc, q);
replay(dbAccessor, configuration, injector, cluster, clusters, amc, config, configHelper);
+ replay(userDAO, clusterDAO, viewDAO, viewInstanceDAO, permissionDAO);
Class<?> c = AbstractUpgradeCatalog.class;
Field f = c.getDeclaredField("configuration");
[2/5] git commit: AMBARI-6827. UpgradeCatalog170Test, Unit test fixed.
Posted by jo...@apache.org.
AMBARI-6827. UpgradeCatalog170Test, Unit test fixed.
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fad3d3ed
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fad3d3ed
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fad3d3ed
Branch: refs/heads/branch-alerts-dev
Commit: fad3d3ed173b7dc0c4265f0b0fb8ddbab6839358
Parents: ace4a3e
Author: Siddharth Wagle <sw...@hortonworks.com>
Authored: Fri Aug 15 14:48:15 2014 -0700
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Aug 18 09:47:45 2014 -0400
----------------------------------------------------------------------
.../server/upgrade/UpgradeCatalog170Test.java | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/fad3d3ed/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
index ac1bd25..5a91f56 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
@@ -36,6 +36,8 @@ import static org.easymock.EasyMock.verify;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -110,9 +112,20 @@ public class UpgradeCatalog170Test {
public void testExecuteDDLUpdates() throws Exception {
final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);
+ Connection connection = createNiceMock(Connection.class);
+ PreparedStatement stmt = createNiceMock(PreparedStatement.class);
Configuration configuration = createNiceMock(Configuration.class);
ResultSet resultSet = createNiceMock(ResultSet.class);
expect(configuration.getDatabaseUrl()).andReturn(Configuration.JDBC_IN_MEMORY_URL).anyTimes();
+ expect(dbAccessor.getNewConnection()).andReturn(connection);
+ expect(connection.prepareStatement("SELECT config_id FROM clusterconfig " +
+ "WHERE type_name = ? ORDER BY create_timestamp")).andReturn(stmt);
+ expect(connection.prepareStatement("UPDATE clusterconfig SET version = ? " +
+ "WHERE config_id = ?")).andReturn(stmt);
+ stmt.close();
+ expectLastCall().times(2);
+ connection.close();
+ expectLastCall();
Capture<DBAccessor.DBColumnInfo> clusterConfigAttributesColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
Capture<DBAccessor.DBColumnInfo> maskColumnCapture = new Capture<DBAccessor.DBColumnInfo>();
@@ -170,7 +183,7 @@ public class UpgradeCatalog170Test {
resultSet.close();
expectLastCall().anyTimes();
- replay(dbAccessor, configuration, resultSet);
+ replay(dbAccessor, configuration, resultSet, connection, stmt);
AbstractUpgradeCatalog upgradeCatalog = getUpgradeCatalog(dbAccessor);
Class<?> c = AbstractUpgradeCatalog.class;
Field f = c.getDeclaredField("configuration");
@@ -178,7 +191,7 @@ public class UpgradeCatalog170Test {
f.set(upgradeCatalog, configuration);
upgradeCatalog.executeDDLUpdates();
- verify(dbAccessor, configuration, resultSet);
+ verify(dbAccessor, configuration, resultSet, connection, stmt);
assertClusterConfigColumns(clusterConfigAttributesColumnCapture);
assertViewColumns(maskColumnCapture);
[3/5] git commit: AMBARI-6884. Config History: implement UI tweaks
for adding Config groups to history.(xiwang)
Posted by jo...@apache.org.
AMBARI-6884. Config History: implement UI tweaks for adding Config groups to history.(xiwang)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2f532000
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2f532000
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2f532000
Branch: refs/heads/branch-alerts-dev
Commit: 2f532000d8827bc8f535569d2b1cda9f4863a928
Parents: fad3d3e
Author: Xi Wang <xi...@apache.org>
Authored: Fri Aug 15 15:15:21 2014 -0700
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Aug 18 09:47:45 2014 -0400
----------------------------------------------------------------------
ambari-web/app/messages.js | 6 +-
ambari-web/app/models/service_config_version.js | 5 +-
ambari-web/app/styles/application.less | 35 +++++++-
.../common/configs/config_history_flow.hbs | 92 +++++++++++---------
.../templates/main/dashboard/config_history.hbs | 3 +
.../views/common/configs/config_history_flow.js | 12 ++-
.../views/main/dashboard/config_history_view.js | 31 +++++--
7 files changed, 126 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2f532000/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index eddbade..d641607 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1401,6 +1401,9 @@ Em.I18n.translations = {
'<b>ambari-server setup --jdbc-db={0} --jdbc-driver=/path/to/{1}/driver.jar</b> ' +
'on the Ambari Server host to make the JDBC driver available and to enable testing the database connection.',
+ 'services.service.config.configHistory.configGroup': 'Group',
+ 'services.service.config.configHistory.makeCurrent.message': 'Are you sure you want to make {0} the current version for {1}:{2} ?',
+
'services.add.header':'Add Service Wizard',
'services.reassign.header':'Move Master Wizard',
'services.service.add':'Add Service',
@@ -1976,8 +1979,9 @@ Em.I18n.translations = {
'dashboard.services.zookeeper.server' : 'ZooKeeper Server',
- 'dashboard.configHistory.title': 'Configs',
+ 'dashboard.configHistory.title': 'Config History',
'dashboard.configHistory.table.version.title' : 'Service',
+ 'dashboard.configHistory.table.configGroup.title' : 'Config Group',
'dashboard.configHistory.table.modified.title' : 'Modified',
'dashboard.configHistory.table.empty' : 'No history to display',
'dashboard.configHistory.table.version.versionText' : 'V{0}',
http://git-wip-us.apache.org/repos/asf/ambari/blob/2f532000/ambari-web/app/models/service_config_version.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config_version.js b/ambari-web/app/models/service_config_version.js
index 4ff3057..6900492 100644
--- a/ambari-web/app/models/service_config_version.js
+++ b/ambari-web/app/models/service_config_version.js
@@ -32,9 +32,8 @@ App.ServiceConfigVersion = DS.Model.extend({
index: DS.attr('number'),
isCurrent: DS.attr('boolean'),
briefNotes: function () {
- var length = this.get('isCurrent') ? 20 : 40;
- return (typeof this.get('notes') === 'string') ? this.get('notes').slice(0, length) : "";
- }.property('notes', 'isCurrent'),
+ return (typeof this.get('notes') === 'string') ? this.get('notes').slice(0, 80) : "";
+ }.property('notes'),
versionText: function () {
return Em.I18n.t('dashboard.configHistory.table.version.versionText').format(this.get('version'));
}.property('version'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/2f532000/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index b3ed5cf..ec751cc 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -4914,6 +4914,7 @@ ul.inline li {
height: 100%;
.box {
position: relative;
+ cursor: pointer;
width: 72%;
height: 90%;
background-color: #ffffff;
@@ -4929,9 +4930,23 @@ ul.inline li {
color: #555555;
}
}
- .displayed {
+ .box.displayed {
+ border: 1px solid #444444;
+ .content {
+ color: #444444;
+ font-weight: bold;
+ }
+ }
+ .box.grayedOut {
background-color: #eeeeee;
- border: 1px solid #dddddd;
+ border: 1px solid #eeeeee;
+ .content {
+ color: #b8b8b8;
+ }
+ .top-label .label {
+ color: #eeeeee;
+ background-color: #b8b8b8;
+ }
}
.arrow-box {
width: 20%;
@@ -4993,6 +5008,7 @@ ul.inline li {
.dropdown-menu {
min-width: 400px;
margin-top: 4px;
+ font-size: 13px;
li {
line-height: 30px;
}
@@ -5002,7 +5018,7 @@ ul.inline li {
color: white;
}
.icon-caret-right {
- font-size: 20px;
+ font-size: 18px;
margin-right: 20px;
}
div.row-fluid, a {
@@ -5010,7 +5026,18 @@ ul.inline li {
}
}
.dropdown-submenu .dropdown-menu {
- min-width: 80px;
+ min-width: 200px;
+ line-height: 20px;
+ margin: 0px;
+ padding: 5px;
+ color: #333333;
+ cursor: default;
+ .content {
+ padding: 1px 5px 15px 5px;
+ }
+ .btn {
+ font-size: 13px;
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/2f532000/ambari-web/app/templates/common/configs/config_history_flow.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/config_history_flow.hbs b/ambari-web/app/templates/common/configs/config_history_flow.hbs
index 7f80c7a..71485f0 100644
--- a/ambari-web/app/templates/common/configs/config_history_flow.hbs
+++ b/ambari-web/app/templates/common/configs/config_history_flow.hbs
@@ -23,7 +23,7 @@
{{#each serviceVersion in view.visibleServiceVersion}}
<div {{bindAttr class=":flow-element :pull-left serviceVersion.first:first"}}>
<div class="arrow-box pull-left"><i class="icon-arrow-right icon-3x"></i></div>
- <div {{bindAttr class=":box :pull-right serviceVersion.isDisplayed:displayed"}}>
+ <div {{bindAttr class=":box :pull-right serviceVersion.isDisplayed:displayed"}} {{action switchVersion serviceVersion target="view"}}>
<div class="top-label">
<span class="label label-info">{{serviceVersion.versionText}}</span>
{{#if serviceVersion.isCurrent}}
@@ -42,50 +42,56 @@
</div>
<div class="version-info-bar">
<div class="row-fluid">
- <div class="btn-group pull-left">
- <button class="btn dropdown-toggle" data-toggle="dropdown" href="#" {{action hideFullList target="view"}} {{bindAttr disabled="view.versionActionsDisabled"}}>
- <i class="icon-random"></i>
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- {{#each serviceVersion in view.dropDownList}}
- <li class="pointer dropdown-submenu">
- <div class="row-fluid">
- <div class="span2">{{serviceVersion.versionText}}</div>
- <div class="span6">{{serviceVersion.modifiedDate}}</div>
- <div class="span3">{{serviceVersion.author}}</div>
- <div class="pull-right"><i class="icon-caret-right"></i></div>
- </div>
- <ul class="dropdown-menu">
- <li><a {{action switchVersion serviceVersion target="view"}}>{{t common.view}}</a></li>
- <li><a {{action compare serviceVersion target="view"}}>{{t common.compare}}</a></li>
- <li><a {{action revert serviceVersion target="view"}}>{{t dashboard.configHistory.info-bar.revert.button}}</a></li>
- </ul>
- </li>
- {{/each}}
- {{#unless view.showFullList}}
- <li class="align-center pointer" id="show_more">
- <a {{action openFullList target="view"}}>
- {{t dashboard.configHistory.info-bar.showMore}} {{view.serviceName}}
- <span class="lowercase ellipsis">{{t dashboard.configHistory.title}}</span>
- </a>
- </li>
- {{/unless}}
- </ul>
- </div>
- <div class="label-wrapper span8">
- <span class="label label-info">{{view.displayedServiceVersion.versionText}}</span>
- {{#if view.displayedServiceVersion.isCurrent}}
- <span class="label label-success">{{t common.current}}</span>
- {{/if}}
- <strong>{{view.displayedServiceVersion.author}}</strong> {{t dashboard.configHistory.info-bar.authoredOn}} <strong>{{view.displayedServiceVersion.modifiedDate}}</strong>
+ <div class="btn-group pull-left">
+ <button class="btn dropdown-toggle" data-toggle="dropdown" href="#" {{action hideFullList target="view"}} {{bindAttr disabled="view.versionActionsDisabled"}}>
+ <i class="icon-random"></i>
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu">
+ {{#each serviceVersion in view.dropDownList}}
+ <li class="pointer dropdown-submenu">
+ <div class="row-fluid" {{action switchVersion serviceVersion target="view"}}>
+ <div class="span2">{{serviceVersion.versionText}}</div>
+ <div class="span6">{{serviceVersion.modifiedDate}}</div>
+ <div class="span3">{{serviceVersion.author}}</div>
+ <div class="pull-right"><i class="icon-caret-right"></i></div>
+ </div>
+ <ul class="dropdown-menu">
+ <div class="content"> <strong>{{serviceVersion.serviceName}}</strong> <span class="label label-info">{{serviceVersion.versionText}}</span>
+ <strong>{{t services.service.config.configHistory.configGroup}}:{{serviceVersion.configGroup}}</strong>
+ <div>{{serviceVersion.briefNotes}}</div>
+ </div>
+ <div>
+ <button class="btn" {{bindAttr disabled="view.disableView"}} {{action switchVersion serviceVersion target="view"}}><i class="icon-search"></i> {{t common.view}}</button>
+ <button class="btn" {{bindAttr disabled="view.disableCompare"}} {{action compare serviceVersion target="view"}}><i class="icon-copy"></i> {{t common.compare}}</button>
+ <button class="btn" {{bindAttr disabled="view.disableMakeCurrent"}} {{action revert serviceVersion target="view"}}>{{t dashboard.configHistory.info-bar.revert.button}}</button>
+ </div>
+ </ul>
+ </li>
+ {{/each}}
+ {{#unless view.showFullList}}
+ <li class="align-center pointer" id="show_more">
+ <a {{action openFullList target="view"}}>
+ {{t dashboard.configHistory.info-bar.showMore}} {{view.serviceName}}
+ <span class="lowercase ellipsis">{{t dashboard.configHistory.title}}</span>
+ </a>
+ </li>
+ {{/unless}}
+ </ul>
+ </div>
+ <div class="label-wrapper span9" data-toggle="tooltip" {{bindAttr data-original-title="view.displayedServiceVersion.briefNotes" }}>
+ <span class="label label-info">{{view.displayedServiceVersion.versionText}}</span>
+ {{#if view.displayedServiceVersion.isCurrent}}
+ <span class="label label-success">{{t common.current}}</span>
+ {{/if}}
+ <strong>{{view.displayedServiceVersion.author}}</strong> {{t dashboard.configHistory.info-bar.authoredOn}} <strong>{{view.displayedServiceVersion.modifiedDate}}</strong>
</div>
<div class="pull-right">
- <div {{bindAttr class="view.displayedServiceVersion.isCurrent::hidden"}}>
- <button class="btn" {{action doCancel target="controller"}} {{bindAttr disabled="view.versionActionsDisabled"}}>{{t common.cancel}}</button>
- <button class="btn btn-success" {{action save target="view"}} {{bindAttr disabled="view.isSaveDisabled"}}>{{t common.save}}</button>
- </div>
- <button class="btn btn-success" {{action revert view.displayedServiceVersion target="view"}} {{bindAttr disabled="view.versionActionsDisabled" class="view.displayedServiceVersion.isCurrent:hidden"}}>{{t dashboard.configHistory.info-bar.revert.button}}</button>
+ <div {{bindAttr class="view.displayedServiceVersion.isCurrent::hidden"}}>
+ <button class="btn" {{action doCancel target="controller"}} {{bindAttr disabled="view.versionActionsDisabled"}}>{{t common.cancel}}</button>
+ <button class="btn btn-success" {{action save target="view"}} {{bindAttr disabled="view.isSaveDisabled"}}>{{t common.save}}</button>
+ </div>
+ <button class="btn btn-success" {{action revert view.displayedServiceVersion target="view"}} {{bindAttr disabled="view.versionActionsDisabled" class="view.displayedServiceVersion.isCurrent:hidden"}}>{{t dashboard.configHistory.info-bar.revert.button}}</button>
</div>
</div>
<div class="label-wrapper">
http://git-wip-us.apache.org/repos/asf/ambari/blob/2f532000/ambari-web/app/templates/main/dashboard/config_history.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/dashboard/config_history.hbs b/ambari-web/app/templates/main/dashboard/config_history.hbs
index dc7dd22..565ee8d 100644
--- a/ambari-web/app/templates/main/dashboard/config_history.hbs
+++ b/ambari-web/app/templates/main/dashboard/config_history.hbs
@@ -21,6 +21,7 @@
<thead>
{{#view view.sortView classNames="label-row"}}
{{view view.parentView.versionSort}}
+ {{view view.parentView.configGroupSort}}
{{view view.parentView.modifiedSort}}
{{view view.parentView.authorSort}}
{{view view.parentView.notesSort}}
@@ -28,6 +29,7 @@
<tr class="filter-row">
<th class="first">{{view view.serviceFilterView}}</th>
+ <th>{{view view.configGroupFilterView}}</th>
<th>{{view view.modifiedFilterView}}</th>
<th>{{view view.authorFilterView}}</th>
<th>{{view view.notesFilterView}}</th>
@@ -48,6 +50,7 @@
{{/if}}
<i {{bindAttr class=":icon-refresh :restart-required-service item.isRestartRequired::hidden"}}></i>
</td>
+ <td>{{item.configGroup}}</td>
<td>{{item.modifiedDate}}</td>
<td>{{item.author}}</td>
<td>{{item.notes}}</td>
http://git-wip-us.apache.org/repos/asf/ambari/blob/2f532000/ambari-web/app/views/common/configs/config_history_flow.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/config_history_flow.js b/ambari-web/app/views/common/configs/config_history_flow.js
index 2b305b5..5f7bfad 100644
--- a/ambari-web/app/views/common/configs/config_history_flow.js
+++ b/ambari-web/app/views/common/configs/config_history_flow.js
@@ -96,6 +96,12 @@ App.ConfigHistoryFlowView = Em.View.extend({
this.set('showFullList', !(this.get('serviceVersions.length') > this.VERSIONS_IN_DROPDOWN));
},
+ didInsertElement: function () {
+ App.tooltip(this.$('[data-toggle=tooltip]'),{
+ placement: 'bottom'
+ });
+ },
+
willInsertElement: function () {
var serviceVersions = this.get('serviceVersions');
var startIndex = 0;
@@ -179,6 +185,7 @@ App.ConfigHistoryFlowView = Em.View.extend({
/**
* add config values of chosen version to view for comparison
+ * add a second version-info-bar for the chosen version
*/
compare: function (event) {
this.set('controller.compareServiceVersion', event.context);
@@ -193,9 +200,12 @@ App.ConfigHistoryFlowView = Em.View.extend({
version: this.get('displayedServiceVersion.version'),
serviceName: this.get('displayedServiceVersion.serviceName')
});
+ var versionText = event.context? event.context.get('versionText') : this.get('displayedServiceVersion.versionText');
App.showConfirmationPopup(function () {
self.sendRevertCall(serviceConfigVersion);
- });
+ },
+ Em.I18n.t('services.service.config.configHistory.makeCurrent.message').format(versionText, this.get('displayedServiceVersion.serviceName'), this.get('displayedServiceVersion.configGroup'))
+ );
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/2f532000/ambari-web/app/views/main/dashboard/config_history_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/config_history_view.js b/ambari-web/app/views/main/dashboard/config_history_view.js
index 8c68477..5f9a943 100644
--- a/ambari-web/app/views/main/dashboard/config_history_view.js
+++ b/ambari-web/app/views/main/dashboard/config_history_view.js
@@ -93,18 +93,24 @@ App.MainConfigHistoryView = App.TableView.extend({
displayName: Em.I18n.t('dashboard.configHistory.table.version.title'),
classNames: ['first']
}),
- modifiedSort: sort.fieldView.extend({
+ configGroupSort: sort.fieldView.extend({
column: 2,
+ name: 'configGroup',
+ displayName: Em.I18n.t('dashboard.configHistory.table.configGroup.title')
+ }),
+ modifiedSort: sort.fieldView.extend({
+ column: 3,
name: 'appliedTime',
+ status: 'sorting_desc',
displayName: Em.I18n.t('dashboard.configHistory.table.modified.title')
}),
authorSort: sort.fieldView.extend({
- column: 3,
+ column: 4,
name: 'author',
displayName: Em.I18n.t('common.author')
}),
notesSort: sort.fieldView.extend({
- column: 4,
+ column: 5,
name: 'notes',
displayName: Em.I18n.t('common.notes')
}),
@@ -121,9 +127,22 @@ App.MainConfigHistoryView = App.TableView.extend({
emptyValue: Em.I18n.t('common.all')
}),
- modifiedFilterView: filters.createSelectView({
+ configGroupFilterView: filters.createSelectView({
column: 2,
fieldType: 'filter-input-width',
+ content: function () {
+ return ['All'].concat(['g1','g2','gn']);
+ }.property('App.router.clusterController.isLoaded'),
+ onChangeValue: function () {
+ this.get('parentView').updateFilter(this.get('column'), this.get('actualValue'), 'select');
+ },
+ emptyValue: Em.I18n.t('common.all')
+ }),
+
+
+ modifiedFilterView: filters.createSelectView({
+ column: 3,
+ fieldType: 'filter-input-width',
content: ['Any', 'Past 1 hour', 'Past 1 Day', 'Past 2 Days', 'Past 7 Days', 'Past 14 Days', 'Past 30 Days', 'Custom'],
valueBinding: "controller.modifiedFilter.optionValue",
startTimeBinding: "controller.modifiedFilter.actualValues.startTime",
@@ -134,7 +153,7 @@ App.MainConfigHistoryView = App.TableView.extend({
}),
authorFilterView: filters.createTextView({
- column: 3,
+ column: 4,
fieldType: 'filter-input-width',
onChangeValue: function () {
this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
@@ -142,7 +161,7 @@ App.MainConfigHistoryView = App.TableView.extend({
}),
notesFilterView: filters.createTextView({
- column: 4,
+ column: 5,
fieldType: 'filter-input-width',
onChangeValue: function () {
this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'string');
[4/5] git commit: AMBARI-6611. container-executor.cfg.j2 contains
hardcoded min.user.id=1000 (aonishuk)
Posted by jo...@apache.org.
AMBARI-6611. container-executor.cfg.j2 contains hardcoded min.user.id=1000 (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/26b162af
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/26b162af
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/26b162af
Branch: refs/heads/branch-alerts-dev
Commit: 26b162af8818b9916988ef657087f047d2877e7a
Parents: 2f53200
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Aug 18 15:05:37 2014 +0300
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Aug 18 09:47:45 2014 -0400
----------------------------------------------------------------------
.../apache/ambari/server/upgrade/UpgradeCatalog170.java | 4 ++++
.../HDP/2.0.6/services/YARN/configuration/yarn-env.xml | 7 ++++++-
.../HDP/2.0.6/services/YARN/package/scripts/params.py | 1 +
.../YARN/package/templates/container-executor.cfg.j2 | 2 +-
.../ambari/server/upgrade/UpgradeCatalog170Test.java | 4 ++++
.../python/stacks/2.0.6/configs/default.hbasedecom.json | 3 ++-
.../src/test/python/stacks/2.0.6/configs/default.json | 3 ++-
.../stacks/2.0.6/configs/default.non_gmetad_host.json | 3 ++-
.../src/test/python/stacks/2.0.6/configs/ha_default.json | 3 ++-
.../src/test/python/stacks/2.0.6/configs/ha_secured.json | 3 ++-
.../stacks/2.0.6/configs/rebalancehdfs_default.json | 3 ++-
.../src/test/python/stacks/2.0.6/configs/secured.json | 3 ++-
ambari-web/app/data/HDP2/site_properties.js | 11 +++++++++++
13 files changed, 41 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
index 10e760b..fa47428 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
@@ -751,6 +751,10 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
updateConfigurationProperties("hbase-env",
Collections.singletonMap("hbase_regionserver_xmn_ratio", "0.2"), false,
false);
+
+ updateConfigurationProperties("yarn-env",
+ Collections.singletonMap("min_user_id", "1000"), false,
+ false);
}
protected void addEnvContentFields() throws AmbariException {
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/configuration/yarn-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/configuration/yarn-env.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/configuration/yarn-env.xml
index 4b22260..184aff1 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/configuration/yarn-env.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/configuration/yarn-env.xml
@@ -51,7 +51,12 @@
<value>1024</value>
<description>Max heapsize for NodeManager using a numerical value in the scale of MB</description>
</property>
-
+ <property>
+ <name>min_user_id</name>
+ <value>1000</value>
+ <description>Set to 0 to disallow root from submitting jobs. Set to 1000 to disallow all superusers from submitting jobs</description>
+ </property>
+
<!-- yarn-env.sh -->
<property>
<name>content</name>
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/params.py
index bc0ad31..8d668d6 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/params.py
@@ -144,4 +144,5 @@ mapred_tt_group = default("/configurations/mapred-site/mapreduce.tasktracker.gro
mapred_local_dir = "/tmp/hadoop-mapred/mapred/local"
hdfs_log_dir_prefix = config['configurations']['hadoop-env']['hdfs_log_dir_prefix']
+min_user_id = config['configurations']['yarn-env']['min_user_id']
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/templates/container-executor.cfg.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/templates/container-executor.cfg.j2 b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/templates/container-executor.cfg.j2
index 90b12e6..c6f1ff6 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/templates/container-executor.cfg.j2
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/templates/container-executor.cfg.j2
@@ -37,4 +37,4 @@ yarn.nodemanager.local-dirs={{nm_local_dirs}}
yarn.nodemanager.log-dirs={{nm_log_dirs}}
yarn.nodemanager.linux-container-executor.group={{yarn_executor_container_group}}
banned.users=hdfs,yarn,mapred,bin
-min.user.id=1000
+min.user.id={{min_user_id}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
index 5a91f56..9325e9f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
@@ -278,6 +278,10 @@ public class UpgradeCatalog170Test {
upgradeCatalog.updateConfigurationProperties("hbase-env",
Collections.singletonMap("hbase_regionserver_xmn_ratio", "0.2"), false, false);
expectLastCall();
+
+ upgradeCatalog.updateConfigurationProperties("yarn-env",
+ Collections.singletonMap("min_user_id", "1000"), false, false);
+ expectLastCall();
expect(entityManager.getTransaction()).andReturn(trans).anyTimes();
expect(entityManager.getCriteriaBuilder()).andReturn(cb).anyTimes();
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/test/python/stacks/2.0.6/configs/default.hbasedecom.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/configs/default.hbasedecom.json b/ambari-server/src/test/python/stacks/2.0.6/configs/default.hbasedecom.json
index 9b0a85e..b3bf5b8 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/configs/default.hbasedecom.json
+++ b/ambari-server/src/test/python/stacks/2.0.6/configs/default.hbasedecom.json
@@ -421,7 +421,8 @@
"yarn_heapsize": "1024",
"yarn_user": "yarn",
"resourcemanager_heapsize": "1024",
- "yarn_log_dir_prefix": "/var/log/hadoop-yarn"
+ "yarn_log_dir_prefix": "/var/log/hadoop-yarn",
+ "min_user_id": "1000"
},
"hadoop-env": {
"security_enabled": "false",
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/configs/default.json b/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
index 67bf6f7..bae564f 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
+++ b/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
@@ -421,7 +421,8 @@
"yarn_heapsize": "1024",
"yarn_user": "yarn",
"resourcemanager_heapsize": "1024",
- "yarn_log_dir_prefix": "/var/log/hadoop-yarn"
+ "yarn_log_dir_prefix": "/var/log/hadoop-yarn",
+ "min_user_id": "1000"
},
"hadoop-env": {
"security_enabled": "false",
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/test/python/stacks/2.0.6/configs/default.non_gmetad_host.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/configs/default.non_gmetad_host.json b/ambari-server/src/test/python/stacks/2.0.6/configs/default.non_gmetad_host.json
index 418c7b2..319863a 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/configs/default.non_gmetad_host.json
+++ b/ambari-server/src/test/python/stacks/2.0.6/configs/default.non_gmetad_host.json
@@ -415,7 +415,8 @@
"yarn_heapsize": "1024",
"yarn_user": "yarn",
"resourcemanager_heapsize": "1024",
- "yarn_log_dir_prefix": "/var/log/hadoop-yarn"
+ "yarn_log_dir_prefix": "/var/log/hadoop-yarn",
+ "min_user_id": "1000"
},
"hadoop-env": {
"security_enabled": "false",
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/test/python/stacks/2.0.6/configs/ha_default.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/configs/ha_default.json b/ambari-server/src/test/python/stacks/2.0.6/configs/ha_default.json
index 8d0afcd..7adf696 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/configs/ha_default.json
+++ b/ambari-server/src/test/python/stacks/2.0.6/configs/ha_default.json
@@ -363,7 +363,8 @@
"yarn_heapsize": "1024",
"yarn_user": "yarn",
"resourcemanager_heapsize": "1024",
- "yarn_log_dir_prefix": "/var/log/hadoop-yarn"
+ "yarn_log_dir_prefix": "/var/log/hadoop-yarn",
+ "min_user_id": "1000"
},
"hadoop-env": {
"security_enabled": "false",
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/test/python/stacks/2.0.6/configs/ha_secured.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/configs/ha_secured.json b/ambari-server/src/test/python/stacks/2.0.6/configs/ha_secured.json
index 3e08e44..6c61278 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/configs/ha_secured.json
+++ b/ambari-server/src/test/python/stacks/2.0.6/configs/ha_secured.json
@@ -342,7 +342,8 @@
"yarn_heapsize": "1024",
"yarn_user": "yarn",
"resourcemanager_heapsize": "1024",
- "yarn_log_dir_prefix": "/var/log/hadoop-yarn"
+ "yarn_log_dir_prefix": "/var/log/hadoop-yarn",
+ "min_user_id": "1000"
},
"hadoop-env": {
"security_enabled": "false",
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/test/python/stacks/2.0.6/configs/rebalancehdfs_default.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/configs/rebalancehdfs_default.json b/ambari-server/src/test/python/stacks/2.0.6/configs/rebalancehdfs_default.json
index ba11bb5..95b8335 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/configs/rebalancehdfs_default.json
+++ b/ambari-server/src/test/python/stacks/2.0.6/configs/rebalancehdfs_default.json
@@ -219,7 +219,8 @@
"yarn_heapsize": "1024",
"yarn_user": "yarn",
"resourcemanager_heapsize": "1024",
- "yarn_log_dir_prefix": "/var/log/hadoop-yarn"
+ "yarn_log_dir_prefix": "/var/log/hadoop-yarn",
+ "min_user_id": "1000"
},
"yarn-log4j": {
"content": ""
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-server/src/test/python/stacks/2.0.6/configs/secured.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/configs/secured.json b/ambari-server/src/test/python/stacks/2.0.6/configs/secured.json
index 1d47873..88de472 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/configs/secured.json
+++ b/ambari-server/src/test/python/stacks/2.0.6/configs/secured.json
@@ -464,7 +464,8 @@
"yarn_heapsize": "1024",
"yarn_user": "yarn",
"resourcemanager_heapsize": "1024",
- "yarn_log_dir_prefix": "/var/log/hadoop-yarn"
+ "yarn_log_dir_prefix": "/var/log/hadoop-yarn",
+ "min_user_id": "1000"
},
"hadoop-env": {
"security_enabled": "true",
http://git-wip-us.apache.org/repos/asf/ambari/blob/26b162af/ambari-web/app/data/HDP2/site_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/site_properties.js b/ambari-web/app/data/HDP2/site_properties.js
index 3beca55..edadbc8 100644
--- a/ambari-web/app/data/HDP2/site_properties.js
+++ b/ambari-web/app/data/HDP2/site_properties.js
@@ -1966,6 +1966,17 @@ module.exports =
},
{
"id": "puppet var",
+ "name": "min_user_id",
+ "displayName": "Minimum user ID for submitting job",
+ "isOverridable": true,
+ "displayType": "int",
+ "isVisible": true,
+ "serviceName": "YARN",
+ "filename": "yarn-env.xml",
+ "category": "Advanced"
+ },
+ {
+ "id": "puppet var",
"name": "yarn_pid_dir_prefix",
"displayName": "YARN PID Dir Prefix",
"description": "",