You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2016/03/29 14:20:17 UTC
[1/2] incubator-slider git commit: SLIDER-1097 Agent Web App does not
respect slider.allowed.ports
Repository: incubator-slider
Updated Branches:
refs/heads/develop dab79496a -> e5ebd266b
SLIDER-1097 Agent Web App does not respect slider.allowed.ports
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/12a96f78
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/12a96f78
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/12a96f78
Branch: refs/heads/develop
Commit: 12a96f7846919298da51c37fe2dea4be6ac47fbc
Parents: dab7949
Author: Steve Loughran <st...@apache.org>
Authored: Tue Mar 29 13:18:01 2016 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Mar 29 13:18:01 2016 +0100
----------------------------------------------------------------------
.../slider/server/appmaster/SliderAppMaster.java | 6 ++++--
.../appmaster/web/rest/agent/AgentWebApp.java | 19 ++++++++++++++++---
.../web/rest/agent/TestAMAgentWebServices.java | 19 +++++++++++++++++++
3 files changed, 39 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/12a96f78/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
index ba5a060..d301f13 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
@@ -1235,7 +1235,7 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
* @throws IOException
*/
private void startAgentWebApp(MapOperations appInformation,
- Configuration serviceConf, WebAppApiImpl webAppApi) throws IOException {
+ Configuration serviceConf, WebAppApiImpl webAppApi) throws IOException, SliderException {
URL[] urls = ((URLClassLoader) AgentWebApp.class.getClassLoader() ).getURLs();
StringBuilder sb = new StringBuilder("AM classpath:");
for (URL url : urls) {
@@ -1252,7 +1252,9 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
webAppApi,
RestPaths.AGENT_WS_CONTEXT)
.withComponentConfig(appMasterConfig)
- .start();
+ .withPort(getPortToRequest())
+ .withSecuredPort(getPortToRequest())
+ .start();
agentOpsUrl =
"https://" + appMasterHostname + ":" + agentWebApp.getSecuredPort();
agentStatusUrl =
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/12a96f78/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
index f9ea06d..200fbc2 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
@@ -56,6 +56,8 @@ public class AgentWebApp implements Closeable {
final String name;
final String wsName;
final WebAppApi application;
+ int port;
+ int securedPort;
MapOperations configsMap;
public Builder(String name, String wsName, WebAppApi application) {
@@ -69,6 +71,16 @@ public class AgentWebApp implements Closeable {
return this;
}
+ public Builder withPort (int port) {
+ this.port = port;
+ return this;
+ }
+
+ public Builder withSecuredPort (int securedPort) {
+ this.securedPort = securedPort;
+ return this;
+ }
+
public AgentWebApp start() throws IOException {
if (configsMap == null) {
throw new IllegalStateException("No SSL Configuration Available");
@@ -80,11 +92,11 @@ public class AgentWebApp implements Closeable {
configsMap.getOptionInt("agent.threadpool.size.max", 25)));
agentServer.setStopAtShutdown(true);
- SslSelectChannelConnector ssl1WayConnector = createSSLConnector(false);
+ SslSelectChannelConnector ssl1WayConnector = createSSLConnector(false, port);
SslSelectChannelConnector ssl2WayConnector =
createSSLConnector(Boolean.valueOf(
configsMap.getOption(AgentKeys.KEY_AGENT_TWO_WAY_SSL_ENABLED,
- "false")));
+ "false")), securedPort);
agentServer.setConnectors(new Connector[]{ssl1WayConnector,
ssl2WayConnector});
@@ -119,7 +131,7 @@ public class AgentWebApp implements Closeable {
}
- private SslSelectChannelConnector createSSLConnector(boolean needClientAuth) {
+ private SslSelectChannelConnector createSSLConnector(boolean needClientAuth, int port) {
SslSelectChannelConnector sslConnector = new
SslSelectChannelConnector();
@@ -135,6 +147,7 @@ public class AgentWebApp implements Closeable {
sslConnector.setTruststoreType("PKCS12");
sslConnector.setNeedClientAuth(needClientAuth);
+ sslConnector.setPort(port);
sslConnector.setAcceptors(2);
return sslConnector;
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/12a96f78/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
----------------------------------------------------------------------
diff --git a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
index 7237ff4..b5d6a94 100644
--- a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
+++ b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.slider.common.SliderKeys;
+import org.apache.slider.common.tools.PortScanner;
import org.apache.slider.common.tools.SliderUtils;
import org.apache.slider.core.conf.MapOperations;
import org.apache.slider.core.exceptions.SliderException;
@@ -61,6 +62,7 @@ import java.io.File;
import java.net.URI;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public class TestAMAgentWebServices {
@@ -84,6 +86,8 @@ public class TestAMAgentWebServices {
public static final String AGENT_URL =
"https://localhost:${PORT}/ws/v1/slider/agents/";
+ public static final int MIN_PORT = 50000;
+ public static final int MAX_PORT = 50050;
static MockFactory factory = new MockFactory();
private static WebAppApi slider;
@@ -131,9 +135,14 @@ public class TestAMAgentWebServices {
MapOperations compOperations = new MapOperations();
+ PortScanner portScanner = new PortScanner();
+ portScanner.setPortRange(Integer.toString(MIN_PORT) + "-" + Integer.toString(MAX_PORT));
+
webApp = AgentWebApp.$for(AgentWebApp.BASE_PATH, slider,
RestPaths.WS_AGENT_CONTEXT_ROOT)
.withComponentConfig(compOperations)
+ .withPort(portScanner.getAvailablePort())
+ .withSecuredPort(portScanner.getAvailablePort())
.start();
base_url = AGENT_URL.replace("${PORT}",
Integer.toString(webApp.getSecuredPort()));
@@ -184,6 +193,16 @@ public class TestAMAgentWebServices {
assertEquals(200, response.getStatus());
}
+ @Test
+ public void testAllowedPortRange() throws Exception {
+ assertTrue(webApp.getPort() >= MIN_PORT && webApp.getPort() <= MAX_PORT);
+ }
+
+ @Test
+ public void testAllowedSecurePortRange() throws Exception {
+ assertTrue(webApp.getSecuredPort() >= MIN_PORT && webApp.getSecuredPort() <= MAX_PORT);
+ }
+
// @Test
// public void testSleepForAWhile() throws Throwable {
// log.info("Agent is running at {}", base_url);
[2/2] incubator-slider git commit: SLIDER-1105 IDE warning about a
couple of lines in ServiceLauncher
Posted by st...@apache.org.
SLIDER-1105
IDE warning about a couple of lines in ServiceLauncher
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/e5ebd266
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/e5ebd266
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/e5ebd266
Branch: refs/heads/develop
Commit: e5ebd266bc9e12c7354f6d9a8c62f6f8d555d4ca
Parents: 12a96f7
Author: Steve Loughran <st...@apache.org>
Authored: Tue Mar 29 13:20:04 2016 +0100
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Mar 29 13:20:04 2016 +0100
----------------------------------------------------------------------
.../java/org/apache/slider/client/rest/RestClientFactory.java | 2 +-
.../main/java/org/apache/slider/core/main/ServiceLauncher.java | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e5ebd266/slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java b/slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java
index 9c18036..4286596 100644
--- a/slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java
+++ b/slider-core/src/main/java/org/apache/slider/client/rest/RestClientFactory.java
@@ -30,7 +30,7 @@ import java.io.IOException;
import static org.apache.slider.server.appmaster.web.rest.RestPaths.SLIDER_PATH_APPLICATION;
/**
- * Factory for the Rest cilent; hides the lookup and instantiation.
+ * Factory for the Rest client; hides the lookup and instantiation.
* <p>
*
*/
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e5ebd266/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java b/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java
index cf6d21f..f192ec8 100644
--- a/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java
+++ b/slider-core/src/main/java/org/apache/slider/core/main/ServiceLauncher.java
@@ -87,7 +87,7 @@ public class ServiceLauncher<S extends Service>
private volatile S service;
private int serviceExitCode;
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
- private final List<IrqHandler> interruptHandlers = new ArrayList<IrqHandler>(1);
+ private final List<IrqHandler> interruptHandlers = new ArrayList<>(1);
private Configuration configuration;
private String serviceClassName;
private static AtomicBoolean signalAlreadyReceived = new AtomicBoolean(false);
@@ -447,7 +447,7 @@ public class ServiceLauncher<S extends Service>
try {
conf.addResource(file.toURI().toURL());
} catch (MalformedURLException e) {
- LOG.debug("File {} cannot be converted to URL: {}", e);
+ LOG.debug("File {} cannot be converted to URL", file, e);
exitWithMessage(EXIT_COMMAND_ARGUMENT_ERROR,
ARG_CONF + ": configuration file path invalid: " + file);
}
@@ -626,7 +626,7 @@ public class ServiceLauncher<S extends Service>
Thread.setDefaultUncaughtExceptionHandler(
new YarnUncaughtExceptionHandler());
- ServiceLauncher serviceLauncher = new ServiceLauncher<Service>(serviceClassName);
+ ServiceLauncher serviceLauncher = new ServiceLauncher<>(serviceClassName);
serviceLauncher.launchServiceAndExit(argsList);
}
}