ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [02/11] ambari git commit: AMBARI-18765 - Services with invalid themes hang the UI when you attempt to add them
Date Fri, 04 Nov 2016 13:26:47 GMT
AMBARI-18765 - Services with invalid themes hang the UI when you attempt to add them


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

Branch: refs/heads/branch-feature-AMBARI-18634
Commit: 2ebc6ed957c468ef5b2e966094ad41b09ceb1fc5
Parents: ba5cbf4
Author: Tim Thorpe <tthorpe@apache.org>
Authored: Thu Nov 3 09:40:42 2016 -0700
Committer: Tim Thorpe <tthorpe@apache.org>
Committed: Thu Nov 3 09:40:42 2016 -0700

----------------------------------------------------------------------
 .../apache/ambari/server/stack/ServiceModule.java    | 15 ++++++++++++---
 .../server/stack/StackManagerExtensionTest.java      |  9 +++++++++
 .../extensions/EXT/0.1/services/OOZIE2/metainfo.xml  |  8 ++++++++
 .../0.1/services/OOZIE2/themes/working_theme.json    |  5 +++++
 .../extensions/EXT/0.2/services/OOZIE2/metainfo.xml  |  8 ++++++++
 .../EXT/0.2/services/OOZIE2/themes/broken_theme.json |  3 +++
 6 files changed, 45 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2ebc6ed9/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
index 826abbc..b6a0da5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
@@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
 import javax.annotation.Nullable;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -421,14 +422,22 @@ public class ServiceModule extends BaseModule<ServiceModule, ServiceInfo>
implem
     String themesDir = serviceDirectory.getAbsolutePath() + File.separator + serviceInfo.getThemesDir();
 
     if (serviceInfo.getThemes() != null) {
+      List<ThemeInfo> themes = new ArrayList<ThemeInfo>(serviceInfo.getThemes().size());
       for (ThemeInfo themeInfo : serviceInfo.getThemes()) {
         File themeFile = new File(themesDir + File.separator + themeInfo.getFileName());
         ThemeModule module = new ThemeModule(themeFile, themeInfo);
-        themeModules.put(module.getId(), module);
+        if (module.isValid()) {
+          themeModules.put(module.getId(), module);
+          themes.add(themeInfo);
+        }
+        else {
+          //lets not fail if theme contain errors
+          LOG.error("Invalid theme {} for service {}", themeInfo.getFileName(), serviceInfo.getName());
+        }
       }
+      //filter out the invalid themes
+      serviceInfo.setThemes(themes);
     }
-
-    //lets not fail if theme contain errors
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/2ebc6ed9/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerExtensionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerExtensionTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerExtensionTest.java
index 044f2c4..0676568 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerExtensionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerExtensionTest.java
@@ -45,6 +45,7 @@ import org.apache.ambari.server.orm.entities.StackEntity;
 import org.apache.ambari.server.state.ExtensionInfo;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.StackInfo;
+import org.apache.ambari.server.state.ThemeInfo;
 import org.apache.ambari.server.state.stack.OsFamily;
 import org.easymock.EasyMock;
 import org.junit.Test;
@@ -109,6 +110,11 @@ public class StackManagerExtensionTest  {
     File checks = oozie.getChecksFolder();
     assertNotNull(checks);
     assertTrue("Checks dir is " + checks.getPath(), checks.getPath().contains("extensions/EXT/0.1/services/OOZIE2/checks"));
+    List<ThemeInfo> themes = oozie.getThemes();
+    assertNotNull(themes);
+    assertTrue("Number of themes is " + themes.size(), themes.size() == 1);
+    ThemeInfo theme = themes.get(0);
+    assertTrue("Theme: " + theme.getFileName(), theme.getFileName().contains("working_theme.json"));
 
     extension = stackManager.getExtension("EXT", "0.2");
     assertNotNull("EXT 0.2's parent: " + extension.getParentExtensionVersion(), extension.getParentExtensionVersion());
@@ -121,6 +127,9 @@ public class StackManagerExtensionTest  {
     checks = oozie.getChecksFolder();
     assertNotNull(checks);
     assertTrue("Checks dir is " + checks.getPath(), checks.getPath().contains("extensions/EXT/0.1/services/OOZIE2/checks"));
+    themes = oozie.getThemes();
+    assertNotNull(themes);
+    assertTrue("Number of themes is " + themes.size(), themes.size() == 0);
 
     StackInfo stack = stackManager.getStack("HDP", "0.2");
     assertNotNull(stack.getService("OOZIE2"));

http://git-wip-us.apache.org/repos/asf/ambari/blob/2ebc6ed9/ambari-server/src/test/resources/extensions/EXT/0.1/services/OOZIE2/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/extensions/EXT/0.1/services/OOZIE2/metainfo.xml
b/ambari-server/src/test/resources/extensions/EXT/0.1/services/OOZIE2/metainfo.xml
index ab67178..5e94b60 100644
--- a/ambari-server/src/test/resources/extensions/EXT/0.1/services/OOZIE2/metainfo.xml
+++ b/ambari-server/src/test/resources/extensions/EXT/0.1/services/OOZIE2/metainfo.xml
@@ -105,6 +105,14 @@
         <config-type>global</config-type>
         <config-type>oozie2-site</config-type>
       </configuration-dependencies>
+
+      <themes>
+        <theme>
+          <fileName>working_theme.json</fileName>
+          <default>true</default>
+        </theme>
+      </themes>
+
     </service>
   </services>
 </metainfo>

http://git-wip-us.apache.org/repos/asf/ambari/blob/2ebc6ed9/ambari-server/src/test/resources/extensions/EXT/0.1/services/OOZIE2/themes/working_theme.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/extensions/EXT/0.1/services/OOZIE2/themes/working_theme.json
b/ambari-server/src/test/resources/extensions/EXT/0.1/services/OOZIE2/themes/working_theme.json
new file mode 100644
index 0000000..fe267ee
--- /dev/null
+++ b/ambari-server/src/test/resources/extensions/EXT/0.1/services/OOZIE2/themes/working_theme.json
@@ -0,0 +1,5 @@
+{
+  "name": "default",
+  "description": "Default theme for OOZIE2 service",
+  "configuration": {}
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/2ebc6ed9/ambari-server/src/test/resources/extensions/EXT/0.2/services/OOZIE2/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/extensions/EXT/0.2/services/OOZIE2/metainfo.xml
b/ambari-server/src/test/resources/extensions/EXT/0.2/services/OOZIE2/metainfo.xml
index 9ae4f4b..9176551 100644
--- a/ambari-server/src/test/resources/extensions/EXT/0.2/services/OOZIE2/metainfo.xml
+++ b/ambari-server/src/test/resources/extensions/EXT/0.2/services/OOZIE2/metainfo.xml
@@ -105,6 +105,14 @@
         <config-type>global</config-type>
         <config-type>oozie2-site</config-type>
       </configuration-dependencies>
+
+      <themes>
+        <theme>
+          <fileName>broken_theme.json</fileName>
+          <default>true</default>
+        </theme>
+      </themes>
+
     </service>
   </services>
 </metainfo>

http://git-wip-us.apache.org/repos/asf/ambari/blob/2ebc6ed9/ambari-server/src/test/resources/extensions/EXT/0.2/services/OOZIE2/themes/broken_theme.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/extensions/EXT/0.2/services/OOZIE2/themes/broken_theme.json
b/ambari-server/src/test/resources/extensions/EXT/0.2/services/OOZIE2/themes/broken_theme.json
new file mode 100644
index 0000000..6e8b5bf
--- /dev/null
+++ b/ambari-server/src/test/resources/extensions/EXT/0.2/services/OOZIE2/themes/broken_theme.json
@@ -0,0 +1,3 @@
+{
+  "configuration": {
+}


Mime
View raw message