ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgerg...@apache.org
Subject ambari git commit: AMBARI-18949 Extend current quick link JSON with properties
Date Wed, 30 Nov 2016 15:25:02 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 964c56e7a -> eec985b16


AMBARI-18949 Extend current quick link JSON with properties

Change-Id: Ie994b82cea7abddcb6d4c32afc6b8597b608f025


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

Branch: refs/heads/branch-2.5
Commit: eec985b1675d35f407913c66b405bfee95527931
Parents: 964c56e
Author: Balazs Bence Sari <bsari@hortonworks.com>
Authored: Wed Nov 30 16:23:40 2016 +0100
Committer: Miklos Gergely <mgergely@hortonworks.com>
Committed: Wed Nov 30 16:23:40 2016 +0100

----------------------------------------------------------------------
 .../ambari/server/state/quicklinks/Link.java    | 21 +++++++
 .../QuickLinksConfigurationModuleTest.java      | 36 +++++++++++
 .../child_quicklinks_with_properties.json       | 64 +++++++++++++++++++
 .../parent_quicklinks_with_properties.json      | 65 ++++++++++++++++++++
 4 files changed, 186 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/eec985b1/ambari-server/src/main/java/org/apache/ambari/server/state/quicklinks/Link.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/quicklinks/Link.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/quicklinks/Link.java
index 091926f..f7c14f3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/quicklinks/Link.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/quicklinks/Link.java
@@ -18,6 +18,11 @@
 
 package org.apache.ambari.server.state.quicklinks;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Nullable;
+
 import org.codehaus.jackson.annotate.JsonIgnoreProperties;
 import org.codehaus.jackson.annotate.JsonProperty;
 import org.codehaus.jackson.map.annotate.JsonSerialize;
@@ -46,6 +51,9 @@ public class Link{
   @JsonProperty("protocol")
   private Protocol protocol;
 
+  @JsonProperty("properties")
+  private List<String> properties;
+
   public String getName() {
     return name;
   }
@@ -102,6 +110,14 @@ public class Link{
     this.protocol = protocol;
   }
 
+  @Nullable
+  public List<String> getProperties() {
+    return properties;
+  }
+
+  public void setProperties(List<String> properties) {
+    this.properties = properties;
+  }
 
   public boolean isRemoved(){
     //treat a link as removed if the section only contains a name
@@ -132,5 +148,10 @@ public class Link{
     } else {
       port.mergetWithParent(parentLink.getPort());
     }
+
+    if (null == properties && null != parentLink.properties) {
+      properties = parentLink.properties;
+    }
   }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/eec985b1/ambari-server/src/test/java/org/apache/ambari/server/stack/QuickLinksConfigurationModuleTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/stack/QuickLinksConfigurationModuleTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/stack/QuickLinksConfigurationModuleTest.java
index 38176aa..f44f741 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/stack/QuickLinksConfigurationModuleTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/stack/QuickLinksConfigurationModuleTest.java
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.stack;
 
+import com.google.common.collect.Lists;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.state.quicklinks.Check;
 import org.apache.ambari.server.state.quicklinks.Link;
@@ -28,7 +29,10 @@ import org.apache.ambari.server.state.quicklinks.QuickLinksConfiguration;
 import org.junit.Test;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import static org.junit.Assert.*;
 
@@ -111,6 +115,38 @@ public class QuickLinksConfigurationModuleTest {
     }
   }
 
+  @Test
+  public void testResolveOverrideProperties() throws Exception{
+    QuickLinks[] results = resolveQuickLinks("parent_quicklinks_with_properties.json",
+        "child_quicklinks_with_properties.json");
+    QuickLinks parentQuickLinks = results[0];
+    QuickLinks childQuickLinks = results[1];
+
+    //resolved quicklinks configuration
+    QuickLinksConfiguration childQuickLinksConfig = childQuickLinks.getQuickLinksConfiguration();
+    assertNotNull(childQuickLinksConfig);
+
+    //links
+    List<Link> links = childQuickLinksConfig.getLinks();
+    assertNotNull(links);
+    assertEquals(3, links.size());
+    Map<String, Link> linksByName = new HashMap<>();
+    for (Link link: links) {
+      linksByName.put(link.getName(), link);
+    }
+    assertEquals("Links are not properly overridden for foo_ui",
+        Lists.newArrayList("authenticated", "sso"),
+        linksByName.get("foo_ui").getProperties());
+    assertEquals("Parent links for foo_jmx are not inherited.",
+        Lists.newArrayList("authenticated"),
+        linksByName.get("foo_jmx").getProperties());
+    assertEquals("Links are not properly overridden for foo_logs",
+        new ArrayList<>(),
+        linksByName.get("foo_logs").getProperties());
+
+  }
+
+
   private QuickLinks[] resolveQuickLinks(String parentJson, String childJson) throws AmbariException{
     File parentQuiclinksFile = new File(this.getClass().getClassLoader().getResource(parentJson).getFile());
     File childQuickLinksFile = new File(this.getClass().getClassLoader().getResource(childJson).getFile());

http://git-wip-us.apache.org/repos/asf/ambari/blob/eec985b1/ambari-server/src/test/resources/child_quicklinks_with_properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/child_quicklinks_with_properties.json b/ambari-server/src/test/resources/child_quicklinks_with_properties.json
new file mode 100644
index 0000000..36cd4f3
--- /dev/null
+++ b/ambari-server/src/test/resources/child_quicklinks_with_properties.json
@@ -0,0 +1,64 @@
+{
+  "name": "default",
+  "description": "default quick links configuration",
+  "configuration": {
+    "protocol":
+    {
+      "type":"http",
+      "checks":[
+        {
+          "property":"foo.http.policy",
+          "desired":"HTTP_ONLY",
+          "site":"foo-site"
+        }
+      ]
+    },
+
+    "links": [
+      {
+        "name": "foo_ui",
+        "label": "Foo UI",
+        "requires_user_name": "false",
+        "url": "%@://%@:%@",
+        "properties": ["authenticated", "sso"],
+        "port":{
+          "http_property": "foo.ui.webapp.address",
+          "http_default_port": "19888",
+          "https_property": "foo.ui.webapp.https.address",
+          "https_default_port": "8090",
+          "regex": "\\w*:(\\d+)",
+          "site": "foo-site"
+        }
+      },
+      {
+        "name":"foo_jmx",
+        "label":"Foo JMX",
+        "requires_user_name":"false",
+        "url":"%@://%@:%@/jmx",
+        "port":{
+          "http_property": "foo.jmx.webapp.address",
+          "http_default_port": "19888",
+          "https_property": "foo.jmx.webapp.https.address",
+          "https_default_port": "8090",
+          "regex": "\\w*:(\\d+)",
+          "site": "foo-site"
+        }
+      },
+      {
+        "name": "foo_logs",
+        "label": "Foo logs",
+        "requires_user_name": "false",
+        "url": "%@://%@:%@/logs",
+        "properties": [],
+        "port":{
+          "http_property": "foo.logs.webapp.address",
+          "http_default_port": "19888",
+          "https_property": "foo.webapp.https.address",
+          "https_default_port": "8090",
+          "regex": "\\w*:(\\d+)",
+          "site": "foo-site"
+        }
+      }
+    ]
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/eec985b1/ambari-server/src/test/resources/parent_quicklinks_with_properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/parent_quicklinks_with_properties.json b/ambari-server/src/test/resources/parent_quicklinks_with_properties.json
new file mode 100644
index 0000000..a315f3f
--- /dev/null
+++ b/ambari-server/src/test/resources/parent_quicklinks_with_properties.json
@@ -0,0 +1,65 @@
+{
+  "name": "default",
+  "description": "default quick links configuration",
+  "configuration": {
+    "protocol":
+    {
+      "type":"http",
+      "checks":[
+        {
+          "property":"foo.http.policy",
+          "desired":"HTTP_ONLY",
+          "site":"foo-site"
+        }
+      ]
+    },
+
+    "links": [
+      {
+        "name": "foo_ui",
+        "label": "Foo UI",
+        "requires_user_name": "false",
+        "url": "%@://%@:%@",
+        "properties": ["authenticated"],
+        "port":{
+          "http_property": "foo.ui.webapp.address",
+          "http_default_port": "19888",
+          "https_property": "foo.ui.webapp.https.address",
+          "https_default_port": "8090",
+          "regex": "\\w*:(\\d+)",
+          "site": "foo-site"
+        }
+      },
+      {
+        "name":"foo_jmx",
+        "label":"Foo JMX",
+        "requires_user_name":"false",
+        "url":"%@://%@:%@/jmx",
+        "properties": ["authenticated"],
+        "port":{
+          "http_property": "foo.jmx.webapp.address",
+          "http_default_port": "19888",
+          "https_property": "foo.jmx.webapp.https.address",
+          "https_default_port": "8090",
+          "regex": "\\w*:(\\d+)",
+          "site": "foo-site"
+        }
+      },
+      {
+        "name": "foo_logs",
+        "label": "Foo logs",
+        "requires_user_name": "false",
+        "url": "%@://%@:%@/logs",
+        "properties": ["authenticated"],
+        "port":{
+          "http_property": "foo.logs.webapp.address",
+          "http_default_port": "19888",
+          "https_property": "foo.webapp.https.address",
+          "https_default_port": "8090",
+          "regex": "\\w*:(\\d+)",
+          "site": "foo-site"
+        }
+      }
+    ]
+  }
+}
\ No newline at end of file


Mime
View raw message