ids =
+ jobRequests.stream().map(JobRequest::getId).collect(Collectors.toList());
logger.info("success query failover jobs , job size: {}, ids: {}", ids.size(), ids);
// failover to local server
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
index efd5e76a45..8ef5c268b5 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
@@ -28,6 +28,7 @@ import org.apache.linkis.entrance.errorcode.EntranceErrorCodeSummary
import org.apache.linkis.entrance.errorcode.EntranceErrorCodeSummary._
import org.apache.linkis.entrance.exception.{EntranceErrorException, SubmitFailedException}
import org.apache.linkis.entrance.execute.EntranceJob
+import org.apache.linkis.entrance.job.EntranceExecutionJob
import org.apache.linkis.entrance.log.{Cache, CacheLogWriter, HDFSCacheLogWriter, LogReader}
import org.apache.linkis.entrance.parser.ParserUtils
import org.apache.linkis.entrance.timeout.JobTimeoutManager
@@ -43,16 +44,16 @@ import org.apache.linkis.rpc.conf.RPCConfiguration
import org.apache.linkis.scheduler.queue.{Job, SchedulerEventState}
import org.apache.linkis.server.conf.ServerConfiguration
import org.apache.linkis.storage.utils.StorageUtils
+
import org.apache.commons.lang3.StringUtils
import org.apache.commons.lang3.exception.ExceptionUtils
-import org.apache.linkis.common.log.LogUtils
import org.springframework.beans.BeanUtils
-import org.apache.linkis.entrance.job.EntranceExecutionJob
import java.{lang, util}
import java.text.{MessageFormat, SimpleDateFormat}
import java.util.Date
+
import scala.collection.JavaConverters._
abstract class EntranceServer extends Logging {
@@ -280,8 +281,10 @@ abstract class EntranceServer extends Logging {
consumeQueueTasks.foreach(job => {
taskIds.add(job.getJobRequest.getId.asInstanceOf[Long])
job match {
- case entranceExecutionJob : EntranceExecutionJob =>
- val msg = LogUtils.generateWarn(s"job ${job.getJobRequest.getId} clean from ConsumeQueue, wait for failover")
+ case entranceExecutionJob: EntranceExecutionJob =>
+ val msg = LogUtils.generateWarn(
+ s"job ${job.getJobRequest.getId} clean from ConsumeQueue, wait for failover"
+ )
entranceExecutionJob.getLogListener.foreach(_.onLogUpdate(entranceExecutionJob, msg))
entranceExecutionJob.getLogWriter.foreach(_.close())
case _ =>
@@ -308,7 +311,9 @@ abstract class EntranceServer extends Logging {
}
val logAppender = new java.lang.StringBuilder()
- logAppender.append("*************************************FAILOVER**************************************")
+ logAppender.append(
+ "*************************************FAILOVER**************************************"
+ )
// try to kill ec
killOldEC(jobRequest, logAppender);
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
index 959d8c68bc..13db69700f 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
@@ -233,12 +233,15 @@ object EntranceConfiguration {
val ENTRANCE_FAILOVER_SCAN_INTERVAL =
CommonVars("linkis.entrance.failover.scan.interval", 30 * 1000).getValue
- val ENTRANCE_FAILOVER_DATA_NUM_LIMIT = CommonVars("linkis.entrance.failover.data.num.limit", 10).getValue
+ val ENTRANCE_FAILOVER_DATA_NUM_LIMIT =
+ CommonVars("linkis.entrance.failover.data.num.limit", 10).getValue
- val ENTRANCE_FAILOVER_DATA_INTERVAL_TIME = CommonVars("linkis.entrance.failover.data.interval.time", new TimeType("7d").toLong).getValue
+ val ENTRANCE_FAILOVER_DATA_INTERVAL_TIME =
+ CommonVars("linkis.entrance.failover.data.interval.time", new TimeType("7d").toLong).getValue
// if true, the waitForRetry job in runningJobs can be failover
- val ENTRANCE_FAILOVER_RETRY_JOB_ENABLED = CommonVars("linkis.entrance.failover.retry.job.enable", true)
+ val ENTRANCE_FAILOVER_RETRY_JOB_ENABLED =
+ CommonVars("linkis.entrance.failover.retry.job.enable", true)
val ENTRANCE_UPDATE_BATCH_SIZE = CommonVars("linkis.entrance.update.batch.size", 100)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceFIFOUserConsumer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceFIFOUserConsumer.scala
index 1977fa68ac..faee683fbf 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceFIFOUserConsumer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceFIFOUserConsumer.scala
@@ -27,6 +27,7 @@ import org.apache.linkis.scheduler.queue.fifoqueue.FIFOUserConsumer
import java.util
import java.util.concurrent.ExecutorService
+
import scala.collection.JavaConverters.collectionAsScalaIterableConverter
class EntranceFIFOUserConsumer(
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceGroupFactory.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceGroupFactory.scala
index 4bd0caca1b..0f31351b48 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceGroupFactory.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceGroupFactory.scala
@@ -27,18 +27,12 @@ import org.apache.linkis.governance.common.protocol.conf.{
RequestQueryEngineConfigWithGlobalConfig,
ResponseQueryConfig
}
-import org.apache.linkis.instance.label.client.InstanceLabelClient
-import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactoryContext
-import org.apache.linkis.manager.label.constant.{LabelKeyConstant, LabelValueConstant}
-import org.apache.linkis.governance.common.protocol.conf.{RequestQueryEngineConfigWithGlobalConfig, ResponseQueryConfig}
import org.apache.linkis.manager.label.entity.Label
import org.apache.linkis.manager.label.entity.engine.{
ConcurrentEngineConnLabel,
EngineTypeLabel,
UserCreatorLabel
}
-import org.apache.linkis.manager.label.entity.route.RouteLabel
-import org.apache.linkis.manager.label.entity.engine.{ConcurrentEngineConnLabel, EngineTypeLabel, UserCreatorLabel}
import org.apache.linkis.manager.label.utils.LabelUtil
import org.apache.linkis.protocol.constants.TaskConstant
import org.apache.linkis.protocol.utils.TaskUtils
@@ -51,13 +45,10 @@ import org.apache.commons.lang3.StringUtils
import java.util
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern
+
import scala.collection.JavaConverters._
+
import com.google.common.cache.{Cache, CacheBuilder}
-import org.apache.linkis.common.ServiceInstance
-import org.apache.linkis.instance.label.client.InstanceLabelClient
-import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactoryContext
-import org.apache.linkis.manager.label.constant.{LabelConstant, LabelKeyConstant}
-import org.apache.linkis.manager.label.entity.route.RouteLabel
class EntranceGroupFactory extends GroupFactory with Logging {
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
index f114981c5c..a067d65829 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
@@ -18,7 +18,6 @@
package org.apache.linkis.entrance.scheduler
import org.apache.linkis.common.ServiceInstance
-import org.apache.linkis.common.conf.CommonVars
import org.apache.linkis.common.utils.Utils
import org.apache.linkis.entrance.conf.EntranceConfiguration
import org.apache.linkis.instance.label.client.InstanceLabelClient
@@ -32,10 +31,11 @@ import org.apache.linkis.scheduler.queue.parallelqueue.{ParallelConsumerManager,
import java.util
import java.util.concurrent.TimeUnit
+
import scala.collection.JavaConverters._
class EntranceParallelConsumerManager(maxParallelismUsers: Int, schedulerName: String)
- extends ParallelConsumerManager(maxParallelismUsers, schedulerName){
+ extends ParallelConsumerManager(maxParallelismUsers, schedulerName) {
override protected def createConsumer(groupName: String): FIFOUserConsumer = {
val group = getSchedulerContext.getOrCreateGroupFactory.getGroup(groupName)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/utils/JobHistoryHelper.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/utils/JobHistoryHelper.scala
index df7b846a7d..3fed0f78be 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/utils/JobHistoryHelper.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/utils/JobHistoryHelper.scala
@@ -30,13 +30,15 @@ import org.apache.linkis.protocol.constants.TaskConstant
import org.apache.linkis.protocol.query.cache.{CacheTaskResult, RequestReadCache}
import org.apache.linkis.rpc.Sender
import org.apache.linkis.scheduler.queue.SchedulerEventState
+
import org.apache.commons.lang3.StringUtils
import javax.servlet.http.HttpServletRequest
+
import java.util
import java.util.Date
+
import scala.collection.JavaConverters._
-import sun.net.util.IPAddressUtil
import com.google.common.net.InetAddresses
@@ -316,15 +318,15 @@ object JobHistoryHelper extends Logging {
val ecResourceMap =
if (resourceInfo == null) new util.HashMap[String, ResourceWithStatus] else resourceInfo
if (resourceMap != null) {
- resourceMap.asInstanceOf[util.HashMap[String, ResourceWithStatus]].putAll(ecResourceMap)
+ resourceMap.asInstanceOf[util.Map[String, ResourceWithStatus]].putAll(ecResourceMap)
} else {
metricsMap.put(TaskConstant.ENTRANCEJOB_YARNRESOURCE, ecResourceMap)
}
- var engineInstanceMap: util.HashMap[String, AnyRef] = null
+ var engineInstanceMap: util.Map[String, AnyRef] = null
if (metricsMap.containsKey(TaskConstant.ENTRANCEJOB_ENGINECONN_MAP)) {
engineInstanceMap = metricsMap
.get(TaskConstant.ENTRANCEJOB_ENGINECONN_MAP)
- .asInstanceOf[util.HashMap[String, AnyRef]]
+ .asInstanceOf[util.Map[String, AnyRef]]
} else {
engineInstanceMap = new util.HashMap[String, AnyRef]()
metricsMap.put(TaskConstant.ENTRANCEJOB_ENGINECONN_MAP, engineInstanceMap)
@@ -334,7 +336,7 @@ object JobHistoryHelper extends Logging {
val ticketId = infoMap.get(TaskConstant.TICKET_ID).asInstanceOf[String]
val engineExtraInfoMap = engineInstanceMap
.getOrDefault(ticketId, new util.HashMap[String, AnyRef])
- .asInstanceOf[util.HashMap[String, AnyRef]]
+ .asInstanceOf[util.Map[String, AnyRef]]
engineExtraInfoMap.putAll(infoMap)
engineInstanceMap.put(ticketId, engineExtraInfoMap)
} else {
diff --git a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/constant/LabelConstant.java b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/constant/LabelConstant.java
index b43501ed9e..4db4bfca40 100644
--- a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/constant/LabelConstant.java
+++ b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/constant/LabelConstant.java
@@ -22,6 +22,4 @@ public class LabelConstant {
public static final int LABEL_BUILDER_ERROR_CODE = 40001;
public static final int LABEL_UTIL_CONVERT_ERROR_CODE = 40002;
-
- public static final String OFFLINE = "offline";
}
diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java
index 6568fb838b..88267e4800 100644
--- a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java
+++ b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java
@@ -110,25 +110,13 @@ Integer countUndoneTaskWithCreatorOnly(
/**
* query wait for failover job
*
- * Sql example:
- * SELECT a.* FROM linkis_ps_job_history_group_history a
- * where (a.instances = ''
- * or a.instances is null
- * or a.instances not in ('192.168.1.123:9104','192.168.1.124:9104')
- * or EXISTS (
- * select 1 from
- * (
- * select '192.168.1.123:9104' as instances, 1697775054098 as registryTime
- * union all
- * select '192.168.1.124:9104' as instances, 1666239054098 as registryTime
- * ) b
- * where a.instances = b.instances and UNIX_TIMESTAMP(a.created_time) * 1000 < b.registryTime
- * )
- * )
- * and
- * status in ('Inited','Running','Scheduled','WaitForRetry')
- * and UNIX_TIMESTAMP(a.created_time) * 1000 >= 1666239054098
- * limit 10
+ * Sql example: SELECT a.* FROM linkis_ps_job_history_group_history a where (a.instances = ''
+ * or a.instances is null or a.instances not in ('192.168.1.123:9104','192.168.1.124:9104') or
+ * EXISTS ( select 1 from ( select '192.168.1.123:9104' as instances, 1697775054098 as
+ * registryTime union all select '192.168.1.124:9104' as instances, 1666239054098 as registryTime
+ * ) b where a.instances = b.instances and UNIX_TIMESTAMP(a.created_time) * 1000 < b.registryTime
+ * ) ) and status in ('Inited','Running','Scheduled','WaitForRetry') and
+ * UNIX_TIMESTAMP(a.created_time) * 1000 >= 1666239054098 limit 10
*
* @param instancesMap
* @param statusList
@@ -136,8 +124,9 @@ Integer countUndoneTaskWithCreatorOnly(
* @param limit
* @return
*/
- List selectFailoverJobHistory(@Param("instancesMap") Map instancesMap,
- @Param("statusList") List statusList,
- @Param("startTimestamp") Long startTimestamp,
- @Param("limit") Integer limit);
+ List selectFailoverJobHistory(
+ @Param("instancesMap") Map instancesMap,
+ @Param("statusList") List statusList,
+ @Param("startTimestamp") Long startTimestamp,
+ @Param("limit") Integer limit);
}
diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/impl/JobHistoryQueryServiceImpl.scala b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/impl/JobHistoryQueryServiceImpl.scala
index 22084f88a6..a44cd0e262 100644
--- a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/impl/JobHistoryQueryServiceImpl.scala
+++ b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/impl/JobHistoryQueryServiceImpl.scala
@@ -252,7 +252,8 @@ class JobHistoryQueryServiceImpl extends JobHistoryQueryService with Logging {
logger.info(s"query failover jobs, start timestamp:${startTimestamp}, limit:${limit}")
val jobResp = new JobRespProtocol
Utils.tryCatch {
- val jobList = jobHistoryMapper.selectFailoverJobHistory(reqMap, statusList, startTimestamp, limit)
+ val jobList =
+ jobHistoryMapper.selectFailoverJobHistory(reqMap, statusList, startTimestamp, limit)
val jobReqList = jobList.asScala.map(jobHistory2JobRequest).toList
val map = new util.HashMap[String, Object]()
map.put(JobRequestConstants.JOB_HISTORY_LIST, jobReqList)
@@ -266,14 +267,6 @@ class JobHistoryQueryServiceImpl extends JobHistoryQueryService with Logging {
jobResp
}
- /* private def queryTaskList2RequestPersistTaskList(queryTask: java.util.List[QueryTask]): java.util.List[RequestPersistTask] = {
- import scala.collection.JavaConversions._
- val tasks = new util.ArrayList[RequestPersistTask]
- import org.apache.linkis.jobhistory.conversions.TaskConversions.queryTask2RequestPersistTask
- queryTask.foreach(f => tasks.add(f))
- tasks
- } */
-
override def getJobHistoryByIdAndName(jobId: java.lang.Long, userName: String): JobHistory = {
val jobReq = new JobHistory
jobReq.setId(jobId)
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceRequestGatewayParser.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceRequestGatewayParser.scala
index 883f252d70..930bfac73a 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceRequestGatewayParser.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceRequestGatewayParser.scala
@@ -17,10 +17,8 @@
package org.apache.linkis.gateway.ujes.parser
-import org.apache.commons.lang3.StringUtils
import org.apache.linkis.common.ServiceInstance
import org.apache.linkis.common.entity.JobInstance
-import org.apache.linkis.common.utils.JsonUtils
import org.apache.linkis.gateway.config.GatewayConfiguration
import org.apache.linkis.gateway.http.GatewayContext
import org.apache.linkis.gateway.parser.AbstractGatewayParser
@@ -30,6 +28,9 @@ import org.apache.linkis.protocol.utils.ZuulEntranceUtils
import org.apache.linkis.rpc.interceptor.ServiceInstanceUtils
import org.apache.linkis.server.BDPJettyServerHelper
import org.apache.linkis.server.conf.ServerConfiguration
+
+import org.apache.commons.lang3.StringUtils
+
import org.springframework.stereotype.Component
import javax.annotation.Resource
@@ -37,7 +38,6 @@ import javax.annotation.Resource
@Component
class EntranceRequestGatewayParser extends AbstractGatewayParser {
-
@Resource
private var jobHistoryQueryService: JobHistoryQueryService = _
@@ -49,9 +49,9 @@ class EntranceRequestGatewayParser extends AbstractGatewayParser {
if (sendResponseWhenNotMatchVersion(gatewayContext, version)) return
val serviceInstance = if (execId.startsWith(EntranceRequestGatewayParser.API_REQUEST)) {
if (
- gatewayContext.getRequest.getQueryParams.containsKey(
- EntranceRequestGatewayParser.INSTANCE
- )
+ gatewayContext.getRequest.getQueryParams.containsKey(
+ EntranceRequestGatewayParser.INSTANCE
+ )
) {
val instances =
gatewayContext.getRequest.getQueryParams.get(EntranceRequestGatewayParser.INSTANCE)
@@ -83,7 +83,8 @@ class EntranceRequestGatewayParser extends AbstractGatewayParser {
}
def buildJobInstance(taskId: Long, gatewayContext: GatewayContext): JobInstance = {
- val histories = jobHistoryQueryService.search(taskId, null, null, null, null, null, null, null)
+ val histories =
+ jobHistoryQueryService.search(taskId, null, null, null, null, null, null, null, null)
if (histories.isEmpty) {
sendErrorResponse(s"taskId $taskId is not exists.", gatewayContext)
return null
From 9e27aec833d3d20e43ff2f6c6c3d1d107860364d Mon Sep 17 00:00:00 2001
From: guoshupei <719126Liyuelynn>
Date: Tue, 28 Feb 2023 14:44:05 +0800
Subject: [PATCH 032/270] set default value
---
.../server/DefaultEntranceServer.java | 13 +-
.../server/EntranceFailoverJobServer.java | 178 +++++++++---------
.../entrance/conf/EntranceConfiguration.scala | 8 +-
3 files changed, 95 insertions(+), 104 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
index 54b855ffbd..b077ab37bb 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
@@ -17,6 +17,7 @@
package org.apache.linkis.entrance.server;
+import org.apache.commons.io.IOUtils;
import org.apache.linkis.entrance.EntranceContext;
import org.apache.linkis.entrance.EntranceServer;
import org.apache.linkis.entrance.conf.EntranceConfiguration;
@@ -25,9 +26,8 @@
import org.apache.linkis.entrance.job.EntranceExecutionJob;
import org.apache.linkis.entrance.log.LogReader;
import org.apache.linkis.rpc.Sender;
-
-import org.apache.commons.io.IOUtils;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.EventListener;
@@ -35,9 +35,6 @@
import javax.annotation.PostConstruct;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/** Description: */
@Component(ServiceNameConsts.ENTRANCE_SERVER)
public class DefaultEntranceServer extends EntranceServer {
@@ -91,9 +88,9 @@ private void shutdownEntrance(ContextClosedEvent event) {
logger.warn("Entrance exit to stop all job");
EntranceJob[] allUndoneTask = getAllUndoneTask(null);
if (null != allUndoneTask) {
- String msg = "Entrance exits the automatic cleanup task and can be rerun(服务退出自动清理任务,可以重跑)";
for (EntranceJob job : allUndoneTask) {
- job.onFailure(msg, null);
+ job.onFailure(
+ "Entrance exits the automatic cleanup task and can be rerun(服务退出自动清理任务,可以重跑)", null);
IOUtils.closeQuietly(((EntranceExecutionJob) job).getLogWriter().get());
}
}
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
index 77e85cba69..73c91f6a36 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
@@ -29,12 +29,12 @@
import org.apache.linkis.publicservice.common.lock.service.CommonLockService;
import org.apache.linkis.rpc.Sender;
import org.apache.linkis.scheduler.queue.SchedulerEventState;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
-
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -43,9 +43,6 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
@Component(ServiceNameConsts.ENTRANCE_FAILOVER_SERVER)
public class EntranceFailoverJobServer {
@@ -61,96 +58,93 @@ public class EntranceFailoverJobServer {
@PostConstruct
public void init() {
- this.scheduledExecutor =
- Executors.newSingleThreadScheduledExecutor(
- Utils.threadFactory("Linkis-Failover-Scheduler-Thread-", true));
- failoverTask();
+ if (EntranceConfiguration.ENTRANCE_FAILOVER_ENABLED()) {
+ this.scheduledExecutor =
+ Executors.newSingleThreadScheduledExecutor(
+ Utils.threadFactory("Linkis-Failover-Scheduler-Thread-", true));
+ failoverTask();
+ }
}
public void failoverTask() {
- if (EntranceConfiguration.ENTRANCE_FAILOVER_ENABLED()) {
- scheduledExecutor.scheduleWithFixedDelay(
- () -> {
- EntranceSchedulerContext schedulerContext =
- (EntranceSchedulerContext)
- entranceServer
- .getEntranceContext()
- .getOrCreateScheduler()
- .getSchedulerContext();
-
- // entrance do not failover job when it is offline
- if (schedulerContext.getOfflineFlag()) return;
-
- CommonLock commonLock = new CommonLock();
- commonLock.setLockObject(ENTRANCE_FAILOVER_LOCK);
- Boolean locked = false;
- try {
- locked = commonLockService.lock(commonLock, 10 * 1000L);
- if (!locked) return;
- logger.info("success locked {}", ENTRANCE_FAILOVER_LOCK);
-
- // get all entrance server from eureka
- ServiceInstance[] serviceInstances =
- Sender.getInstances(Sender.getThisServiceInstance().getApplicationName());
- if (serviceInstances == null || serviceInstances.length <= 0) return;
-
- // serverInstance to map
- Map serverInstanceMap =
- Arrays.stream(serviceInstances)
- .collect(
- Collectors.toMap(
- ServiceInstance::getInstance,
- ServiceInstance::getRegistryTimestamp,
- (k1, k2) -> k2));
-
- // It is very important to avoid repeated execute job
- // when failover self job, if self instance is empty, the job can be repeated execute
- if (!serverInstanceMap.containsKey(Sender.getThisInstance())) {
- logger.warn(
- "server has just started and has not get self info, it does not failover");
- return;
- }
-
- // get failover job expired time (获取任务故障转移过期时间,配置为0表示不过期, 过期则不处理)
- long expiredTimestamp = 0L;
- if (EntranceConfiguration.ENTRANCE_FAILOVER_DATA_INTERVAL_TIME() > 0) {
- expiredTimestamp =
- System.currentTimeMillis()
- - EntranceConfiguration.ENTRANCE_FAILOVER_DATA_INTERVAL_TIME();
- }
-
- // get uncompleted status
- List statusList =
- Arrays.stream(SchedulerEventState.uncompleteStatusArray())
- .map(Object::toString)
- .collect(Collectors.toList());
-
- List jobRequests =
- JobHistoryHelper.queryWaitForFailoverTask(
- serverInstanceMap,
- statusList,
- expiredTimestamp,
- EntranceConfiguration.ENTRANCE_FAILOVER_DATA_NUM_LIMIT());
- if (jobRequests.isEmpty()) return;
- List ids =
- jobRequests.stream().map(JobRequest::getId).collect(Collectors.toList());
- logger.info("success query failover jobs , job size: {}, ids: {}", ids.size(), ids);
-
- // failover to local server
- for (JobRequest jobRequest : jobRequests) {
- entranceServer.failoverExecute(jobRequest);
- }
- logger.info("finished execute failover jobs, job ids: {}", ids);
-
- } catch (Exception e) {
- logger.error("failover failed", e);
- } finally {
- if (locked) commonLockService.unlock(commonLock);
+ scheduledExecutor.scheduleWithFixedDelay(
+ () -> {
+ EntranceSchedulerContext schedulerContext =
+ (EntranceSchedulerContext)
+ entranceServer.getEntranceContext().getOrCreateScheduler().getSchedulerContext();
+
+ // entrance do not failover job when it is offline
+ if (schedulerContext.getOfflineFlag()) return;
+
+ CommonLock commonLock = new CommonLock();
+ commonLock.setLockObject(ENTRANCE_FAILOVER_LOCK);
+ Boolean locked = false;
+ try {
+ locked = commonLockService.lock(commonLock, 30 * 1000L);
+ if (!locked) return;
+ logger.info("success locked {}", ENTRANCE_FAILOVER_LOCK);
+
+ // get all entrance server from eureka
+ ServiceInstance[] serviceInstances =
+ Sender.getInstances(Sender.getThisServiceInstance().getApplicationName());
+ if (serviceInstances == null || serviceInstances.length <= 0) return;
+
+ // serverInstance to map
+ Map serverInstanceMap =
+ Arrays.stream(serviceInstances)
+ .collect(
+ Collectors.toMap(
+ ServiceInstance::getInstance,
+ ServiceInstance::getRegistryTimestamp,
+ (k1, k2) -> k2));
+
+ // It is very important to avoid repeated execute job
+ // when failover self job, if self instance is empty, the job can be repeated execute
+ if (!serverInstanceMap.containsKey(Sender.getThisInstance())) {
+ logger.warn(
+ "server has just started and has not get self info, it does not failover");
+ return;
}
- },
- EntranceConfiguration.ENTRANCE_FAILOVER_SCAN_INIT_TIME(),
- EntranceConfiguration.ENTRANCE_FAILOVER_SCAN_INTERVAL(),
- TimeUnit.MILLISECONDS);
- }
+
+ // get failover job expired time (获取任务故障转移过期时间,配置为0表示不过期, 过期则不处理)
+ long expiredTimestamp = 0L;
+ if (EntranceConfiguration.ENTRANCE_FAILOVER_DATA_INTERVAL_TIME() > 0) {
+ expiredTimestamp =
+ System.currentTimeMillis()
+ - EntranceConfiguration.ENTRANCE_FAILOVER_DATA_INTERVAL_TIME();
+ }
+
+ // get uncompleted status
+ List statusList =
+ Arrays.stream(SchedulerEventState.uncompleteStatusArray())
+ .map(Object::toString)
+ .collect(Collectors.toList());
+
+ List jobRequests =
+ JobHistoryHelper.queryWaitForFailoverTask(
+ serverInstanceMap,
+ statusList,
+ expiredTimestamp,
+ EntranceConfiguration.ENTRANCE_FAILOVER_DATA_NUM_LIMIT());
+ if (jobRequests.isEmpty()) return;
+ List ids =
+ jobRequests.stream().map(JobRequest::getId).collect(Collectors.toList());
+ logger.info("success query failover jobs , job size: {}, ids: {}", ids.size(), ids);
+
+ // failover to local server
+ for (JobRequest jobRequest : jobRequests) {
+ entranceServer.failoverExecute(jobRequest);
+ }
+ logger.info("finished execute failover jobs, job ids: {}", ids);
+
+ } catch (Exception e) {
+ logger.error("failover failed", e);
+ } finally {
+ if (locked) commonLockService.unlock(commonLock);
+ }
+ },
+ EntranceConfiguration.ENTRANCE_FAILOVER_SCAN_INIT_TIME(),
+ EntranceConfiguration.ENTRANCE_FAILOVER_SCAN_INTERVAL(),
+ TimeUnit.MILLISECONDS);
}
}
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
index 13db69700f..d8248620b7 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
@@ -241,7 +241,7 @@ object EntranceConfiguration {
// if true, the waitForRetry job in runningJobs can be failover
val ENTRANCE_FAILOVER_RETRY_JOB_ENABLED =
- CommonVars("linkis.entrance.failover.retry.job.enable", true)
+ CommonVars("linkis.entrance.failover.retry.job.enable", false)
val ENTRANCE_UPDATE_BATCH_SIZE = CommonVars("linkis.entrance.update.batch.size", 100)
@@ -255,12 +255,12 @@ object EntranceConfiguration {
val ENTRANCE_GROUP_SCAN_INTERVAL = CommonVars("linkis.entrance.group.scan.interval", 60 * 1000)
val ENTRANCE_FAILOVER_RETAIN_ENGINE_CONN_ENABLED =
- CommonVars("linkis.entrance.failover.retain.engine.conn.enable", true)
+ CommonVars("linkis.entrance.failover.retain.engine.conn.enable", false)
val ENTRANCE_FAILOVER_RETAIN_YARN_RESOURCE_ENABLED =
- CommonVars("linkis.entrance.failover.retain.yarn.resource.enable", true)
+ CommonVars("linkis.entrance.failover.retain.yarn.resource.enable", false)
val ENTRANCE_FAILOVER_RUNNING_KILL_ENABLED =
- CommonVars("linkis.entrance.failover.running.kill.enable", true)
+ CommonVars("linkis.entrance.failover.running.kill.enable", false)
}
From 3dda863d37aa94326b77c52a33251bf934e588d3 Mon Sep 17 00:00:00 2001
From: guoshupei <719126Liyuelynn>
Date: Tue, 28 Feb 2023 15:27:17 +0800
Subject: [PATCH 033/270] add config to properties
---
.../linkis/entrance/server/DefaultEntranceServer.java | 9 ++++++---
.../entrance/server/EntranceFailoverJobServer.java | 7 +++++--
.../org/apache/linkis/entrance/EntranceServer.scala | 2 +-
linkis-dist/package/conf/linkis-cg-entrance.properties | 7 ++++++-
linkis-dist/package/conf/linkis-mg-gateway.properties | 4 ++--
5 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
index b077ab37bb..14bea60435 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
@@ -17,7 +17,6 @@
package org.apache.linkis.entrance.server;
-import org.apache.commons.io.IOUtils;
import org.apache.linkis.entrance.EntranceContext;
import org.apache.linkis.entrance.EntranceServer;
import org.apache.linkis.entrance.conf.EntranceConfiguration;
@@ -26,8 +25,9 @@
import org.apache.linkis.entrance.job.EntranceExecutionJob;
import org.apache.linkis.entrance.log.LogReader;
import org.apache.linkis.rpc.Sender;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import org.apache.commons.io.IOUtils;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.EventListener;
@@ -35,6 +35,9 @@
import javax.annotation.PostConstruct;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/** Description: */
@Component(ServiceNameConsts.ENTRANCE_SERVER)
public class DefaultEntranceServer extends EntranceServer {
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
index 73c91f6a36..d7f5ce5951 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
@@ -29,12 +29,12 @@
import org.apache.linkis.publicservice.common.lock.service.CommonLockService;
import org.apache.linkis.rpc.Sender;
import org.apache.linkis.scheduler.queue.SchedulerEventState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
+
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -43,6 +43,9 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
@Component(ServiceNameConsts.ENTRANCE_FAILOVER_SERVER)
public class EntranceFailoverJobServer {
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
index 8ef5c268b5..8e9bbeeac0 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
@@ -390,7 +390,7 @@ abstract class EntranceServer extends Logging {
engineStopRequest.setServiceInstance(ecInstance)
// send to linkismanager kill ec
Sender
- .getSender(RPCConfiguration.LINKIS_MANAGER_APPLICATION_NAME.getValue)
+ .getSender(RPCConfiguration.LINKIS_MANAGER_SERVICE_NAME.getValue)
.send(engineStopRequest)
val msg =
s"job ${jobRequest.getId} send EngineStopRequest to linkismanager, kill EC instance $ecInstance"
diff --git a/linkis-dist/package/conf/linkis-cg-entrance.properties b/linkis-dist/package/conf/linkis-cg-entrance.properties
index e89ced2159..639256d5cf 100644
--- a/linkis-dist/package/conf/linkis-cg-entrance.properties
+++ b/linkis-dist/package/conf/linkis-cg-entrance.properties
@@ -33,4 +33,9 @@ spring.server.port=9104
wds.linkis.entrance.user.creator.ip.interceptor.switch=false
## you may set service version if you want to distinguish different configuration version
-spring.eureka.instance.metadata-map.linkis.conf.version=v1
\ No newline at end of file
+spring.eureka.instance.metadata-map.linkis.conf.version=v1
+
+
+wds.linkis.server.mybatis.mapperLocations=classpath*:mapper/common/*.xml,classpath*:mapper/mysql/*.xml
+wds.linkis.server.mybatis.BasePackage=org.apache.linkis.publicservice.common.lock.dao
+wds.linkis.server.mybatis.typeAliasesPackage=org.apache.linkis.publicservice.common.lock.entity
\ No newline at end of file
diff --git a/linkis-dist/package/conf/linkis-mg-gateway.properties b/linkis-dist/package/conf/linkis-mg-gateway.properties
index 84be3d897d..27656f7f31 100644
--- a/linkis-dist/package/conf/linkis-mg-gateway.properties
+++ b/linkis-dist/package/conf/linkis-mg-gateway.properties
@@ -21,8 +21,8 @@ wds.linkis.gateway.conf.url.pass.auth=/dss/
wds.linkis.gateway.conf.enable.token.auth=true
wds.linkis.is.gateway=true
wds.linkis.server.mybatis.mapperLocations=classpath*:mapper/common/*.xml,classpath*:mapper/mysql/*.xml
-wds.linkis.server.mybatis.typeAliasesPackage=org.apache.linkis.instance.label.entity
-wds.linkis.server.mybatis.BasePackage=org.apache.linkis.instance.label.dao,org.apache.linkis.gateway.authentication.dao
+wds.linkis.server.mybatis.typeAliasesPackage=org.apache.linkis.instance.label.entity,org.apache.linkis.jobhistory.entity
+wds.linkis.server.mybatis.BasePackage=org.apache.linkis.instance.label.dao,org.apache.linkis.gateway.authentication.dao,org.apache.linkis.jobhistory.dao
wds.linkis.label.entity.packages=org.apache.linkis.gateway.ujes.route.label
wds.linkis.login_encrypt.enable=false
##LDAP
From ff2871919e7903877e175f14979d797e20706dd6 Mon Sep 17 00:00:00 2001
From: guoshupei <719126Liyuelynn>
Date: Tue, 28 Feb 2023 21:09:58 +0800
Subject: [PATCH 034/270] change HashMap to Map
---
.../main/scala/org/apache/linkis/entrance/EntranceServer.scala | 2 +-
.../linkis/entrance/interceptor/impl/CustomVariableUtils.scala | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
index 8e9bbeeac0..55be20fd4d 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
@@ -312,7 +312,7 @@ abstract class EntranceServer extends Logging {
val logAppender = new java.lang.StringBuilder()
logAppender.append(
- "*************************************FAILOVER**************************************"
+ "*************************************FAILOVER**************************************\n"
)
// try to kill ec
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CustomVariableUtils.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CustomVariableUtils.scala
index 7a7cb7463a..a40c3fa35d 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CustomVariableUtils.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CustomVariableUtils.scala
@@ -63,7 +63,7 @@ object CustomVariableUtils extends Logging {
}
val variableMap = TaskUtils
.getVariableMap(jobRequest.getParams)
- .asInstanceOf[util.HashMap[String, String]]
+ .asInstanceOf[util.Map[String, String]]
variables.putAll(variableMap)
if (!variables.containsKey("user")) {
variables.put("user", jobRequest.getExecuteUser)
From 39d45d3b40d27427a2aa28d334f2bc88189b55e5 Mon Sep 17 00:00:00 2001
From: guoshupei <719126Liyuelynn>
Date: Wed, 1 Mar 2023 11:03:56 +0800
Subject: [PATCH 035/270] update default value
---
.../main/scala/org/apache/linkis/entrance/EntranceServer.scala | 2 +-
.../org/apache/linkis/entrance/conf/EntranceConfiguration.scala | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
index 55be20fd4d..5560cc716d 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
@@ -312,7 +312,7 @@ abstract class EntranceServer extends Logging {
val logAppender = new java.lang.StringBuilder()
logAppender.append(
- "*************************************FAILOVER**************************************\n"
+ "*************************************FAILOVER************************************** \n"
)
// try to kill ec
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
index d8248620b7..17f2dffd9c 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
@@ -237,7 +237,7 @@ object EntranceConfiguration {
CommonVars("linkis.entrance.failover.data.num.limit", 10).getValue
val ENTRANCE_FAILOVER_DATA_INTERVAL_TIME =
- CommonVars("linkis.entrance.failover.data.interval.time", new TimeType("7d").toLong).getValue
+ CommonVars("linkis.entrance.failover.data.interval.time", new TimeType("1d").toLong).getValue
// if true, the waitForRetry job in runningJobs can be failover
val ENTRANCE_FAILOVER_RETRY_JOB_ENABLED =
From fdc54d45cb2b9f6f88a1eeef9e06ba3424a24fa5 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Thu, 2 Mar 2023 12:08:08 +0800
Subject: [PATCH 036/270] Optimal refresh consumer group maxAllowRunningJobs
logic
---
.../entrance/scheduler/EntranceParallelConsumerManager.scala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
index a067d65829..a6e24388a6 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
@@ -75,7 +75,7 @@ class EntranceParallelConsumerManager(maxParallelismUsers: Int, schedulerName: S
}
def refreshAllGroupMaxAllowRunningJobs(validInsCount: Int): Unit = {
- if (validInsCount <= 0) return
+ if (validInsCount <= 1) return
listConsumers()
.foreach(item => {
item.getGroup match {
From 0b0ef7917eeccc2707754b88eb74421c1d3e3913 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Sun, 5 Mar 2023 18:44:38 +0800
Subject: [PATCH 037/270] rename config key
---
.../org/apache/linkis/server/conf/ServerConfiguration.scala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/ServerConfiguration.scala b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/ServerConfiguration.scala
index 8d9f9d65ad..3c6a25a343 100644
--- a/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/ServerConfiguration.scala
+++ b/linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/conf/ServerConfiguration.scala
@@ -208,6 +208,6 @@ object ServerConfiguration extends Logging {
CommonVars("wds.linkis.session.proxy.user.ticket.key", "linkis_user_session_proxy_ticket_id_v1")
val LINKIS_SERVER_ENTRANCE_HEADER_KEY =
- CommonVars("wds.linkis.server.entrance.header.key", "jobInstanceKey")
+ CommonVars("linkis.server.entrance.header.key", "jobInstanceKey")
}
From 75eddde7591a59c2b721a92afd8b5dc88b1143e3 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Mon, 6 Mar 2023 11:46:01 +0800
Subject: [PATCH 038/270] rename metric config key
---
.../scala/org/apache/linkis/entrance/EntranceServer.scala | 4 ++--
.../linkis/entrance/conf/EntranceConfiguration.scala | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
index 5560cc716d..e9c3da2cda 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
@@ -625,7 +625,7 @@ abstract class EntranceServer extends Logging {
)
val metricMap = new util.HashMap[String, Object]()
- if (EntranceConfiguration.ENTRANCE_FAILOVER_RETAIN_ENGINE_CONN_ENABLED.getValue) {
+ if (EntranceConfiguration.ENTRANCE_FAILOVER_RETAIN_METRIC_ENGINE_CONN_ENABLED.getValue) {
if (
jobRequest.getMetrics != null && jobRequest.getMetrics.containsKey(
TaskConstant.ENTRANCEJOB_ENGINECONN_MAP
@@ -638,7 +638,7 @@ abstract class EntranceServer extends Logging {
}
}
- if (EntranceConfiguration.ENTRANCE_FAILOVER_RETAIN_YARN_RESOURCE_ENABLED.getValue) {
+ if (EntranceConfiguration.ENTRANCE_FAILOVER_RETAIN_METRIC_YARN_RESOURCE_ENABLED.getValue) {
if (
jobRequest.getMetrics != null && jobRequest.getMetrics.containsKey(
TaskConstant.ENTRANCEJOB_YARNRESOURCE
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
index 17f2dffd9c..617584f278 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
@@ -254,11 +254,11 @@ object EntranceConfiguration {
val ENTRANCE_GROUP_SCAN_INTERVAL = CommonVars("linkis.entrance.group.scan.interval", 60 * 1000)
- val ENTRANCE_FAILOVER_RETAIN_ENGINE_CONN_ENABLED =
- CommonVars("linkis.entrance.failover.retain.engine.conn.enable", false)
+ val ENTRANCE_FAILOVER_RETAIN_METRIC_ENGINE_CONN_ENABLED =
+ CommonVars("linkis.entrance.failover.retain.metric.engine.conn.enable", false)
- val ENTRANCE_FAILOVER_RETAIN_YARN_RESOURCE_ENABLED =
- CommonVars("linkis.entrance.failover.retain.yarn.resource.enable", false)
+ val ENTRANCE_FAILOVER_RETAIN_METRIC_YARN_RESOURCE_ENABLED =
+ CommonVars("linkis.entrance.failover.retain.metric.yarn.resource.enable", false)
val ENTRANCE_FAILOVER_RUNNING_KILL_ENABLED =
CommonVars("linkis.entrance.failover.running.kill.enable", false)
From 6fee59f67d637dad555fc96715164e327c1eee08 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Wed, 8 Mar 2023 11:02:34 +0800
Subject: [PATCH 039/270] - failover server close - use logger template
---
.../server/EntranceFailoverJobServer.java | 182 ++++++++++--------
.../EntranceParallelConsumerManager.scala | 10 +-
2 files changed, 108 insertions(+), 84 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
index d7f5ce5951..d162be0820 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
@@ -31,6 +31,8 @@
import org.apache.linkis.scheduler.queue.SchedulerEventState;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@@ -38,9 +40,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
import java.util.stream.Collectors;
import org.slf4j.Logger;
@@ -59,6 +59,8 @@ public class EntranceFailoverJobServer {
private ScheduledExecutorService scheduledExecutor;
+ private Future future;
+
@PostConstruct
public void init() {
if (EntranceConfiguration.ENTRANCE_FAILOVER_ENABLED()) {
@@ -69,85 +71,101 @@ public void init() {
}
}
+ @EventListener
+ private void shutdownFailover(ContextClosedEvent event) {
+ if (future != null && !future.isDone()) {
+ future.cancel(true);
+ }
+ if (scheduledExecutor != null) {
+ scheduledExecutor.shutdown();
+ logger.info("Entrance Failover Server exit!");
+ }
+ }
+
public void failoverTask() {
- scheduledExecutor.scheduleWithFixedDelay(
- () -> {
- EntranceSchedulerContext schedulerContext =
- (EntranceSchedulerContext)
- entranceServer.getEntranceContext().getOrCreateScheduler().getSchedulerContext();
-
- // entrance do not failover job when it is offline
- if (schedulerContext.getOfflineFlag()) return;
-
- CommonLock commonLock = new CommonLock();
- commonLock.setLockObject(ENTRANCE_FAILOVER_LOCK);
- Boolean locked = false;
- try {
- locked = commonLockService.lock(commonLock, 30 * 1000L);
- if (!locked) return;
- logger.info("success locked {}", ENTRANCE_FAILOVER_LOCK);
-
- // get all entrance server from eureka
- ServiceInstance[] serviceInstances =
- Sender.getInstances(Sender.getThisServiceInstance().getApplicationName());
- if (serviceInstances == null || serviceInstances.length <= 0) return;
-
- // serverInstance to map
- Map serverInstanceMap =
- Arrays.stream(serviceInstances)
- .collect(
- Collectors.toMap(
- ServiceInstance::getInstance,
- ServiceInstance::getRegistryTimestamp,
- (k1, k2) -> k2));
-
- // It is very important to avoid repeated execute job
- // when failover self job, if self instance is empty, the job can be repeated execute
- if (!serverInstanceMap.containsKey(Sender.getThisInstance())) {
- logger.warn(
- "server has just started and has not get self info, it does not failover");
- return;
- }
-
- // get failover job expired time (获取任务故障转移过期时间,配置为0表示不过期, 过期则不处理)
- long expiredTimestamp = 0L;
- if (EntranceConfiguration.ENTRANCE_FAILOVER_DATA_INTERVAL_TIME() > 0) {
- expiredTimestamp =
- System.currentTimeMillis()
- - EntranceConfiguration.ENTRANCE_FAILOVER_DATA_INTERVAL_TIME();
- }
-
- // get uncompleted status
- List statusList =
- Arrays.stream(SchedulerEventState.uncompleteStatusArray())
- .map(Object::toString)
- .collect(Collectors.toList());
-
- List jobRequests =
- JobHistoryHelper.queryWaitForFailoverTask(
- serverInstanceMap,
- statusList,
- expiredTimestamp,
- EntranceConfiguration.ENTRANCE_FAILOVER_DATA_NUM_LIMIT());
- if (jobRequests.isEmpty()) return;
- List ids =
- jobRequests.stream().map(JobRequest::getId).collect(Collectors.toList());
- logger.info("success query failover jobs , job size: {}, ids: {}", ids.size(), ids);
-
- // failover to local server
- for (JobRequest jobRequest : jobRequests) {
- entranceServer.failoverExecute(jobRequest);
- }
- logger.info("finished execute failover jobs, job ids: {}", ids);
-
- } catch (Exception e) {
- logger.error("failover failed", e);
- } finally {
- if (locked) commonLockService.unlock(commonLock);
- }
- },
- EntranceConfiguration.ENTRANCE_FAILOVER_SCAN_INIT_TIME(),
- EntranceConfiguration.ENTRANCE_FAILOVER_SCAN_INTERVAL(),
- TimeUnit.MILLISECONDS);
+ future =
+ scheduledExecutor.scheduleWithFixedDelay(
+ () -> {
+ EntranceSchedulerContext schedulerContext =
+ (EntranceSchedulerContext)
+ entranceServer
+ .getEntranceContext()
+ .getOrCreateScheduler()
+ .getSchedulerContext();
+
+ // entrance do not failover job when it is offline
+ if (schedulerContext.getOfflineFlag()) return;
+
+ CommonLock commonLock = new CommonLock();
+ commonLock.setLockObject(ENTRANCE_FAILOVER_LOCK);
+ Boolean locked = false;
+ try {
+ locked = commonLockService.lock(commonLock, 30 * 1000L);
+ if (!locked) return;
+ logger.info("success locked {}", ENTRANCE_FAILOVER_LOCK);
+
+ // get all entrance server from eureka
+ ServiceInstance[] serviceInstances =
+ Sender.getInstances(Sender.getThisServiceInstance().getApplicationName());
+ if (serviceInstances == null || serviceInstances.length <= 0) return;
+
+ // serverInstance to map
+ Map serverInstanceMap =
+ Arrays.stream(serviceInstances)
+ .collect(
+ Collectors.toMap(
+ ServiceInstance::getInstance,
+ ServiceInstance::getRegistryTimestamp,
+ (k1, k2) -> k2));
+
+ // It is very important to avoid repeated execute job
+ // when failover self job, if self instance is empty, the job can be repeated
+ // execute
+ if (!serverInstanceMap.containsKey(Sender.getThisInstance())) {
+ logger.warn(
+ "server has just started and has not get self info, it does not failover");
+ return;
+ }
+
+ // get failover job expired time (获取任务故障转移过期时间,配置为0表示不过期, 过期则不处理)
+ long expiredTimestamp = 0L;
+ if (EntranceConfiguration.ENTRANCE_FAILOVER_DATA_INTERVAL_TIME() > 0) {
+ expiredTimestamp =
+ System.currentTimeMillis()
+ - EntranceConfiguration.ENTRANCE_FAILOVER_DATA_INTERVAL_TIME();
+ }
+
+ // get uncompleted status
+ List statusList =
+ Arrays.stream(SchedulerEventState.uncompleteStatusArray())
+ .map(Object::toString)
+ .collect(Collectors.toList());
+
+ List jobRequests =
+ JobHistoryHelper.queryWaitForFailoverTask(
+ serverInstanceMap,
+ statusList,
+ expiredTimestamp,
+ EntranceConfiguration.ENTRANCE_FAILOVER_DATA_NUM_LIMIT());
+ if (jobRequests.isEmpty()) return;
+ List ids =
+ jobRequests.stream().map(JobRequest::getId).collect(Collectors.toList());
+ logger.info("success query failover jobs , job size: {}, ids: {}", ids.size(), ids);
+
+ // failover to local server
+ for (JobRequest jobRequest : jobRequests) {
+ entranceServer.failoverExecute(jobRequest);
+ }
+ logger.info("finished execute failover jobs, job ids: {}", ids);
+
+ } catch (Exception e) {
+ logger.error("failover failed", e);
+ } finally {
+ if (locked) commonLockService.unlock(commonLock);
+ }
+ },
+ EntranceConfiguration.ENTRANCE_FAILOVER_SCAN_INIT_TIME(),
+ EntranceConfiguration.ENTRANCE_FAILOVER_SCAN_INTERVAL(),
+ TimeUnit.MILLISECONDS);
}
}
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
index a6e24388a6..060fcbdd65 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
@@ -30,10 +30,12 @@ import org.apache.linkis.scheduler.queue.fifoqueue.FIFOUserConsumer
import org.apache.linkis.scheduler.queue.parallelqueue.{ParallelConsumerManager, ParallelGroup}
import java.util
-import java.util.concurrent.TimeUnit
+import java.util.concurrent.{ScheduledFuture, TimeUnit}
import scala.collection.JavaConverters._
+import com.sun.javafx.util.Logging
+
class EntranceParallelConsumerManager(maxParallelismUsers: Int, schedulerName: String)
extends ParallelConsumerManager(maxParallelismUsers, schedulerName) {
@@ -84,7 +86,11 @@ class EntranceParallelConsumerManager(maxParallelismUsers: Int, schedulerName: S
group.setMaxAllowRunningJobs(maxAllowRunningJobs)
logger
.info(
- s"group ${group.getGroupName} refresh maxAllowRunningJobs => ${group.getMaxRunningJobs}/$validInsCount=$maxAllowRunningJobs"
+ "group {} refresh maxAllowRunningJobs => {}/{}={}",
+ group.getGroupName,
+ group.getMaxRunningJobs,
+ validInsCount,
+ maxAllowRunningJobs
)
case _ =>
}
From 37567a86bbdac42952727497737fb6fc5f596843 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Wed, 8 Mar 2023 11:41:03 +0800
Subject: [PATCH 040/270] Remove useless references
---
.../entrance/scheduler/EntranceParallelConsumerManager.scala | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
index 060fcbdd65..d30f53a8f5 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
@@ -30,12 +30,10 @@ import org.apache.linkis.scheduler.queue.fifoqueue.FIFOUserConsumer
import org.apache.linkis.scheduler.queue.parallelqueue.{ParallelConsumerManager, ParallelGroup}
import java.util
-import java.util.concurrent.{ScheduledFuture, TimeUnit}
+import java.util.concurrent.TimeUnit
import scala.collection.JavaConverters._
-import com.sun.javafx.util.Logging
-
class EntranceParallelConsumerManager(maxParallelismUsers: Int, schedulerName: String)
extends ParallelConsumerManager(maxParallelismUsers, schedulerName) {
From 71d3e089dcd455027bc36026711e26a4abeb8f40 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Wed, 8 Mar 2023 12:36:25 +0800
Subject: [PATCH 041/270] cast string when use logger template
---
.../scheduler/EntranceParallelConsumerManager.scala | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
index d30f53a8f5..726d93c500 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
@@ -86,9 +86,9 @@ class EntranceParallelConsumerManager(maxParallelismUsers: Int, schedulerName: S
.info(
"group {} refresh maxAllowRunningJobs => {}/{}={}",
group.getGroupName,
- group.getMaxRunningJobs,
- validInsCount,
- maxAllowRunningJobs
+ group.getMaxRunningJobs.toString,
+ validInsCount.toString,
+ maxAllowRunningJobs.toString
)
case _ =>
}
From 8ae8a3de4b3d2741459adcd63d309ff4e54dfbc5 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Wed, 8 Mar 2023 15:29:07 +0800
Subject: [PATCH 042/270] use logger template
---
.../scheduler/EntranceParallelConsumerManager.scala | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
index 726d93c500..afaf6b16e7 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
@@ -85,10 +85,12 @@ class EntranceParallelConsumerManager(maxParallelismUsers: Int, schedulerName: S
logger
.info(
"group {} refresh maxAllowRunningJobs => {}/{}={}",
- group.getGroupName,
- group.getMaxRunningJobs.toString,
- validInsCount.toString,
- maxAllowRunningJobs.toString
+ Array(
+ group.getGroupName,
+ group.getMaxRunningJobs,
+ validInsCount,
+ maxAllowRunningJobs
+ )
)
case _ =>
}
From cb048534aa2a7180365b3c1f15b3cacc053c461e Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Wed, 8 Mar 2023 16:47:07 +0800
Subject: [PATCH 043/270] use logger template
---
.../entrance/scheduler/EntranceParallelConsumerManager.scala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
index afaf6b16e7..5e74d48939 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
@@ -90,7 +90,7 @@ class EntranceParallelConsumerManager(maxParallelismUsers: Int, schedulerName: S
group.getMaxRunningJobs,
validInsCount,
maxAllowRunningJobs
- )
+ ): _*
)
case _ =>
}
From 800074e400c834735fb04299f4422d35803cc3bf Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Wed, 8 Mar 2023 18:01:33 +0800
Subject: [PATCH 044/270] use logger template
---
.../scheduler/EntranceParallelConsumerManager.scala | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
index 5e74d48939..6d756ad1a8 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
@@ -87,9 +87,9 @@ class EntranceParallelConsumerManager(maxParallelismUsers: Int, schedulerName: S
"group {} refresh maxAllowRunningJobs => {}/{}={}",
Array(
group.getGroupName,
- group.getMaxRunningJobs,
- validInsCount,
- maxAllowRunningJobs
+ group.getMaxRunningJobs.toString,
+ validInsCount.toString,
+ maxAllowRunningJobs.toString
): _*
)
case _ =>
From 2d4f7848754f5a439f1d870350863d3f19883bce Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Tue, 28 Mar 2023 15:26:07 +0800
Subject: [PATCH 045/270] Update the maximum concurrency of orchestrator from
200 to 1000
---
.../linkis/orchestrator/conf/OrchestratorConfiguration.scala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linkis-orchestrator/linkis-orchestrator-core/src/main/scala/org/apache/linkis/orchestrator/conf/OrchestratorConfiguration.scala b/linkis-orchestrator/linkis-orchestrator-core/src/main/scala/org/apache/linkis/orchestrator/conf/OrchestratorConfiguration.scala
index 50dbef632c..10f3a64d13 100644
--- a/linkis-orchestrator/linkis-orchestrator-core/src/main/scala/org/apache/linkis/orchestrator/conf/OrchestratorConfiguration.scala
+++ b/linkis-orchestrator/linkis-orchestrator-core/src/main/scala/org/apache/linkis/orchestrator/conf/OrchestratorConfiguration.scala
@@ -48,7 +48,7 @@ object OrchestratorConfiguration {
CommonVars("wds.linkis.orchestrator.execution.task.max.parallelism", 5)
val TASK_RUNNER_MAX_SIZE =
- CommonVars("wds.linkis.orchestrator.execution.task.runner.max.size", 200)
+ CommonVars("wds.linkis.orchestrator.execution.task.runner.max.size", 1000)
val EXEC_RUNNER_FACTORY_CLASS =
CommonVars("wds.linkis.orchestrator.exec.task.runner.factory.class", "")
From 8dafb2cdc421bba440fae45abad83c733dc3cf2b Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Tue, 28 Mar 2023 17:21:19 +0800
Subject: [PATCH 046/270] - moved JobInstance from linkis-common to
linkis-protocol - add isInitedStr,isRunningStr method and remove
uncompleteStatusArray method in SchedulerEventState
---
.../linkis/protocol/engine}/JobInstance.scala | 2 +-
.../scheduler/queue/SchedulerEventState.scala | 6 ++---
.../common/entity/job/JobRequest.java | 1 +
.../entrance/restful/EntranceRestfulApi.java | 2 +-
.../server/EntranceFailoverJobServer.java | 23 +++++++++++++------
.../linkis/entrance/EntranceServer.scala | 4 ++--
.../parser/EntranceRequestGatewayParser.scala | 2 +-
7 files changed, 25 insertions(+), 15 deletions(-)
rename linkis-commons/{linkis-common/src/main/scala/org/apache/linkis/common/entity => linkis-protocol/src/main/scala/org/apache/linkis/protocol/engine}/JobInstance.scala (95%)
diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/entity/JobInstance.scala b/linkis-commons/linkis-protocol/src/main/scala/org/apache/linkis/protocol/engine/JobInstance.scala
similarity index 95%
rename from linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/entity/JobInstance.scala
rename to linkis-commons/linkis-protocol/src/main/scala/org/apache/linkis/protocol/engine/JobInstance.scala
index aa9db730ee..5e2eb10a59 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/entity/JobInstance.scala
+++ b/linkis-commons/linkis-protocol/src/main/scala/org/apache/linkis/protocol/engine/JobInstance.scala
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.linkis.common.entity
+package org.apache.linkis.protocol.engine
case class JobInstance(
status: String,
diff --git a/linkis-commons/linkis-scheduler/src/main/scala/org/apache/linkis/scheduler/queue/SchedulerEventState.scala b/linkis-commons/linkis-scheduler/src/main/scala/org/apache/linkis/scheduler/queue/SchedulerEventState.scala
index a64103628c..26087d99f0 100644
--- a/linkis-commons/linkis-scheduler/src/main/scala/org/apache/linkis/scheduler/queue/SchedulerEventState.scala
+++ b/linkis-commons/linkis-scheduler/src/main/scala/org/apache/linkis/scheduler/queue/SchedulerEventState.scala
@@ -38,8 +38,8 @@ object SchedulerEventState extends Enumeration {
SchedulerEventState.withName(jobState)
)
- def uncompleteStatusArray(): Array[SchedulerEventState] = {
- SchedulerEventState.values.filterNot(isCompleted).toArray
- }
+ def isInitedByStr(jobState: String): Boolean = SchedulerEventState.withName(jobState) == Inited
+
+ def isRunningByStr(jobState: String): Boolean = isRunning(SchedulerEventState.withName(jobState))
}
diff --git a/linkis-computation-governance/linkis-computation-governance-common/src/main/java/org/apache/linkis/governance/common/entity/job/JobRequest.java b/linkis-computation-governance/linkis-computation-governance-common/src/main/java/org/apache/linkis/governance/common/entity/job/JobRequest.java
index 75134bd84a..46fa8a69ef 100644
--- a/linkis-computation-governance/linkis-computation-governance-common/src/main/java/org/apache/linkis/governance/common/entity/job/JobRequest.java
+++ b/linkis-computation-governance/linkis-computation-governance-common/src/main/java/org/apache/linkis/governance/common/entity/job/JobRequest.java
@@ -49,6 +49,7 @@ public class JobRequest {
/** result location */
private String resultLocation;
+ /** Task status updates is ordered, if false, not checked */
private Boolean updateOrderFlag = true;
private String observeInfo;
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 71b0df4250..6dcfcdc4b7 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
@@ -17,7 +17,6 @@
package org.apache.linkis.entrance.restful;
-import org.apache.linkis.common.entity.JobInstance;
import org.apache.linkis.common.log.LogUtils;
import org.apache.linkis.entrance.EntranceServer;
import org.apache.linkis.entrance.conf.EntranceConfiguration;
@@ -29,6 +28,7 @@
import org.apache.linkis.governance.common.entity.job.JobRequest;
import org.apache.linkis.manager.common.protocol.resource.ResourceWithStatus;
import org.apache.linkis.protocol.constants.TaskConstant;
+import org.apache.linkis.protocol.engine.JobInstance;
import org.apache.linkis.protocol.engine.JobProgressInfo;
import org.apache.linkis.protocol.utils.ZuulEntranceUtils;
import org.apache.linkis.rpc.Sender;
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
index d162be0820..4e66da5cc3 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/EntranceFailoverJobServer.java
@@ -37,12 +37,16 @@
import javax.annotation.PostConstruct;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;
import java.util.stream.Collectors;
+import scala.Enumeration;
+import scala.collection.Iterator;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -135,16 +139,10 @@ public void failoverTask() {
- EntranceConfiguration.ENTRANCE_FAILOVER_DATA_INTERVAL_TIME();
}
- // get uncompleted status
- List statusList =
- Arrays.stream(SchedulerEventState.uncompleteStatusArray())
- .map(Object::toString)
- .collect(Collectors.toList());
-
List jobRequests =
JobHistoryHelper.queryWaitForFailoverTask(
serverInstanceMap,
- statusList,
+ getUnCompleteStatus(),
expiredTimestamp,
EntranceConfiguration.ENTRANCE_FAILOVER_DATA_NUM_LIMIT());
if (jobRequests.isEmpty()) return;
@@ -168,4 +166,15 @@ public void failoverTask() {
EntranceConfiguration.ENTRANCE_FAILOVER_SCAN_INTERVAL(),
TimeUnit.MILLISECONDS);
}
+
+ private List getUnCompleteStatus() {
+ List status = new ArrayList<>();
+ Enumeration.ValueSet values = SchedulerEventState.values();
+ Iterator iterator = values.iterator();
+ while (iterator.hasNext()) {
+ Enumeration.Value next = iterator.next();
+ if (!SchedulerEventState.isCompleted(next)) status.add(next.toString());
+ }
+ return status;
+ }
}
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
index e9c3da2cda..45be36287b 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
@@ -319,13 +319,13 @@ abstract class EntranceServer extends Logging {
killOldEC(jobRequest, logAppender);
// deal Inited jobRequest, if status is Inited, need to deal by all Interceptors, such as set log_path
- if (jobRequest.getStatus.equals(SchedulerEventState.Inited.toString)) {
+ if (SchedulerEventState.isInitedByStr(jobRequest.getStatus)) {
dealInitedJobRequest(jobRequest, logAppender)
}
if (
EntranceConfiguration.ENTRANCE_FAILOVER_RUNNING_KILL_ENABLED.getValue &&
- jobRequest.getStatus.equals(SchedulerEventState.Running.toString)
+ SchedulerEventState.isRunningByStr(jobRequest.getStatus)
) {
// deal Running jobRequest, if enabled, status changed from Running to Cancelled
dealRunningJobRequest(jobRequest, logAppender)
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceRequestGatewayParser.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceRequestGatewayParser.scala
index 930bfac73a..04f206d6f6 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceRequestGatewayParser.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceRequestGatewayParser.scala
@@ -18,12 +18,12 @@
package org.apache.linkis.gateway.ujes.parser
import org.apache.linkis.common.ServiceInstance
-import org.apache.linkis.common.entity.JobInstance
import org.apache.linkis.gateway.config.GatewayConfiguration
import org.apache.linkis.gateway.http.GatewayContext
import org.apache.linkis.gateway.parser.AbstractGatewayParser
import org.apache.linkis.gateway.ujes.parser.EntranceExecutionGatewayParser._
import org.apache.linkis.jobhistory.service.JobHistoryQueryService
+import org.apache.linkis.protocol.engine.JobInstance
import org.apache.linkis.protocol.utils.ZuulEntranceUtils
import org.apache.linkis.rpc.interceptor.ServiceInstanceUtils
import org.apache.linkis.server.BDPJettyServerHelper
From e624b373359f9c35bdd27ad5a77ff49962f01e24 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Tue, 28 Mar 2023 17:57:46 +0800
Subject: [PATCH 047/270] Add description
---
.../org/apache/linkis/entrance/conf/EntranceConfiguration.scala | 2 ++
1 file changed, 2 insertions(+)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
index 617584f278..839b3123cc 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/conf/EntranceConfiguration.scala
@@ -245,6 +245,7 @@ object EntranceConfiguration {
val ENTRANCE_UPDATE_BATCH_SIZE = CommonVars("linkis.entrance.update.batch.size", 100)
+ // if true, the job in ConsumeQueue can be failover
val ENTRANCE_SHUTDOWN_FAILOVER_CONSUME_QUEUE_ENABLED =
CommonVars("linkis.entrance.shutdown.failover.consume.queue.enable", true).getValue
@@ -260,6 +261,7 @@ object EntranceConfiguration {
val ENTRANCE_FAILOVER_RETAIN_METRIC_YARN_RESOURCE_ENABLED =
CommonVars("linkis.entrance.failover.retain.metric.yarn.resource.enable", false)
+ // if true, job whose status is running will be set to Cancelled
val ENTRANCE_FAILOVER_RUNNING_KILL_ENABLED =
CommonVars("linkis.entrance.failover.running.kill.enable", false)
From 94f3ec15a1995ee00614058ef7fb867d4035c654 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Fri, 7 Apr 2023 21:49:37 +0800
Subject: [PATCH 048/270] replace constant
---
.../entrance/restful/EntranceRestfulApi.java | 23 +++++++++----------
.../server/DefaultEntranceServer.java | 2 +-
.../linkis/entrance/EntranceServer.scala | 18 +++++++--------
3 files changed, 21 insertions(+), 22 deletions(-)
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 3335eec90f..90a1bdbd2b 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
@@ -439,7 +439,7 @@ public Message progressWithResource(HttpServletRequest req, @PathVariable("id")
message = Message.ok();
message.setMethod("/api/entrance/" + id + "/progressWithResource");
message
- .data(TaskConstant.ENTRANCEJOB_YARNRESOURCE, null)
+ .data(TaskConstant.JOB_YARNRESOURCE, null)
.data("progress", 0)
.data("execID", "")
.data("taskID", id)
@@ -499,18 +499,17 @@ private void buildYarnResource(
JobRequest jobRequest, Map metricsVo, Message message) {
try {
Map metrics = jobRequest.getMetrics();
- if (metrics.containsKey(TaskConstant.ENTRANCEJOB_YARNRESOURCE)) {
+ if (metrics.containsKey(TaskConstant.JOB_YARNRESOURCE)) {
HashMap resourceMap =
- (HashMap)
- metrics.get(TaskConstant.ENTRANCEJOB_YARNRESOURCE);
+ (HashMap) metrics.get(TaskConstant.JOB_YARNRESOURCE);
ArrayList resoureList = new ArrayList<>(12);
if (null != resourceMap && !resourceMap.isEmpty()) {
resourceMap.forEach(
(applicationId, resource) -> {
resoureList.add(new YarnResourceWithStatusVo(applicationId, resource));
});
- metricsVo.put(TaskConstant.ENTRANCEJOB_YARNRESOURCE, resoureList);
+ metricsVo.put(TaskConstant.JOB_YARNRESOURCE, resoureList);
Optional cores =
resourceMap.values().stream()
.map(resource -> resource.queueCores())
@@ -533,17 +532,17 @@ private void buildYarnResource(
}
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.JOB_CORE_PERCENT, corePercent);
+ metricsVo.put(TaskConstant.JOB_MEMORY_PERCENT, memoryPercent);
+ metricsVo.put(TaskConstant.JOB_CORE_RGB, coreRGB);
+ metricsVo.put(TaskConstant.JOB_MEMORY_RGB, memoryRGB);
- message.data(TaskConstant.ENTRANCEJOB_YARN_METRICS, metricsVo);
+ message.data(TaskConstant.JOB_YARN_METRICS, metricsVo);
} else {
- message.data(TaskConstant.ENTRANCEJOB_YARNRESOURCE, null);
+ message.data(TaskConstant.JOB_YARNRESOURCE, null);
}
} else {
- message.data(TaskConstant.ENTRANCEJOB_YARNRESOURCE, null);
+ message.data(TaskConstant.JOB_YARNRESOURCE, null);
}
} catch (Exception e) {
logger.error("build yarnResource error", e);
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
index 24d077068f..66a241026c 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
@@ -20,8 +20,8 @@
import org.apache.linkis.common.ServiceInstance;
import org.apache.linkis.entrance.EntranceContext;
import org.apache.linkis.entrance.EntranceServer;
-import org.apache.linkis.entrance.conf.EntranceConfiguration$;
import org.apache.linkis.entrance.conf.EntranceConfiguration;
+import org.apache.linkis.entrance.conf.EntranceConfiguration$;
import org.apache.linkis.entrance.constant.ServiceNameConsts;
import org.apache.linkis.entrance.execute.EntranceJob;
import org.apache.linkis.entrance.job.EntranceExecutionJob;
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
index 45be36287b..c44eb07922 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
@@ -353,7 +353,7 @@ abstract class EntranceServer extends Logging {
if (
jobRequest.getMetrics == null
- || !jobRequest.getMetrics.containsKey(TaskConstant.ENTRANCEJOB_ENGINECONN_MAP)
+ || !jobRequest.getMetrics.containsKey(TaskConstant.JOB_ENGINECONN_MAP)
) {
val msg = s"job ${jobRequest.getId} not have EC info, ignore it"
logger.info(msg)
@@ -362,7 +362,7 @@ abstract class EntranceServer extends Logging {
}
val engineMap = jobRequest.getMetrics
- .get(TaskConstant.ENTRANCEJOB_ENGINECONN_MAP)
+ .get(TaskConstant.JOB_ENGINECONN_MAP)
.asInstanceOf[util.Map[String, Object]]
val engineInstance =
@@ -628,26 +628,26 @@ abstract class EntranceServer extends Logging {
if (EntranceConfiguration.ENTRANCE_FAILOVER_RETAIN_METRIC_ENGINE_CONN_ENABLED.getValue) {
if (
jobRequest.getMetrics != null && jobRequest.getMetrics.containsKey(
- TaskConstant.ENTRANCEJOB_ENGINECONN_MAP
+ TaskConstant.JOB_ENGINECONN_MAP
)
) {
val oldEngineconnMap = jobRequest.getMetrics
- .get(TaskConstant.ENTRANCEJOB_ENGINECONN_MAP)
+ .get(TaskConstant.JOB_ENGINECONN_MAP)
.asInstanceOf[util.Map[String, Object]]
- metricMap.put(TaskConstant.ENTRANCEJOB_ENGINECONN_MAP, oldEngineconnMap)
+ metricMap.put(TaskConstant.JOB_ENGINECONN_MAP, oldEngineconnMap)
}
}
if (EntranceConfiguration.ENTRANCE_FAILOVER_RETAIN_METRIC_YARN_RESOURCE_ENABLED.getValue) {
if (
jobRequest.getMetrics != null && jobRequest.getMetrics.containsKey(
- TaskConstant.ENTRANCEJOB_YARNRESOURCE
+ TaskConstant.JOB_YARNRESOURCE
)
) {
val oldResourceMap = jobRequest.getMetrics
- .get(TaskConstant.ENTRANCEJOB_YARNRESOURCE)
+ .get(TaskConstant.JOB_YARNRESOURCE)
.asInstanceOf[util.Map[String, Object]]
- metricMap.put(TaskConstant.ENTRANCEJOB_YARNRESOURCE, oldResourceMap)
+ metricMap.put(TaskConstant.JOB_YARNRESOURCE, oldResourceMap)
}
}
@@ -659,7 +659,7 @@ abstract class EntranceServer extends Logging {
jobRequest.setErrorCode(0)
jobRequest.setErrorDesc("")
jobRequest.setMetrics(metricMap)
- jobRequest.getMetrics.put(TaskConstant.ENTRANCEJOB_SUBMIT_TIME, initDate)
+ jobRequest.getMetrics.put(TaskConstant.JOB_SUBMIT_TIME, initDate)
jobRequest.setUpdateOrderFlag(false)
logAppender.append(
From acc91db7d6dac9132faf0287d43761807df31e3c Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Mon, 10 Apr 2023 09:56:11 +0800
Subject: [PATCH 049/270] replace Option.apply to null
---
.../entrance/restful/EntranceRestfulApi.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
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 90a1bdbd2b..873f5fd8a4 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
@@ -263,7 +263,7 @@ public Message status(
}
}
- Option job = Option.apply(null);
+ Option job = null;
try {
job = entranceServer.getJob(realId);
} catch (Exception e) {
@@ -281,7 +281,7 @@ public Message status(
message.data("status", status).data("execID", execID);
return message;
}
- if (job.isDefined()) {
+ if (job != null && job.isDefined()) {
if (job.get() instanceof EntranceJob) {
((EntranceJob) job.get()).updateNewestAccessByClientTimestamp();
}
@@ -638,7 +638,7 @@ public Message log(HttpServletRequest req, @PathVariable("id") String id) {
}
}
- Option job = Option.apply(null);
+ Option job = null;
try {
job = entranceServer.getJob(realId);
} catch (final Throwable t) {
@@ -648,7 +648,7 @@ public Message log(HttpServletRequest req, @PathVariable("id") String id) {
message.setMethod("/api/entrance/" + id + "/log");
return message;
}
- if (job.isDefined()) {
+ if (job != null && job.isDefined()) {
logger.debug("begin to get log for {}(开始获取 {} 的日志)", job.get().getId(), job.get().getId());
LogReader logReader =
entranceServer.getEntranceContext().getOrCreateLogManager().getLogReader(realId);
@@ -741,7 +741,7 @@ public Message killJobs(
String id = idNode.get(i).asText();
Long taskID = taskIDNode.get(i).asLong();
String realId = ZuulEntranceUtils.parseExecID(id)[3];
- Option job = Option.apply(null);
+ Option job = null;
try {
job = entranceServer.getJob(realId);
} catch (Exception e) {
@@ -755,7 +755,7 @@ public Message killJobs(
continue;
}
Message message = null;
- if (job.isEmpty()) {
+ if (job == null || job.isEmpty()) {
logger.warn("can not find a job in entranceServer, will force to kill it");
waitToForceKill.add(taskID);
message = Message.ok("Forced Kill task (强制杀死任务)");
@@ -877,7 +877,7 @@ public Message kill(
}
}
- Option job = Option.apply(null);
+ Option job = null;
try {
job = entranceServer.getJob(realId);
} catch (Exception e) {
@@ -894,7 +894,7 @@ public Message kill(
return message;
}
- if (job.isEmpty()) {
+ if (job == null || job.isEmpty()) {
logger.warn("can not find a job in entranceServer, will force to kill it");
// 如果在内存中找不到该任务,那么该任务可能已经完成了,或者就是重启导致的
JobHistoryHelper.forceKill(taskID);
From caeeab9fc13489adad51a06cf86bd0733a761e05 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Mon, 14 Aug 2023 11:23:30 +0800
Subject: [PATCH 050/270] sql optimize and bug fix
---
.../linkis/entrance/EntranceServer.scala | 3 ++
.../EntranceParallelConsumerManager.scala | 38 ++++++++++---------
.../jobhistory/dao/JobHistoryMapper.java | 6 +--
.../mapper/common/JobHistoryMapper.xml | 4 +-
4 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
index c44eb07922..fc73887534 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
@@ -531,6 +531,9 @@ abstract class EntranceServer extends Logging {
.createPersistenceEngine()
.updateIfNeeded(jobRequest)
+ // reset `UpdateOrderFlag`
+ jobRequest.setUpdateOrderFlag(true)
+
logger.info(s"job ${jobRequest.getId} update JobRequest success")
val job = getEntranceContext.getOrCreateEntranceParser().parseToJob(jobRequest)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
index 6d756ad1a8..0f86c2a335 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/scheduler/EntranceParallelConsumerManager.scala
@@ -46,26 +46,28 @@ class EntranceParallelConsumerManager(maxParallelismUsers: Int, schedulerName: S
Utils.defaultScheduler.scheduleAtFixedRate(
new Runnable {
override def run(): Unit = {
- logger.info("start refresh consumer group maxAllowRunningJobs")
- // get all entrance server from eureka
- val serviceInstances =
- Sender.getInstances(Sender.getThisServiceInstance.getApplicationName)
- if (null == serviceInstances || serviceInstances.isEmpty) return
+ Utils.tryAndError {
+ logger.info("start refresh consumer group maxAllowRunningJobs")
+ // get all entrance server from eureka
+ val serviceInstances =
+ Sender.getInstances(Sender.getThisServiceInstance.getApplicationName)
+ if (null == serviceInstances || serviceInstances.isEmpty) return
- // get all offline label server
- val routeLabel = LabelBuilderFactoryContext.getLabelBuilderFactory
- .createLabel[RouteLabel](LabelKeyConstant.ROUTE_KEY, LabelValueConstant.OFFLINE_VALUE)
- val labels = new util.ArrayList[Label[_]]
- labels.add(routeLabel)
- val labelInstances = InstanceLabelClient.getInstance.getInstanceFromLabel(labels)
+ // get all offline label server
+ val routeLabel = LabelBuilderFactoryContext.getLabelBuilderFactory
+ .createLabel[RouteLabel](LabelKeyConstant.ROUTE_KEY, LabelValueConstant.OFFLINE_VALUE)
+ val labels = new util.ArrayList[Label[_]]
+ labels.add(routeLabel)
+ val labelInstances = InstanceLabelClient.getInstance.getInstanceFromLabel(labels)
- // get active entrance server
- val allInstances = new util.ArrayList[ServiceInstance]()
- allInstances.addAll(serviceInstances.toList.asJava)
- allInstances.removeAll(labelInstances)
- // refresh all group maxAllowRunningJobs
- refreshAllGroupMaxAllowRunningJobs(allInstances.size())
- logger.info("Finished to refresh consumer group maxAllowRunningJobs")
+ // get active entrance server
+ val allInstances = new util.ArrayList[ServiceInstance]()
+ allInstances.addAll(serviceInstances.toList.asJava)
+ allInstances.removeAll(labelInstances)
+ // refresh all group maxAllowRunningJobs
+ refreshAllGroupMaxAllowRunningJobs(allInstances.size())
+ logger.info("Finished to refresh consumer group maxAllowRunningJobs")
+ }
}
},
EntranceConfiguration.ENTRANCE_GROUP_SCAN_INIT_TIME.getValue,
diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java
index 64e76de0f0..806d8ec70c 100644
--- a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java
+++ b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java
@@ -117,9 +117,9 @@ void updateJobHistoryCancelById(
* or a.instances is null or a.instances not in ('192.168.1.123:9104','192.168.1.124:9104') or
* EXISTS ( select 1 from ( select '192.168.1.123:9104' as instances, 1697775054098 as
* registryTime union all select '192.168.1.124:9104' as instances, 1666239054098 as registryTime
- * ) b where a.instances = b.instances and UNIX_TIMESTAMP(a.created_time) * 1000 < b.registryTime
- * ) ) and status in ('Inited','Running','Scheduled','WaitForRetry') and
- * UNIX_TIMESTAMP(a.created_time) * 1000 >= 1666239054098 limit 10
+ * ) b where a.instances = b.instances and a.created_time < FROM_UNIXTIME(b.registryTime/1000) ) )
+ * and status in ('Inited','Running','Scheduled','WaitForRetry') and a.created_time >=
+ * FROM_UNIXTIME(1666239054098/1000) limit 10
*
* @param instancesMap
* @param statusList
diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/common/JobHistoryMapper.xml b/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/common/JobHistoryMapper.xml
index a99dbf3c87..9d76d27ddf 100644
--- a/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/common/JobHistoryMapper.xml
+++ b/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/common/JobHistoryMapper.xml
@@ -244,12 +244,12 @@
select #{key} as instances, #{val} as registryTime
) b
- where a.instances = b.instances and UNIX_TIMESTAMP(a.created_time) * 1000 b.registryTime
+ where a.instances = b.instances and a.created_time FROM_UNIXTIME(b.registryTime/1000)
)
)
and
status in #{status}
- and UNIX_TIMESTAMP(a.created_time) * 1000 >= #{startTimestamp}
+ and a.created_time >= FROM_UNIXTIME(#{startTimestamp}/1000)
limit #{limit}
From 3d681fb8a74142417c510687527438deb2e31577 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Mon, 14 Aug 2023 15:05:45 +0800
Subject: [PATCH 051/270] merge master
---
.../server/DefaultEntranceServer.java | 3 ++-
.../linkis/entrance/EntranceServer.scala | 2 +-
.../conf/linkis-cg-entrance.properties | 1 -
.../package/conf/linkis-mg-gateway.properties | 1 -
.../mapper/postgresql/JobHistoryMapper.xml | 22 +++++++++++++++++++
5 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
index af2bbaf19c..94531cd5fe 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/server/DefaultEntranceServer.java
@@ -108,7 +108,8 @@ private void shutdownEntrance(ContextClosedEvent event) {
if (null != allUndoneTask) {
for (EntranceJob job : allUndoneTask) {
job.onFailure(
- "Your job will be marked as canceled because the Entrance service restarted(因为Entrance服务重启,您的任务将被标记为取消)", null);
+ "Your job will be marked as canceled because the Entrance service restarted(因为Entrance服务重启,您的任务将被标记为取消)",
+ null);
IOUtils.closeQuietly(((EntranceExecutionJob) job).getLogWriter().get());
}
}
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
index 53cf0256e6..2fa5ff23c4 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
@@ -36,9 +36,9 @@ import org.apache.linkis.entrance.utils.JobHistoryHelper
import org.apache.linkis.governance.common.conf.GovernanceCommonConf
import org.apache.linkis.governance.common.entity.job.JobRequest
import org.apache.linkis.governance.common.protocol.task.RequestTaskKill
+import org.apache.linkis.governance.common.utils.LoggerUtils
import org.apache.linkis.manager.common.protocol.engine.EngineStopRequest
import org.apache.linkis.manager.label.entity.entrance.ExecuteOnceLabel
-import org.apache.linkis.governance.common.utils.LoggerUtils
import org.apache.linkis.protocol.constants.TaskConstant
import org.apache.linkis.rpc.Sender
import org.apache.linkis.rpc.conf.RPCConfiguration
diff --git a/linkis-dist/package/conf/linkis-cg-entrance.properties b/linkis-dist/package/conf/linkis-cg-entrance.properties
index 579ac25a18..c0568288a5 100644
--- a/linkis-dist/package/conf/linkis-cg-entrance.properties
+++ b/linkis-dist/package/conf/linkis-cg-entrance.properties
@@ -39,6 +39,5 @@ spring.eureka.instance.metadata-map.linkis.conf.version=v1
linkis.entrance.auto.clean.dirty.data.enable=true
-wds.linkis.server.mybatis.mapperLocations=classpath*:mapper/common/*.xml,classpath*:mapper/mysql/*.xml
wds.linkis.server.mybatis.BasePackage=org.apache.linkis.publicservice.common.lock.dao
wds.linkis.server.mybatis.typeAliasesPackage=org.apache.linkis.publicservice.common.lock.entity
\ No newline at end of file
diff --git a/linkis-dist/package/conf/linkis-mg-gateway.properties b/linkis-dist/package/conf/linkis-mg-gateway.properties
index 27656f7f31..1f1d2416b4 100644
--- a/linkis-dist/package/conf/linkis-mg-gateway.properties
+++ b/linkis-dist/package/conf/linkis-mg-gateway.properties
@@ -20,7 +20,6 @@ wds.linkis.gateway.conf.enable.proxy.user=false
wds.linkis.gateway.conf.url.pass.auth=/dss/
wds.linkis.gateway.conf.enable.token.auth=true
wds.linkis.is.gateway=true
-wds.linkis.server.mybatis.mapperLocations=classpath*:mapper/common/*.xml,classpath*:mapper/mysql/*.xml
wds.linkis.server.mybatis.typeAliasesPackage=org.apache.linkis.instance.label.entity,org.apache.linkis.jobhistory.entity
wds.linkis.server.mybatis.BasePackage=org.apache.linkis.instance.label.dao,org.apache.linkis.gateway.authentication.dao,org.apache.linkis.jobhistory.dao
wds.linkis.label.entity.packages=org.apache.linkis.gateway.ujes.route.label
diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/postgresql/JobHistoryMapper.xml b/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/postgresql/JobHistoryMapper.xml
index 30e4e85b34..e194a2e4cd 100644
--- a/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/postgresql/JobHistoryMapper.xml
+++ b/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/postgresql/JobHistoryMapper.xml
@@ -229,4 +229,26 @@
#{id}
+
From bdc3e0eb72ce543db841bb937bb5d96fcbd7a005 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Tue, 22 Aug 2023 16:08:52 +0800
Subject: [PATCH 052/270] add comment
---
.../main/scala/org/apache/linkis/entrance/EntranceServer.scala | 1 +
1 file changed, 1 insertion(+)
diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
index 2fa5ff23c4..4931659742 100644
--- a/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
+++ b/linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/EntranceServer.scala
@@ -669,6 +669,7 @@ abstract class EntranceServer extends Logging {
jobRequest.setErrorDesc("")
jobRequest.setMetrics(metricMap)
jobRequest.getMetrics.put(TaskConstant.JOB_SUBMIT_TIME, initDate)
+ // Allow task status updates to be unordered
jobRequest.setUpdateOrderFlag(false)
logAppender.append(
From 5fa73f2576cc159dfd394c7b6bdc3ad57f777380 Mon Sep 17 00:00:00 2001
From: guoshupei <15764973965@163.com>
Date: Tue, 22 Aug 2023 21:57:10 +0800
Subject: [PATCH 053/270] add mybatis config
---
linkis-dist/package/conf/linkis-cg-entrance.properties | 2 +-
linkis-dist/package/conf/linkis-mg-gateway.properties | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/linkis-dist/package/conf/linkis-cg-entrance.properties b/linkis-dist/package/conf/linkis-cg-entrance.properties
index c0568288a5..62b1de5d5e 100644
--- a/linkis-dist/package/conf/linkis-cg-entrance.properties
+++ b/linkis-dist/package/conf/linkis-cg-entrance.properties
@@ -38,6 +38,6 @@ spring.eureka.instance.metadata-map.linkis.conf.version=v1
## clean dirty data when the entrance start
linkis.entrance.auto.clean.dirty.data.enable=true
-
+wds.linkis.server.mybatis.mapperLocations=classpath*:mapper/common/*.xml,classpath*:mapper/mysql/*.xml
wds.linkis.server.mybatis.BasePackage=org.apache.linkis.publicservice.common.lock.dao
wds.linkis.server.mybatis.typeAliasesPackage=org.apache.linkis.publicservice.common.lock.entity
\ No newline at end of file
diff --git a/linkis-dist/package/conf/linkis-mg-gateway.properties b/linkis-dist/package/conf/linkis-mg-gateway.properties
index 1f1d2416b4..27656f7f31 100644
--- a/linkis-dist/package/conf/linkis-mg-gateway.properties
+++ b/linkis-dist/package/conf/linkis-mg-gateway.properties
@@ -20,6 +20,7 @@ wds.linkis.gateway.conf.enable.proxy.user=false
wds.linkis.gateway.conf.url.pass.auth=/dss/
wds.linkis.gateway.conf.enable.token.auth=true
wds.linkis.is.gateway=true
+wds.linkis.server.mybatis.mapperLocations=classpath*:mapper/common/*.xml,classpath*:mapper/mysql/*.xml
wds.linkis.server.mybatis.typeAliasesPackage=org.apache.linkis.instance.label.entity,org.apache.linkis.jobhistory.entity
wds.linkis.server.mybatis.BasePackage=org.apache.linkis.instance.label.dao,org.apache.linkis.gateway.authentication.dao,org.apache.linkis.jobhistory.dao
wds.linkis.label.entity.packages=org.apache.linkis.gateway.ujes.route.label
From 42435c50c9282a1b5e47ecd934f0abadc08fc734 Mon Sep 17 00:00:00 2001
From: peacewong
Date: Mon, 4 Sep 2023 19:19:07 +0800
Subject: [PATCH 054/270] bak
---
linkis-extensions/linkis-et-monitor/pom.xml | 128 ++++++++
.../src/main/assembly/distribution.xml | 297 ++++++++++++++++++
.../app/LinkisDirtyDataCleanApplication.java | 111 +++++++
.../app/LinkisJobHistoryScanApplication.java | 172 ++++++++++
.../app/LinksMonitorResourceApplication.java | 32 ++
.../app/instance/dao/InsLabelRelationDao.java | 35 +++
.../app/instance/dao/InstanceInfoDao.java | 36 +++
.../app/instance/dao/InstanceLabelDao.java | 41 +++
.../instance/entity/InsPersistenceLabel.java | 82 +++++
.../entity/InsPersistenceLabelValue.java | 59 ++++
.../app/instance/entity/InstanceInfo.java | 92 ++++++
.../scan/app/jobhistory/QueryUtils.java | 31 ++
.../app/jobhistory/dao/JobHistoryMapper.java | 68 ++++
.../app/jobhistory/entity/JobHistory.java | 221 +++++++++++++
.../exception/AnomalyScannerException.java | 37 +++
.../exception/DirtyDataCleanException.java | 37 +++
.../app/monitor/config/ListenerConfig.java | 46 +++
.../app/monitor/config/MonitorConfig.java | 71 +++++
.../app/monitor/config/ScheduledConfig.java | 39 +++
.../app/monitor/entity/ChatbotEntity.java | 87 +++++
.../scan/app/monitor/entity/EngineEntity.java | 53 ++++
.../app/monitor/entity/EntranceEntity.java | 63 ++++
.../scan/app/monitor/entity/IndexEntity.java | 85 +++++
.../scan/app/monitor/scheduled/BmlClear.java | 47 +++
.../app/monitor/scheduled/EcRecordClear.java | 53 ++++
.../monitor/scheduled/JobHistoryClear.java | 53 ++++
.../monitor/scheduled/JobHistoryMonitor.java | 264 ++++++++++++++++
.../monitor/scheduled/ResourceMonitor.java | 151 +++++++++
.../app/monitor/scheduled/TaskLogClear.java | 53 ++++
.../app/monitor/scheduled/TaskMonitor.java | 183 +++++++++++
.../monitor/scheduled/UserModeMonitor.java | 156 +++++++++
.../app/monitor/scheduled/ValidatorClear.java | 51 +++
.../scan/app/monitor/until/CacheUtils.java | 35 +++
.../scan/app/monitor/until/HttpsUntils.java | 183 +++++++++++
.../scan/app/monitor/until/ThreadUtils.java | 68 ++++
.../mapper/common/InsLabelRelationMapper.xml | 67 ++++
.../mapper/common/InstanceInfoMapper.xml | 53 ++++
.../mapper/common/InstanceLabelMapper.xml | 57 ++++
.../mapper/common/JobHistoryMapper.xml | 172 ++++++++++
...kisJobHistoryScanSpringConfiguration.scala | 49 +++
.../scan/app/factory/MapperFactory.scala | 64 ++++
.../jobhistory/JobHistoryDataFetcher.scala | 111 +++++++
.../errorcode/JobHistoryErrCodeHitEvent.scala | 23 ++
.../errorcode/JobHistoryErrCodeRule.scala | 80 +++++
.../JobHistoryErrorCodeAlertSender.scala | 97 ++++++
.../jobtime/JobTimeExceedAlertSender.scala | 112 +++++++
.../jobtime/JobTimeExceedHitEvent.scala | 23 ++
.../jobtime/JobTimeExceedRule.scala | 103 ++++++
.../labels/JobHistoryLabelsAlertSender.scala | 69 ++++
.../labels/JobHistoryLabelsHitEvent.scala | 22 ++
.../labels/JobHistoryLabelsRule.scala | 112 +++++++
.../runtime/CommonJobRunTimeRule.scala | 79 +++++
.../runtime/CommonRunTimeAlertSender.scala | 88 ++++++
.../runtime/CommonRunTimeHitEvent.scala | 22 ++
.../JobHistoryRunTimeAlertSender.scala | 73 +++++
.../runtime/JobHistoryRunTimeHitEvent.scala | 22 ++
.../runtime/JobHistoryRunTimeRule.scala | 82 +++++
.../scan/client/MonitorHTTPClient.scala | 117 +++++++
.../client/MonitorHTTPClientClientImpl.scala | 39 +++
.../scan/client/MonitorResourceClient.scala | 112 +++++++
.../client/MonitorResourceClientImpl.scala | 39 +++
.../monitor/scan/constants/Constants.scala | 113 +++++++
.../scan/constants/ScanOperatorEnum.scala | 24 ++
.../linkis/monitor/scan/core/ob/Event.scala | 29 ++
.../monitor/scan/core/ob/Observer.scala | 27 ++
.../scan/core/ob/SingleObserverEvent.java | 43 +++
.../scan/core/pac/AbstractDataFetcher.scala | 30 ++
.../scan/core/pac/AbstractScanRule.scala | 52 +++
.../scan/core/pac/BaseScannedData.scala | 27 ++
.../monitor/scan/core/pac/DataFetcher.scala | 40 +++
.../monitor/scan/core/pac/ScanBuffer.scala | 43 +++
.../monitor/scan/core/pac/ScanRule.scala | 50 +++
.../monitor/scan/core/pac/ScannedData.scala | 27 ++
.../scan/core/scanner/AbstractScanner.scala | 168 ++++++++++
.../scan/core/scanner/AnomalyScanner.scala | 95 ++++++
.../scan/core/scanner/DefaultScanner.scala | 29 ++
.../monitor/scan/request/EmsListAction.scala | 74 +++++
.../scan/request/EntranceTaskAction.scala | 76 +++++
.../scan/request/MonitorResourceAction.scala | 22 ++
.../monitor/scan/request/UserAction.scala | 26 ++
.../scan/response/EntranceTaskResult.scala | 36 +++
.../scan/response/MonitorResourceResult.scala | 33 ++
.../linkis/monitor/scan/utils/ScanUtils.java | 71 +++++
.../monitor/scan/utils/alert/AlertDesc.scala | 26 ++
.../scan/utils/alert/AlertSender.scala | 30 ++
.../scan/utils/alert/PooledAlertSender.scala | 112 +++++++
.../scan/utils/alert/ims/ImsAlertDesc.scala | 155 +++++++++
.../scan/utils/alert/ims/ImsAlertLevel.scala | 29 ++
.../scan/utils/alert/ims/ImsAlertWay.scala | 27 ++
.../scan/utils/alert/ims/ImsRequest.scala | 36 +++
...storyScanImsAlertPropFileParserUtils.scala | 132 ++++++++
.../utils/alert/ims/MonitorAlertUtils.scala | 229 ++++++++++++++
.../alert/ims/PooledImsAlertSender.scala | 110 +++++++
.../utils/alert/ims/PooledImsAlertUtils.scala | 115 +++++++
.../utils/alert/ims/UserLabelAlertUtils.scala | 126 ++++++++
.../monitor/scan/utils/log/LogUtils.scala | 25 ++
...ryScanImsAlertPropFileParserUtilsTest.java | 48 +++
.../LinkisJobHistoryScanApplicationTest.java | 38 +++
.../utils/alert/PooledImsAlertSenderTest.java | 67 ++++
.../utils/alert/PooledImsAlertUtilsTest.java | 49 +++
.../linkis-et-jobhistory-scan-ims.properties | 6 +
.../linkis-et-jobhistory-scan.properties | 14 +
.../src/test/resources/log4j2-console.xml | 46 +++
linkis-extensions/pom.xml | 1 +
104 files changed, 7663 insertions(+)
create mode 100644 linkis-extensions/linkis-et-monitor/pom.xml
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/assembly/distribution.xml
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinkisDirtyDataCleanApplication.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinkisJobHistoryScanApplication.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinksMonitorResourceApplication.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InsLabelRelationDao.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InstanceInfoDao.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InstanceLabelDao.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InsPersistenceLabel.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InsPersistenceLabelValue.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InstanceInfo.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/QueryUtils.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/dao/JobHistoryMapper.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/entity/JobHistory.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/exception/AnomalyScannerException.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/exception/DirtyDataCleanException.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/ListenerConfig.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/MonitorConfig.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/ScheduledConfig.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/ChatbotEntity.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/EngineEntity.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/EntranceEntity.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/IndexEntity.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/BmlClear.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/EcRecordClear.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/JobHistoryClear.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/JobHistoryMonitor.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/ResourceMonitor.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/TaskLogClear.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/TaskMonitor.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/UserModeMonitor.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/ValidatorClear.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/until/CacheUtils.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/until/HttpsUntils.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/until/ThreadUtils.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/resources/mapper/common/InsLabelRelationMapper.xml
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/resources/mapper/common/InstanceInfoMapper.xml
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/resources/mapper/common/InstanceLabelMapper.xml
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/resources/mapper/common/JobHistoryMapper.xml
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/LinkisJobHistoryScanSpringConfiguration.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/factory/MapperFactory.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/JobHistoryDataFetcher.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/errorcode/JobHistoryErrCodeHitEvent.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/errorcode/JobHistoryErrCodeRule.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/errorcode/JobHistoryErrorCodeAlertSender.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/jobtime/JobTimeExceedAlertSender.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/jobtime/JobTimeExceedHitEvent.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/jobtime/JobTimeExceedRule.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/labels/JobHistoryLabelsAlertSender.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/labels/JobHistoryLabelsHitEvent.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/labels/JobHistoryLabelsRule.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/runtime/CommonJobRunTimeRule.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/runtime/CommonRunTimeAlertSender.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/runtime/CommonRunTimeHitEvent.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/runtime/JobHistoryRunTimeAlertSender.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/runtime/JobHistoryRunTimeHitEvent.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/app/jobhistory/runtime/JobHistoryRunTimeRule.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/client/MonitorHTTPClient.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/client/MonitorHTTPClientClientImpl.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/client/MonitorResourceClient.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/client/MonitorResourceClientImpl.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/constants/Constants.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/constants/ScanOperatorEnum.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/ob/Event.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/ob/Observer.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/ob/SingleObserverEvent.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/pac/AbstractDataFetcher.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/pac/AbstractScanRule.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/pac/BaseScannedData.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/pac/DataFetcher.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/pac/ScanBuffer.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/pac/ScanRule.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/pac/ScannedData.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/scanner/AbstractScanner.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/scanner/AnomalyScanner.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/core/scanner/DefaultScanner.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/request/EmsListAction.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/request/EntranceTaskAction.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/request/MonitorResourceAction.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/request/UserAction.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/response/EntranceTaskResult.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/response/MonitorResourceResult.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/ScanUtils.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/AlertDesc.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/AlertSender.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/PooledAlertSender.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/ims/ImsAlertDesc.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/ims/ImsAlertLevel.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/ims/ImsAlertWay.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/ims/ImsRequest.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/ims/JobHistoryScanImsAlertPropFileParserUtils.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/ims/MonitorAlertUtils.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/ims/PooledImsAlertSender.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/ims/PooledImsAlertUtils.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/alert/ims/UserLabelAlertUtils.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/main/scala/org/apache/linkis/monitor/scan/utils/log/LogUtils.scala
create mode 100644 linkis-extensions/linkis-et-monitor/src/test/java/org/apache/linkis/monitor/scan/app/JobHistoryScanImsAlertPropFileParserUtilsTest.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/test/java/org/apache/linkis/monitor/scan/app/LinkisJobHistoryScanApplicationTest.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/test/java/org/apache/linkis/monitor/scan/utils/alert/PooledImsAlertSenderTest.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/test/java/org/apache/linkis/monitor/scan/utils/alert/PooledImsAlertUtilsTest.java
create mode 100644 linkis-extensions/linkis-et-monitor/src/test/resources/linkis-et-jobhistory-scan-ims.properties
create mode 100644 linkis-extensions/linkis-et-monitor/src/test/resources/linkis-et-jobhistory-scan.properties
create mode 100644 linkis-extensions/linkis-et-monitor/src/test/resources/log4j2-console.xml
diff --git a/linkis-extensions/linkis-et-monitor/pom.xml b/linkis-extensions/linkis-et-monitor/pom.xml
new file mode 100644
index 0000000000..5e62fa60b5
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/pom.xml
@@ -0,0 +1,128 @@
+
+
+
+ 4.0.0
+
+ org.apache.linkis
+ linkis
+ ${revision}
+ ../../pom.xml
+
+
+ linkis-et-monitor
+
+
+
+ org.apache.linkis
+ linkis-httpclient
+ ${project.version}
+
+
+ org.apache.linkis
+ linkis-mybatis
+ ${project.version}
+
+
+
+ org.apache.linkis
+ linkis-wedatasphere-common
+ ${project.version}
+
+
+
+ org.apache.linkis
+ linkis-module
+ ${project.version}
+ provided
+
+
+
+ org.apache.linkis
+ linkis-gateway-httpclient-support
+ ${project.version}
+
+
+
+ org.apache.linkis
+ linkis-common
+ ${project.version}
+
+
+
+ org.springframework
+ spring-test
+ test
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ org.apache.linkis
+ linkis-computation-client
+ ${project.version}
+
+
+ org.apache.linkis
+ linkis-bml-cleaner
+ ${project.version}
+
+
+ org.apache.linkis
+ linkis-storage
+ ${project.version}
+ provided
+
+
+ org.apache.linkis
+ linkis-rpc
+ ${project.version}
+
+
+
+
+
+ net.alchim31.maven
+ scala-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ false
+
+ false
+ out
+ false
+ false
+
+ src/main/assembly/distribution.xml
+
+
+
+
+ make-assembly
+
+ single
+
+ package
+
+
+
+
+
+
+
diff --git a/linkis-extensions/linkis-et-monitor/src/main/assembly/distribution.xml b/linkis-extensions/linkis-et-monitor/src/main/assembly/distribution.xml
new file mode 100644
index 0000000000..8cc9e7ea7b
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/assembly/distribution.xml
@@ -0,0 +1,297 @@
+
+
+
+
+ linkis-et-monitor
+
+ dir
+
+ false
+
+
+
+
+
+ lib
+ true
+ true
+ false
+ false
+ true
+
+
+ antlr:antlr:jar
+ aopalliance:aopalliance:jar
+ asm:asm:jar
+ cglib:cglib:jar
+ com.amazonaws:aws-java-sdk-autoscaling:jar
+ com.amazonaws:aws-java-sdk-core:jar
+ com.amazonaws:aws-java-sdk-ec2:jar
+ com.amazonaws:aws-java-sdk-route53:jar
+ com.amazonaws:aws-java-sdk-sts:jar
+ com.amazonaws:jmespath-java:jar
+ com.fasterxml.jackson.core:jackson-annotations:jar
+ com.fasterxml.jackson.core:jackson-core:jar
+ com.fasterxml.jackson.core:jackson-databind:jar
+ com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar
+ com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar
+ com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar
+ com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar
+ com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar
+ com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar
+ com.fasterxml.jackson.module:jackson-module-parameter-names:jar
+ com.fasterxml.jackson.module:jackson-module-paranamer:jar
+ com.fasterxml.jackson.module:jackson-module-scala_2.11:jar
+ com.github.andrewoma.dexx:dexx-collections:jar
+ com.github.vlsi.compactmap:compactmap:jar
+ com.google.code.findbugs:annotations:jar
+ com.google.code.findbugs:jsr305:jar
+ com.google.code.gson:gson:jar
+ com.google.guava:guava:jar
+ com.google.inject:guice:jar
+ com.google.protobuf:protobuf-java:jar
+ com.netflix.archaius:archaius-core:jar
+ com.netflix.eureka:eureka-client:jar
+ com.netflix.eureka:eureka-core:jar
+ com.netflix.hystrix:hystrix-core:jar
+ com.netflix.netflix-commons:netflix-commons-util:jar
+ com.netflix.netflix-commons:netflix-eventbus:jar
+ com.netflix.netflix-commons:netflix-infix:jar
+ com.netflix.netflix-commons:netflix-statistics:jar
+ com.netflix.ribbon:ribbon:jar
+ com.netflix.ribbon:ribbon-core:jar
+ com.netflix.ribbon:ribbon-eureka:jar
+ com.netflix.ribbon:ribbon-httpclient:jar
+ com.netflix.ribbon:ribbon-loadbalancer:jar
+ com.netflix.ribbon:ribbon-transport:jar
+ com.netflix.servo:servo-core:jar
+ com.ning:async-http-client:jar
+ com.sun.jersey.contribs:jersey-apache-client4:jar
+ com.sun.jersey:jersey-client:jar
+ com.sun.jersey:jersey-core:jar
+ com.sun.jersey:jersey-json:jar
+ com.sun.jersey:jersey-server:jar
+ com.sun.jersey:jersey-servlet:jar
+ com.sun.xml.bind:jaxb-impl:jar
+ com.thoughtworks.paranamer:paranamer:jar
+ com.thoughtworks.xstream:xstream:jar
+ org.apache.linkis:linkis-common:jar
+ org.apache.linkis:linkis-module:jar
+ commons-beanutils:commons-beanutils:jar
+ commons-beanutils:commons-beanutils-core:jar
+ commons-cli:commons-cli:jar
+ commons-codec:commons-codec:jar
+ commons-collections:commons-collections:jar
+ commons-configuration:commons-configuration:jar
+ commons-daemon:commons-daemon:jar
+ commons-dbcp:commons-dbcp:jar
+ commons-digester:commons-digester:jar
+ commons-httpclient:commons-httpclient:jar
+ commons-io:commons-io:jar
+ commons-jxpath:commons-jxpath:jar
+ commons-lang:commons-lang:jar
+ commons-logging:commons-logging:jar
+ commons-net:commons-net:jar
+ commons-pool:commons-pool:jar
+ io.micrometer:micrometer-core:jar
+ io.netty:netty:jar
+ io.netty:netty-all:jar
+ io.netty:netty-buffer:jar
+ io.netty:netty-codec:jar
+ io.netty:netty-codec-http:jar
+ io.netty:netty-common:jar
+ io.netty:netty-handler:jar
+ io.netty:netty-transport:jar
+ io.netty:netty-transport-native-epoll:jar
+ io.reactivex:rxjava:jar
+ io.reactivex:rxnetty:jar
+ io.reactivex:rxnetty-contexts:jar
+ io.reactivex:rxnetty-servo:jar
+ javax.activation:activation:jar
+ javax.annotation:javax.annotation-api:jar
+ javax.inject:javax.inject:jar
+ javax.servlet:javax.servlet-api:jar
+ javax.servlet.jsp:jsp-api:jar
+ javax.validation:validation-api:jar
+ javax.websocket:javax.websocket-api:jar
+ javax.ws.rs:javax.ws.rs-api:jar
+ javax.xml.bind:jaxb-api:jar
+ javax.xml.stream:stax-api:jar
+ joda-time:joda-time:jar
+ log4j:log4j:jar
+ mysql:mysql-connector-java:jar
+ net.databinder.dispatch:dispatch-core_2.11:jar
+ net.databinder.dispatch:dispatch-json4s-jackson_2.11:jar
+ org.antlr:antlr-runtime:jar
+ org.antlr:stringtemplate:jar
+ org.apache.commons:commons-compress:jar
+ org.apache.commons:commons-math:jar
+ org.apache.commons:commons-math3:jar
+ org.apache.curator:curator-client:jar
+ org.apache.curator:curator-framework:jar
+ org.apache.curator:curator-recipes:jar
+ org.apache.directory.api:api-asn1-api:jar
+ org.apache.directory.api:api-util:jar
+ org.apache.directory.server:apacheds-i18n:jar
+ org.apache.directory.server:apacheds-kerberos-codec:jar
+ org.apache.hadoop:hadoop-annotations:jar
+ org.apache.hadoop:hadoop-auth:jar
+ org.apache.hadoop:hadoop-common:jar
+ org.apache.hadoop:hadoop-hdfs:jar
+ org.apache.htrace:htrace-core:jar
+ org.apache.httpcomponents:httpclient:jar
+ org.apache.httpcomponents:httpcore:jar
+ org.apache.logging.log4j:log4j-api:jar
+ org.apache.logging.log4j:log4j-core:jar
+ org.apache.logging.log4j:log4j-jul:jar
+ org.apache.logging.log4j:log4j-slf4j-impl:jar
+ org.apache.zookeeper:zookeeper:jar
+ org.aspectj:aspectjweaver:jar
+ org.bouncycastle:bcpkix-jdk15on:jar
+ org.bouncycastle:bcprov-jdk15on:jar
+ org.codehaus.jackson:jackson-jaxrs:jar
+ org.codehaus.jackson:jackson-xc:jar
+ org.codehaus.jettison:jettison:jar
+ org.codehaus.woodstox:stax2-api:jar
+ org.codehaus.woodstox:woodstox-core-asl:jar
+ org.eclipse.jetty:jetty-annotations:jar
+ org.eclipse.jetty:jetty-client:jar
+ org.eclipse.jetty:jetty-continuation:jar
+ org.eclipse.jetty:jetty-http:jar
+ org.eclipse.jetty:jetty-io:jar
+ org.eclipse.jetty:jetty-jndi:jar
+ org.eclipse.jetty:jetty-plus:jar
+ org.eclipse.jetty:jetty-security:jar
+ org.eclipse.jetty:jetty-server:jar
+ org.eclipse.jetty:jetty-servlet:jar
+ org.eclipse.jetty:jetty-servlets:jar
+ org.eclipse.jetty:jetty-util:jar
+ org.eclipse.jetty:jetty-webapp:jar
+ org.eclipse.jetty:jetty-xml:jar
+ org.eclipse.jetty.websocket:javax-websocket-client-impl:jar
+ org.eclipse.jetty.websocket:javax-websocket-server-impl:jar
+ org.eclipse.jetty.websocket:websocket-api:jar
+ org.eclipse.jetty.websocket:websocket-client:jar
+ org.eclipse.jetty.websocket:websocket-common:jar
+ org.eclipse.jetty.websocket:websocket-server:jar
+ org.eclipse.jetty.websocket:websocket-servlet:jar
+ org.fusesource.leveldbjni:leveldbjni-all:jar
+ org.glassfish.hk2:class-model:jar
+ org.glassfish.hk2:config-types:jar
+ org.glassfish.hk2.external:aopalliance-repackaged:jar
+ org.glassfish.hk2.external:asm-all-repackaged:jar
+ org.glassfish.hk2.external:bean-validator:jar
+ org.glassfish.hk2.external:javax.inject:jar
+ org.glassfish.hk2:hk2:jar
+ org.glassfish.hk2:hk2-api:jar
+ org.glassfish.hk2:hk2-config:jar
+ org.glassfish.hk2:hk2-core:jar
+ org.glassfish.hk2:hk2-locator:jar
+ org.glassfish.hk2:hk2-runlevel:jar
+ org.glassfish.hk2:hk2-utils:jar
+ org.glassfish.hk2:osgi-resource-locator:jar
+ org.glassfish.hk2:spring-bridge:jar
+ org.glassfish.jersey.bundles:jaxrs-ri:jar
+ org.glassfish.jersey.bundles.repackaged:jersey-guava:jar
+ org.glassfish.jersey.containers:jersey-container-servlet:jar
+ org.glassfish.jersey.containers:jersey-container-servlet-core:jar
+ org.glassfish.jersey.core:jersey-client:jar
+ org.glassfish.jersey.core:jersey-common:jar
+ org.glassfish.jersey.core:jersey-server:jar
+ org.glassfish.jersey.ext:jersey-entity-filtering:jar
+ org.glassfish.jersey.ext:jersey-spring3:jar
+ org.glassfish.jersey.media:jersey-media-jaxb:jar
+ org.glassfish.jersey.media:jersey-media-json-jackson:jar
+ org.glassfish.jersey.media:jersey-media-multipart:jar
+ org.hdrhistogram:HdrHistogram:jar
+ org.javassist:javassist:jar
+ org.json4s:json4s-ast_2.11:jar
+ org.json4s:json4s-core_2.11:jar
+ org.json4s:json4s-jackson_2.11:jar
+ org.jsoup:jsoup:jar
+ org.jvnet.mimepull:mimepull:jar
+ org.jvnet:tiger-types:jar
+ org.latencyutils:LatencyUtils:jar
+ org.mortbay.jasper:apache-el:jar
+ org.mortbay.jetty:jetty:jar
+ org.mortbay.jetty:jetty-util:jar
+ org.ow2.asm:asm-analysis:jar
+ org.ow2.asm:asm-commons:jar
+ org.ow2.asm:asm-tree:jar
+ org.reflections:reflections:jar
+ org.scala-lang.modules:scala-parser-combinators_2.11:jar
+ org.scala-lang.modules:scala-xml_2.11:jar
+ org.scala-lang:scala-compiler:jar
+ org.scala-lang:scala-library:jar
+ org.scala-lang:scala-reflect:jar
+ org.scala-lang:scalap:jar
+ org.slf4j:jul-to-slf4j:jar
+ org.slf4j:slf4j-api:jar
+ org.springframework.boot:spring-boot:jar
+ org.springframework.boot:spring-boot-actuator:jar
+ org.springframework.boot:spring-boot-actuator-autoconfigure:jar
+ org.springframework.boot:spring-boot-autoconfigure:jar
+ org.springframework.boot:spring-boot-starter:jar
+ org.springframework.boot:spring-boot-starter-actuator:jar
+ org.springframework.boot:spring-boot-starter-aop:jar
+ org.springframework.boot:spring-boot-starter-jetty:jar
+ org.springframework.boot:spring-boot-starter-json:jar
+ org.springframework.boot:spring-boot-starter-log4j2:jar
+ org.springframework.boot:spring-boot-starter-web:jar
+ org.springframework.cloud:spring-cloud-commons:jar
+ org.springframework.cloud:spring-cloud-config-client:jar
+ org.springframework.cloud:spring-cloud-context:jar
+ org.springframework.cloud:spring-cloud-netflix-archaius:jar
+ org.springframework.cloud:spring-cloud-netflix-core:jar
+ org.springframework.cloud:spring-cloud-netflix-eureka-client:jar
+ org.springframework.cloud:spring-cloud-netflix-ribbon:jar
+ org.springframework.cloud:spring-cloud-starter:jar
+ org.springframework.cloud:spring-cloud-starter-config:jar
+ org.springframework.cloud:spring-cloud-starter-eureka:jar
+ org.springframework.cloud:spring-cloud-starter-netflix-archaius:jar
+ org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:jar
+ org.springframework.cloud:spring-cloud-starter-netflix-ribbon:jar
+ org.springframework.security:spring-security-crypto:jar
+ org.springframework.security:spring-security-rsa:jar
+ org.springframework:spring-aop:jar
+ org.springframework:spring-beans:jar
+ org.springframework:spring-context:jar
+ org.springframework:spring-core:jar
+ org.springframework:spring-expression:jar
+ org.springframework:spring-jcl:jar
+ org.springframework:spring-web:jar
+ org.springframework:spring-webmvc:jar
+ org.tukaani:xz:jar
+ org.yaml:snakeyaml:jar
+ software.amazon.ion:ion-java:jar
+ xerces:xercesImpl:jar
+ xmlenc:xmlenc:jar
+ xmlpull:xmlpull:jar
+ xpp3:xpp3_min:jar
+
+
+
+
+
+
+
+
+
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinkisDirtyDataCleanApplication.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinkisDirtyDataCleanApplication.java
new file mode 100644
index 0000000000..3530ef5139
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinkisDirtyDataCleanApplication.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app;
+
+import org.apache.linkis.monitor.scan.app.dirtydata.entrance.EntranceDirtyDataHandler;
+import org.apache.linkis.monitor.scan.utils.log.LogUtils;
+import org.apache.linkis.server.utils.LinkisMainHelper;
+
+import org.apache.commons.lang3.StringUtils;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
+
+import org.slf4j.Logger;
+
+public class LinkisDirtyDataCleanApplication {
+ private static final Logger logger = LogUtils.stdOutLogger();
+
+ /** @param args: args[0]: host args[1] port */
+ public static void main(String[] args) throws ReflectiveOperationException {
+ if (args.length == 0
+ || StringUtils.equalsIgnoreCase(args[0], "help")
+ || StringUtils.equalsIgnoreCase(args[0], "--help")) {
+ LogUtils.stdOutLogger()
+ .info(
+ "[help-message]this app cleans entrance dirty-data. args[0]: command-type (entrance/help/...) args[1]: entrance-hostname(not null), args[2]: entrance-port(can be null)");
+ return;
+ }
+ String serviceName = System.getProperty(LinkisMainHelper.SERVER_NAME_KEY());
+ LinkisMainHelper.formatPropertyFiles(serviceName);
+
+ if (StringUtils.equalsIgnoreCase(args[0], "entrance")) {
+ AbstractApplicationContext context =
+ new AnnotationConfigApplicationContext(LinkisJobHistoryScanSpringConfiguration.class);
+
+ String host = "";
+ String port = "";
+ if (args.length > 1) {
+ host = args[1];
+ }
+ if (args.length > 2) {
+ port = args[2];
+ }
+ if (args.length > 3) {
+ printIllegalInput("wrong number of arguments");
+ return;
+ }
+ try {
+ removeDirtyEurekaInstance(host, port);
+ } catch (Exception e) {
+ LogUtils.stdOutLogger().error("Failed to remove dirty eureka-instance", e);
+ }
+ try {
+ removeDbDirtyData(host, port);
+ } catch (Exception e) {
+ LogUtils.stdOutLogger().error("Failed to remove dirty db-data", e);
+ }
+
+ context.close();
+ } else {
+ LogUtils.stdOutLogger().error("Upsupported command type: " + args[0]);
+ }
+ }
+
+ private static void printIllegalInput(String msg) {
+ LogUtils.stdOutLogger().error("illegal input: " + msg);
+ LogUtils.stdOutLogger()
+ .info(
+ "[help-message] this app cleans entrance dirty-data. args[0]: entrance-hostname, args[1]: entrance-port");
+ return;
+ }
+
+ private static void removeDirtyEurekaInstance(String host, String port) {
+ if (StringUtils.isBlank(host)) {
+ printIllegalInput("host cannot be blank");
+ return;
+ }
+ if (StringUtils.isBlank(port)) {
+ EntranceDirtyDataHandler.handleEurekaDirtyData(host);
+ } else {
+ EntranceDirtyDataHandler.handleEurekaDirtyData(host, port);
+ }
+ }
+
+ private static void removeDbDirtyData(String host, String port) {
+ if (StringUtils.isBlank(host)) {
+ printIllegalInput("host cannot be blank");
+ return;
+ }
+ if (StringUtils.isBlank(port)) {
+ EntranceDirtyDataHandler.handleDbDirtData(host);
+ } else {
+ EntranceDirtyDataHandler.handleDbDirtData(host, port);
+ }
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinkisJobHistoryScanApplication.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinkisJobHistoryScanApplication.java
new file mode 100644
index 0000000000..8b4366805e
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinkisJobHistoryScanApplication.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app;
+
+import org.apache.linkis.monitor.scan.app.factory.MapperFactory;
+import org.apache.linkis.monitor.scan.app.jobhistory.JobHistoryDataFetcher;
+import org.apache.linkis.monitor.scan.app.jobhistory.errorcode.JobHistoryErrCodeRule;
+import org.apache.linkis.monitor.scan.app.jobhistory.errorcode.JobHistoryErrorCodeAlertSender;
+import org.apache.linkis.monitor.scan.app.jobhistory.jobtime.JobTimeExceedAlertSender;
+import org.apache.linkis.monitor.scan.app.jobhistory.jobtime.JobTimeExceedRule;
+import org.apache.linkis.monitor.scan.constants.Constants;
+import org.apache.linkis.monitor.scan.core.pac.DataFetcher;
+import org.apache.linkis.monitor.scan.core.scanner.AnomalyScanner;
+import org.apache.linkis.monitor.scan.core.scanner.DefaultScanner;
+import org.apache.linkis.monitor.scan.utils.alert.AlertDesc;
+import org.apache.linkis.monitor.scan.utils.alert.ims.ImsAlertDesc;
+import org.apache.linkis.monitor.scan.utils.alert.ims.JobHistoryScanImsAlertPropFileParserUtils;
+import org.apache.linkis.monitor.scan.utils.log.LogUtils;
+import org.apache.linkis.server.utils.LinkisMainHelper;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
+
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+
+public class LinkisJobHistoryScanApplication {
+ private static final Logger logger = LogUtils.stdOutLogger();
+
+ /** @param args: args[0]: startTime, args[1] endTime */
+ public static void main(String[] args) throws ReflectiveOperationException {
+
+ String serviceName = System.getProperty(LinkisMainHelper.SERVER_NAME_KEY());
+ LinkisMainHelper.formatPropertyFiles(serviceName);
+
+ long intervalMs = Constants.SCAN_INTERVALS_SECONDS() * 1000;
+ long maxIntervalMs = Constants.MAX_INTERVALS_SECONDS() * 1000;
+ long endTime = System.currentTimeMillis();
+ long startTime = endTime - intervalMs;
+ /** parse input into timestamp */
+ if (args != null && args.length == 2) {
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH");
+ Long tmpStart;
+ Long tmpEnd;
+ try {
+ tmpStart = format.parse(args[0]).getTime();
+ tmpEnd = format.parse(args[1]).getTime();
+ } catch (ParseException e) {
+ logger.info(
+ "Failed to parse input into startTime and endTime." + ExceptionUtils.getMessage(e));
+ return;
+ }
+ if (endTime <= startTime) {
+ logger.info("[error] startTime larger than endTime");
+ return;
+ }
+ if (tmpStart != null && tmpEnd != null) {
+ startTime = tmpStart;
+ endTime = tmpEnd;
+ }
+ }
+ long realIntervals = endTime - startTime < maxIntervalMs ? endTime - startTime : maxIntervalMs;
+
+ runApp(startTime, endTime, realIntervals, maxIntervalMs);
+ }
+
+ private static void runApp(long startTime, long endTime, long realIntervals, long maxIntervalMs) {
+
+ AbstractApplicationContext context =
+ new AnnotationConfigApplicationContext(LinkisJobHistoryScanSpringConfiguration.class);
+
+ AnomalyScanner scanner = new DefaultScanner();
+ boolean shouldStart = false;
+
+ List fetchers = generateFetchers(startTime, endTime, maxIntervalMs);
+ if (fetchers == null) {
+ logger.warn("generated 0 dataFetchers, plz check input");
+ return;
+ }
+
+ Map errorCodeAlerts =
+ JobHistoryScanImsAlertPropFileParserUtils.getAlerts(Constants.SCAN_PREFIX_ERRORCODE());
+ if (errorCodeAlerts == null || errorCodeAlerts.size() == 0) {
+ logger.info("[INFO] Loaded 0 errorcode alert from alert-rule properties file.");
+ } else {
+ logger.info(
+ "[INFO] Loaded {} errorcode alert from alert-rules properties file.",
+ errorCodeAlerts.size());
+ shouldStart = true;
+ addIntervalToImsAlerts(errorCodeAlerts, realIntervals);
+ JobHistoryErrCodeRule jobHistoryErrCodeRule =
+ new JobHistoryErrCodeRule(
+ errorCodeAlerts.keySet(), new JobHistoryErrorCodeAlertSender(errorCodeAlerts));
+ scanner.addScanRule(jobHistoryErrCodeRule);
+ }
+
+ Map jobTimeAlerts =
+ JobHistoryScanImsAlertPropFileParserUtils.getAlerts(
+ Constants.SCAN_PREFIX_UNFINISHED_JOBTIME_EXCEED_SEC());
+ if (jobTimeAlerts == null || jobTimeAlerts.size() == 0) {
+ logger.info("[INFO] Loaded 0 alerts jobtime alert-rule from alert properties file.");
+ } else {
+ logger.info(
+ "[INFO] Loaded {} alerts jobtime alert-rules from alert properties file.",
+ jobTimeAlerts.size());
+ shouldStart = true;
+ addIntervalToImsAlerts(jobTimeAlerts, realIntervals);
+ JobTimeExceedRule jobTimeExceedRule =
+ new JobTimeExceedRule(
+ jobTimeAlerts.keySet(), new JobTimeExceedAlertSender(jobTimeAlerts));
+ scanner.addScanRule(jobTimeExceedRule);
+ }
+ if (shouldStart) {
+ scanner.addDataFetchers(fetchers);
+ scanner.run();
+ scanner.shutdown(); // wait all alert to be send
+ }
+ context.close();
+ }
+
+ private static List generateFetchers(
+ long startTime, long endTime, long maxIntervalMs) {
+ List ret = new ArrayList<>();
+ long pe = endTime;
+ long ps;
+ while (pe > startTime) {
+ ps = pe - maxIntervalMs > startTime ? pe - maxIntervalMs : startTime;
+ String[] fetcherArgs = new String[] {String.valueOf(ps), String.valueOf(pe)};
+ ret.add(new JobHistoryDataFetcher(fetcherArgs, MapperFactory.getJobHistoryMapper()));
+ logger.info(
+ "Generated dataFetcher for startTime: "
+ + new Date(ps).toString()
+ + ". EndTime: "
+ + new Date(pe).toString());
+ pe = pe - maxIntervalMs;
+ }
+ return ret;
+ }
+
+ private static void addIntervalToImsAlerts(Map alerts, long realIntervals) {
+ for (AlertDesc alert : alerts.values()) {
+ if (!(alert instanceof ImsAlertDesc)) {
+ logger.info("[warn] ignore wrong alert" + alert);
+ } else {
+ ((ImsAlertDesc) alert).hitIntervalMs_$eq(realIntervals);
+ }
+ }
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinksMonitorResourceApplication.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinksMonitorResourceApplication.java
new file mode 100644
index 0000000000..405d94037b
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/LinksMonitorResourceApplication.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app;
+
+import org.apache.linkis.LinkisBaseServerApp;
+
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+@EnableScheduling
+@SpringBootApplication
+public class LinksMonitorResourceApplication {
+
+ public static void main(String[] args) throws ReflectiveOperationException {
+ LinkisBaseServerApp.main(args);
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InsLabelRelationDao.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InsLabelRelationDao.java
new file mode 100644
index 0000000000..3705288e66
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InsLabelRelationDao.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.instance.dao;
+
+import org.apache.linkis.monitor.scan.app.instance.entity.InsPersistenceLabel;
+
+import java.util.List;
+
+public interface InsLabelRelationDao {
+
+ /**
+ * Search labels
+ *
+ * @param instance instance value (http:port)
+ * @return
+ */
+ List searchLabelsByInstance(String instance);
+
+ void dropRelationsByInstance(String instance);
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InstanceInfoDao.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InstanceInfoDao.java
new file mode 100644
index 0000000000..73a7166a5f
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InstanceInfoDao.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.instance.dao;
+
+import org.apache.linkis.common.ServiceInstance;
+import org.apache.linkis.monitor.scan.app.instance.entity.InstanceInfo;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface InstanceInfoDao {
+
+ void removeInstance(ServiceInstance instance);
+
+ List getInstanceInfoByApplicationNameAndHostnameFuzzy(
+ @Param("hostname") String hostname, @Param("applicationName") String applicationName);
+
+ List getInstanceInfoByApplicationNameAndInstanceName(
+ @Param("instanceName") String instanceName, @Param("applicationName") String applicationName);
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InstanceLabelDao.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InstanceLabelDao.java
new file mode 100644
index 0000000000..8f73f0349a
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/dao/InstanceLabelDao.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.instance.dao;
+
+import org.apache.linkis.monitor.scan.app.instance.entity.InsPersistenceLabel;
+
+import java.util.List;
+
+
+public interface InstanceLabelDao {
+ /**
+ * Remove label
+ *
+ * @param label label entity
+ */
+ void remove(InsPersistenceLabel label);
+
+ /**
+ * Remove key -> value map from label id
+ *
+ * @param labelId
+ */
+ void doRemoveKeyValues(Integer labelId);
+
+ void doRemoveKeyValuesBatch(List labelIds);
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InsPersistenceLabel.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InsPersistenceLabel.java
new file mode 100644
index 0000000000..e828328b43
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InsPersistenceLabel.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.instance.entity;
+
+import java.util.Date;
+
+public class InsPersistenceLabel {
+ private Integer id;
+ private int labelValueSize = -1;
+ private String stringValue;
+ private Boolean modifiable = false;
+
+ private String labelKey;
+
+ private String feature;
+
+ private Date updateTime;
+ private Date createTime;
+
+ public Boolean getModifiable() {
+ return modifiable;
+ }
+
+ public void setModifiable(Boolean modifiable) {
+ this.modifiable = modifiable;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public int getLabelValueSize() {
+ return labelValueSize;
+ }
+
+ public void setLabelValueSize(int labelValueSize) {
+ this.labelValueSize = labelValueSize;
+ }
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setStringValue(String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+ public Date getUpdateTime() {
+ return updateTime;
+ }
+
+ public void setUpdateTime(Date updateTime) {
+ this.updateTime = updateTime;
+ }
+
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InsPersistenceLabelValue.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InsPersistenceLabelValue.java
new file mode 100644
index 0000000000..53ab4bd806
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InsPersistenceLabelValue.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.instance.entity;
+
+public class InsPersistenceLabelValue {
+
+ private Integer labelId;
+
+ private String valueKey;
+
+ private String valueContent;
+
+ public InsPersistenceLabelValue() {}
+
+ public InsPersistenceLabelValue(Integer labelId, String key, String content) {
+ this.labelId = labelId;
+ this.valueKey = key;
+ this.valueContent = content;
+ }
+
+ public String getValueKey() {
+ return valueKey;
+ }
+
+ public void setValueKey(String valueKey) {
+ this.valueKey = valueKey;
+ }
+
+ public String getValueContent() {
+ return valueContent;
+ }
+
+ public void setValueContent(String valueContent) {
+ this.valueContent = valueContent;
+ }
+
+ public Integer getLabelId() {
+ return labelId;
+ }
+
+ public void setLabelId(Integer labelId) {
+ this.labelId = labelId;
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InstanceInfo.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InstanceInfo.java
new file mode 100644
index 0000000000..a74cfaabb0
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/instance/entity/InstanceInfo.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.instance.entity;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class InstanceInfo {
+ /** Automatic increment */
+ private Integer id;
+
+ private String applicationName;
+
+ private String instance;
+
+ private Date updateTime;
+
+ private Date createTime;
+ /** Labels related */
+ private List labels = new ArrayList<>();
+
+ public InstanceInfo() {}
+
+ public InstanceInfo(String applicationName, String instance) {
+ this.applicationName = applicationName;
+ this.instance = instance;
+ }
+
+ public List getLabels() {
+ return labels;
+ }
+
+ public void setLabels(List labels) {
+ this.labels = labels;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getApplicationName() {
+ return applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ public String getInstance() {
+ return instance;
+ }
+
+ public void setInstance(String instance) {
+ this.instance = instance;
+ }
+
+ public Date getUpdateTime() {
+ return updateTime;
+ }
+
+ public void setUpdateTime(Date updateTime) {
+ this.updateTime = updateTime;
+ }
+
+ public Date getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Date createTime) {
+ this.createTime = createTime;
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/QueryUtils.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/QueryUtils.java
new file mode 100644
index 0000000000..799eae89a6
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/QueryUtils.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.jobhistory;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class QueryUtils {
+
+ private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+
+ public static String dateToString(Date date) {
+ return dateFormat.format(date);
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/dao/JobHistoryMapper.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/dao/JobHistoryMapper.java
new file mode 100644
index 0000000000..b3774860af
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/dao/JobHistoryMapper.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.jobhistory.dao;
+
+import org.apache.linkis.monitor.scan.app.jobhistory.entity.JobHistory;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+
+public interface JobHistoryMapper {
+
+ List selectJobHistory(JobHistory jobReq);
+
+ List search(
+ @Param("id") Long id,
+ @Param("umUser") String username,
+ @Param("status") List status,
+ @Param("startDate") Date startDate,
+ @Param("endDate") Date endDate,
+ @Param("engineType") String engineType);
+
+ void updateIncompleteJobStatusGivenIDList(
+ @Param("idList") List idList, @Param("targetStatus") String targetStatus);
+
+ void updateJobStatusForInstanceGivenStatusList(
+ @Param("instanceName") String instanceName,
+ @Param("statusList") List statusList,
+ @Param("targetStatus") String targetStatus,
+ @Param("startDate") Date startDate);
+
+ List searchByCache(
+ @Param("id") Long id,
+ @Param("umUser") String username,
+ @Param("status") List status,
+ @Param("startDate") Date startDate,
+ @Param("endDate") Date endDate,
+ @Param("engineType") String engineType);
+
+ List searchByCacheAndUpdateTime(
+ @Param("id") Long id,
+ @Param("umUser") String username,
+ @Param("status") List status,
+ @Param("startDate") Date startDate,
+ @Param("endDate") Date endDate,
+ @Param("engineType") String engineType);
+
+ Long selectIdByHalfDay(@Param("id") long beginId);
+
+ Long selectMaxId();
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/entity/JobHistory.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/entity/JobHistory.java
new file mode 100644
index 0000000000..937eff410b
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/entity/JobHistory.java
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.jobhistory.entity;
+
+import org.apache.linkis.monitor.scan.app.jobhistory.QueryUtils;
+
+import java.util.Date;
+
+public class JobHistory {
+
+ private Long id;
+
+ private String jobReqId;
+
+ private String submitUser;
+
+ private String executeUser;
+
+ private String source;
+
+ private String labels;
+
+ private String params;
+
+ private String progress;
+
+ private String status;
+
+ private String logPath;
+
+ private Integer errorCode;
+
+ private String errorDesc;
+
+ private Date createdTime;
+
+ private Date updatedTime;
+
+ private String updateTimeMills;
+
+ private String instances;
+
+ private String metrics;
+
+ private String engineType;
+
+ private String executionCode;
+
+ private String observeInfo;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getJobReqId() {
+ return jobReqId;
+ }
+
+ public void setJobReqId(String jobReqId) {
+ this.jobReqId = jobReqId;
+ }
+
+ public String getSubmitUser() {
+ return submitUser;
+ }
+
+ public void setSubmitUser(String submitUser) {
+ this.submitUser = submitUser;
+ }
+
+ public String getExecuteUser() {
+ return executeUser;
+ }
+
+ public void setExecuteUser(String executeUser) {
+ this.executeUser = executeUser;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public String getLabels() {
+ return labels;
+ }
+
+ public void setLabels(String labels) {
+ this.labels = labels;
+ }
+
+ public String getParams() {
+ return params;
+ }
+
+ public void setParams(String params) {
+ this.params = params;
+ }
+
+ public String getProgress() {
+ return progress;
+ }
+
+ public void setProgress(String progress) {
+ this.progress = progress;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getLogPath() {
+ return logPath;
+ }
+
+ public void setLogPath(String logPath) {
+ this.logPath = logPath;
+ }
+
+ public Integer getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(Integer errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorDesc() {
+ return errorDesc;
+ }
+
+ public void setErrorDesc(String errorDesc) {
+ this.errorDesc = errorDesc;
+ }
+
+ public Date getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Date createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Date getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Date updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public String getInstances() {
+ return instances;
+ }
+
+ public void setInstances(String instances) {
+ this.instances = instances;
+ }
+
+ public String getMetrics() {
+ return metrics;
+ }
+
+ public void setMetrics(String metrics) {
+ this.metrics = metrics;
+ }
+
+ public String getEngineType() {
+ return engineType;
+ }
+
+ public void setEngineType(String engineType) {
+ this.engineType = engineType;
+ }
+
+ public String getExecutionCode() {
+ return executionCode;
+ }
+
+ public void setExecutionCode(String executionCode) {
+ this.executionCode = executionCode;
+ }
+
+ public String getUpdateTimeMills() {
+ return QueryUtils.dateToString(getUpdatedTime());
+ }
+
+ public String getObserveInfo() {
+ return observeInfo;
+ }
+
+ public void setObserveInfo(String observeInfo) {
+ this.observeInfo = observeInfo;
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/exception/AnomalyScannerException.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/exception/AnomalyScannerException.java
new file mode 100644
index 0000000000..0e3dd10d6b
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/exception/AnomalyScannerException.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.jobhistory.exception;
+
+import org.apache.linkis.common.exception.ErrorException;
+import org.apache.linkis.common.exception.ExceptionLevel;
+
+public class AnomalyScannerException extends ErrorException {
+ public AnomalyScannerException(int errCode, String desc) {
+ super(errCode, desc);
+ }
+
+ public AnomalyScannerException(
+ int errCode, String desc, String ip, int port, String serviceKind) {
+ super(errCode, desc, ip, port, serviceKind);
+ }
+
+ @Override
+ public ExceptionLevel getLevel() {
+ return super.getLevel();
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/exception/DirtyDataCleanException.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/exception/DirtyDataCleanException.java
new file mode 100644
index 0000000000..93b6065f75
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/jobhistory/exception/DirtyDataCleanException.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.jobhistory.exception;
+
+import org.apache.linkis.common.exception.ErrorException;
+import org.apache.linkis.common.exception.ExceptionLevel;
+
+public class DirtyDataCleanException extends ErrorException {
+ public DirtyDataCleanException(int errCode, String desc) {
+ super(errCode, desc);
+ }
+
+ public DirtyDataCleanException(
+ int errCode, String desc, String ip, int port, String serviceKind) {
+ super(errCode, desc, ip, port, serviceKind);
+ }
+
+ @Override
+ public ExceptionLevel getLevel() {
+ return super.getLevel();
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/ListenerConfig.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/ListenerConfig.java
new file mode 100644
index 0000000000..fae16b63a3
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/ListenerConfig.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.config;
+
+import org.apache.linkis.monitor.scan.app.monitor.until.HttpsUntils;
+import org.apache.linkis.monitor.scan.app.monitor.until.ThreadUtils;
+import org.apache.linkis.monitor.scan.utils.log.LogUtils;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.context.event.EventListener;
+
+import java.io.IOException;
+
+import org.slf4j.Logger;
+
+@Configuration
+public class ListenerConfig {
+
+ private static final Logger logger = LogUtils.stdOutLogger();
+
+ @EventListener
+ private void shutdownEntrance(ContextClosedEvent event) {
+ try {
+ ThreadUtils.executors.shutdown();
+ HttpsUntils.client.close();
+ } catch (IOException e) {
+ logger.error("ListenerConfig error msg {}", e.getMessage());
+ }
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/MonitorConfig.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/MonitorConfig.java
new file mode 100644
index 0000000000..fab9a5cbe7
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/MonitorConfig.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.config;
+
+import org.apache.linkis.common.conf.CommonVars;
+import org.apache.linkis.common.conf.Configuration;
+
+public class MonitorConfig {
+
+ public static final String shellPath = Configuration.getLinkisHome() + "/admin/";
+
+ public static final CommonVars GATEWAY_URL = CommonVars.apply("wds.linkis.gateway.url");
+
+ public static final CommonVars USER_MODE_TIMEOUT =
+ CommonVars.apply("linkis.monitor.user.timeOut", 300);
+ public static final CommonVars USER_MODE_AUTHTOKEN =
+ CommonVars.apply("linkis.monitor.user.authToken","VALIDATOR-AUTH");
+ public static final CommonVars USER_MODE_ENGINE =
+ CommonVars.apply("linkis.monitor.user.enginelist","[]");
+
+ public static final CommonVars ECM_TASK_MAJOR =
+ CommonVars.apply("linkis.monitor.ecmResourceTask.major", 0.03);
+ public static final CommonVars ECM_TASK_MINOR =
+ CommonVars.apply("linkis.monitor.ecmResourceTask.minor", 0.1);
+ public static final CommonVars ECM_TASK_IMURL =
+ CommonVars.apply("linkis.monitor.metrics.imsUrl");
+ public static final CommonVars ECM_TASK_USER_AUTHKEY =
+ CommonVars.apply("linkis.monitor.metrics.userAuthKey");
+
+ public static final CommonVars JOB_HISTORY_TIME_EXCEED =
+ CommonVars.apply("linkis.monitor.jobhistory.id.timeExceed",0L);
+
+ public static final CommonVars ENTRANCE_TASK_USERTOTAL =
+ CommonVars.apply("linkis.monitor.entranceTask.userTotalTask", 1000);
+ public static final CommonVars ENTRANCE_TASK_TOTAL_MAJOR =
+ CommonVars.apply("linkis.monitor.entranceTask.linkisTotalTaskMajor", 50000);
+ public static final CommonVars ENTRANCE_TASK_TOTAL_MINOR =
+ CommonVars.apply("linkis.monitor.entranceTask.linkisTotalTaskMinor", 10000);
+ public static final CommonVars ENTRANCE_TASK_USERLIST =
+ CommonVars.apply("linkis.monitor.entranceTask.userlist","[]");
+
+ public static final CommonVars SCHEDULED_CONFIG_NUM =
+ CommonVars.apply("linkis.monitor.scheduled.pool.cores.num", 10);
+
+ public static final CommonVars SHELL_TIMEOUT =
+ CommonVars.apply("linkis.monitor.shell.time.out.minute", 30);
+
+ public static final CommonVars USER_MODE_INTERFACE_TIMEOUT =
+ CommonVars.apply("linkis.monitor.user.mode.time.out", 30*1000);
+
+ public static final CommonVars CHATBOT_KEY_ID = CommonVars.apply("linkis.monitor.chatbot.key.id","23e6afad1b78a0c5eed67e4d24de7063");
+ public static final CommonVars CHATBOT_TYPE = CommonVars.apply("linkis.monitor.chatbot.type","text");
+ public static final CommonVars CHATBOT_SERVICE_NAME= CommonVars.apply("linkis.monitor.chatbot.serviceName","大数据生产助手(BDP_PRD)");
+ public static final CommonVars CHATBOT_URL= CommonVars.apply("linkis.monitor.chatbot.url","http://172.21.3.43:1377/pros-chatbot/yuanfang/sendEMsg");
+ public static final CommonVars SOLUTION_URL = CommonVars.apply("linkis.monitor.jobhistory.solution.url", "http://kn.dss.weoa.com/linkis/qa");
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/ScheduledConfig.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/ScheduledConfig.java
new file mode 100644
index 0000000000..30495a87e1
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/config/ScheduledConfig.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.SchedulingConfigurer;
+import org.springframework.scheduling.config.ScheduledTaskRegistrar;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+@Configuration
+public class ScheduledConfig implements SchedulingConfigurer {
+ @Bean
+ public Executor taskExecutor() {
+ return Executors.newScheduledThreadPool(MonitorConfig.SCHEDULED_CONFIG_NUM.getValue());
+ }
+
+ @Override
+ public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
+ scheduledTaskRegistrar.setScheduler(taskExecutor());
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/ChatbotEntity.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/ChatbotEntity.java
new file mode 100644
index 0000000000..3cf288adbb
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/ChatbotEntity.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.entity;
+
+import org.apache.linkis.monitor.scan.app.monitor.config.MonitorConfig;
+
+public class ChatbotEntity {
+ private String keyid;
+ private String content;
+ private String type;
+ private String userName;
+ private String serviceName;
+
+ public ChatbotEntity(String content, String userName) {
+ this.keyid = MonitorConfig.CHATBOT_KEY_ID.getValue();
+ this.content = content;
+ this.type = MonitorConfig.CHATBOT_TYPE.getValue();
+ this.userName = userName;
+ this.serviceName = MonitorConfig.CHATBOT_SERVICE_NAME.getValue();
+ }
+
+ public String getKeyid() {
+ return keyid;
+ }
+
+ public void setKeyid(String keyid) {
+ this.keyid = keyid;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceNameuserName) {
+ this.serviceName = serviceNameuserName;
+ }
+
+ @Override
+ public String toString() {
+ return "ChatbotEntity{" +
+ "keyid='" + keyid + '\'' +
+ ", content='" + content + '\'' +
+ ", type='" + type + '\'' +
+ ", userName='" + userName + '\'' +
+ ", serviceName='" + serviceName + '\'' +
+ '}';
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/EngineEntity.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/EngineEntity.java
new file mode 100644
index 0000000000..650fa081cc
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/EngineEntity.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.entity;
+
+import java.io.Serializable;
+
+public class EngineEntity implements Serializable {
+
+ private String engineType;
+
+ private String code;
+
+ private String runType;
+
+ public String getEngineType() {
+ return engineType;
+ }
+
+ public void setEngineType(String engineType) {
+ this.engineType = engineType;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getRunType() {
+ return runType;
+ }
+
+ public void setRunType(String runType) {
+ this.runType = runType;
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/EntranceEntity.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/EntranceEntity.java
new file mode 100644
index 0000000000..6fa9441474
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/EntranceEntity.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.entity;
+
+import java.io.Serializable;
+
+public class EntranceEntity implements Serializable {
+
+ private Integer runningtasks;
+
+ private Integer queuedtasks;
+
+ private String alteruser;
+
+ private String username;
+
+ public Integer getQueuedtasks() {
+ return queuedtasks;
+ }
+
+ public void setQueuedtasks(Integer queuedtasks) {
+ this.queuedtasks = queuedtasks;
+ }
+
+ public String getAlteruser() {
+ return alteruser;
+ }
+
+ public void setAlteruser(String alteruser) {
+ this.alteruser = alteruser;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public Integer getRunningtasks() {
+ return runningtasks;
+ }
+
+ public void setRunningtasks(Integer runningtasks) {
+ this.runningtasks = runningtasks;
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/IndexEntity.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/IndexEntity.java
new file mode 100644
index 0000000000..fbea8886e8
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/entity/IndexEntity.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.entity;
+
+import org.apache.linkis.monitor.scan.constants.Constants;
+
+public class IndexEntity {
+
+ private final String subsystemId = Constants.ALERT_SUB_SYSTEM_ID();
+ private String interfaceName;
+ private String attrGroup;
+ private String attrName;
+ private String hostIp;
+ private String metricValue;
+
+ public String getSubsystemId() {
+ return subsystemId;
+ }
+
+ public String getInterfaceName() {
+ return interfaceName;
+ }
+
+ public void setInterfaceName(String interfaceName) {
+ this.interfaceName = interfaceName;
+ }
+
+ public String getAttrGroup() {
+ return attrGroup;
+ }
+
+ public void setAttrGroup(String attrGroup) {
+ this.attrGroup = attrGroup;
+ }
+
+ public String getAttrName() {
+ return attrName;
+ }
+
+ public void setAttrName(String attrName) {
+ this.attrName = attrName;
+ }
+
+ public String getHostIp() {
+ return hostIp;
+ }
+
+ public void setHostIp(String hostIp) {
+ this.hostIp = hostIp;
+ }
+
+ public String getMetricValue() {
+ return metricValue;
+ }
+
+ public void setMetricValue(String metricValue) {
+ this.metricValue = metricValue;
+ }
+
+ public IndexEntity() {}
+
+ public IndexEntity(
+ String interfaceName, String attrGroup, String attrName, String hostIp, String metricValue) {
+ this.interfaceName = interfaceName;
+ this.attrGroup = attrGroup;
+ this.attrName = attrName;
+ this.hostIp = hostIp;
+ this.metricValue = metricValue;
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/BmlClear.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/BmlClear.java
new file mode 100644
index 0000000000..75d415ac0d
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/BmlClear.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.scheduled;
+
+import org.apache.linkis.bml.cleaner.service.CleanerService;
+import org.apache.linkis.monitor.scan.utils.log.LogUtils;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+import org.slf4j.Logger;
+
+
+@Component
+@PropertySource(value = "classpath:linkis-et-monitor.properties", encoding = "UTF-8")
+public class BmlClear {
+
+ private static final Logger logger = LogUtils.stdOutLogger();
+
+ @Autowired private CleanerService cleanerServices;
+
+ @Scheduled(cron = "${linkis.monitor.bml.clear.historyVersion.cron}")
+ public void jobHistoryScanTask() {
+ logger.info("start to clear bml history version");
+ cleanerServices.run();
+ logger.info("end to clear bml history version");
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/EcRecordClear.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/EcRecordClear.java
new file mode 100644
index 0000000000..dced6117b1
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/EcRecordClear.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.scheduled;
+
+import org.apache.linkis.monitor.scan.app.monitor.config.MonitorConfig;
+import org.apache.linkis.monitor.scan.app.monitor.until.ThreadUtils;
+import org.apache.linkis.monitor.scan.utils.log.LogUtils;
+
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Logger;
+
+/***
+ * Task: clean up linkis_cg_ec_resource_info_record data
+ */
+@Component
+@PropertySource(value = "classpath:linkis-et-monitor.properties", encoding = "UTF-8")
+public class EcRecordClear {
+
+ private static final Logger logger = LogUtils.stdOutLogger();
+
+ @Scheduled(cron = "${linkis.monitor.clear.ecRecord.cron}")
+ public void ecRecordClear() {
+ logger.info("Start to clear_ec_record shell");
+ List cmdlist = new ArrayList<>();
+ cmdlist.add("sh");
+ cmdlist.add(MonitorConfig.shellPath + "clear_ec_record.sh");
+ logger.info("clear_ec_record shell command {}", cmdlist);
+ String exec = ThreadUtils.run(cmdlist, "clear_ec_record.sh");
+ logger.info("shell log {}", exec);
+ logger.info("End to clear_ec_record shell ");
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/JobHistoryClear.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/JobHistoryClear.java
new file mode 100644
index 0000000000..4880a600cc
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/JobHistoryClear.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.scheduled;
+
+import org.apache.linkis.monitor.scan.app.monitor.config.MonitorConfig;
+import org.apache.linkis.monitor.scan.app.monitor.until.ThreadUtils;
+import org.apache.linkis.monitor.scan.utils.log.LogUtils;
+
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Logger;
+
+/***
+ * Task: clean up linkis_ps_job_history_group_history data
+ */
+@Component
+@PropertySource(value = "classpath:linkis-et-monitor.properties", encoding = "UTF-8")
+public class JobHistoryClear {
+
+ private static final Logger logger = LogUtils.stdOutLogger();
+
+ @Scheduled(cron = "${linkis.monitor.clear.historyTask.cron}")
+ public void historyTaskClear() {
+ logger.info("Start to clear_history_task shell");
+ List cmdlist = new ArrayList<>();
+ cmdlist.add("sh");
+ cmdlist.add(MonitorConfig.shellPath + "clear_history_task.sh");
+ logger.info("clear_history_task shell command {}", cmdlist);
+ String exec = ThreadUtils.run(cmdlist, "clear_history_task.sh");
+ logger.info("shell log {}", exec);
+ logger.info("End to clear_history_task shell ");
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/JobHistoryMonitor.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/JobHistoryMonitor.java
new file mode 100644
index 0000000000..01873a988b
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/JobHistoryMonitor.java
@@ -0,0 +1,264 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.scheduled;
+
+import org.apache.linkis.monitor.scan.app.factory.MapperFactory;
+import org.apache.linkis.monitor.scan.app.jobhistory.JobHistoryDataFetcher;
+import org.apache.linkis.monitor.scan.app.jobhistory.errorcode.JobHistoryErrCodeRule;
+import org.apache.linkis.monitor.scan.app.jobhistory.errorcode.JobHistoryErrorCodeAlertSender;
+import org.apache.linkis.monitor.scan.app.jobhistory.jobtime.JobTimeExceedAlertSender;
+import org.apache.linkis.monitor.scan.app.jobhistory.jobtime.JobTimeExceedRule;
+import org.apache.linkis.monitor.scan.app.jobhistory.labels.JobHistoryLabelsAlertSender;
+import org.apache.linkis.monitor.scan.app.jobhistory.labels.JobHistoryLabelsRule;
+import org.apache.linkis.monitor.scan.app.jobhistory.runtime.CommonRunTimeAlertSender;
+import org.apache.linkis.monitor.scan.app.jobhistory.runtime.CommonJobRunTimeRule;
+import org.apache.linkis.monitor.scan.app.jobhistory.runtime.JobHistoryRunTimeAlertSender;
+import org.apache.linkis.monitor.scan.app.jobhistory.runtime.JobHistoryRunTimeRule;
+import org.apache.linkis.monitor.scan.app.monitor.config.MonitorConfig;
+import org.apache.linkis.monitor.scan.app.monitor.until.CacheUtils;
+import org.apache.linkis.monitor.scan.constants.Constants;
+import org.apache.linkis.monitor.scan.core.pac.DataFetcher;
+import org.apache.linkis.monitor.scan.core.scanner.AnomalyScanner;
+import org.apache.linkis.monitor.scan.core.scanner.DefaultScanner;
+import org.apache.linkis.monitor.scan.utils.alert.AlertDesc;
+import org.apache.linkis.monitor.scan.utils.alert.ims.ImsAlertDesc;
+import org.apache.linkis.monitor.scan.utils.alert.ims.JobHistoryScanImsAlertPropFileParserUtils;
+import org.apache.linkis.monitor.scan.utils.alert.ims.UserLabelAlertUtils;
+import org.apache.linkis.monitor.scan.utils.log.LogUtils;
+
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+import org.slf4j.Logger;
+
+/***
+ * jobHistory monitor
+ * 1.errorCode: Monitor the error code
+ * 2.userLabel: tenant label monitoring, scan the execution data within the first 20 minutes, and judge the labels field of the data
+ * 3.jobResultRunTime: Scan the execution data within the first 20 minutes, and judge the completed tasks. If the parm field in the jobhistory contains (task.notification.conditions) and the result of executing the task is (Succeed, Failed, Canceled, Timeout, ALL) any one of them, an alarm is triggered and the result of the job is that it has ended. All three are indispensable
+ * 4.jobResultRunTimeForDSS: Scan the execution data within the first 20 minutes, scan the tasks that have been marked for notification, if the task has ended, a notification will be initiated
+ * 5.jobHistoryUnfinishedScan: monitor the status of the execution task, scan the data outside 12 hours and within 24 hours
+ */
+@Component
+@PropertySource(value = "classpath:linkis-et-monitor.properties", encoding = "UTF-8")
+public class JobHistoryMonitor {
+
+ private static final Logger logger = LogUtils.stdOutLogger();
+ private static final long backtrackNum = 1000000L;
+
+ /**
+ * Scan tasks completed within 20 minutes
+ */
+ @Scheduled(cron = "0 0/10 * * * ?")
+ public void jobHistoryFinishedScan() {
+ long intervalMs = 20 * 60 * 1000; // 20分钟
+ long maxIntervalMs = Constants.MAX_INTERVALS_SECONDS() * 1000;
+ long endTime = System.currentTimeMillis();
+ long startTime = endTime - intervalMs;
+ long realIntervals = endTime - startTime < maxIntervalMs ? endTime - startTime : maxIntervalMs;
+ AnomalyScanner scanner = new DefaultScanner();
+ boolean shouldStart = false;
+ long id;
+ if (null == CacheUtils.cacheBuilder.getIfPresent("jobHistoryId")) {
+ //20230206:新增获取最大值-100W 作为初始id进行查询,防止慢查询
+ long maxId = MapperFactory.getJobHistoryMapper().selectMaxId();
+ long beginId = 0L;
+ if (maxId > backtrackNum) {
+ beginId = maxId - backtrackNum;
+ }
+ id = MapperFactory.getJobHistoryMapper().selectIdByHalfDay(beginId);
+ CacheUtils.cacheBuilder.put("jobHistoryId", id);
+ } else {
+ id = CacheUtils.cacheBuilder.getIfPresent("jobHistoryId");
+ }
+ List fetchers = generateFetchersfortime(startTime, endTime, id, "updated_time");
+ if (fetchers == null) {
+ logger.warn("generated 0 dataFetchers, plz check input");
+ return;
+ }
+ // errorCode
+ try {
+ Map errorCodeAlerts = JobHistoryScanImsAlertPropFileParserUtils.getAlerts(Constants.SCAN_PREFIX_ERRORCODE());
+
+ if (errorCodeAlerts == null || errorCodeAlerts.size() == 0) {
+ logger.info("[INFO] Loaded 0 errorcode alert from alert-rule properties file.");
+ } else {
+ logger.info(
+ "[INFO] Loaded {} errorcode alert from alert-rules properties file.",
+ errorCodeAlerts.size());
+ shouldStart = true;
+ addIntervalToImsAlerts(errorCodeAlerts, realIntervals);
+ JobHistoryErrCodeRule jobHistoryErrCodeRule =
+ new JobHistoryErrCodeRule(
+ errorCodeAlerts.keySet(), new JobHistoryErrorCodeAlertSender(errorCodeAlerts));
+ scanner.addScanRule(jobHistoryErrCodeRule);
+ }
+ } catch (Exception e) {
+ logger.warn("Jobhistory Monitor ErrorCode Faily: "+ e.getMessage());
+ }
+ // userLabel
+ try {
+ Map userLabelAlerts =
+ UserLabelAlertUtils.getAlerts(Constants.USER_LABEL_MONITOR(), "");
+ if (userLabelAlerts == null || userLabelAlerts.size() == 0) {
+ logger.info("[INFO] Loaded 0 alerts userLabel alert-rule from alert properties file.");
+ } else {
+ logger.info(
+ "[INFO] Loaded {} alerts userLabel alert-rules from alert properties file.",
+ userLabelAlerts.size());
+ shouldStart = true;
+ JobHistoryLabelsRule jobHistoryLabelsRule =
+ new JobHistoryLabelsRule(new JobHistoryLabelsAlertSender());
+ scanner.addScanRule(jobHistoryLabelsRule);
+ }
+ } catch (Exception e) {
+ logger.warn("Jobhistory Monitor UserLabel Faily: "+ e.getMessage());
+ }
+ // jobResultRunTime
+ try {
+ Map jobResultAlerts =
+ JobHistoryScanImsAlertPropFileParserUtils.getAlerts(Constants.SCAN_PREFIX_ERRORCODE());
+ if (jobResultAlerts == null || jobResultAlerts.size() == 0) {
+ logger.info("[INFO] Loaded 0 jobResult alert from alert-rule properties file.");
+ } else {
+ logger.info(
+ "[INFO] Loaded {} alerts jobResult alert-rules from alert properties file.",
+ jobResultAlerts.size());
+ shouldStart = true;
+ JobHistoryRunTimeRule jobHistoryRunTimeRule =
+ new JobHistoryRunTimeRule(new JobHistoryRunTimeAlertSender());
+ scanner.addScanRule(jobHistoryRunTimeRule);
+ }
+ } catch (Exception e) {
+ logger.warn("Jobhistory Monitor JobResultRunTime Faily: "+ e.getMessage());
+ }
+ // jobResultRunTimeForDSS
+ try {
+ Map dssJobResultAlerts =
+ JobHistoryScanImsAlertPropFileParserUtils.getAlerts(Constants.SCAN_PREFIX_ERRORCODE());
+ if (dssJobResultAlerts == null || dssJobResultAlerts.size() == 0) {
+ logger.info("[INFO] Loaded 0 jobResult alert from alert-rule properties file.");
+ } else {
+ logger.info(
+ "[INFO] Loaded {} alerts jobResult alert-rules from alert properties file.",
+ dssJobResultAlerts.size());
+ shouldStart = true;
+
+ CommonJobRunTimeRule commonJobRunTimeRule =
+ new CommonJobRunTimeRule(new CommonRunTimeAlertSender());
+ scanner.addScanRule(commonJobRunTimeRule);
+ }
+ } catch (Exception e) {
+ logger.warn("Jobhistory JobResultRunTimeForDSS ErrorCode Faily: "+ e.getMessage());
+ }
+ run(scanner, fetchers, shouldStart);
+ }
+
+ /***
+ * Whether scanning data within 12 hours has timed out
+ */
+ @Scheduled(cron = "${linkis.monitor.jobHistory.ScanTask.cron}")
+ public void jobHistoryUnfinishedScan() {
+ long id =
+ Optional.ofNullable(CacheUtils.cacheBuilder.getIfPresent("jobhistoryScan"))
+ .orElse(MonitorConfig.JOB_HISTORY_TIME_EXCEED.getValue());
+ long intervalMs = Constants.SCAN_INTERVALS_SECONDS() * 1000;
+ long maxIntervalMs = Constants.MAX_INTERVALS_SECONDS() * 1000;
+ long endTime = System.currentTimeMillis();
+ long startTime = endTime - intervalMs;
+ long realIntervals = endTime - startTime < maxIntervalMs ? endTime - startTime : maxIntervalMs;
+ AnomalyScanner scanner = new DefaultScanner();
+ boolean shouldStart = false;
+ List fetchers = generateFetchers(startTime, endTime, maxIntervalMs, id, "created_time");
+ if (fetchers == null) {
+ logger.warn("generated 0 dataFetchers, plz check input");
+ return;
+ }
+ Map jobTimeAlerts =
+ JobHistoryScanImsAlertPropFileParserUtils.getAlerts(
+ Constants.SCAN_PREFIX_UNFINISHED_JOBTIME_EXCEED_SEC());
+ if (jobTimeAlerts == null || jobTimeAlerts.size() == 0) {
+ logger.info("[INFO] Loaded 0 alerts jobtime alert-rule from alert properties file.");
+ } else {
+ logger.info(
+ "[INFO] Loaded {} alerts jobtime alert-rules from alert properties file.",
+ jobTimeAlerts.size());
+ shouldStart = true;
+ addIntervalToImsAlerts(jobTimeAlerts, realIntervals);
+ JobTimeExceedRule jobTimeExceedRule =
+ new JobTimeExceedRule(
+ jobTimeAlerts.keySet(), new JobTimeExceedAlertSender(jobTimeAlerts));
+ scanner.addScanRule(jobTimeExceedRule);
+ }
+ run(scanner, fetchers, shouldStart);
+ }
+
+ public static void run(AnomalyScanner scanner, List fetchers, Boolean shouldStart) {
+ if (shouldStart) {
+ scanner.addDataFetchers(fetchers);
+ scanner.run();
+ // scanner.shutdown(); // wait all alert to be send
+ }
+ }
+
+ private static List generateFetchers(
+ long startTime, long endTime, long maxIntervalMs, long id, String timeType) {
+ List ret = new ArrayList<>();
+ long pe = endTime;
+ long ps;
+ while (pe > startTime) {
+ ps = pe - maxIntervalMs > startTime ? pe - maxIntervalMs : startTime;
+ String[] fetcherArgs =
+ new String[]{String.valueOf(ps), String.valueOf(pe), String.valueOf(id), timeType};
+ ret.add(new JobHistoryDataFetcher(fetcherArgs, MapperFactory.getJobHistoryMapper()));
+ logger.info(
+ "Generated dataFetcher for startTime: "
+ + new Date(ps).toString()
+ + ". EndTime: "
+ + new Date(pe).toString());
+ pe = pe - maxIntervalMs;
+ }
+ return ret;
+ }
+
+ private static List generateFetchersfortime(long startTime, long endTime, long id, String timeType) {
+ List fetchers = new ArrayList<>();
+ String[] fetcherArgs =
+ new String[]{String.valueOf(startTime), String.valueOf(endTime), String.valueOf(id), timeType};
+ fetchers.add(new JobHistoryDataFetcher(fetcherArgs, MapperFactory.getJobHistoryMapper()));
+ logger.info(
+ "Generated dataFetcher for startTime: "
+ + new Date(startTime).toString()
+ + ". EndTime: "
+ + new Date(endTime).toString());
+ return fetchers;
+ }
+
+ private static void addIntervalToImsAlerts(Map alerts, long realIntervals) {
+ for (AlertDesc alert : alerts.values()) {
+ if (!(alert instanceof ImsAlertDesc)) {
+ logger.info("[warn] ignore wrong alert" + alert);
+ } else {
+ ((ImsAlertDesc) alert).hitIntervalMs_$eq(realIntervals);
+ }
+ }
+ }
+}
diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/ResourceMonitor.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/ResourceMonitor.java
new file mode 100644
index 0000000000..b7066ba420
--- /dev/null
+++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scan/app/monitor/scheduled/ResourceMonitor.java
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.monitor.scan.app.monitor.scheduled;
+
+import org.apache.linkis.common.utils.ByteTimeUtils;
+import org.apache.linkis.monitor.scan.app.monitor.config.MonitorConfig;
+import org.apache.linkis.monitor.scan.app.monitor.entity.IndexEntity;
+import org.apache.linkis.monitor.scan.app.monitor.until.HttpsUntils;
+import org.apache.linkis.monitor.scan.constants.Constants;
+import org.apache.linkis.monitor.scan.utils.alert.AlertDesc;
+import org.apache.linkis.monitor.scan.utils.alert.ims.MonitorAlertUtils;
+import org.apache.linkis.monitor.scan.utils.alert.ims.PooledImsAlertUtils;
+
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/***
+ * Monitor the usage of ECM resources for monitoring and metrics reporting
+ */
+@Component
+@PropertySource(value = "classpath:linkis-et-monitor.properties", encoding = "UTF-8")
+public class ResourceMonitor {
+
+ private static final Logger logger = LoggerFactory.getLogger(ResourceMonitor.class);
+
+ @Scheduled(cron = "${linkis.monitor.ecmResourceTask.cron}")
+ public void ecmResourceTask() {
+ Map resultmap = null;
+ AtomicReference tenant = new AtomicReference<>("租户标签:公共资源");
+ AtomicReference totalMemory = new AtomicReference<>(0.0);
+ AtomicReference totalInstance = new AtomicReference<>(0.0);
+ AtomicReference totalCores = new AtomicReference<>(0.0);
+ try {
+ resultmap = HttpsUntils.sendHttp(null, null);
+ logger.info("ResourceMonitor response {}:", resultmap);
+ } catch (IOException e) {
+ logger.warn("failed to get EcmResource data");
+ }
+ // got interface data
+ Map>> data = MapUtils.getMap(resultmap, "data");
+ List