You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2020/06/20 14:42:27 UTC

[GitHub] [incubator-dolphinscheduler] yangyichao-mango commented on a change in pull request #2965: [Feature-2925][server] Init TaskLogger in TaskExecuteProcessor (#2925)

yangyichao-mango commented on a change in pull request #2965:
URL: https://github.com/apache/incubator-dolphinscheduler/pull/2965#discussion_r443136046



##########
File path: dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java
##########
@@ -138,24 +153,39 @@ public static String getResourceViewSuffixs() {
      * @param userName user name
      * @throws IOException errors
      */
-    public static void createWorkDirAndUserIfAbsent(String execLocalPath, String userName) throws IOException{
+    public static void createWorkDirAndUserIfAbsent(String execLocalPath, String userName) throws IOException {
         //if work dir exists, first delete
         File execLocalPathFile = new File(execLocalPath);
 
-        if (execLocalPathFile.exists()){
+        if (execLocalPathFile.exists()) {
             org.apache.commons.io.FileUtils.forceDelete(execLocalPathFile);
         }
 
         //create work dir
         org.apache.commons.io.FileUtils.forceMkdir(execLocalPathFile);
-        logger.info("create dir success {}" , execLocalPath);
-
+        String mkdirLog = "create dir success " + execLocalPath;
+        LoggerUtils.logInfo(logger, taskLoggerThreadLocal::get, mkdirLog);
 
         //if not exists this user,then create
-        if (!OSUtils.getUserList().contains(userName)){
-            OSUtils.createUser(userName);
+        Logger taskLogger = taskLoggerThreadLocal.get();
+        OSUtils.taskLoggerThreadLocal.set(taskLogger);
+        try {
+            if (!OSUtils.getUserList().contains(userName)) {
+                boolean isSuccessCreateUser = OSUtils.createUser(userName);
+
+                if (isSuccessCreateUser) {
+                    String infoLog = String.format("create user name success %s", userName);
+                    taskLogger.info(infoLog);
+                    logger.info(infoLog);
+                } else {
+                    String infoLog = String.format("create user name fail %s", userName);
+                    taskLogger.error(infoLog);
+                    logger.error(infoLog);
+                }
+            }
+        } catch (Throwable ignored) {
         }

Review comment:
       > why swallow exception?
   
   Thx a lot for your review @dailidong . I've removed the unused exception try catch clause.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org