You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2016/12/01 08:13:53 UTC
[10/50] ambari git commit: Revert "AMBARI-18976. Config History
request execution time depends on config versions count. (mpapirkovskyy)"
Revert "AMBARI-18976. Config History request execution time depends on config versions count. (mpapirkovskyy)"
This reverts commit ce4d4fa768375aac631703dbfceac44fd8faa151.
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/568d1e65
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/568d1e65
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/568d1e65
Branch: refs/heads/branch-feature-AMBARI-18901
Commit: 568d1e656b1f1c651e594a54f3b3744f62984653
Parents: 1df9b46
Author: Myroslav Papirkovskyi <mp...@hortonworks.com>
Authored: Mon Nov 28 18:41:20 2016 +0200
Committer: Myroslav Papirkovskyi <mp...@hortonworks.com>
Committed: Mon Nov 28 18:41:20 2016 +0200
----------------------------------------------------------------------
.../server/state/cluster/ClusterImpl.java | 42 +++++++++++++++-----
1 file changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/568d1e65/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 7bf24ce..8b157c7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -2534,10 +2534,12 @@ public class ClusterImpl implements Cluster {
if (serviceConfigEntity.getGroupId() == null) {
Collection<String> configTypes = serviceConfigTypes.get(serviceName);
List<ClusterConfigMappingEntity> mappingEntities =
- clusterDAO.getSelectedConfigMappingByTypes(getClusterId(), new ArrayList<>(configTypes));
+ clusterDAO.getClusterConfigMappingEntitiesByCluster(getClusterId());
for (ClusterConfigMappingEntity entity : mappingEntities) {
- entity.setSelected(0);
- clusterDAO.mergeConfigMapping(entity);
+ if (configTypes.contains(entity.getType()) && entity.isSelected() > 0) {
+ entity.setSelected(0);
+ entity = clusterDAO.mergeConfigMapping(entity);
+ }
}
for (ClusterConfigEntity configEntity : serviceConfigEntity.getClusterConfigEntities()) {
@@ -2597,12 +2599,14 @@ public class ClusterImpl implements Cluster {
@Transactional
void selectConfig(String type, String tag, String user) {
Collection<ClusterConfigMappingEntity> entities =
- clusterDAO.getLatestClusterConfigMappingsEntityByType(getClusterId(), type);
+ clusterDAO.getClusterConfigMappingEntitiesByCluster(getClusterId());
//disable previous config
for (ClusterConfigMappingEntity e : entities) {
- e.setSelected(0);
- clusterDAO.mergeConfigMapping(e);
+ if (e.isSelected() > 0 && e.getType().equals(type)) {
+ e.setSelected(0);
+ e = clusterDAO.mergeConfigMapping(e);
+ }
}
ClusterEntity clusterEntity = getClusterEntity();
@@ -2668,15 +2672,32 @@ public class ClusterImpl implements Cluster {
}
private List<ClusterConfigEntity> getClusterConfigEntitiesByService(String serviceName) {
+ List<ClusterConfigEntity> configEntities = new ArrayList<ClusterConfigEntity>();
+
+ //add configs from this service
Collection<String> configTypes = serviceConfigTypes.get(serviceName);
- return clusterDAO.getLatestClusterConfigsByTypes(getClusterId(), new ArrayList<>(configTypes));
+ for (ClusterConfigMappingEntity mappingEntity : clusterDAO.getClusterConfigMappingEntitiesByCluster(getClusterId())) {
+ if (mappingEntity.isSelected() > 0 && configTypes.contains(mappingEntity.getType())) {
+ ClusterConfigEntity configEntity =
+ clusterDAO.findConfig(getClusterId(), mappingEntity.getType(), mappingEntity.getTag());
+ if (configEntity != null) {
+ configEntities.add(configEntity);
+ } else {
+ LOG.error("Desired cluster config type={}, tag={} is not present in database," +
+ " unable to add to service config version");
+ }
+ }
+ }
+ return configEntities;
}
@Override
public Config getDesiredConfigByType(String configType) {
- List<ClusterConfigMappingEntity> entities = clusterDAO.getLatestClusterConfigMappingsEntityByType(getClusterId(), configType);
- if (!entities.isEmpty()) {
- return getConfig(configType, entities.get(0).getTag());
+ for (ClusterConfigMappingEntity e : clusterDAO.getClusterConfigMappingEntitiesByCluster(
+ getClusterId())) {
+ if (e.isSelected() > 0 && e.getType().equals(configType)) {
+ return getConfig(e.getType(), e.getTag());
+ }
}
return null;
@@ -3433,4 +3454,5 @@ public class ClusterImpl implements Cluster {
m_clusterPropertyCache.clear();
}
+
}