You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by et...@apache.org on 2020/04/08 21:09:25 UTC
[storm] branch master updated: [STORM-3604] HealthChecker should
print out error message when it fails (#3231)
This is an automated email from the ASF dual-hosted git repository.
ethanli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/storm.git
The following commit(s) were added to refs/heads/master by this push:
new ef9ab9c [STORM-3604] HealthChecker should print out error message when it fails (#3231)
ef9ab9c is described below
commit ef9ab9cc379af1f45fd2d0994a51ad759bdbeffc
Author: Meng Li (Ethan) <et...@gmail.com>
AuthorDate: Wed Apr 8 16:09:17 2020 -0500
[STORM-3604] HealthChecker should print out error message when it fails (#3231)
---
.../apache/storm/healthcheck/HealthChecker.java | 29 ++++++++++++++++------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/storm-server/src/main/java/org/apache/storm/healthcheck/HealthChecker.java b/storm-server/src/main/java/org/apache/storm/healthcheck/HealthChecker.java
index 8896fd4..e68e07c 100644
--- a/storm-server/src/main/java/org/apache/storm/healthcheck/HealthChecker.java
+++ b/storm-server/src/main/java/org/apache/storm/healthcheck/HealthChecker.java
@@ -22,6 +22,7 @@ import com.codahale.metrics.Meter;
import java.io.BufferedReader;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.channels.ClosedByInterruptException;
@@ -119,14 +120,16 @@ public class HealthChecker {
curThread.interrupted();
if (process.exitValue() != 0) {
- String str;
- InputStream stdin = process.getInputStream();
- BufferedReader reader = new BufferedReader(new InputStreamReader(stdin));
- while ((str = reader.readLine()) != null) {
- if (str.startsWith("ERROR")) {
- LOG.warn("The healthcheck process {} exited with code {}", script, process.exitValue());
- return FAILED;
- }
+ String outMessage = readFromStream(process.getInputStream());
+ String errMessage = readFromStream(process.getErrorStream());
+
+ LOG.warn("The healthcheck process {} exited with code: {}; output: {}; err: {}.",
+ script, process.exitValue(), outMessage, errMessage);
+
+ //Keep this for backwards compatibility.
+ //It relies on "ERROR" at the beginning of stdout to determine FAILED status
+ if (outMessage.startsWith("ERROR")) {
+ return FAILED;
}
return FAILED_WITH_EXIT_CODE;
}
@@ -144,4 +147,14 @@ public class HealthChecker {
}
}
+ private static String readFromStream(InputStream is) throws IOException {
+ StringBuilder stringBuilder = new StringBuilder();
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
+ String str;
+ while ((str = reader.readLine()) != null) {
+ stringBuilder.append(str).append("\n");
+ }
+ }
+ return stringBuilder.toString().trim();
+ }
}