ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpapirkovs...@apache.org
Subject [2/3] ambari git commit: temp scv
Date Mon, 28 Nov 2016 16:39:27 GMT
temp scv


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/59d11cf3
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/59d11cf3
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/59d11cf3

Branch: refs/heads/branch-2.5
Commit: 59d11cf36b9fa283ba9592c8440f6be53debadd0
Parents: e62bf6e
Author: Myroslav Papirkovskyi <mpapyrkovskyy@hortonworks.com>
Authored: Mon Nov 21 19:56:33 2016 +0200
Committer: Myroslav Papirkovskyi <mpapyrkovskyy@hortonworks.com>
Committed: Mon Nov 28 18:39:06 2016 +0200

----------------------------------------------------------------------
 .../internal/ClusterControllerImpl.java         |  2 +-
 .../ServiceConfigVersionResourceProvider.java   |  3 ++-
 .../logging/LoggingSearchPropertyProvider.java  | 11 +++++++--
 .../ambari/server/orm/dao/ClusterDAO.java       | 24 ++++++++++++++++++++
 .../ambari/server/orm/dao/ServiceConfigDAO.java | 13 +++++------
 .../orm/entities/ClusterConfigEntity.java       |  7 +++++-
 .../entities/ClusterConfigMappingEntity.java    |  6 +++++
 .../orm/entities/ServiceConfigEntity.java       |  5 ++--
 8 files changed, 57 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/59d11cf3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
index 32bed7b..c752e80 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
@@ -858,7 +858,7 @@ public class ClusterControllerImpl implements ClusterController {
       if (compVal == 0) {
         Schema schema = getSchema(resourceType);
 
-        for (Type type : Type.values()) {
+        for (Type type : schema.getKeyTypes()) {
           String keyPropertyId = schema.getKeyPropertyId(type);
           if (keyPropertyId != null) {
             compVal = compareValues(resource1.getPropertyValue(keyPropertyId),

http://git-wip-us.apache.org/repos/asf/ambari/blob/59d11cf3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
index 2edbe9b..e5ca389 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
@@ -91,8 +91,9 @@ public class ServiceConfigVersionResourceProvider extends
     PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_IS_COMPATIBLE_PROPERTY_ID);
 
     // keys
-    KEY_PROPERTY_IDS.put(Resource.Type.ServiceConfigVersion,SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID);
+    KEY_PROPERTY_IDS.put(Resource.Type.Service,SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID);
     KEY_PROPERTY_IDS.put(Resource.Type.Cluster,SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID);
+    KEY_PROPERTY_IDS.put(Resource.Type.ServiceConfigVersion,SERVICE_CONFIG_VERSION_PROPERTY_ID);
   }
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/59d11cf3/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java
index d9db290..16788ed 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java
@@ -39,8 +39,10 @@ import org.apache.log4j.Logger;
 
 import java.util.Collections;
 import java.util.EnumSet;
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -73,7 +75,7 @@ public class LoggingSearchPropertyProvider implements PropertyProvider {
 
   @Override
   public Set<Resource> populateResources(Set<Resource> resources, Request request,
Predicate predicate) throws SystemException {
-
+    Map<String, Boolean> isLogSearchRunning = new HashMap<>();
     for (Resource resource : resources) {
       // obtain the required identifying properties on the host component resource
       final String componentName = (String)resource.getPropertyValue(PropertyHelper.getPropertyId("HostRoles",
"component_name"));
@@ -90,7 +92,12 @@ public class LoggingSearchPropertyProvider implements PropertyProvider
{
         continue;
       }
 
-      if (!logSearchServerRunning(clusterName)) {
+      Boolean isLogSearchRunningForSpecifiedCluster = isLogSearchRunning.get(clusterName);
+      if (isLogSearchRunningForSpecifiedCluster == null) {
+        isLogSearchRunningForSpecifiedCluster = logSearchServerRunning(clusterName);
+        isLogSearchRunning.put(clusterName, isLogSearchRunningForSpecifiedCluster);
+      }
+      if (!isLogSearchRunningForSpecifiedCluster) {
         continue;
       }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/59d11cf3/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
index e93ac0e..b727c72 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
@@ -116,6 +116,18 @@ public class ClusterDAO {
   }
 
   @RequiresSession
+  public List<ClusterConfigEntity> getLatestClusterConfigsByTypes(Long clusterId, List<String>
types) {
+    TypedQuery<ClusterConfigEntity> query = entityManagerProvider.get().createNamedQuery(
+      "ClusterConfigEntity.findLatestClusterConfigsByTypes",
+      ClusterConfigEntity.class);
+
+    query.setParameter("clusterId", clusterId);
+    query.setParameter("types", types);
+
+    return daoUtils.selectList(query);
+  }
+
+  @RequiresSession
   public ClusterConfigEntity findConfig(Long clusterId, String type, Long version) {
     CriteriaBuilder cb = entityManagerProvider.get().getCriteriaBuilder();
     CriteriaQuery<ClusterConfigEntity> cq = cb.createQuery(ClusterConfigEntity.class);
@@ -240,6 +252,18 @@ public class ClusterDAO {
     return daoUtils.selectList(query);
   }
 
+  @RequiresSession
+  public List<ClusterConfigMappingEntity> getLatestClusterConfigMappingsEntityByType(long
clusterId, String configType) {
+    TypedQuery<ClusterConfigMappingEntity> query = entityManagerProvider.get().createNamedQuery(
+      "ClusterConfigMappingEntity.findLatestClusterConfigMappingsByType",
+      ClusterConfigMappingEntity.class);
+
+    query.setParameter("clusterId", clusterId);
+    query.setParameter("typeName", configType);
+
+    return daoUtils.selectList(query);
+  }
+
   /**
    * Gets selected mappings for provided config types
    * @param clusterId cluster id

http://git-wip-us.apache.org/repos/asf/ambari/blob/59d11cf3/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
index 2cbee8d..212a9f0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
@@ -115,14 +115,13 @@ public class ServiceConfigDAO {
 
   @RequiresSession
   public List<ServiceConfigEntity> getLastServiceConfigs(Long clusterId) {
-    TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().
-      createQuery("SELECT scv FROM ServiceConfigEntity scv " +
-        "WHERE scv.clusterId = ?1 AND scv.createTimestamp = (" +
-        "SELECT MAX(scv2.createTimestamp) FROM ServiceConfigEntity scv2 " +
-        "WHERE scv2.serviceName = scv.serviceName AND scv2.clusterId = ?1 AND scv2.groupId
IS NULL)",
-        ServiceConfigEntity.class);
+    TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().createNamedQuery(
+      "ServiceConfigEntity.findLatestServiceConfigsByCluster",
+      ServiceConfigEntity.class);
 
-    return daoUtils.selectList(query, clusterId);
+    query.setParameter("clusterId", clusterId);
+
+    return daoUtils.selectList(query);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/59d11cf3/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java
index bf0faee..937e872 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java
@@ -55,7 +55,12 @@ import javax.persistence.UniqueConstraint;
     @NamedQuery(name = "ClusterConfigEntity.findClusterConfigMappingsByStack",
       query = "SELECT mapping FROM ClusterConfigMappingEntity mapping " +
         "JOIN ClusterConfigEntity config ON mapping.typeName = config.type AND mapping.tag
= config.tag " +
-        "WHERE mapping.clusterId = :clusterId AND config.stack = :stack")
+        "WHERE mapping.clusterId = :clusterId AND config.stack = :stack"),
+    @NamedQuery(name = "ClusterConfigEntity.findLatestClusterConfigsByTypes",
+      query = "SELECT cc FROM ClusterConfigEntity cc " +
+        "JOIN ClusterConfigMappingEntity ccm " +
+        "ON cc.clusterId = ccm.clusterId AND cc.type = ccm.typeName AND cc.tag = ccm.tag
" +
+        "WHERE cc.clusterId = :clusterId AND ccm.selectedInd > 0 AND ccm.typeName IN :types")
 })
 
 public class ClusterConfigEntity {

http://git-wip-us.apache.org/repos/asf/ambari/blob/59d11cf3/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
index c3c3e9e..04c6030 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
@@ -23,6 +23,8 @@ import javax.persistence.Id;
 import javax.persistence.IdClass;
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
 import javax.persistence.Table;
 
 /**
@@ -31,6 +33,10 @@ import javax.persistence.Table;
 @Table(name = "clusterconfigmapping")
 @Entity
 @IdClass(ClusterConfigMappingEntityPK.class)
+@NamedQueries({
+  @NamedQuery(name = "ClusterConfigMappingEntity.findLatestClusterConfigMappingsByType",
+    query = "SELECT mapping FROM ClusterConfigMappingEntity mapping WHERE mapping.clusterId
= :clusterId AND mapping.selectedInd > 0 AND mapping.typeName = :typeName")})
+
 public class ClusterConfigMappingEntity {
 
   @Id

http://git-wip-us.apache.org/repos/asf/ambari/blob/59d11cf3/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
index 7c28835..0df6f68 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
@@ -51,7 +51,8 @@ import javax.persistence.TableGenerator;
     @NamedQuery(name = "ServiceConfigEntity.findNextServiceConfigVersion", query = "SELECT
COALESCE(MAX(serviceConfig.version), 0) + 1 AS nextVersion FROM ServiceConfigEntity serviceConfig
WHERE serviceConfig.serviceName=:serviceName AND serviceConfig.clusterId=:clusterId"),
     @NamedQuery(name = "ServiceConfigEntity.findAllServiceConfigsByStack", query = "SELECT
serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId=:clusterId
AND serviceConfig.stack=:stack"),
     @NamedQuery(name = "ServiceConfigEntity.findLatestServiceConfigsByStack", query = "SELECT
serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId = :clusterId
AND serviceConfig.version = (SELECT MAX(serviceConfig2.version) FROM ServiceConfigEntity serviceConfig2
WHERE serviceConfig2.clusterId=:clusterId AND serviceConfig2.stack=:stack AND serviceConfig2.serviceName
= serviceConfig.serviceName)"),
-    @NamedQuery(name = "ServiceConfigEntity.findLatestServiceConfigsByService", query = "SELECT
scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceName = :serviceName
AND scv.version = (SELECT MAX(scv2.version) FROM ServiceConfigEntity scv2 WHERE (scv2.serviceName
= :serviceName AND scv2.clusterId = :clusterId) AND (scv2.groupId = scv.groupId OR (scv2.groupId
IS NULL AND scv.groupId IS NULL)))")})
+    @NamedQuery(name = "ServiceConfigEntity.findLatestServiceConfigsByService", query = "SELECT
scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceName = :serviceName
AND scv.version = (SELECT MAX(scv2.version) FROM ServiceConfigEntity scv2 WHERE (scv2.serviceName
= :serviceName AND scv2.clusterId = :clusterId) AND (scv2.groupId = scv.groupId OR (scv2.groupId
IS NULL AND scv.groupId IS NULL)))"),
+    @NamedQuery(name = "ServiceConfigEntity.findLatestServiceConfigsByCluster", query = "SELECT
scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceConfigId
IN (SELECT MAX(scv1.serviceConfigId) FROM ServiceConfigEntity scv1 WHERE (scv1.clusterId =
:clusterId) AND (scv1.groupId IS NULL) GROUP BY scv1.serviceName)")})
 public class ServiceConfigEntity {
   @Id
   @Column(name = "service_config_id")
@@ -263,4 +264,4 @@ public class ServiceConfigEntity {
     }
     return true;
   }
-}
\ No newline at end of file
+}


Mime
View raw message