You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/03/06 10:28:34 UTC

[GitHub] [incubator-inlong] LvJiancheng opened a new pull request #2948: [INLONG-2908] fix uuid blank space

LvJiancheng opened a new pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948


   ### Title Name: [INLONG-2908][agent] fix uuid blank space
   
   where *XYZ* should be replaced by the actual issue number.
   
   Fixes #2908
   
   ### Motivation
   
   *Explain here the context, and why you're making that change. What is the problem you're trying to solve.*
   
   ### Modifications
   
   *Describe the modifications you've done.*
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] LvJiancheng commented on a change in pull request #2948: [INLONG-2908][Agent] Remove the space before the UUID

Posted by GitBox <gi...@apache.org>.
LvJiancheng commented on a change in pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948#discussion_r820224423



##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);
+                return uuid;
+            }
+        } catch (Exception e) {
+            LOGGER.error("fetch uuid  error");
+            e.printStackTrace();
+        }
+        return uuid;

Review comment:
       Unless the result is null ,the uuid still return null; but whatever the agent conf has configured uuid ,the  "ExcuteLinux" execute all time ,still optimize




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] LvJiancheng commented on a change in pull request #2948: [INLONG-2908][Agent] Remove the space before the UUID

Posted by GitBox <gi...@apache.org>.
LvJiancheng commented on a change in pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948#discussion_r820221969



##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);

Review comment:
       the result like :      UUID.  :   XXXX-XXX-XXXX
   drop the blank space




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] EMsnap merged pull request #2948: [INLONG-2908][Agent] Remove the space before the UUID

Posted by GitBox <gi...@apache.org>.
EMsnap merged pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] healchow commented on a change in pull request #2948: [INLONG-2908][Agent] Remove the space before the UUID

Posted by GitBox <gi...@apache.org>.
healchow commented on a change in pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948#discussion_r820217189



##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);
+                return uuid;
+            }
+        } catch (Exception e) {
+            LOGGER.error("fetch uuid  error");
+            e.printStackTrace();

Review comment:
       Please print exception stack trace with LOGGER.error, for example:
   `LOGGER.error("fetch uuid error", e);`




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] LvJiancheng commented on a change in pull request #2948: [INLONG-2908][Agent] Remove the space before the UUID

Posted by GitBox <gi...@apache.org>.
LvJiancheng commented on a change in pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948#discussion_r820221761



##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);
+                return uuid;
+            }
+        } catch (Exception e) {
+            LOGGER.error("fetch uuid  error");
+            e.printStackTrace();
+        }
+        return uuid;

Review comment:
       ok 

##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);

Review comment:
       ok




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] LvJiancheng commented on a change in pull request #2948: [INLONG-2908][Agent] Remove the space before the UUID

Posted by GitBox <gi...@apache.org>.
LvJiancheng commented on a change in pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948#discussion_r820221989



##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);
+                return uuid;
+            }
+        } catch (Exception e) {
+            LOGGER.error("fetch uuid  error");
+            e.printStackTrace();
+        }
+        return uuid;

Review comment:
       done




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] healchow commented on a change in pull request #2948: [INLONG-2908][Agent] Remove the space before the UUID

Posted by GitBox <gi...@apache.org>.
healchow commented on a change in pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948#discussion_r820345423



##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,24 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = "";
+        try {
+            String localUuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID);
+            if (!StringUtils.isEmpty(localUuid)) {

Review comment:
       Please use `StringUtils.isNotEmtpy()`.

##########
File path: inlong-agent/conf/agent.properties
##########
@@ -51,6 +51,8 @@ agent.fetcher.classname=org.apache.inlong.agent.plugin.fetcher.ManagerFetcher
 # max wait time(s) for thread pool to terminate running
 thread.pool.await.time=30
 agent.local.ip=127.0.0.1
+agent.local.uuid=
+

Review comment:
       Remove the blank line.

##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,24 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = "";
+        try {
+            String localUuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID);
+            if (!StringUtils.isEmpty(localUuid)) {
+                uuid = localUuid;
+                return uuid;
+            }
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result)
+                    && StringUtils.containsIgnoreCase(result,"UUID")) {
+                    uuid = result.split(":")[1].trim();
+                    return uuid;
+                }

Review comment:
       The indent style is not correct.

##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);
+                return uuid;
+            }
+        } catch (Exception e) {
+            LOGGER.error("fetch uuid  error");
+            e.printStackTrace();

Review comment:
       Please delete `e.printStackTrace();`.




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] EMsnap commented on a change in pull request #2948: [INLONG-2908] fix uuid blank space

Posted by GitBox <gi...@apache.org>.
EMsnap commented on a change in pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948#discussion_r820214664



##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);

Review comment:
       extra blank space ?

##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);
+                return uuid;
+            }
+        } catch (Exception e) {
+            LOGGER.error("fetch uuid  error");
+            e.printStackTrace();
+        }
+        return uuid;

Review comment:
       If agent conf has configured uuid,  your method still return null

##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);
+                return uuid;
+            }
+        } catch (Exception e) {
+            LOGGER.error("fetch uuid  error");
+            e.printStackTrace();
+        }
+        return uuid;

Review comment:
        optional or emty string would be better




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] LvJiancheng commented on a change in pull request #2948: [INLONG-2908][Agent] Remove the space before the UUID

Posted by GitBox <gi...@apache.org>.
LvJiancheng commented on a change in pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948#discussion_r820221999



##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,19 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = null;
+        try {
+            String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
+            if (!StringUtils.isEmpty(result) && StringUtils.containsIgnoreCase(result,"UUID")) {
+                String uuidResult = result.split(":")[1].trim();
+                 uuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, uuidResult);
+                return uuid;
+            }
+        } catch (Exception e) {
+            LOGGER.error("fetch uuid  error");
+            e.printStackTrace();

Review comment:
       done




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] LvJiancheng commented on a change in pull request #2948: [INLONG-2908][Agent] Remove the space before the UUID

Posted by GitBox <gi...@apache.org>.
LvJiancheng commented on a change in pull request #2948:
URL: https://github.com/apache/incubator-inlong/pull/2948#discussion_r820347455



##########
File path: inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/utils/AgentUtils.java
##########
@@ -344,8 +344,24 @@ public static String fetchLocalIp() {
      * check agent uuid from manager
      */
     public static String  fetchLocalUuid() {
-        String result = ExcuteLinux.exeCmd("dmidecode | grep UUID");
-        return AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID, result);
+        String uuid = "";
+        try {
+            String localUuid = AgentConfiguration.getAgentConf().get(AGENT_LOCAL_UUID);
+            if (!StringUtils.isEmpty(localUuid)) {

Review comment:
       done




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

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