This is an automated email from the ASF dual-hosted git repository.
chesnay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new 74dc909 [FLINK-10441][rest] Log initial creation of uploadDir on INFO
74dc909 is described below
commit 74dc90953b300b657a66a86fe16a02d12db7f885
Author: tianchen92 <[email protected]>
AuthorDate: Sun Apr 28 04:05:54 2019 +0800
[FLINK-10441][rest] Log initial creation of uploadDir on INFO
---
.../org/apache/flink/runtime/rest/FileUploadHandler.java | 4 ++--
.../org/apache/flink/runtime/rest/RestServerEndpoint.java | 12 ++++++++----
.../apache/flink/runtime/rest/RestServerEndpointTest.java | 4 ++--
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git
a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/FileUploadHandler.java
b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/FileUploadHandler.java
index b99de66..3cd9732 100644
---
a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/FileUploadHandler.java
+++
b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/FileUploadHandler.java
@@ -104,7 +104,7 @@ public class FileUploadHandler extends
SimpleChannelInboundHandler<HttpObject> {
currentHttpRequest =
ReferenceCountUtil.retain(httpRequest);
// make sure that we still have
a upload dir in case that it got deleted in the meanwhile
-
RestServerEndpoint.createUploadDir(uploadDir, LOG);
+
RestServerEndpoint.createUploadDir(uploadDir, LOG, false);
currentUploadDir =
Files.createDirectory(uploadDir.resolve(UUID.randomUUID().toString()));
} else {
@@ -116,7 +116,7 @@ public class FileUploadHandler extends
SimpleChannelInboundHandler<HttpObject> {
} else if (msg instanceof HttpContent &&
currentHttpPostRequestDecoder != null) {
LOG.trace("Received http content.");
// make sure that we still have a upload dir in
case that it got deleted in the meanwhile
- RestServerEndpoint.createUploadDir(uploadDir,
LOG);
+ RestServerEndpoint.createUploadDir(uploadDir,
LOG, false);
final HttpContent httpContent = (HttpContent)
msg;
currentHttpPostRequestDecoder.offer(httpContent);
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 195b714..486fcff 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
@@ -107,7 +107,7 @@ public abstract class RestServerEndpoint implements
AutoCloseableAsync {
this.sslHandlerFactory = configuration.getSslHandlerFactory();
this.uploadDir = configuration.getUploadDir();
- createUploadDir(uploadDir, log);
+ createUploadDir(uploadDir, log, true);
this.maxContentLength = configuration.getMaxContentLength();
this.responseHeaders = configuration.getResponseHeaders();
@@ -448,10 +448,14 @@ public abstract class RestServerEndpoint implements
AutoCloseableAsync {
* Creates the upload dir if needed.
*/
@VisibleForTesting
- static void createUploadDir(final Path uploadDir, final Logger log)
throws IOException {
+ static void createUploadDir(final Path uploadDir, final Logger log,
final boolean initialCreation) throws IOException {
if (!Files.exists(uploadDir)) {
- log.warn("Upload directory {} does not exist, or has
been deleted externally. " +
- "Previously uploaded files are no longer
available.", uploadDir);
+ if (initialCreation) {
+ log.info("Upload directory {} does not exist. "
+ uploadDir);
+ } else {
+ log.warn("Upload directory {} has been deleted
externally. " +
+ "Previously uploaded files are no
longer available.", uploadDir);
+ }
checkAndCreateUploadDir(uploadDir, log);
}
}
diff --git
a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointTest.java
b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointTest.java
index f7fcc62..c51c985 100644
---
a/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointTest.java
+++
b/flink-runtime/src/test/java/org/apache/flink/runtime/rest/RestServerEndpointTest.java
@@ -80,7 +80,7 @@ public class RestServerEndpointTest extends TestLogger {
final File file = temporaryFolder.newFolder();
final Path testUploadDir =
file.toPath().resolve("testUploadDir");
assertFalse(Files.exists(testUploadDir));
- RestServerEndpoint.createUploadDir(testUploadDir,
NOPLogger.NOP_LOGGER);
+ RestServerEndpoint.createUploadDir(testUploadDir,
NOPLogger.NOP_LOGGER, true);
assertTrue(Files.exists(testUploadDir));
}
@@ -92,7 +92,7 @@ public class RestServerEndpointTest extends TestLogger {
final Path testUploadDir =
file.toPath().resolve("testUploadDir");
assertFalse(Files.exists(testUploadDir));
try {
- RestServerEndpoint.createUploadDir(testUploadDir,
NOPLogger.NOP_LOGGER);
+ RestServerEndpoint.createUploadDir(testUploadDir,
NOPLogger.NOP_LOGGER, true);
fail("Expected exception not thrown.");
} catch (IOException e) {
}