apex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pra...@apache.org
Subject [1/2] apex-core git commit: APEXCORE-488: Issues in SSL communication with StrAM - Fixed Application Master trackingURL - StramAgent shall not assume always HTTP
Date Tue, 19 Jul 2016 06:00:58 GMT
Repository: apex-core
Updated Branches:
  refs/heads/master d32ea3c04 -> 7ca1ed12d


APEXCORE-488: Issues in SSL communication with StrAM
 - Fixed Application Master trackingURL
 - StramAgent shall not assume always HTTP


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

Branch: refs/heads/master
Commit: 4f3ab00ac6738b5ec491dd1a6ec7ce6a201cd203
Parents: 1b1813f
Author: Pradeep A. Dalvi <prad@apache.org>
Authored: Mon Jul 11 15:59:32 2016 -0700
Committer: Pradeep A. Dalvi <prad@apache.org>
Committed: Wed Jul 13 20:35:32 2016 -0700

----------------------------------------------------------------------
 .../stram/StreamingAppMasterService.java         |  7 ++++++-
 .../com/datatorrent/stram/client/StramAgent.java |  9 ++++++++-
 .../com/datatorrent/stram/util/ConfigUtils.java  | 19 +++++++++++++++++--
 3 files changed, 31 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/apex-core/blob/4f3ab00a/engine/src/main/java/com/datatorrent/stram/StreamingAppMasterService.java
----------------------------------------------------------------------
diff --git a/engine/src/main/java/com/datatorrent/stram/StreamingAppMasterService.java b/engine/src/main/java/com/datatorrent/stram/StreamingAppMasterService.java
index 1c7c893..43ab743 100644
--- a/engine/src/main/java/com/datatorrent/stram/StreamingAppMasterService.java
+++ b/engine/src/main/java/com/datatorrent/stram/StreamingAppMasterService.java
@@ -105,6 +105,7 @@ import com.datatorrent.stram.security.StramDelegationTokenIdentifier;
 import com.datatorrent.stram.security.StramDelegationTokenManager;
 import com.datatorrent.stram.security.StramUserLogin;
 import com.datatorrent.stram.security.StramWSFilterInitializer;
+import com.datatorrent.stram.util.ConfigUtils;
 import com.datatorrent.stram.util.SecurityUtils;
 import com.datatorrent.stram.webapp.AppInfo;
 import com.datatorrent.stram.webapp.StramWebApp;
@@ -614,7 +615,11 @@ public class StreamingAppMasterService extends CompositeService
       }
       WebApp webApp = WebApps.$for("stram", StramAppContext.class, appContext, "ws").with(config).start(new
StramWebApp(this.dnmgr));
       LOG.info("Started web service at port: " + webApp.port());
-      this.appMasterTrackingUrl = NetUtils.getConnectAddress(webApp.getListenerAddress()).getHostName()
+ ":" + webApp.port();
+      appMasterTrackingUrl = NetUtils.getConnectAddress(webApp.getListenerAddress()).getHostName()
+ ":" + webApp.port();
+
+      if (ConfigUtils.isSSLEnabled(config)) {
+        appMasterTrackingUrl = "https://" + appMasterTrackingUrl;
+      }
       LOG.info("Setting tracking URL to: " + appMasterTrackingUrl);
     } catch (Exception e) {
       LOG.error("Webapps failed to start. Ignoring for now:", e);

http://git-wip-us.apache.org/repos/asf/apex-core/blob/4f3ab00a/engine/src/main/java/com/datatorrent/stram/client/StramAgent.java
----------------------------------------------------------------------
diff --git a/engine/src/main/java/com/datatorrent/stram/client/StramAgent.java b/engine/src/main/java/com/datatorrent/stram/client/StramAgent.java
index 1e38ef2..29de7aa 100644
--- a/engine/src/main/java/com/datatorrent/stram/client/StramAgent.java
+++ b/engine/src/main/java/com/datatorrent/stram/client/StramAgent.java
@@ -204,7 +204,14 @@ public class StramAgent extends FSAgent
     if (info != null) {
       //ws = wsClient.resource("http://" + info.appMasterTrackingUrl).path(WebServices.PATH).path(info.version).path("stram");
       // the filter should convert to the right version
-      ub = UriBuilder.fromUri("http://" + info.appMasterTrackingUrl).path(WebServices.PATH).path(WebServices.VERSION).path("stram");
+      String url;
+      if (!info.appMasterTrackingUrl.startsWith("http://")
+          && !info.appMasterTrackingUrl.startsWith("https://")) {
+        url = "http://" + info.appMasterTrackingUrl;
+      } else {
+        url = info.appMasterTrackingUrl;
+      }
+      ub = UriBuilder.fromUri(url).path(WebServices.PATH).path(WebServices.VERSION).path("stram");
       WebServicesVersionConversion.Converter versionConverter = WebServicesVersionConversion.getConverter(info.version);
       if (versionConverter != null) {
         VersionConversionFilter versionConversionFilter = new VersionConversionFilter(versionConverter);

http://git-wip-us.apache.org/repos/asf/apex-core/blob/4f3ab00a/engine/src/main/java/com/datatorrent/stram/util/ConfigUtils.java
----------------------------------------------------------------------
diff --git a/engine/src/main/java/com/datatorrent/stram/util/ConfigUtils.java b/engine/src/main/java/com/datatorrent/stram/util/ConfigUtils.java
index 0275535..9da0b0c 100644
--- a/engine/src/main/java/com/datatorrent/stram/util/ConfigUtils.java
+++ b/engine/src/main/java/com/datatorrent/stram/util/ConfigUtils.java
@@ -68,15 +68,30 @@ public class ConfigUtils
     return principal;
   }
 
-  public static String getSchemePrefix(YarnConfiguration conf)
+  public static boolean isSSLEnabled(Configuration conf)
+  {
+    if (HttpConfig.Policy.HTTPS_ONLY == HttpConfig.Policy.fromString(
+        conf.get(YarnConfiguration.YARN_HTTP_POLICY_KEY, YarnConfiguration.YARN_HTTP_POLICY_DEFAULT)))
{
+      return true;
+    }
+    return false;
+  }
+
+  public static String getSchemePrefix(Configuration conf)
   {
-    if (HttpConfig.Policy.HTTPS_ONLY == HttpConfig.Policy.fromString(conf.get(YarnConfiguration.YARN_HTTP_POLICY_KEY,
YarnConfiguration.YARN_HTTP_POLICY_DEFAULT))) {
+    if (isSSLEnabled(conf)) {
       return "https://";
     } else {
       return "http://";
     }
   }
 
+  @Deprecated
+  public static String getSchemePrefix(YarnConfiguration conf)
+  {
+    return getSchemePrefix((Configuration)conf);
+  }
+
   public static String getYarnLogDir()
   {
     if (yarnLogDir != null) {


Mime
View raw message