You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mp...@apache.org on 2018/11/20 17:09:48 UTC

[ambari] branch trunk updated: AMBARI-24842. BE: Performance Tune Hosts Pages (mpapirkovskyy) (#2635)

This is an automated email from the ASF dual-hosted git repository.

mpapirkovskyy pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new f15a271  AMBARI-24842. BE: Performance Tune Hosts Pages (mpapirkovskyy) (#2635)
f15a271 is described below

commit f15a271c71137b11368cdc0fa6319b685d85edef
Author: Myroslav Papirkovskyi <mp...@apache.org>
AuthorDate: Tue Nov 20 19:09:43 2018 +0200

    AMBARI-24842. BE: Performance Tune Hosts Pages (mpapirkovskyy) (#2635)
---
 .../java/org/apache/ambari/server/state/Host.java  | 29 ++++++++++
 .../apache/ambari/server/state/host/HostImpl.java  | 65 +++++++++++++++++-----
 2 files changed, 79 insertions(+), 15 deletions(-)

diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
index e2b5911..cdf36f0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Host.java
@@ -28,6 +28,7 @@ import org.apache.ambari.server.agent.HostInfo;
 import org.apache.ambari.server.agent.RecoveryReport;
 import org.apache.ambari.server.controller.HostResponse;
 import org.apache.ambari.server.orm.entities.HostEntity;
+import org.apache.ambari.server.orm.entities.HostStateEntity;
 import org.apache.ambari.server.orm.entities.HostVersionEntity;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
@@ -176,6 +177,13 @@ public interface Host extends Comparable {
    */
   String getOsFamily();
 
+  /**
+   * Gets the os family from host attributes
+   * @param hostAttributes host attributes
+   * @return the os family for host
+   */
+  String getOsFamily(Map<String, String> hostAttributes);
+
   String getOSFamilyFromHostAttributes(Map<String, String> hostAttributes);
 
   /**
@@ -200,6 +208,13 @@ public interface Host extends Comparable {
   HostHealthStatus getHealthStatus();
 
   /**
+   * Gets the health status from host attributes
+   * @param hostStateEntity host attributes
+   * @return the health status
+   */
+  HostHealthStatus getHealthStatus(HostStateEntity hostStateEntity);
+
+  /**
    * Get detailed recovery report for the host
    * @return
    */
@@ -223,6 +238,13 @@ public interface Host extends Comparable {
   Map<String, String> getHostAttributes();
 
   /**
+   * Gets host attributes from host entity
+   * @param hostEntity host entity
+   * @return the host attributes
+   */
+  Map<String, String> getHostAttributes(HostEntity hostEntity);
+
+  /**
    * @param hostAttributes the hostAttributes to set
    */
   void setHostAttributes(Map<String, String> hostAttributes);
@@ -290,6 +312,13 @@ public interface Host extends Comparable {
   AgentVersion getAgentVersion();
 
   /**
+   * Gets version of the ambari agent running on the host.
+   * @param hostStateEntity host state entity
+   * @return the agentVersion
+   */
+  AgentVersion getAgentVersion(HostStateEntity hostStateEntity);
+
+  /**
    * @param agentVersion the agentVersion to set
    */
   void setAgentVersion(AgentVersion agentVersion);
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
index 2bb22fd..4b5a2dd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
@@ -765,6 +765,11 @@ public class HostImpl implements Host {
   }
 
   @Override
+  public String getOsFamily(Map<String, String> hostAttributes) {
+	  return getOSFamilyFromHostAttributes(hostAttributes);
+  }
+
+  @Override
   public String getOSFamilyFromHostAttributes(Map<String, String> hostAttributes) {
     try {
       String majorVersion = hostAttributes.get(OS_RELEASE_VERSION).split("\\.")[0];
@@ -806,6 +811,15 @@ public class HostImpl implements Host {
   }
 
   @Override
+  public HostHealthStatus getHealthStatus(HostStateEntity hostStateEntity) {
+    if (hostStateEntity != null) {
+      return gson.fromJson(hostStateEntity.getHealthStatus(), HostHealthStatus.class);
+    }
+
+    return null;
+  }
+
+  @Override
   public void setHealthStatus(HostHealthStatus healthStatus) {
     HostStateEntity hostStateEntity = getHostStateEntity();
     if (hostStateEntity != null) {
@@ -837,6 +851,11 @@ public class HostImpl implements Host {
   }
 
   @Override
+  public Map<String, String> getHostAttributes(HostEntity hostEntity) {
+    return gson.fromJson(hostEntity.getHostAttributes(), hostAttributesType);
+  }
+
+  @Override
   public void setHostAttributes(Map<String, String> hostAttributes) {
     HostEntity hostEntity = getHostEntity();
     Map<String, String> hostAttrs = gson.fromJson(hostEntity.getHostAttributes(), hostAttributesType);
@@ -903,6 +922,15 @@ public class HostImpl implements Host {
   }
 
   @Override
+  public AgentVersion getAgentVersion(HostStateEntity hostStateEntity) {
+    if (hostStateEntity != null) {
+      return gson.fromJson(hostStateEntity.getAgentVersion(), AgentVersion.class);
+    }
+
+    return null;
+  }
+
+  @Override
   public void setAgentVersion(AgentVersion agentVersion) {
     HostStateEntity hostStateEntity = getHostStateEntity();
     if (hostStateEntity != null) {
@@ -964,26 +992,33 @@ public class HostImpl implements Host {
   public HostResponse convertToResponse() {
     HostResponse r = new HostResponse(getHostName());
 
-    r.setAgentVersion(getAgentVersion());
-    r.setPhCpuCount(getPhCpuCount());
-    r.setCpuCount(getCpuCount());
+    HostEntity hostEntity = getHostEntity();
+    HostStateEntity hostStateEntity = getHostStateEntity();
+
+    Map<String, String> hostAttributes = getHostAttributes(hostEntity);
+    r.setHostAttributes(hostAttributes);
+    r.setOsFamily(getOsFamily(hostAttributes));
+
+    r.setAgentVersion(getAgentVersion(hostStateEntity));
+    r.setHealthStatus(getHealthStatus(hostStateEntity));
+
+    r.setPhCpuCount(hostEntity.getPhCpuCount());
+    r.setCpuCount(hostEntity.getCpuCount());
+    r.setIpv4(hostEntity.getIpv4());
+    r.setOsArch(hostEntity.getOsArch());
+    r.setOsType(hostEntity.getOsType());
+    r.setTotalMemBytes(hostEntity.getTotalMem());
+    r.setLastRegistrationTime(hostEntity.getLastRegistrationTime());
+    r.setPublicHostName(hostEntity.getPublicHostName());
+    r.setRackInfo(hostEntity.getRackInfo());
+
     r.setDisksInfo(getDisksInfo());
-    r.setHealthStatus(getHealthStatus());
-    r.setHostAttributes(getHostAttributes());
-    r.setIpv4(getIPv4());
+    r.setStatus(getStatus());
     r.setLastHeartbeatTime(getLastHeartbeatTime());
     r.setLastAgentEnv(lastAgentEnv);
-    r.setLastRegistrationTime(getLastRegistrationTime());
-    r.setOsArch(getOsArch());
-    r.setOsType(getOsType());
-    r.setOsFamily(getOsFamily());
-    r.setRackInfo(getRackInfo());
-    r.setTotalMemBytes(getTotalMemBytes());
-    r.setPublicHostName(getPublicHostName());
-    r.setHostState(getState());
-    r.setStatus(getStatus());
     r.setRecoveryReport(getRecoveryReport());
     r.setRecoverySummary(getRecoveryReport().getSummary());
+    r.setHostState(getState());
     return r;
   }