ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbhowm...@apache.org
Subject ambari git commit: AMBARI-16138. Converting cluster to Kerberos the views should automatically adjust and work prior to the kerberization. (Gaurav Nagar via dipayanb)
Date Tue, 17 May 2016 19:52:08 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 aa29e0798 -> 4a2868c82


AMBARI-16138. Converting cluster to Kerberos the views should automatically adjust and work
prior to the kerberization. (Gaurav Nagar via dipayanb)


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

Branch: refs/heads/branch-2.4
Commit: 4a2868c82d3f948d68e0a3d207a2874521fb3bb6
Parents: aa29e07
Author: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Authored: Wed May 18 01:21:05 2016 +0530
Committer: Dipayan Bhowmick <dipayan.bhowmick@gmail.com>
Committed: Wed May 18 01:21:47 2016 +0530

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog240.java       |  9 ++++
 .../server/upgrade/UpgradeCatalog240Test.java   |  7 +++
 .../apache/ambari/view/hive/HelpService.java    |  2 +-
 .../view/hive/client/ConnectionFactory.java     | 53 ++++++++++++++++----
 .../jobs/atsJobs/ATSParserFactory.java          |  9 ++--
 contrib/views/hive/src/main/resources/view.xml  |  1 -
 .../apache/ambari/view/hive/BaseHiveTest.java   |  4 +-
 contrib/views/pig/src/main/resources/view.xml   |  2 +-
 contrib/views/tez/readme.md                     |  2 +-
 .../apache/ambari/view/tez/ViewController.java  |  2 +-
 contrib/views/tez/src/main/resources/view.xml   |  2 +-
 .../ambari/view/utils/ambari/Services.java      |  2 +-
 .../utils/hdfs/AuthConfigurationBuilder.java    |  9 +++-
 .../view/utils/hdfs/ConfigurationBuilder.java   | 44 +++++++++++++++-
 .../ambari/view/utils/ambari/ServicesTest.java  |  4 +-
 15 files changed, 127 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
index 1f3b1d3..41f538e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
@@ -328,6 +328,7 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
     consolidateUserRoles();
     createRolePrincipals();
     updateHDFSWidgetDefinition();
+    updateTezViewProperty();
   }
 
   protected void updateClusterInheritedPermissionsConfig() throws SQLException {
@@ -2008,4 +2009,12 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
       }
     }
   }
+
+  /**
+   *  Update properties with name
+   *  yarn.timeline-server.url to yarn.ats.url
+   */
+  private void updateTezViewProperty() throws SQLException {
+    dbAccessor.executeUpdate("UPDATE viewinstanceproperty SET name = 'yarn.ats.url' where
name = 'yarn.timeline-server.url'");
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
index f36e640..20fa50f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
@@ -462,6 +462,9 @@ public class UpgradeCatalog240Test {
     DBAccessor dbAccessor = createStrictMock(DBAccessor.class);
     expect(dbAccessor.executeUpdate(capture(capturedStatements))).andReturn(1).times(7);
 
+    Capture<String> capturedTezViewUpdate = newCapture();
+    expect(dbAccessor.executeUpdate(capture(capturedTezViewUpdate))).andReturn(1).once();
+
     UpgradeCatalog240 upgradeCatalog240 = createMockBuilder(UpgradeCatalog240.class)
             .addMockedMethod(addNewConfigurationsFromXml)
             .addMockedMethod(updateAlerts)
@@ -521,6 +524,10 @@ public class UpgradeCatalog240Test {
     Assert.assertTrue(statements.contains("UPDATE adminpermission SET sort_order=5 WHERE
permission_name='SERVICE.OPERATOR'"));
     Assert.assertTrue(statements.contains("UPDATE adminpermission SET sort_order=6 WHERE
permission_name='CLUSTER.USER'"));
     Assert.assertTrue(statements.contains("UPDATE adminpermission SET sort_order=7 WHERE
permission_name='VIEW.USER'"));
+
+    Assert.assertNotNull(capturedTezViewUpdate.getValue());
+    Assert.assertEquals("UPDATE viewinstanceproperty SET name = 'yarn.ats.url' where name
= 'yarn.timeline-server.url'",
+      capturedTezViewUpdate.getValue());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/HelpService.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/HelpService.java
b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/HelpService.java
index 05b55d2..3a7f823 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/HelpService.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/HelpService.java
@@ -87,7 +87,7 @@ public class HelpService extends BaseService {
   @Produces(MediaType.APPLICATION_JSON)
   public Response atsStatus() {
     try {
-      ATSRequestsDelegateImpl atsimpl = new ATSRequestsDelegateImpl(context, ATSParserFactory.getATSUrl(context));
+      ATSRequestsDelegateImpl atsimpl = new ATSRequestsDelegateImpl(context, new ATSParserFactory(context).getATSUrl());
       atsimpl.checkATSStatus();
       return getOKResponse();
     }catch (Exception e){

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/client/ConnectionFactory.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/client/ConnectionFactory.java
b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/client/ConnectionFactory.java
index 1442748..f93b7b3 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/client/ConnectionFactory.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/client/ConnectionFactory.java
@@ -41,6 +41,11 @@ public class ConnectionFactory implements UserLocalFactory<Connection>
{
   private AmbariApi ambariApi;
   private HdfsApi hdfsApi = null;
 
+  public static String HIVE_SERVER2_AUTHENTICATION = "hive.server2.authentication" ;
+  public static String HIVE_SITE = "hive-site" ;
+  public static String HIVE_SERVER2_KERBEROS_PRINCIPAL = "hive.server2.authentication.kerberos.principal"
;
+  public static String HIVE_SASL_QOP = "hive.server2.thrift.sasl.qop" ;
+
   public ConnectionFactory(ViewContext context, HiveAuthCredentials credentials) {
     this.context = context;
     this.credentials = credentials;
@@ -105,22 +110,52 @@ public class ConnectionFactory implements UserLocalFactory<Connection>
{
   private Map<String, String> getHiveAuthParams() {
     String auth = context.getProperties().get("hive.auth");
     Map<String, String> params = new HashMap<String, String>();
-    if (auth == null || auth.isEmpty()) {
-      auth = "auth=NOSASL";
-    }
-    for(String param : auth.split(";")) {
-      String[] keyvalue = param.split("=");
-      if (keyvalue.length != 2) {
-        //Should never happen because validator already checked this
-        throw new ServiceFormattedException("H010 Can not parse authentication param " +
param + " in " + auth);
+    if ((auth == null || auth.isEmpty()) && context.getCluster() != null) {
+      params.putAll(getDefaultAuthParams());
+    } else if(auth == null || auth.isEmpty()) {
+      params.put("auth","NOSASL");
+    } else {
+      for (String param : auth.split(";")) {
+        String[] keyvalue = param.split("=");
+        if (keyvalue.length != 2) {
+          //Should never happen because validator already checked this
+          throw new ServiceFormattedException("H010 Can not parse authentication param "
+ param + " in " + auth);
+        }
+        params.put(keyvalue[0], keyvalue[1]);
       }
-      params.put(keyvalue[0], keyvalue[1]);
     }
     params.put(Utils.HiveAuthenticationParams.TRANSPORT_MODE,context.getProperties().get("hive.transport.mode"));
     params.put(Utils.HiveAuthenticationParams.HTTP_PATH,context.getProperties().get("hive.http.path"));
     return params;
   }
 
+  private Map<String,String> getDefaultAuthParams(){
+    Map<String,String> params = new HashMap<String,String>();
+    String auth = getProperty(HIVE_SITE,HIVE_SERVER2_AUTHENTICATION);
+    params.put("auth",auth);
+
+    if(auth.equalsIgnoreCase("KERBEROS")){
+      params.put("principal",getProperty(HIVE_SITE,HIVE_SERVER2_KERBEROS_PRINCIPAL));
+      params.put(Utils.HiveAuthenticationParams.HS2_PROXY_USER,"${username}");
+    } else if(auth.equalsIgnoreCase("LDAP") || auth.equalsIgnoreCase("CUSTOM")){
+      params.put("auth","NONE");
+      params.put("password","${ask_password}");
+    }
+
+    String qop = getProperty(HIVE_SITE,HIVE_SASL_QOP);
+    if(qop != null && !qop.equals("auth")){
+      params.put(Utils.HiveAuthenticationParams.AUTH_QOP,qop);
+    }
+    return params;
+  }
+
+  private String getProperty(String type,String key){
+    if(context.getCluster() != null){
+      return context.getCluster().getConfigurationValue(type,key);
+    }
+    return null;
+  }
+
   public HiveAuthCredentials getCredentials() {
     return credentials;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/atsJobs/ATSParserFactory.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/atsJobs/ATSParserFactory.java
b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/atsJobs/ATSParserFactory.java
index f5e9bcf..f035f75 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/atsJobs/ATSParserFactory.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/atsJobs/ATSParserFactory.java
@@ -19,6 +19,7 @@
 package org.apache.ambari.view.hive.resources.jobs.atsJobs;
 
 import org.apache.ambari.view.ViewContext;
+import org.apache.ambari.view.utils.ambari.AmbariApi;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -26,17 +27,19 @@ import java.util.Map;
 public class ATSParserFactory {
 
   private ViewContext context;
+  private final AmbariApi ambariApi;
 
   public ATSParserFactory(ViewContext context) {
     this.context = context;
+    this.ambariApi = new AmbariApi(context);
   }
 
   public ATSParser getATSParser() {
-    ATSRequestsDelegateImpl delegate = new ATSRequestsDelegateImpl(context, getATSUrl(context));
+    ATSRequestsDelegateImpl delegate = new ATSRequestsDelegateImpl(context, getATSUrl());
     return new ATSParser(delegate);
   }
 
-  public static String getATSUrl(ViewContext context) {
-    return context.getProperties().get("yarn.ats.url");
+  public String getATSUrl() {
+    return ambariApi.getServices().getTimelineServerUrl();
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/hive/src/main/resources/view.xml
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/view.xml b/contrib/views/hive/src/main/resources/view.xml
index 8f8a470..90df262 100644
--- a/contrib/views/hive/src/main/resources/view.xml
+++ b/contrib/views/hive/src/main/resources/view.xml
@@ -80,7 +80,6 @@
       <description>Semicolon-separated authentication configs.</description>
       <label>Hive Authentication</label>
       <placeholder>auth=NONE</placeholder>
-      <default-value>auth=NONE</default-value>
       <required>false</required>
     </parameter>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/BaseHiveTest.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/BaseHiveTest.java
b/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/BaseHiveTest.java
index 25db721..adcd988 100644
--- a/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/BaseHiveTest.java
+++ b/contrib/views/hive/src/test/java/org/apache/ambari/view/hive/BaseHiveTest.java
@@ -77,8 +77,8 @@ public abstract class BaseHiveTest {
     properties.put("dataworker.storagePath", hiveStorageFile.toString());
     properties.put("scripts.dir", "/tmp/.hiveQueries");
     properties.put("jobs.dir", "/tmp/.hiveJobs");
-    properties.put("yarn.ats.url", "127.0.0.1:8188");
-    properties.put("yarn.resourcemanager.url", "127.0.0.1:8088");
+    properties.put("yarn.ats.url", "http://127.0.0.1:8188");
+    properties.put("yarn.resourcemanager.url", "http://127.0.0.1:8088");
   }
 
   public ViewContext makeContext(Map<String, String> properties, String username, String
instanceName) throws Exception {

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/pig/src/main/resources/view.xml
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/resources/view.xml b/contrib/views/pig/src/main/resources/view.xml
index 9df91f8..de338da 100644
--- a/contrib/views/pig/src/main/resources/view.xml
+++ b/contrib/views/pig/src/main/resources/view.xml
@@ -112,7 +112,7 @@
         <name>webhdfs.auth</name>
         <description>Semicolon-separated authentication configs. Default: auth=SIMPLE</description>
         <label>WebHDFS Authentication</label>
-        <default-value>auth=SIMPLE</default-value>
+        <placeholder>auth=SIMPLE</placeholder>
         <required>false</required>
     </parameter>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/tez/readme.md
----------------------------------------------------------------------
diff --git a/contrib/views/tez/readme.md b/contrib/views/tez/readme.md
index fdb9459..3d36696 100644
--- a/contrib/views/tez/readme.md
+++ b/contrib/views/tez/readme.md
@@ -81,7 +81,7 @@ From the Ambari Administration interface, create a TEZ view instance.
 | Details: Instance Name | TEZUI |
 | Details: Display Name | TEZ |
 | Details: Description | A web interface for TEZ |
-| Properties: yarn.timeline-server.url | http://yarn.timeline-service.hostname:8188 |
+| Properties: yarn.ats.url | http://yarn.timeline-service.hostname:8188 |
 | Properties: yarn.resourcemanager.url | http://yarn.resourcemanager.hostname:8088 |
 
 Login to Ambari as **"admin"** and browse to the view instance.

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
index 440ac65..4ef1a43 100644
--- a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
+++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
@@ -26,7 +26,7 @@ import com.google.inject.ImplementedBy;
 @ImplementedBy(ViewControllerImpl.class)
 public interface ViewController {
 
-  public static final String PARAM_YARN_ATS_URL = "yarn.timeline-server.url";
+  public static final String PARAM_YARN_ATS_URL = "yarn.ats.url";
   public static final String PARAM_YARN_RESOURCEMANAGER_URL = "yarn.resourcemanager.url";
   public static final String PARAM_YARN_PROTOCOL = "yarn.protocol";
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/tez/src/main/resources/view.xml
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/resources/view.xml b/contrib/views/tez/src/main/resources/view.xml
index d8105f1..7bf19d5 100644
--- a/contrib/views/tez/src/main/resources/view.xml
+++ b/contrib/views/tez/src/main/resources/view.xml
@@ -22,7 +22,7 @@ limitations under the License. Kerberos, LDAP, Custom. Binary/Htt
   <description>Ambari view for Apache Tez</description>
 
   <parameter>
-    <name>yarn.timeline-server.url</name>
+    <name>yarn.ats.url</name>
     <description>The URL to the YARN Application Timeline Server, used to provide Tez
information. Typically this is the yarn.timeline-service.webapp.address property in the yarn-site.xml
configuration. Url must be accessible from Ambari server.</description>
     <label>YARN Timeline Server URL</label>
     <placeholder>yarn.timeline-service.hostname:8188</placeholder>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java
----------------------------------------------------------------------
diff --git a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java
b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java
index 1bace94..782a61f 100644
--- a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java
+++ b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/Services.java
@@ -51,7 +51,7 @@ public class Services {
   private static final String YARN_RESOURCEMANAGER_DEFAULT_HTTPS_PORT = "8090";
 
 
-  private static final String YARN_ATS_URL = "yarn.timeline-server.url";
+  private static final String YARN_ATS_URL = "yarn.ats.url";
   private final static String YARN_TIMELINE_WEBAPP_HTTP_ADDRESS_KEY = "yarn.timeline-service.webapp.address";
   private final static String YARN_TIMELINE_WEBAPP_HTTPS_ADDRESS_KEY = "yarn.timeline-service.webapp.https.address";
   public static final String RM_INFO_API_ENDPOINT = "/ws/v1/cluster/info";

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/AuthConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/AuthConfigurationBuilder.java
b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/AuthConfigurationBuilder.java
index 4911455..10ec1fb 100644
--- a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/AuthConfigurationBuilder.java
+++ b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/AuthConfigurationBuilder.java
@@ -81,7 +81,14 @@ public class AuthConfigurationBuilder {
   private String getConfigurationFromAmbari() throws NoClusterAssociatedException {
     String authMethod = context.getCluster().getConfigurationValue(
         "core-site", "hadoop.security.authentication");
-    return String.format("auth=%s", authMethod);
+
+    String authString = String.format("auth=%s", authMethod);
+
+    String proxyUser = context.getCluster().getConfigurationValue("cluster-env","ambari_principal_name");
+    if(proxyUser != null && !authMethod.equalsIgnoreCase("SIMPLE")){
+      authString = authString + String.format(";proxyuser=%s",proxyUser.split("@")[0]);
+    }
+    return authString;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/ConfigurationBuilder.java
b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/ConfigurationBuilder.java
index 8b45cd6..a371889 100644
--- a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/ConfigurationBuilder.java
+++ b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/ConfigurationBuilder.java
@@ -67,6 +67,14 @@ public class ConfigurationBuilder {
   public static final String UMASK_CLUSTER_PROPERTY = "fs.permissions.umask-mode";
   public static final String UMASK_INSTANCE_PROPERTY = "hdfs.umask-mode";
 
+  public static final String DFS_WEBHDFS_ENABLED = "dfs.webhdfs.enabled";
+  public static final String DFS_HTTP_POLICY = "dfs.http.policy";
+  public static final String DFS_HTTP_POLICY_HTTPS_ONLY = "HTTPS";
+
+  public static final String DFS_NAMENODE_HTTP_ADDERSS = "dfs.namenode.http-address";
+  public static final String DFS_NAMENODE_HTTPS_ADDERSS = "dfs.namenode.https-address";
+
+
   private Configuration conf = new Configuration();
   private ViewContext context;
   private AmbariApi ambariApi = null;
@@ -93,7 +101,7 @@ public class ConfigurationBuilder {
 
         LOG.info("HA HDFS cluster found.");
       } else {
-        if (defaultFS.startsWith("hdfs://") && !hasPort(defaultFS)) {
+        if (defaultFS.startsWith("webhdfs://") && !hasPort(defaultFS)) {
           defaultFS = addPortIfMissing(defaultFS);
         }
       }
@@ -116,6 +124,33 @@ public class ConfigurationBuilder {
       throw new HdfsApiException("HDFS070 fs.defaultFS is not configured");
 
     defaultFS = addProtocolIfMissing(defaultFS);
+
+    if(context.getCluster() != null){
+      try {
+        URI fsUri = new URI(defaultFS);
+        String protocol = fsUri.getScheme();
+        String hostWithPort = defaultFS.substring(protocol.length() + 3);
+
+        Boolean webHdfsEnabled = Boolean.valueOf(getProperty(HDFS_SITE,DFS_WEBHDFS_ENABLED));
+        Boolean isHttps = DFS_HTTP_POLICY_HTTPS_ONLY.equals(getProperty(HDFS_SITE,DFS_HTTP_POLICY));
+
+        boolean isHA = isHAEnabled(defaultFS);
+
+        if(webHdfsEnabled && isHttps){
+          protocol = "swebhdfs";
+          String httpAddr = getProperty(HDFS_SITE,DFS_NAMENODE_HTTPS_ADDERSS);
+          if(!isHA && httpAddr != null) hostWithPort = httpAddr ;
+        }else if(webHdfsEnabled){
+          protocol = "webhdfs";
+          String httpsAddr = getProperty(HDFS_SITE,DFS_NAMENODE_HTTP_ADDERSS);
+          if(!isHA) hostWithPort = httpsAddr;
+        }
+
+        return protocol + "://" +hostWithPort;
+      } catch (URISyntaxException e) {
+        throw new HdfsApiException("Invalid URI format."+e.getMessage(),e);
+      }
+    }
     return defaultFS;
   }
 
@@ -130,6 +165,13 @@ public class ConfigurationBuilder {
     return value;
   }
 
+  private String getProperty(String type,String key){
+    if(context.getCluster() != null){
+      return context.getCluster().getConfigurationValue(type,key);
+    }
+    return null;
+  }
+
   private void copyPropertyIfExists(String type, String key) {
     String value;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4a2868c8/contrib/views/utils/src/test/java/org/apache/ambari/view/utils/ambari/ServicesTest.java
----------------------------------------------------------------------
diff --git a/contrib/views/utils/src/test/java/org/apache/ambari/view/utils/ambari/ServicesTest.java
b/contrib/views/utils/src/test/java/org/apache/ambari/view/utils/ambari/ServicesTest.java
index c7c0990..6c14de1 100644
--- a/contrib/views/utils/src/test/java/org/apache/ambari/view/utils/ambari/ServicesTest.java
+++ b/contrib/views/utils/src/test/java/org/apache/ambari/view/utils/ambari/ServicesTest.java
@@ -63,7 +63,7 @@ public class ServicesTest extends EasyMockSupport {
   @Test
   public void shouldReturnATSUrlConfiguredInCustomMode() throws Exception {
     Map<String, String> map = new HashMap<>();
-    map.put("yarn.timeline-server.url", HTTP_RM_URL1);
+    map.put("yarn.ats.url", HTTP_RM_URL1);
     ViewContext viewContext = getViewContext(map);
 
     AmbariApi ambariApi = createNiceMock(AmbariApi.class);
@@ -78,7 +78,7 @@ public class ServicesTest extends EasyMockSupport {
   @Test(expected = AmbariApiException.class)
   public void shouldThrowExceptionIfNoProtocolInCustomMode() {
     Map<String, String> map = new HashMap<>();
-    map.put("yarn.timeline-server.url", RM_URL1_HOST_PORT);
+    map.put("yarn.ats.url", RM_URL1_HOST_PORT);
     ViewContext viewContext = getViewContext(map);
 
     AmbariApi ambariApi = createNiceMock(AmbariApi.class);


Mime
View raw message