You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/06/07 12:44:51 UTC

[incubator-linkis] 05/09: 1. linkis-module - add default logger in mybatis-config.xml 2. linkis-entrance - fix resource NPE

This is an automated email from the ASF dual-hosted git repository.

peacewong pushed a commit to branch dev-1.1.3
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git

commit b42554fa70cf8d6da8f19b11a3235fe120363af1
Author: alexkun <xu...@qq.com>
AuthorDate: Tue May 31 23:14:20 2022 +0800

    1. linkis-module - add default logger in mybatis-config.xml
    2. linkis-entrance - fix resource NPE
---
 .../src/main/resources/mybatis-config.xml          |  2 +
 .../entrance/restful/EntranceRestfulApi.java       | 66 +++++++++++-----------
 2 files changed, 36 insertions(+), 32 deletions(-)

diff --git a/linkis-commons/linkis-module/src/main/resources/mybatis-config.xml b/linkis-commons/linkis-module/src/main/resources/mybatis-config.xml
index a55c1cf20..71a2f0e37 100644
--- a/linkis-commons/linkis-module/src/main/resources/mybatis-config.xml
+++ b/linkis-commons/linkis-module/src/main/resources/mybatis-config.xml
@@ -49,6 +49,8 @@
 		<!-- 默认为OTHER,为了解决oracle插入null报错的问题要设置为NULL -->
 		<setting name="jdbcTypeForNull" value="NULL" />
 		<setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString" />
+		<!-- 开启日志 -->
+		<setting name="logImpl" value="LOG4J2" />
 	</settings>
 	
 </configuration>
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/restful/EntranceRestfulApi.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/restful/EntranceRestfulApi.java
index 11d8958f3..62f425b16 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/restful/EntranceRestfulApi.java
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/restful/EntranceRestfulApi.java
@@ -300,39 +300,41 @@ public class EntranceRestfulApi implements EntranceRestfulRemote {
                                     resoureList.add(
                                             new YarnResourceWithStatusVo(applicationId, resource));
                                 });
-                    }
-                    metricsVo.put(TaskConstant.ENTRANCEJOB_YARNRESOURCE, resoureList);
-                    Optional<Integer> cores =
-                            resourceMap.values().stream()
-                                    .map(resource -> resource.queueCores())
-                                    .reduce((x, y) -> x + y);
-                    Optional<Long> memory =
-                            resourceMap.values().stream()
-                                    .map(resource -> resource.queueMemory())
-                                    .reduce((x, y) -> x + y);
-                    float corePercent = 0.0f;
-                    float memoryPercent = 0.0f;
-                    if (cores.isPresent()) {
-                        corePercent =
-                                cores.get().floatValue()
-                                        / EntranceConfiguration.YARN_QUEUE_CORES_MAX().getValue();
-                        memoryPercent =
-                                memory.get().floatValue()
-                                        / (EntranceConfiguration.YARN_QUEUE_MEMORY_MAX()
-                                                        .getValue()
-                                                        .longValue()
-                                                * 1024
-                                                * 1024
-                                                * 1024);
-                    }
-                    String coreRGB = RGBUtils.getRGB(corePercent);
-                    String memoryRGB = RGBUtils.getRGB(memoryPercent);
-                    metricsVo.put(TaskConstant.ENTRANCEJOB_CORE_PERCENT, corePercent);
-                    metricsVo.put(TaskConstant.ENTRANCEJOB_MEMORY_PERCENT, memoryPercent);
-                    metricsVo.put(TaskConstant.ENTRANCEJOB_CORE_RGB, coreRGB);
-                    metricsVo.put(TaskConstant.ENTRANCEJOB_MEMORY_RGB, memoryRGB);
+                        metricsVo.put(TaskConstant.ENTRANCEJOB_YARNRESOURCE, resoureList);
+                        Optional<Integer> cores =
+                                resourceMap.values().stream()
+                                        .map(resource -> resource.queueCores())
+                                        .reduce((x, y) -> x + y);
+                        Optional<Long> memory =
+                                resourceMap.values().stream()
+                                        .map(resource -> resource.queueMemory())
+                                        .reduce((x, y) -> x + y);
+                        float corePercent = 0.0f;
+                        float memoryPercent = 0.0f;
+                        if (cores.isPresent()) {
+                            corePercent =
+                                    cores.get().floatValue()
+                                            / EntranceConfiguration.YARN_QUEUE_CORES_MAX().getValue();
+                            memoryPercent =
+                                    memory.get().floatValue()
+                                            / (EntranceConfiguration.YARN_QUEUE_MEMORY_MAX()
+                                            .getValue()
+                                            .longValue()
+                                            * 1024
+                                            * 1024
+                                            * 1024);
+                        }
+                        String coreRGB = RGBUtils.getRGB(corePercent);
+                        String memoryRGB = RGBUtils.getRGB(memoryPercent);
+                        metricsVo.put(TaskConstant.ENTRANCEJOB_CORE_PERCENT, corePercent);
+                        metricsVo.put(TaskConstant.ENTRANCEJOB_MEMORY_PERCENT, memoryPercent);
+                        metricsVo.put(TaskConstant.ENTRANCEJOB_CORE_RGB, coreRGB);
+                        metricsVo.put(TaskConstant.ENTRANCEJOB_MEMORY_RGB, memoryRGB);
 
-                    message.data(TaskConstant.ENTRANCEJOB_YARN_METRICS, metricsVo);
+                        message.data(TaskConstant.ENTRANCEJOB_YARN_METRICS, metricsVo);
+                    } else {
+                        message.data(TaskConstant.ENTRANCEJOB_YARNRESOURCE, null);
+                    }
                 } else {
                     message.data(TaskConstant.ENTRANCEJOB_YARNRESOURCE, null);
                 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org