ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-11498 Perf: Skip calling hostVersionDAO by HostComponentResourceProvider if host_version isn't requested (dsen)
Date Thu, 28 May 2015 19:12:53 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f81b4f896 -> 98586c0ce


AMBARI-11498 Perf: Skip calling hostVersionDAO by HostComponentResourceProvider if host_version
isn't requested (dsen)


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

Branch: refs/heads/trunk
Commit: 98586c0ceccb94092b0f3698361ec3ac7b099eb4
Parents: f81b4f8
Author: Dmytro Sen <dsen@apache.org>
Authored: Thu May 28 22:11:24 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Thu May 28 22:11:24 2015 +0300

----------------------------------------------------------------------
 .../internal/HostComponentResourceProvider.java   | 18 ++++++++++--------
 .../src/main/resources/META-INF/persistence.xml   |  1 -
 .../HostComponentResourceProviderTest.java        |  8 ++++----
 3 files changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/98586c0c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
index 818147b..40e3d5f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
@@ -101,9 +101,9 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
       = PropertyHelper.getPropertyId("HostRoles", "desired_admin_state");
   protected static final String HOST_COMPONENT_MAINTENANCE_STATE_PROPERTY_ID
       = "HostRoles/maintenance_state";
-  protected static final String HOST_COMPONENT_HDP_VERSION
+  protected static final String HOST_COMPONENT_HDP_VERSION_PROPERTY_ID
       = PropertyHelper.getPropertyId("HostRoles", "hdp_version");
-  protected static final String HOST_COMPONENT_UPGRADE_STATE = "HostRoles/upgrade_state";
+  protected static final String HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID = "HostRoles/upgrade_state";
 
   //Component name mappings
   private final Map<String, PropertyProvider> HOST_COMPONENT_PROPERTIES_PROVIDER =
new HashMap<String, PropertyProvider>();
@@ -249,14 +249,16 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
               response.getActualConfigs(), requestedIds);
       setResourceProperty(resource, HOST_COMPONENT_STALE_CONFIGS_PROPERTY_ID,
               response.isStaleConfig(), requestedIds);
-      setResourceProperty(resource, HOST_COMPONENT_UPGRADE_STATE,
+      setResourceProperty(resource, HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID,
               response.getUpgradeState(), requestedIds);
 
-      HostVersionEntity versionEntity = hostVersionDAO.
-              findByHostAndStateCurrent(response.getClusterName(), response.getHostname());
-      if (versionEntity != null) {
-        setResourceProperty(resource, HOST_COMPONENT_HDP_VERSION,
-                versionEntity.getRepositoryVersion().getDisplayName(), requestedIds);
+      if (requestedIds.contains(HOST_COMPONENT_HDP_VERSION_PROPERTY_ID)) {
+        HostVersionEntity versionEntity = hostVersionDAO.
+            findByHostAndStateCurrent(response.getClusterName(), response.getHostname());
+        if (versionEntity != null) {
+          setResourceProperty(resource, HOST_COMPONENT_HDP_VERSION_PROPERTY_ID,
+              versionEntity.getRepositoryVersion().getDisplayName(), requestedIds);
+        }
       }
 
       if (response.getAdminState() != null) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/98586c0c/ambari-server/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/META-INF/persistence.xml b/ambari-server/src/main/resources/META-INF/persistence.xml
index 4b30c0c..deb30bb 100644
--- a/ambari-server/src/main/resources/META-INF/persistence.xml
+++ b/ambari-server/src/main/resources/META-INF/persistence.xml
@@ -63,7 +63,6 @@
     <class>org.apache.ambari.server.orm.entities.ResourceTypeEntity</class>
     <class>org.apache.ambari.server.orm.entities.RoleSuccessCriteriaEntity</class>
     <class>org.apache.ambari.server.orm.entities.ServiceComponentDesiredStateEntity</class>
-    <class>org.apache.ambari.server.orm.entities.ServiceConfigApplicationEntity</class>
     <class>org.apache.ambari.server.orm.entities.ServiceConfigEntity</class>
     <class>org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity</class>
     <class>org.apache.ambari.server.orm.entities.StackEntity</class>

http://git-wip-us.apache.org/repos/asf/ambari/blob/98586c0c/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
index f6898e9..c38b142 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
@@ -163,7 +163,7 @@ public class HostComponentResourceProviderTest {
     expectedNameValues.put(
         HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID, stackId2.getStackId());
     expectedNameValues.put(
-        HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE, UpgradeState.NONE.name());
+        HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID, UpgradeState.NONE.name());
 
 
     // set expectations
@@ -196,7 +196,7 @@ public class HostComponentResourceProviderTest {
     hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID,
State.STARTED.name());
     hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_STACK_ID_PROPERTY_ID,
stackId.getStackId());
     hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID,
stackId2.getStackId());
-    hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE,
UpgradeState.NONE.name());
+    hostsComponentResource1.setProperty(HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID,
UpgradeState.NONE.name());
 
     Resource hostsComponentResource2 = new ResourceImpl(Resource.Type.HostComponent);
     hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID,
"Cluster100");
@@ -207,7 +207,7 @@ public class HostComponentResourceProviderTest {
     hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID,
State.STARTED.name());
     hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_STACK_ID_PROPERTY_ID,
stackId.getStackId());
     hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID,
stackId2.getStackId());
-    hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE,
UpgradeState.NONE.name());
+    hostsComponentResource2.setProperty(HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID,
UpgradeState.NONE.name());
 
     Resource hostsComponentResource3 = new ResourceImpl(Resource.Type.HostComponent);
     hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID,
"Cluster100");
@@ -218,7 +218,7 @@ public class HostComponentResourceProviderTest {
     hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STATE_PROPERTY_ID,
State.STARTED.name());
     hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_STACK_ID_PROPERTY_ID,
stackId.getStackId());
     hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_DESIRED_STACK_ID_PROPERTY_ID,
stackId2.getStackId());
-    hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE,
UpgradeState.NONE.name());
+    hostsComponentResource3.setProperty(HostComponentResourceProvider.HOST_COMPONENT_UPGRADE_STATE_PROPERTY_ID,
UpgradeState.NONE.name());
 
     hostsComponentResources.add(hostsComponentResource1);
     hostsComponentResources.add(hostsComponentResource2);


Mime
View raw message