Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-14714-ui 9306544e5 -> 5ddb07cdb


Revert "AMBARI-22131 Move resources/stacks/HDP/3.0/widgets.json to 
resources/widgets.json (dsen)"

This reverts commit 7172655ff269fbb7e0d29ba93197aa5a804749c0.


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: b358ee20e857d31017e54c1bde6f3c1aac084030
Parents: fab2aa3
Author: Dmytro Sen <d...@apache.org>
Authored: Fri Oct 6 16:44:41 2017 +0300
Committer: Dmytro Sen <d...@apache.org>
Committed: Fri Oct 6 16:44:59 2017 +0300

----------------------------------------------------------------------
 .../server/api/services/AmbariMetaInfo.java     |  8 --
 .../AmbariManagementControllerImpl.java         | 22 +++--
 .../internal/ServiceResourceProvider.java       |  8 ++
 .../internal/StackArtifactResourceProvider.java | 18 +++-
 .../server/orm/entities/WidgetLayoutEntity.java |  6 +-
 .../ambari/server/stack/StackDirectory.java     | 18 ++++
 .../apache/ambari/server/stack/StackModule.java |  5 ++
 .../apache/ambari/server/state/StackInfo.java   |  8 ++
 .../resources/stacks/HDP/2.0.6/widgets.json     | 95 ++++++++++++++++++++
 .../main/resources/stacks/HDP/3.0/widgets.json  | 95 ++++++++++++++++++++
 .../server/api/services/AmbariMetaInfoTest.java |  8 --
 .../AmbariManagementControllerImplTest.java     |  6 +-
 .../AmbariManagementControllerTest.java         |  6 --
 .../resources/stacks/OTHER/1.0/widgets.json     | 95 ++++++++++++++++++++
 14 files changed, 364 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
index 425d247..de84965 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
@@ -21,7 +21,6 @@ package org.apache.ambari.server.api.services;
 import static 
org.apache.ambari.server.controller.spi.Resource.InternalType.Component;
 import static 
org.apache.ambari.server.controller.spi.Resource.InternalType.HostComponent;
 import static 
org.apache.ambari.server.controller.utilities.PropertyHelper.AGGREGATE_FUNCTION_IDENTIFIERS;
-import static 
org.apache.ambari.server.stack.StackDirectory.WIDGETS_DESCRIPTOR_FILE_NAME;
 
 import java.io.File;
 import java.io.FileReader;
@@ -126,7 +125,6 @@ public class AmbariMetaInfo {
   private File commonServicesRoot;
   private File extensionsRoot;
   private File serverVersionFile;
-  private File commonWidgetsDescriptorFile;
   private File customActionRoot;
   private Map<String, VersionDefinitionXml> versionDefinitions = null;
 
@@ -216,8 +214,6 @@ public class AmbariMetaInfo {
     serverVersionFile = new File(serverVersionFilePath);
 
     customActionRoot = new File(conf.getCustomActionDefinitionPath());
-
-    commonWidgetsDescriptorFile = new File(conf.getResourceDirPath(), 
WIDGETS_DESCRIPTOR_FILE_NAME);
   }
 
   /**
@@ -1439,8 +1435,4 @@ public class AmbariMetaInfo {
 
     return null;
   }
-
-  public File getCommonWidgetsDescriptorFile() {
-    return commonWidgetsDescriptorFile;
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/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 5642575..b2993e3 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
@@ -5184,12 +5184,22 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
         widgetDescriptorFiles.add(widgetDescriptorFile);
       }
     } else {
-      // common cluster level widgets
-      File commonWidgetsFile = ambariMetaInfo.getCommonWidgetsDescriptorFile();
-      if (commonWidgetsFile != null && commonWidgetsFile.exists()) {
-        widgetDescriptorFiles.add(commonWidgetsFile);
-      } else {
-        LOG.warn("Common widgets file with path {%s} doesn't exist. No cluster 
widgets will be created.", commonWidgetsFile);
+      Set<StackId> stackIds = new HashSet<>();
+
+      for (Service svc : cluster.getServices().values()) {
+        stackIds.add(svc.getDesiredStackId());
+      }
+
+      for (StackId stackId : stackIds) {
+        StackInfo stackInfo = ambariMetaInfo.getStack(stackId);
+
+        String widgetDescriptorFileLocation = 
stackInfo.getWidgetsDescriptorFileLocation();
+        if (widgetDescriptorFileLocation != null) {
+          File widgetDescriptorFile = new File(widgetDescriptorFileLocation);
+          if (widgetDescriptorFile.exists()) {
+            widgetDescriptorFiles.add(widgetDescriptorFile);
+          }
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
index e65693b..76a4547 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
@@ -423,6 +423,8 @@ public class ServiceResourceProvider extends 
AbstractControllerResourceProvider
     // do all validation checks
     validateCreateRequests(requests, clusters);
 
+    Set<Cluster> clustersSetFromRequests = new HashSet<>();
+
     for (ServiceRequest request : requests) {
       Cluster cluster = clusters.getCluster(request.getClusterName());
 
@@ -478,6 +480,12 @@ public class ServiceResourceProvider extends 
AbstractControllerResourceProvider
 
       // Initialize service widgets
       getManagementController().initializeWidgetsAndLayouts(cluster, s);
+      clustersSetFromRequests.add(cluster);
+    }
+
+    // Create cluster widgets and layouts
+    for (Cluster cluster : clustersSetFromRequests) {
+      getManagementController().initializeWidgetsAndLayouts(cluster, null);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackArtifactResourceProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackArtifactResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackArtifactResourceProvider.java
index a7f7710..2e8a32a 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackArtifactResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackArtifactResourceProvider.java
@@ -426,7 +426,7 @@ public class StackArtifactResourceProvider extends 
AbstractControllerResourcePro
     }
 
     if (StringUtils.isEmpty(serviceName)) {
-      return null;
+      return getWidgetsDescriptorForCluster(stackInfo);
     } else {
       return getWidgetsDescriptorForService(stackInfo, serviceName);
     }
@@ -450,6 +450,22 @@ public class StackArtifactResourceProvider extends 
AbstractControllerResourcePro
     return widgetDescriptor;
   }
 
+  public Map<String, Object> getWidgetsDescriptorForCluster(StackInfo 
stackInfo)
+      throws NoSuchParentResourceException, IOException {
+
+    Map<String, Object> widgetDescriptor = null;
+
+    String widgetDescriptorFileLocation = 
stackInfo.getWidgetsDescriptorFileLocation();
+    if (widgetDescriptorFileLocation != null) {
+      File widgetDescriptorFile = new File(widgetDescriptorFileLocation);
+      if (widgetDescriptorFile.exists()) {
+        widgetDescriptor = gson.fromJson(new FileReader(widgetDescriptorFile), 
widgetLayoutType);
+      }
+    }
+
+    return widgetDescriptor;
+  }
+
   /**
    * Get a kerberos descriptor.
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/WidgetLayoutEntity.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/WidgetLayoutEntity.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/WidgetLayoutEntity.java
index 1fa45e9..90d98fc 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/WidgetLayoutEntity.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/WidgetLayoutEntity.java
@@ -33,7 +33,6 @@ import javax.persistence.OneToMany;
 import javax.persistence.OrderBy;
 import javax.persistence.Table;
 import javax.persistence.TableGenerator;
-import javax.persistence.UniqueConstraint;
 
 @Entity
 @Table(name = "widget_layout")
@@ -42,8 +41,7 @@ import javax.persistence.UniqueConstraint;
         pkColumnName = "sequence_name",
         valueColumnName = "sequence_value",
         pkColumnValue = "widget_layout_id_seq",
-        initialValue = 0,
-        uniqueConstraints=@UniqueConstraint(columnNames={"layout_name", 
"cluster_id"})
+        initialValue = 0
 )
 @NamedQueries({
     @NamedQuery(name = "WidgetLayoutEntity.findAll", query = "SELECT 
widgetLayout FROM WidgetLayoutEntity widgetLayout"),
@@ -58,7 +56,7 @@ public class WidgetLayoutEntity {
   @Column(name = "id", nullable = false, updatable = false)
   private Long id;
 
-  @Column(name = "layout_name", nullable = false, length = 255)
+  @Column(name = "layout_name", nullable = false, unique = true, length = 255)
   private String layoutName;
 
   @Column(name = "section_name", nullable = false, length = 255)

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/main/java/org/apache/ambari/server/stack/StackDirectory.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackDirectory.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackDirectory.java
index e3c586b..9259466 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackDirectory.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackDirectory.java
@@ -94,6 +94,11 @@ public class StackDirectory extends StackDefinitionDirectory 
{
   private String kerberosDescriptorPreconfigureFilePath;
 
   /**
+   * widgets descriptor file path
+   */
+  private String widgetsDescriptorFilePath;
+
+  /**
    * repository file
    */
   private RepositoryXml repoFile;
@@ -228,6 +233,15 @@ public class StackDirectory extends 
StackDefinitionDirectory {
   }
 
   /**
+   * Obtain the path to the (stack-level) widgets descriptor file
+   *
+   * @return the path to the (stack-level) widgets descriptor file
+   */
+  public String getWidgetsDescriptorFilePath() {
+    return widgetsDescriptorFilePath;
+  }
+
+  /**
    * Obtain the repository directory path.
    *
    * @return repository directory path
@@ -310,6 +324,10 @@ public class StackDirectory extends 
StackDefinitionDirectory {
       kerberosDescriptorPreconfigureFilePath = getAbsolutePath() + 
File.separator + KERBEROS_DESCRIPTOR_PRECONFIGURE_FILE_NAME;
     }
 
+    if (subDirs.contains(WIDGETS_DESCRIPTOR_FILE_NAME)) {
+      widgetsDescriptorFilePath = getAbsolutePath() + File.separator + 
WIDGETS_DESCRIPTOR_FILE_NAME;
+    }
+
     parseUpgradePacks(subDirs);
     parseServiceDirectories(subDirs);
     parseRepoFile(subDirs);

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java 
b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java
index 71235f3..742706d 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java
@@ -294,6 +294,10 @@ public class StackModule extends BaseModule<StackModule, 
StackInfo> implements V
       
stackInfo.setKerberosDescriptorPreConfigurationFileLocation(parentStack.getModuleInfo().getKerberosDescriptorPreConfigurationFileLocation());
     }
 
+    if (stackInfo.getWidgetsDescriptorFileLocation() == null) {
+      
stackInfo.setWidgetsDescriptorFileLocation(parentStack.getModuleInfo().getWidgetsDescriptorFileLocation());
+    }
+
     mergeServicesWithParent(parentStack, allStacks, commonServices, 
extensions);
   }
 
@@ -569,6 +573,7 @@ public class StackModule extends BaseModule<StackModule, 
StackInfo> implements V
       stackInfo.setRcoFileLocation(stackDirectory.getRcoFilePath());
       
stackInfo.setKerberosDescriptorFileLocation(stackDirectory.getKerberosDescriptorFilePath());
       
stackInfo.setKerberosDescriptorPreConfigurationFileLocation(stackDirectory.getKerberosDescriptorPreconfigureFilePath());
+      
stackInfo.setWidgetsDescriptorFileLocation(stackDirectory.getWidgetsDescriptorFilePath());
       stackInfo.setUpgradesFolder(stackDirectory.getUpgradesDir());
       stackInfo.setUpgradePacks(stackDirectory.getUpgradePacks());
       stackInfo.setConfigUpgradePack(stackDirectory.getConfigUpgradePack());

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java 
b/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
index 3efc997..dcf850f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
@@ -429,6 +429,14 @@ public class StackInfo implements Comparable<StackInfo>, 
Validable {
     this.kerberosDescriptorPreConfigurationFileLocation = 
kerberosDescriptorPreConfigurationFileLocation;
   }
 
+  public String getWidgetsDescriptorFileLocation() {
+    return widgetsDescriptorFileLocation;
+  }
+
+  public void setWidgetsDescriptorFileLocation(String 
widgetsDescriptorFileLocation) {
+    this.widgetsDescriptorFileLocation = widgetsDescriptorFileLocation;
+  }
+
   /**
    * Set the path of the stack upgrade directory.
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/main/resources/stacks/HDP/2.0.6/widgets.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/widgets.json 
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/widgets.json
new file mode 100644
index 0000000..3176354
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/widgets.json
@@ -0,0 +1,95 @@
+{
+  "layouts": [
+    {
+      "layout_name": "default_system_heatmap",
+      "display_name": "Heatmaps",
+      "section_name": "SYSTEM_HEATMAPS",
+      "widgetLayoutInfo": [
+        {
+          "widget_name": "Host Disk Space Used %",
+          "description": "",
+          "widget_type": "HEATMAP",
+          "is_visible": true,
+          "metrics": [
+            {
+              "name": "disk_free",
+              "metric_path": "metrics/disk/disk_free",
+              "service_name": "STACK"
+            },
+            {
+              "name": "disk_total",
+              "metric_path": "metrics/disk/disk_total",
+              "service_name": "STACK"
+            }
+          ],
+          "values": [
+            {
+              "name": "Host Disk Space Used %",
+              "value": "${((disk_total-disk_free)/disk_total)*100}"
+            }
+          ],
+          "properties": {
+            "display_unit": "%",
+            "max_limit": "100"
+          }
+        },
+        {
+          "widget_name": "Host Memory Used %",
+          "description": "",
+          "widget_type": "HEATMAP",
+          "is_visible": false,
+          "metrics": [
+            {
+              "name": "mem_total",
+              "metric_path": "metrics/memory/mem_total",
+              "service_name": "STACK"
+            },
+            {
+              "name": "mem_free",
+              "metric_path": "metrics/memory/mem_free",
+              "service_name": "STACK"
+            },
+            {
+              "name": "mem_cached",
+              "metric_path": "metrics/memory/mem_cached",
+              "service_name": "STACK"
+            }
+          ],
+          "values": [
+            {
+              "name": "Host Memory Used %",
+              "value": "${((mem_total-mem_free-mem_cached)/mem_total)*100}"
+            }
+          ],
+          "properties": {
+            "display_unit": "%",
+            "max_limit": "100"
+          }
+        },
+        {
+          "widget_name": "Host CPU Wait IO %",
+          "description": "",
+          "widget_type": "HEATMAP",
+          "is_visible": false,
+          "metrics": [
+            {
+              "name": "cpu_wio",
+              "metric_path": "metrics/cpu/cpu_wio",
+              "service_name": "STACK"
+            }
+          ],
+          "values": [
+            {
+              "name": "Host Memory Used %",
+              "value": "${cpu_wio*100}"
+            }
+          ],
+          "properties": {
+            "display_unit": "%",
+            "max_limit": "100"
+          }
+        }
+      ]
+    }
+  ]
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/main/resources/stacks/HDP/3.0/widgets.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/3.0/widgets.json 
b/ambari-server/src/main/resources/stacks/HDP/3.0/widgets.json
new file mode 100644
index 0000000..3176354
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/3.0/widgets.json
@@ -0,0 +1,95 @@
+{
+  "layouts": [
+    {
+      "layout_name": "default_system_heatmap",
+      "display_name": "Heatmaps",
+      "section_name": "SYSTEM_HEATMAPS",
+      "widgetLayoutInfo": [
+        {
+          "widget_name": "Host Disk Space Used %",
+          "description": "",
+          "widget_type": "HEATMAP",
+          "is_visible": true,
+          "metrics": [
+            {
+              "name": "disk_free",
+              "metric_path": "metrics/disk/disk_free",
+              "service_name": "STACK"
+            },
+            {
+              "name": "disk_total",
+              "metric_path": "metrics/disk/disk_total",
+              "service_name": "STACK"
+            }
+          ],
+          "values": [
+            {
+              "name": "Host Disk Space Used %",
+              "value": "${((disk_total-disk_free)/disk_total)*100}"
+            }
+          ],
+          "properties": {
+            "display_unit": "%",
+            "max_limit": "100"
+          }
+        },
+        {
+          "widget_name": "Host Memory Used %",
+          "description": "",
+          "widget_type": "HEATMAP",
+          "is_visible": false,
+          "metrics": [
+            {
+              "name": "mem_total",
+              "metric_path": "metrics/memory/mem_total",
+              "service_name": "STACK"
+            },
+            {
+              "name": "mem_free",
+              "metric_path": "metrics/memory/mem_free",
+              "service_name": "STACK"
+            },
+            {
+              "name": "mem_cached",
+              "metric_path": "metrics/memory/mem_cached",
+              "service_name": "STACK"
+            }
+          ],
+          "values": [
+            {
+              "name": "Host Memory Used %",
+              "value": "${((mem_total-mem_free-mem_cached)/mem_total)*100}"
+            }
+          ],
+          "properties": {
+            "display_unit": "%",
+            "max_limit": "100"
+          }
+        },
+        {
+          "widget_name": "Host CPU Wait IO %",
+          "description": "",
+          "widget_type": "HEATMAP",
+          "is_visible": false,
+          "metrics": [
+            {
+              "name": "cpu_wio",
+              "metric_path": "metrics/cpu/cpu_wio",
+              "service_name": "STACK"
+            }
+          ],
+          "values": [
+            {
+              "name": "Host Memory Used %",
+              "value": "${cpu_wio*100}"
+            }
+          ],
+          "properties": {
+            "display_unit": "%",
+            "max_limit": "100"
+          }
+        }
+      ]
+    }
+  ]
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
index 25e8d04..4baca5c 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
@@ -1894,14 +1894,6 @@ public class AmbariMetaInfoTest {
     
Assert.assertTrue(descriptor.getService("NEW_SERVICE").shouldPreconfigure());
   }
 
-  @Test
-  public void testGetCommonWidgetsFile() throws AmbariException {
-    File widgetsFile = metaInfo.getCommonWidgetsDescriptorFile();
-
-    Assert.assertNotNull(widgetsFile);
-    Assert.assertEquals("/var/lib/ambari-server/resources/widgets.json", 
widgetsFile.getPath());
-  }
-
   private File getStackRootTmp(String buildDir) {
     return new File(buildDir + "/ambari-metaInfo");
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
index 9547271..a02690f 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
@@ -2367,14 +2367,18 @@ public class AmbariManagementControllerImplTest {
     Cluster cluster = createNiceMock(Cluster.class);
     Service service = createNiceMock(Service.class);
     expect(service.getDesiredStackId()).andReturn(stackId).atLeastOnce();
+    expect(cluster.getServices()).andReturn(ImmutableMap.<String, 
Service>builder()
+        .put("HDFS", service)
+        .build());
 
     expect(clusters.getCluster("c1")).andReturn(cluster).atLeastOnce();
 
 
     StackInfo stackInfo = createNiceMock(StackInfo.class);
+    
expect(stackInfo.getWidgetsDescriptorFileLocation()).andReturn(null).once();
 
     expect(ambariMetaInfo.getStack("HDP", 
"2.1")).andReturn(stackInfo).atLeastOnce();
-    
expect(ambariMetaInfo.getCommonWidgetsDescriptorFile()).andReturn(null).once();
+    
expect(ambariMetaInfo.getStack(stackId)).andReturn(stackInfo).atLeastOnce();
 
     replay(injector, clusters, ambariMetaInfo, stackInfo, cluster, service, 
repoVersionDAO, repoVersion);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/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 7094caa..b370829 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
@@ -34,7 +34,6 @@ import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import java.io.File;
 import java.io.StringReader;
 import java.lang.reflect.Type;
 import java.text.MessageFormat;
@@ -10425,11 +10424,6 @@ public class AmbariManagementControllerTest {
     Assert.assertEquals("UPDATED_BLOCKED_TIME", 
layoutUserWidgetEntities.get(3).getWidget().getWidgetName());
     Assert.assertEquals("HBASE_SUMMARY", 
layoutUserWidgetEntities.get(0).getWidget().getDefaultSectionName());
 
-    File widgetsFile  = ambariMetaInfo.getCommonWidgetsDescriptorFile();
-    assertNotNull(widgetsFile);
-    assertEquals("src/test/resources/widgets.json", widgetsFile.getPath());
-    assertTrue(widgetsFile.exists());
-
     candidateLayoutEntity = null;
     for (WidgetLayoutEntity entity : layoutEntities) {
       if (entity.getLayoutName().equals("default_system_heatmap")) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b358ee20/ambari-server/src/test/resources/stacks/OTHER/1.0/widgets.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/stacks/OTHER/1.0/widgets.json 
b/ambari-server/src/test/resources/stacks/OTHER/1.0/widgets.json
new file mode 100644
index 0000000..3176354
--- /dev/null
+++ b/ambari-server/src/test/resources/stacks/OTHER/1.0/widgets.json
@@ -0,0 +1,95 @@
+{
+  "layouts": [
+    {
+      "layout_name": "default_system_heatmap",
+      "display_name": "Heatmaps",
+      "section_name": "SYSTEM_HEATMAPS",
+      "widgetLayoutInfo": [
+        {
+          "widget_name": "Host Disk Space Used %",
+          "description": "",
+          "widget_type": "HEATMAP",
+          "is_visible": true,
+          "metrics": [
+            {
+              "name": "disk_free",
+              "metric_path": "metrics/disk/disk_free",
+              "service_name": "STACK"
+            },
+            {
+              "name": "disk_total",
+              "metric_path": "metrics/disk/disk_total",
+              "service_name": "STACK"
+            }
+          ],
+          "values": [
+            {
+              "name": "Host Disk Space Used %",
+              "value": "${((disk_total-disk_free)/disk_total)*100}"
+            }
+          ],
+          "properties": {
+            "display_unit": "%",
+            "max_limit": "100"
+          }
+        },
+        {
+          "widget_name": "Host Memory Used %",
+          "description": "",
+          "widget_type": "HEATMAP",
+          "is_visible": false,
+          "metrics": [
+            {
+              "name": "mem_total",
+              "metric_path": "metrics/memory/mem_total",
+              "service_name": "STACK"
+            },
+            {
+              "name": "mem_free",
+              "metric_path": "metrics/memory/mem_free",
+              "service_name": "STACK"
+            },
+            {
+              "name": "mem_cached",
+              "metric_path": "metrics/memory/mem_cached",
+              "service_name": "STACK"
+            }
+          ],
+          "values": [
+            {
+              "name": "Host Memory Used %",
+              "value": "${((mem_total-mem_free-mem_cached)/mem_total)*100}"
+            }
+          ],
+          "properties": {
+            "display_unit": "%",
+            "max_limit": "100"
+          }
+        },
+        {
+          "widget_name": "Host CPU Wait IO %",
+          "description": "",
+          "widget_type": "HEATMAP",
+          "is_visible": false,
+          "metrics": [
+            {
+              "name": "cpu_wio",
+              "metric_path": "metrics/cpu/cpu_wio",
+              "service_name": "STACK"
+            }
+          ],
+          "values": [
+            {
+              "name": "Host Memory Used %",
+              "value": "${cpu_wio*100}"
+            }
+          ],
+          "properties": {
+            "display_unit": "%",
+            "max_limit": "100"
+          }
+        }
+      ]
+    }
+  ]
+}

Reply via email to