You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apex.apache.org by davidyan74 <gi...@git.apache.org> on 2015/10/06 01:14:59 UTC
[GitHub] incubator-apex-core pull request: APEX-181 expose getting of rm we...
GitHub user davidyan74 opened a pull request:
https://github.com/apache/incubator-apex-core/pull/103
APEX-181 expose getting of rm web app address
@PramodSSImmaneni I need to expose the function of getting all RM webapp addresses when HA is enabled so I'm moving some of the code to StramClientUtils from StramWSFilter. Please review.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/davidyan74/incubator-apex-core APEX-181
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-apex-core/pull/103.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #103
----
commit d431004fb8d8e22f73e280e35931bf46459d40f1
Author: David Yan <da...@datatorrent.com>
Date: 2015-10-05T20:08:03Z
APEX-181 expose getting of rm web app address
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-apex-core pull request: APEX-181 expose getting of rm we...
Posted by davidyan74 <gi...@git.apache.org>.
Github user davidyan74 commented on a diff in the pull request:
https://github.com/apache/incubator-apex-core/pull/103#discussion_r41224481
--- Diff: engine/src/main/java/com/datatorrent/stram/client/StramClientUtils.java ---
@@ -732,4 +734,33 @@ public static ApplicationReport getStartedAppInstanceByName(YarnClient clientRMS
return null;
}
+ public static InetSocketAddress getRMWebAddress(Configuration conf, String rmId)
+ {
+ boolean sslEnabled = conf.getBoolean(CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_KEY, CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_DEFAULT);
+ return getRMWebAddress(conf, sslEnabled, rmId);
+ }
+
+ public static InetSocketAddress getRMWebAddress(Configuration conf, boolean sslEnabled, String rmId)
+ {
+ rmId = (rmId == null) ? "" : ("." + rmId);
+ InetSocketAddress address;
+ if (sslEnabled) {
+ address = conf.getSocketAddr(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS + rmId, YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_ADDRESS, YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_PORT);
+ } else {
+ address = conf.getSocketAddr(YarnConfiguration.RM_WEBAPP_ADDRESS + rmId, YarnConfiguration.DEFAULT_RM_WEBAPP_ADDRESS, YarnConfiguration.DEFAULT_RM_WEBAPP_PORT);
+ }
+ LOG.info("rm webapp address setting {}", address);
+ LOG.debug("rm setting sources {}", conf.getPropertySources(YarnConfiguration.RM_WEBAPP_ADDRESS));
+ address = NetUtils.getConnectAddress(address);
+ InetAddress resolved = address.getAddress();
+ if (resolved == null || resolved.isAnyLocalAddress() || resolved.isLoopbackAddress()) {
+ try {
+ address = new InetSocketAddress(InetAddress.getLocalHost(), address.getPort());
--- End diff --
I have difficulty understanding this one. Let's discuss this in person tomorrow.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-apex-core pull request: APEX-181 expose getting of rm we...
Posted by davidyan74 <gi...@git.apache.org>.
Github user davidyan74 commented on the pull request:
https://github.com/apache/incubator-apex-core/pull/103#issuecomment-146006862
Pramod, the PR is updated. However, I tried getCanonicalHostName on a LocalAddress on my machine and it returns "localhost". This doesn't seem to be what you intended.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-apex-core pull request: APEX-181 expose getting of rm we...
Posted by PramodSSImmaneni <gi...@git.apache.org>.
Github user PramodSSImmaneni commented on a diff in the pull request:
https://github.com/apache/incubator-apex-core/pull/103#discussion_r41222951
--- Diff: engine/src/main/java/com/datatorrent/stram/security/StramWSFilterInitializer.java ---
@@ -100,51 +97,20 @@ public String getProxyHostAndPort(Configuration conf)
Replace with methods from Hadoop when HA support is available
HttpConfig is not used as it's audience is private as well and it's interface has changed from Hadoop 2.2 to 2.6
*/
- public String getResolvedRMWebAppURLWithoutScheme(Configuration conf, String rmId) {
- boolean sslEnabled = conf.getBoolean(
- CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_KEY,
- CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_DEFAULT);
- return getResolvedRMWebAppURLWithoutScheme(conf, sslEnabled, (rmId != null) ? "." + rmId : "");
+ public String getResolvedRMWebAppURLWithoutScheme(Configuration conf, String rmId)
+ {
+ InetSocketAddress socketAddress = StramClientUtils.getRMWebAddress(conf, rmId);
+ return socketAddress.getHostString() + ":" + socketAddress.getPort();
}
/*
From org.apache.hadoop.yarn.webapp.util.WebAppUtils
Modified for HA support
*/
- public String getResolvedRMWebAppURLWithoutScheme(Configuration conf, boolean sslEnabled, String rmPrpKey)
+ public String getResolvedRMWebAppURLWithoutScheme(Configuration conf, boolean sslEnabled, String rmId)
--- End diff --
Looks like contract of this method has changed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-apex-core pull request: APEX-181 expose getting of rm we...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/incubator-apex-core/pull/103
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-apex-core pull request: APEX-181 expose getting of rm we...
Posted by davidyan74 <gi...@git.apache.org>.
Github user davidyan74 commented on a diff in the pull request:
https://github.com/apache/incubator-apex-core/pull/103#discussion_r41224451
--- Diff: engine/src/main/java/com/datatorrent/stram/security/StramWSFilterInitializer.java ---
@@ -100,51 +97,20 @@ public String getProxyHostAndPort(Configuration conf)
Replace with methods from Hadoop when HA support is available
HttpConfig is not used as it's audience is private as well and it's interface has changed from Hadoop 2.2 to 2.6
*/
- public String getResolvedRMWebAppURLWithoutScheme(Configuration conf, String rmId) {
- boolean sslEnabled = conf.getBoolean(
- CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_KEY,
- CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_DEFAULT);
- return getResolvedRMWebAppURLWithoutScheme(conf, sslEnabled, (rmId != null) ? "." + rmId : "");
+ public String getResolvedRMWebAppURLWithoutScheme(Configuration conf, String rmId)
+ {
+ InetSocketAddress socketAddress = StramClientUtils.getRMWebAddress(conf, rmId);
+ return socketAddress.getHostString() + ":" + socketAddress.getPort();
}
/*
From org.apache.hadoop.yarn.webapp.util.WebAppUtils
Modified for HA support
*/
- public String getResolvedRMWebAppURLWithoutScheme(Configuration conf, boolean sslEnabled, String rmPrpKey)
+ public String getResolvedRMWebAppURLWithoutScheme(Configuration conf, boolean sslEnabled, String rmId)
--- End diff --
I actually think it should change because getResolvedRMWebAppURLWithoutScheme was originally an overloaded method with different behaviors among the two different signatures. They should be consistent especially since they both are public methods
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-apex-core pull request: APEX-181 expose getting of rm we...
Posted by PramodSSImmaneni <gi...@git.apache.org>.
Github user PramodSSImmaneni commented on a diff in the pull request:
https://github.com/apache/incubator-apex-core/pull/103#discussion_r41222832
--- Diff: engine/src/main/java/com/datatorrent/stram/client/StramClientUtils.java ---
@@ -732,4 +734,33 @@ public static ApplicationReport getStartedAppInstanceByName(YarnClient clientRMS
return null;
}
+ public static InetSocketAddress getRMWebAddress(Configuration conf, String rmId)
+ {
+ boolean sslEnabled = conf.getBoolean(CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_KEY, CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_DEFAULT);
+ return getRMWebAddress(conf, sslEnabled, rmId);
+ }
+
+ public static InetSocketAddress getRMWebAddress(Configuration conf, boolean sslEnabled, String rmId)
+ {
+ rmId = (rmId == null) ? "" : ("." + rmId);
+ InetSocketAddress address;
+ if (sslEnabled) {
+ address = conf.getSocketAddr(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS + rmId, YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_ADDRESS, YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_PORT);
+ } else {
+ address = conf.getSocketAddr(YarnConfiguration.RM_WEBAPP_ADDRESS + rmId, YarnConfiguration.DEFAULT_RM_WEBAPP_ADDRESS, YarnConfiguration.DEFAULT_RM_WEBAPP_PORT);
+ }
+ LOG.info("rm webapp address setting {}", address);
+ LOG.debug("rm setting sources {}", conf.getPropertySources(YarnConfiguration.RM_WEBAPP_ADDRESS));
+ address = NetUtils.getConnectAddress(address);
+ InetAddress resolved = address.getAddress();
+ if (resolved == null || resolved.isAnyLocalAddress() || resolved.isLoopbackAddress()) {
+ try {
+ address = new InetSocketAddress(InetAddress.getLocalHost(), address.getPort());
--- End diff --
For local address we need canonical hostname
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-apex-core pull request: APEX-181 expose getting of rm we...
Posted by PramodSSImmaneni <gi...@git.apache.org>.
Github user PramodSSImmaneni commented on a diff in the pull request:
https://github.com/apache/incubator-apex-core/pull/103#discussion_r41410996
--- Diff: engine/src/main/java/com/datatorrent/stram/client/StramClientUtils.java ---
@@ -732,4 +734,45 @@ public static ApplicationReport getStartedAppInstanceByName(YarnClient clientRMS
return null;
}
+ public static InetSocketAddress getRMWebAddress(Configuration conf, String rmId)
+ {
+ boolean sslEnabled = conf.getBoolean(CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_KEY, CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_DEFAULT);
+ return getRMWebAddress(conf, sslEnabled, rmId);
+ }
+
+ public static InetSocketAddress getRMWebAddress(Configuration conf, boolean sslEnabled, String rmId)
+ {
+ rmId = (rmId == null) ? "" : ("." + rmId);
+ InetSocketAddress address;
+ if (sslEnabled) {
+ address = conf.getSocketAddr(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS + rmId, YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_ADDRESS, YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_PORT);
+ } else {
+ address = conf.getSocketAddr(YarnConfiguration.RM_WEBAPP_ADDRESS + rmId, YarnConfiguration.DEFAULT_RM_WEBAPP_ADDRESS, YarnConfiguration.DEFAULT_RM_WEBAPP_PORT);
+ }
+ LOG.info("rm webapp address setting {}", address);
+ LOG.debug("rm setting sources {}", conf.getPropertySources(YarnConfiguration.RM_WEBAPP_ADDRESS));
+ address = NetUtils.getConnectAddress(address);
+ InetAddress resolved = address.getAddress();
+ if (resolved == null || resolved.isAnyLocalAddress() || resolved.isLoopbackAddress()) {
+ try {
+ address = new InetSocketAddress(InetAddress.getLocalHost(), address.getPort());
+ } catch (UnknownHostException e) {
+ //Ignore and fallback.
+ }
+ }
+ return address;
+ }
+
+ public static String getSocketConnectString(InetSocketAddress socketAddress)
+ {
+ String host;
+ InetAddress address = socketAddress.getAddress();
+ if (address.isAnyLocalAddress() || address.isLoopbackAddress()) {
--- End diff --
Do either of these two
1. Add address.equals(InetAddress.getLocalHost()) to the check as a local inet address may still not match the two specified conditions above.
2. Create an unresolved InetSocketAddress in getRMWebAddress with canonical hostname and check for null InetAddress here
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---