You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by ca...@apache.org on 2022/08/11 13:49:06 UTC

[incubator-linkis] branch dev-1.3.0 updated: Add regular interval for Loghelper to push logs (#2709)

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

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


The following commit(s) were added to refs/heads/dev-1.3.0 by this push:
     new e3353b831 Add regular interval for Loghelper to push logs (#2709)
e3353b831 is described below

commit e3353b8312f75be9e693a265620337ead7ff2d7f
Author: Alexyang <xu...@qq.com>
AuthorDate: Thu Aug 11 21:49:02 2022 +0800

    Add regular interval for Loghelper to push logs (#2709)
    
    * #2420
    linkis-accessible-executor - Add regular interval for LogHelper to push logs
    
    * linkis-accessible-executor - refactor LogHelper in interval of sending logs
---
 .../acessible/executor/log/LogHelper.scala           | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/accessible-executor/src/main/scala/org/apache/linkis/engineconn/acessible/executor/log/LogHelper.scala b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/accessible-executor/src/main/scala/org/apache/linkis/engineconn/acessible/executor/log/LogHelper.scala
index a96dadc0a..6fcad02e1 100644
--- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/accessible-executor/src/main/scala/org/apache/linkis/engineconn/acessible/executor/log/LogHelper.scala
+++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/accessible-executor/src/main/scala/org/apache/linkis/engineconn/acessible/executor/log/LogHelper.scala
@@ -29,6 +29,7 @@ import scala.collection.JavaConversions._
 
 object LogHelper extends Logging {
 
+  val SEND_LOG_INTERVAL_MILLS = 10 * 1000
 
   val logCache = new MountLogCache(AccessibleExecutorConfiguration.ENGINECONN_LOG_CACHE_NUM.getValue)
 
@@ -36,6 +37,8 @@ object LogHelper extends Logging {
 
   private val CACHE_SIZE = AccessibleExecutorConfiguration.ENGINECONN_LOG_SEND_SIZE.getValue
 
+  private var lastUpdateTimeMills = System.currentTimeMillis()
+
   def setLogListener(logListener: LogListener): Unit = this.logListener = logListener
 
   def pushAllRemainLogs(): Unit = {
@@ -46,6 +49,7 @@ object LogHelper extends Logging {
       logger.warn("logListener is null, can not push remain logs")
       //return
     } else {
+
       var logs: util.List[String] = null
       logCache.synchronized {
         logs = logCache.getRemain
@@ -77,7 +81,21 @@ object LogHelper extends Logging {
         logger.debug("logCache or logListener is null")
         return
       } else {
-        if (logCache.size > CACHE_SIZE) {
+        val reachRegularInterval = {
+          if (SEND_LOG_INTERVAL_MILLS <= AccessibleExecutorConfiguration.ENGINECONN_LOG_SEND_TIME_INTERVAL.getValue) {
+            logger.warn(s"EngineConn send log interval : ${AccessibleExecutorConfiguration.ENGINECONN_LOG_SEND_TIME_INTERVAL.getValue}ms is longer than regular interval : ${SEND_LOG_INTERVAL_MILLS}ms")
+            false
+          } else {
+            if (System.currentTimeMillis() - lastUpdateTimeMills >= SEND_LOG_INTERVAL_MILLS) {
+              lastUpdateTimeMills = System.currentTimeMillis()
+              true
+            } else {
+              false
+            }
+          }
+        }
+        if (reachRegularInterval || logCache.size > CACHE_SIZE) {
+
           val logs = logCache.getRemain
           val sb = new StringBuilder
 


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