ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smn...@apache.org
Subject [1/2] ambari git commit: AMBARI-18778: Ambari-server: Blueprint enhancements to support enabling or disabling credential store
Date Mon, 07 Nov 2016 17:02:01 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 6ab95eda7 -> 6ebd84875


AMBARI-18778: Ambari-server: Blueprint enhancements to support enabling or disabling credential
store


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

Branch: refs/heads/branch-2.5
Commit: 5527fd7ff57fa89e06dc23b5812053ec984f009e
Parents: 6ab95ed
Author: Nahappan Somasundaram <nsomasundaram@hortonworks.com>
Authored: Wed Nov 2 16:35:42 2016 -0700
Committer: Nahappan Somasundaram <nsomasundaram@hortonworks.com>
Committed: Mon Nov 7 08:56:24 2016 -0800

----------------------------------------------------------------------
 .../ambari/server/topology/AmbariContext.java   |  3 +-
 .../ambari/server/topology/Blueprint.java       |  9 ++++
 .../ambari/server/topology/BlueprintImpl.java   | 49 ++++++++++++++++++++
 .../apache/ambari/server/topology/Setting.java  | 21 +++++++++
 .../server/topology/AmbariContextTest.java      |  1 +
 5 files changed, 82 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5527fd7f/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
index b11d9d3..83f8470 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
@@ -199,7 +199,8 @@ public class AmbariContext {
     Set<ServiceRequest> serviceRequests = new HashSet<ServiceRequest>();
     Set<ServiceComponentRequest> componentRequests = new HashSet<ServiceComponentRequest>();
     for (String service : services) {
-      serviceRequests.add(new ServiceRequest(clusterName, service, null));
+      String credentialStoreEnabled = topology.getBlueprint().getCredentialStoreEnabled(service);
+      serviceRequests.add(new ServiceRequest(clusterName, service, null, credentialStoreEnabled));
       for (String component : topology.getBlueprint().getComponents(service)) {
         String recoveryEnabled = topology.getBlueprint().getRecoveryEnabled(service, component);
         componentRequests.add(new ServiceComponentRequest(clusterName, service, component,
null, recoveryEnabled));

http://git-wip-us.apache.org/repos/asf/ambari/blob/5527fd7f/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
index 8061f37..a82f02a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Blueprint.java
@@ -97,6 +97,15 @@ public interface Blueprint {
   public String getRecoveryEnabled(String serviceName, String componentName);
 
   /**
+   * Get whether a service is enabled for credential store use.
+   *
+   * @param serviceName - Service name.
+   *
+   * @return null if value is not specified; true or false if specified.
+   */
+  public String getCredentialStoreEnabled(String serviceName);
+
+  /**
    * Check if auto skip failure is enabled.
    * @return true if enabled, otherwise false.
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/5527fd7f/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
index df0187e..3ea90b4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
@@ -208,6 +208,55 @@ public class BlueprintImpl implements Blueprint {
     return null;
   }
 
+  /**
+   * Get whether the specified service is enabled for credential store use.
+   *
+   * <pre>
+   *     {@code
+   *       {
+   *         "service_settings" : [
+   *         { "name" : "RANGER",
+   *           "recovery_enabled" : "true",
+   *           "credential_store_enabled" : "true"
+   *         },
+   *         { "name" : "HIVE",
+   *           "recovery_enabled" : "true",
+   *           "credential_store_enabled" : "false"
+   *         },
+   *         { "name" : "TEZ",
+   *           "recovery_enabled" : "false"
+   *         }
+   *       ]
+   *     }
+   *   }
+   * </pre>
+   *
+   * @param serviceName - Service name.
+   *
+   * @return null if value is not specified; true or false if specified.
+   */
+  @Override
+  public String getCredentialStoreEnabled(String serviceName) {
+    if (setting == null)
+      return null;
+
+    /**
+     * Look up the service and return the credential_store_enabled value.
+     */
+    Set<HashMap<String, String>> settingValue = setting.getSettingValue(Setting.SETTING_NAME_SERVICE_SETTINGS);
+    for (Map<String, String> setting : settingValue) {
+      String name = setting.get(Setting.SETTING_NAME_NAME);
+      if (StringUtils.equals(name, serviceName)) {
+        if (!StringUtils.isEmpty(setting.get(Setting.SETTING_NAME_CREDENTIAL_STORE_ENABLED)))
{
+          return setting.get(Setting.SETTING_NAME_CREDENTIAL_STORE_ENABLED);
+        }
+        break;
+      }
+    }
+
+    return null;
+  }
+
   @Override
   public boolean shouldSkipFailure() {
     if (setting == null) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/5527fd7f/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
index 601cbfd..6a14331 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
@@ -45,6 +45,27 @@ public class Setting {
   public static final String SETTING_NAME_NAME = "name";
 
   /**
+   * When specified under the "service_settings" section, it indicates whether credential
store
+   * use is enabled for that service. Value is "true" or "false". Specify a value of "true"
+   * only if the stack definition for the service has a credential_store_supported value
of "true".
+   * If credential_store_enabled is not specified, value will be taken as null and default
value
+   * will be picked up from the stack definition, if available.
+   *   <pre>
+   *     {@code
+   *       {
+   *         "service_settings" : [
+   *           { "name" : "RANGER",
+   *             "recovery_enabled" : "true",
+   *             "credential_store_enabled" : "true"
+   *           },
+   *           :
+   *       }
+   *     }
+   *   </pre>
+   */
+  public static final String SETTING_NAME_CREDENTIAL_STORE_ENABLED = "credential_store_enabled";
+
+  /**
    * Settings.
    *
    * @param properties  setting name-->Set(property name-->property value)

http://git-wip-us.apache.org/repos/asf/ambari/blob/5527fd7f/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
index 6ef240d..ee64ac9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
@@ -185,6 +185,7 @@ public class AmbariContextTest {
     expect(blueprint.getComponents("service1")).andReturn(Arrays.asList("s1Component1", "s1Component2")).anyTimes();
     expect(blueprint.getComponents("service2")).andReturn(Collections.singleton("s2Component1")).anyTimes();
     expect(blueprint.getConfiguration()).andReturn(bpConfiguration).anyTimes();
+    expect(blueprint.getCredentialStoreEnabled("service1")).andReturn("true").anyTimes();
 
     expect(stack.getName()).andReturn(STACK_NAME).anyTimes();
     expect(stack.getVersion()).andReturn(STACK_VERSION).anyTimes();


Mime
View raw message