Skip to content

Commit

Permalink
[improve][core] print more detail error message
Browse files Browse the repository at this point in the history
  • Loading branch information
wgzhao committed Jan 19, 2025
1 parent 903ac58 commit 1c2ab7d
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions core/src/main/java/com/wgzhao/addax/core/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@
/**
* Engine是 Addax 入口类,该类负责初始化Job或者Task的运行容器,并运行插件的Job或者Task逻辑
*/
public class Engine {
public class Engine
{
private static final Logger LOG = LoggerFactory.getLogger(Engine.class);

/* check job model (job/task) first */
public void start(Configuration allConf) {
public void start(Configuration allConf)
{

// 绑定column转换信息
ColumnCast.bind(allConf);
Expand All @@ -65,7 +67,8 @@ public void start(Configuration allConf) {
}

// 注意屏蔽敏感信息
public static String filterJobConfiguration(final Configuration configuration) {
public static String filterJobConfiguration(final Configuration configuration)
{
Configuration jobConfWithSetting = configuration.getConfiguration("job").clone();

Configuration jobContent = jobConfWithSetting.getConfiguration("content");
Expand All @@ -77,7 +80,8 @@ public static String filterJobConfiguration(final Configuration configuration) {
return jobConfWithSetting.beautify();
}

public static void filterSensitiveConfiguration(Configuration configuration) {
public static void filterSensitiveConfiguration(Configuration configuration)
{
Set<String> keys = configuration.getKeys();
for (String key : keys) {
boolean isSensitive = StringUtils.endsWithIgnoreCase(key, "password")
Expand All @@ -90,7 +94,8 @@ public static void filterSensitiveConfiguration(Configuration configuration) {
}

public static void entry(String[] args)
throws Throwable {
throws Throwable
{
Options options = new Options();
options.addOption("job", true, "Job config.");

Expand All @@ -115,39 +120,39 @@ public static void entry(String[] args)
engine.start(configuration);
}

public static String getVersion() {
public static String getVersion()
{
try {
final Properties properties = new Properties();
properties.load(Engine.class.getClassLoader().getResourceAsStream("project.properties"));
return properties.getProperty("version");
} catch (IOException e) {
}
catch (IOException e) {
return null;
}
}

public static void main(String[] args) {
public static void main(String[] args)
{
LOG.info("\n ___ _ _ \n" +
" / _ \\ | | | | \n" +
"/ /_\\ \\ __| | __| | __ ___ __\n" +
"| _ |/ _` |/ _` |/ _` \\ \\/ /\n" +
"| | | | (_| | (_| | (_| |> < \n" +
"\\_| |_/\\__,_|\\__,_|\\__,_/_/\\_\\\n"+
":: Addax version :: (v{})", Engine.getVersion());
"\\_| |_/\\__,_|\\__,_|\\__,_/_/\\_\\\n" +
":: Addax version :: (v{})", Engine.getVersion());
if (args.length < 2) {
LOG.error("need a job file");
System.exit(1);
}
try {
Engine.entry(args);
} catch (Throwable e) {
if (e instanceof AddaxException) {
LOG.error(e.getMessage());
} else {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
LOG.error(sw.toString());
}
}
catch (Throwable e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
LOG.error(sw.toString());
System.exit(2);
}
System.exit(0);
Expand Down

0 comments on commit 1c2ab7d

Please sign in to comment.