Browse Source

code style

pull/3/MERGE
江蓠 4 years ago
parent
commit
4c7743f3bd
  1. 3
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/OSUtils.java
  2. 12
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ProcessUtils.java
  3. 6
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannelFactory.java
  4. 2
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptSender.java
  5. 1
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptType.java
  6. 2
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/StreamGobbler.java
  7. 9
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/test/script/shell/example.sh

3
dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/OSUtils.java

@ -17,6 +17,9 @@
package org.apache.dolphinscheduler.plugin.alert.script;
/**
* OSUtils
*/
public class OSUtils {
public static Boolean isWindows() {

12
dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ProcessUtils.java

@ -22,12 +22,22 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ProcessUtils
*/
public class ProcessUtils {
private static final Logger logger = LoggerFactory.getLogger(ProcessUtils.class);
/**
* executeScript
*
* @param cmd cmd params
* @return exit code
*/
public static Integer executeScript(String... cmd) {
int exitCode = -1;
@ -49,7 +59,7 @@ public class ProcessUtils {
return process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
logger.error("execute alert script error", e.getMessage());
}
return exitCode;

6
dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannelFactory.java

@ -17,9 +17,6 @@
package org.apache.dolphinscheduler.plugin.alert.script;
import java.util.Arrays;
import java.util.List;
import org.apache.dolphinscheduler.spi.alert.AlertChannel;
import org.apache.dolphinscheduler.spi.alert.AlertChannelFactory;
import org.apache.dolphinscheduler.spi.params.InputParam;
@ -28,6 +25,9 @@ import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate;
import java.util.Arrays;
import java.util.List;
/**
* ScriptAlertChannelFactory
*/

2
dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptSender.java

@ -31,7 +31,6 @@ public class ScriptSender {
private static final Logger logger = LoggerFactory.getLogger(ScriptSender.class);
private String scriptPath;
private Integer scriptType;
@ -44,7 +43,6 @@ public class ScriptSender {
userParams = config.get(ScriptParamsConstants.NAME_SCRIPT_USER_PARAMS);
}
public AlertResult sendScriptAlert(String msg) {
AlertResult alertResult = new AlertResult();
if (ScriptType.of(scriptType).equals(ScriptType.SHELL)) {

1
dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptType.java

@ -53,7 +53,6 @@ public enum ScriptType {
}
}
public static ScriptType of(Integer code) {
if (SCRIPT_TYPE_MAP.containsKey(code)) {
return SCRIPT_TYPE_MAP.get(code);

2
dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/StreamGobbler.java

@ -34,12 +34,10 @@ public class StreamGobbler extends Thread {
InputStream inputStream;
StreamGobbler(InputStream inputStream) {
this.inputStream = inputStream;
}
public void run() {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader inputBufferReader = new BufferedReader(inputStreamReader);

9
dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/test/script/shell/example.sh

@ -15,14 +15,11 @@
# limitations under the License.
#
content=$1
msg=$2
msg=$1
content=$2
# Write your specific logic here
echo $content
echo $msg
# Set the exit code according to your execution result, and alert needs to use it to judge the status of this alarm result
exit 888
exit 0

Loading…
Cancel
Save