You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ga...@apache.org on 2019/03/01 06:44:46 UTC
[flink] branch release-1.8 updated (c2bc493 -> f8d0855)
This is an automated email from the ASF dual-hosted git repository.
gary pushed a change to branch release-1.8
in repository https://gitbox.apache.org/repos/asf/flink.git.
from c2bc493 [FLINK-11379][core] Fix OutOfMemoryError caused by Files.readAllBytes() when TM loads a large size TDD
new eb58bf7 [FLINK-10585][tests, ssl] Re-create testing keystore and truststore
new 33e0ca7 [FLINK-10585][tests] Explicitly bind testing RestServerEndpoint on loopback address
new 9b66985 [FLINK-10585][runtime] Use java.net.URL to build restBaseUrl
new f8d0855 [FLINK-10585][tests] Extract method getTestResource in RestServerEndpointITCase
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../flink/runtime/rest/RestServerEndpoint.java | 21 +++++++-------
.../runtime/rest/RestServerEndpointITCase.java | 31 +++++++++++----------
flink-runtime/src/test/resources/local127.keystore | Bin 2130 -> 4311 bytes
.../src/test/resources/local127.truststore | Bin 840 -> 1508 bytes
4 files changed, 28 insertions(+), 24 deletions(-)
[flink] 01/04: [FLINK-10585][tests,
ssl] Re-create testing keystore and truststore
Posted by ga...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gary pushed a commit to branch release-1.8
in repository https://gitbox.apache.org/repos/asf/flink.git
commit eb58bf7113267da35b021a3682ca3966b74ddf84
Author: Gary Yao <ga...@apache.org>
AuthorDate: Tue Feb 26 11:14:44 2019 +0100
[FLINK-10585][tests, ssl] Re-create testing keystore and truststore
Create new key so that IPv6 loopback address is included in subject alternative
names section. Used the commands below to re-create the stores:
keytool -genkeypair -alias flink.test -keystore test.keystore -keyalg RSA \
-keysize 4096 -storetype PKCS12 -ext "SAN=dns:localhost,ip:127.0.0.1,ip:::1" \
-dname "CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown" \
-storepass password
keytool -exportcert -keystore test.keystore -alias flink.test -file test.cer \
-storepass password
keytool -importcert -keystore test.truststore -alias ca -storepass password \
-file test.cer --noprompt
---
flink-runtime/src/test/resources/local127.keystore | Bin 2130 -> 4311 bytes
flink-runtime/src/test/resources/local127.truststore | Bin 840 -> 1508 bytes
2 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/flink-runtime/src/test/resources/local127.keystore b/flink-runtime/src/test/resources/local127.keystore
index 1b3ca36..4992ac4 100644
Binary files a/flink-runtime/src/test/resources/local127.keystore and b/flink-runtime/src/test/resources/local127.keystore differ
diff --git a/flink-runtime/src/test/resources/local127.truststore b/flink-runtime/src/test/resources/local127.truststore
index 4a1da38..df4acf8 100644
Binary files a/flink-runtime/src/test/resources/local127.truststore and b/flink-runtime/src/test/resources/local127.truststore differ
[flink] 03/04: [FLINK-10585][runtime] Use java.net.URL to build
restBaseUrl
Posted by ga...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gary pushed a commit to branch release-1.8
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 9b66985fe0589b7b8239f3c3d48eb8719ec6e8b2
Author: Gary Yao <ga...@apache.org>
AuthorDate: Tue Feb 26 11:48:27 2019 +0100
[FLINK-10585][runtime] Use java.net.URL to build restBaseUrl
In URLs, IPv6 addresses have to be put inside "[" and "]", which is handled by
the URL class.
---
.../flink/runtime/rest/RestServerEndpoint.java | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestServerEndpoint.java b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestServerEndpoint.java
index 28f47ff..195b714 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestServerEndpoint.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestServerEndpoint.java
@@ -57,6 +57,7 @@ import java.io.IOException;
import java.io.Serializable;
import java.net.BindException;
import java.net.InetSocketAddress;
+import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
@@ -161,7 +162,7 @@ public abstract class RestServerEndpoint implements AutoCloseableAsync {
RouterHandler handler = new RouterHandler(router, responseHeaders);
// SSL should be the first handler in the pipeline
- if (sslHandlerFactory != null) {
+ if (isHttpsEnabled()) {
ch.pipeline().addLast("ssl",
new RedirectingSslHandler(restAddress, restAddressFuture, sslHandlerFactory));
}
@@ -231,15 +232,7 @@ public abstract class RestServerEndpoint implements AutoCloseableAsync {
log.info("Rest endpoint listening at {}:{}", advertisedAddress, port);
- final String protocol;
-
- if (sslHandlerFactory != null) {
- protocol = "https://";
- } else {
- protocol = "http://";
- }
-
- restBaseUrl = protocol + advertisedAddress + ':' + port;
+ restBaseUrl = new URL(determineProtocol(), advertisedAddress, port, "").toString();
restAddressFuture.complete(restBaseUrl);
@@ -409,6 +402,14 @@ public abstract class RestServerEndpoint implements AutoCloseableAsync {
}
}
+ private boolean isHttpsEnabled() {
+ return sslHandlerFactory != null;
+ }
+
+ private String determineProtocol() {
+ return isHttpsEnabled() ? "https" : "http";
+ }
+
private static void registerHandler(Router router, Tuple2<RestHandlerSpecification, ChannelInboundHandler> specificationHandler, Logger log) {
final String handlerURL = specificationHandler.f0.getTargetRestEndpointURL();
// setup versioned urls
[flink] 02/04: [FLINK-10585][tests] Explicitly bind testing
RestServerEndpoint on loopback address
Posted by ga...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gary pushed a commit to branch release-1.8
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 33e0ca7d7c052dde404f0cabc4e514a7be284501
Author: Gary Yao <ga...@apache.org>
AuthorDate: Tue Feb 26 11:21:19 2019 +0100
[FLINK-10585][tests] Explicitly bind testing RestServerEndpoint on loopback address
If we do not bind on a loopback address, the wildcard address will be chosen.
The downside of that is it can happen that the server will be only available via
either IPv4 or IPv6 (but not both). This can happen, for example, if another
application chose to bind on the same (random) port but only using the IPv4
stack. In this case, the bind operation in the RestServerEndpoint will only
succeed for IPv6 and silently fail for IPv4.
---
.../apache/flink/runtime/rest/RestServerEndpointITCase.java | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java
index 3fe7168..5e2f853 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java
@@ -81,6 +81,7 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.URL;
import java.nio.charset.StandardCharsets;
@@ -171,9 +172,12 @@ public class RestServerEndpointITCase extends TestLogger {
}
private static Configuration getBaseConfig() {
+ final String loopbackAddress = InetAddress.getLoopbackAddress().getHostAddress();
+
final Configuration config = new Configuration();
config.setString(RestOptions.BIND_PORT, "0");
- config.setString(RestOptions.ADDRESS, "localhost");
+ config.setString(RestOptions.BIND_ADDRESS, loopbackAddress);
+ config.setString(RestOptions.ADDRESS, loopbackAddress);
config.setInteger(RestOptions.SERVER_MAX_CONTENT_LENGTH, TEST_REST_MAX_CONTENT_LENGTH);
config.setInteger(RestOptions.CLIENT_MAX_CONTENT_LENGTH, TEST_REST_MAX_CONTENT_LENGTH);
return config;
@@ -194,14 +198,12 @@ public class RestServerEndpointITCase extends TestLogger {
RestServerEndpointConfiguration serverConfig = RestServerEndpointConfiguration.fromConfiguration(config);
RestClientConfiguration clientConfig = RestClientConfiguration.fromConfiguration(config);
- final String restAddress = "http://localhost:1234";
RestfulGateway mockRestfulGateway = mock(RestfulGateway.class);
final GatewayRetriever<RestfulGateway> mockGatewayRetriever = () ->
CompletableFuture.completedFuture(mockRestfulGateway);
testHandler = new TestHandler(
- CompletableFuture.completedFuture(restAddress),
mockGatewayRetriever,
RpcUtils.INF_TIMEOUT);
@@ -636,10 +638,7 @@ public class RestServerEndpointITCase extends TestLogger {
private Function<Integer, CompletableFuture<TestResponse>> handlerBody;
- TestHandler(
- CompletableFuture<String> localAddressFuture,
- GatewayRetriever<RestfulGateway> leaderRetriever,
- Time timeout) {
+ TestHandler(GatewayRetriever<RestfulGateway> leaderRetriever, Time timeout) {
super(
leaderRetriever,
timeout,
[flink] 04/04: [FLINK-10585][tests] Extract method getTestResource
in RestServerEndpointITCase
Posted by ga...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gary pushed a commit to branch release-1.8
in repository https://gitbox.apache.org/repos/asf/flink.git
commit f8d0855949c24c8c283d1ace6350175d837d9cd2
Author: Gary Yao <ga...@apache.org>
AuthorDate: Tue Feb 26 13:18:44 2019 +0100
[FLINK-10585][tests] Extract method getTestResource in RestServerEndpointITCase
---
.../flink/runtime/rest/RestServerEndpointITCase.java | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java
index 5e2f853..51d1d2e 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointITCase.java
@@ -147,13 +147,8 @@ public class RestServerEndpointITCase extends TestLogger {
public static Collection<Object[]> data() {
final Configuration config = getBaseConfig();
- final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
- final String truststorePath = new File(classLoader
- .getResource("local127.truststore")
- .getFile()).getAbsolutePath();
- final String keystorePath = new File(classLoader
- .getResource("local127.keystore")
- .getFile()).getAbsolutePath();
+ final String truststorePath = getTestResource("local127.truststore").getAbsolutePath();
+ final String keystorePath = getTestResource("local127.keystore").getAbsolutePath();
final Configuration sslConfig = new Configuration(config);
sslConfig.setBoolean(SecurityOptions.SSL_REST_ENABLED, true);
@@ -592,6 +587,15 @@ public class RestServerEndpointITCase extends TestLogger {
}
}
+ private static File getTestResource(final String fileName) {
+ final ClassLoader classLoader = ClassLoader.getSystemClassLoader();
+ final URL resource = classLoader.getResource(fileName);
+ if (resource == null) {
+ throw new IllegalArgumentException(String.format("Test resource %s does not exist", fileName));
+ }
+ return new File(resource.getFile());
+ }
+
private HttpURLConnection openHttpConnectionForUpload(final String boundary) throws IOException {
final HttpURLConnection connection =
(HttpURLConnection) new URL(serverEndpoint.getRestBaseUrl() + "/upload").openConnection();