This is an automated email from the ASF dual-hosted git repository.
casion pushed a commit to branch dev-1.3.2
in repository https://gitbox.apache.org/repos/asf/linkis.git
The following commit(s) were added to refs/heads/dev-1.3.2 by this push:
new e9c538c12 [feature]New alarm button of management console (#3869)
e9c538c12 is described below
commit e9c538c12f72e13f5c5d7fad6c0659f228eef9d3
Author: huangKai-2323 <[email protected]>
AuthorDate: Thu Dec 29 14:00:28 2022 +0800
[feature]New alarm button of management console (#3869)
---
.../linkis/protocol/constants/TaskConstant.java | 4 +
.../org/apache/linkis/ujes/client/UJESClient.scala | 8 ++
.../client/request/JobDeleteObserveAction.scala | 54 +++++++++
.../ujes/client/request/JobObserveAction.scala | 97 ++++++++++++++++
.../client/response/JobDeleteObserveResult.scala | 23 ++++
.../ujes/client/response/JobObserveResult.scala | 28 +++++
.../linkis/ujes/client/JobObserveActionTest.scala | 60 ++++++++++
.../governance/common/entity/job/JobRequest.java | 10 ++
.../db/upgrade/1.3.2_schema/mysql/linkis_dml.sql | 3 +
.../linkis/jobhistory/dao/JobHistoryMapper.java | 2 +
.../jobhistory/dao/impl/JobHistoryMapper.xml | 9 +-
.../linkis/jobhistory/entity/JobHistory.java | 10 ++
.../apache/linkis/jobhistory/entity/MonitorVO.java | 90 +++++++++++++++
.../linkis/jobhistory/entity/QueryTaskVO.java | 10 ++
.../restful/api/JobhistorySettingApi.java | 126 +++++++++++++++++++++
.../jobhistory/conf/JobhistoryConfiguration.scala | 3 +
.../jobhistory/conversions/TaskConversions.scala | 5 +
.../jobhistory/service/JobHistoryQueryService.java | 2 +
.../service/impl/JobHistoryQueryServiceImpl.scala | 4 +
.../jobhistory/dao/JobHistoryMapperTest.java | 1 +
.../service/JobHistoryDetailQueryServiceTest.java | 1 +
.../service/JobHistoryQueryServiceTest.java | 1 +
.../src/test/resources/create.sql | 1 +
23 files changed, 550 insertions(+), 2 deletions(-)
diff --git
a/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/constants/TaskConstant.java
b/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/constants/TaskConstant.java
index f0829be0b..2844fce46 100644
---
a/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/constants/TaskConstant.java
+++
b/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/constants/TaskConstant.java
@@ -73,4 +73,8 @@ public interface TaskConstant {
String CODE = "code";
String REQUEST_IP = "requestIP";
+ String MONITOR_LEVEL = "monitorLevel";
+ String RECEIVER = "receiver";
+ String SUB_SYSTEM_ID = "subSystemId";
+ String EXTRA = "extra";
}
diff --git
a/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/UJESClient.scala
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/UJESClient.scala
index f7241144b..6431c47eb 100644
---
a/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/UJESClient.scala
+++
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/UJESClient.scala
@@ -133,6 +133,14 @@ abstract class UJESClient extends Closeable {
executeUJESJob(emsListAction).asInstanceOf[EmsListResult]
}
+ def addJobObserve(jobObserveAction: JobObserveAction): JobObserveResult = {
+ executeUJESJob(jobObserveAction).asInstanceOf[JobObserveResult]
+ }
+
+ def deleteJobObserve(jobDeleteObserveAction: JobDeleteObserveAction):
JobDeleteObserveResult = {
+ executeUJESJob(jobDeleteObserveAction).asInstanceOf[JobDeleteObserveResult]
+ }
+
}
object UJESClient {
diff --git
a/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/request/JobDeleteObserveAction.scala
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/request/JobDeleteObserveAction.scala
new file mode 100644
index 000000000..7626b652a
--- /dev/null
+++
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/request/JobDeleteObserveAction.scala
@@ -0,0 +1,54 @@
+/*
+ * 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.ujes.client.request
+
+import org.apache.linkis.httpclient.request.GetAction
+
+import org.apache.commons.lang3.StringUtils
+
+class JobDeleteObserveAction extends GetAction with UJESJobAction {
+ override def suffixURLs: Array[String] = Array("jobhistory", "setting",
"deleteObserveInfo")
+}
+
+object JobDeleteObserveAction {
+ def newBuilder(): Builder = new Builder
+
+ class Builder private[JobDeleteObserveAction] () {
+ private var user: String = _
+ private var taskId: Long = _
+
+ def setTaskId(taskId: Long): Builder = {
+ this.taskId = taskId
+ this
+ }
+
+ def setUser(user: String): Builder = {
+ this.user = user
+ this
+ }
+
+ def build(): JobDeleteObserveAction = {
+ val jobDeleteObserve = new JobDeleteObserveAction
+ if (StringUtils.isNotBlank(user)) jobDeleteObserve.setUser(user)
+ jobDeleteObserve.setParameter("taskId", taskId)
+ jobDeleteObserve
+ }
+
+ }
+
+}
diff --git
a/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/request/JobObserveAction.scala
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/request/JobObserveAction.scala
new file mode 100644
index 000000000..06e9b7366
--- /dev/null
+++
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/request/JobObserveAction.scala
@@ -0,0 +1,97 @@
+/*
+ * 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.ujes.client.request
+
+import org.apache.linkis.httpclient.dws.DWSHttpClient
+import org.apache.linkis.httpclient.request.{GetAction, POSTAction}
+import org.apache.linkis.protocol.constants.TaskConstant
+import org.apache.linkis.ujes.client.exception.UJESClientBuilderException
+
+import java.util
+import java.util.Map
+
+class JobObserveAction private () extends POSTAction with UJESJobAction {
+
+ override def suffixURLs: Array[String] = Array("jobhistory", "setting",
"addObserveInfo")
+
+ override def getRequestPayload: String =
+ DWSHttpClient.jacksonJson.writeValueAsString(getRequestPayloads)
+
+}
+
+object JobObserveAction {
+ def builder(): Builder = new Builder
+
+ class Builder private[JobObserveAction] () {
+
+ private var user: String = _
+ private var taskId: String = _
+ private var monitorLevel: String = _
+ private var receiver: String = _
+ private var subSystemId: String = _
+ private var extra: util.Map[String, String] = _
+
+ def setUser(user: String): Builder = {
+ this.user = user
+ this
+ }
+
+ def setTaskId(taskId: String): Builder = {
+ this.taskId = taskId
+ this
+ }
+
+ def setMonitorLevel(monitorLevel: String): Builder = {
+ this.monitorLevel = monitorLevel
+ this
+ }
+
+ def setReceiver(receiver: String): Builder = {
+ this.receiver = receiver
+ this
+ }
+
+ def setSubSystemId(subSystemId: String): Builder = {
+ this.subSystemId = subSystemId
+ this
+ }
+
+ def setExtra(extra: util.Map[String, String]): Builder = {
+ this.extra = extra
+ this
+ }
+
+ def build(): JobObserveAction = {
+ val JobObserveAction = new JobObserveAction
+ if (taskId == null) throw new UJESClientBuilderException("taskId is
needed!")
+ if (monitorLevel == null) throw new
UJESClientBuilderException("monitorLevel is needed!")
+ if (receiver == null) throw new UJESClientBuilderException("receiver is
needed!")
+ if (subSystemId == null) throw new
UJESClientBuilderException("subSystemId is needed!")
+ if (extra == null) throw new UJESClientBuilderException("extra is
needed!")
+ JobObserveAction.setUser(user)
+ JobObserveAction.addRequestPayload("taskId", taskId)
+ JobObserveAction.addRequestPayload(TaskConstant.MONITOR_LEVEL,
monitorLevel)
+ JobObserveAction.addRequestPayload(TaskConstant.RECEIVER, receiver)
+ JobObserveAction.addRequestPayload(TaskConstant.SUB_SYSTEM_ID,
subSystemId)
+ JobObserveAction.addRequestPayload(TaskConstant.EXTRA, extra)
+ JobObserveAction
+ }
+
+ }
+
+}
diff --git
a/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/response/JobDeleteObserveResult.scala
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/response/JobDeleteObserveResult.scala
new file mode 100644
index 000000000..06873aa0c
--- /dev/null
+++
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/response/JobDeleteObserveResult.scala
@@ -0,0 +1,23 @@
+/*
+ * 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.ujes.client.response
+
+import org.apache.linkis.httpclient.dws.annotation.DWSHttpMessageResult
+
+@DWSHttpMessageResult("/api/rest_j/v\\d+/jobhistory/setting/deleteObserveInfo")
+class JobDeleteObserveResult extends JobExecuteResult {}
diff --git
a/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/response/JobObserveResult.scala
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/response/JobObserveResult.scala
new file mode 100644
index 000000000..c1fcc72b7
--- /dev/null
+++
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/main/scala/org/apache/linkis/ujes/client/response/JobObserveResult.scala
@@ -0,0 +1,28 @@
+/*
+ * 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.ujes.client.response
+
+import org.apache.linkis.httpclient.dws.annotation.DWSHttpMessageResult
+import org.apache.linkis.httpclient.dws.response.DWSResult
+
+import java.util
+
+import scala.beans.BeanProperty
+
+@DWSHttpMessageResult("/api/rest_j/v\\d+/jobhistory/setting/addObserveInfo")
+class JobObserveResult extends JobExecuteResult {}
diff --git
a/linkis-computation-governance/linkis-client/linkis-computation-client/src/test/java/org/apache/linkis/ujes/client/JobObserveActionTest.scala
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/test/java/org/apache/linkis/ujes/client/JobObserveActionTest.scala
new file mode 100644
index 000000000..683b9b47b
--- /dev/null
+++
b/linkis-computation-governance/linkis-client/linkis-computation-client/src/test/java/org/apache/linkis/ujes/client/JobObserveActionTest.scala
@@ -0,0 +1,60 @@
+/*
+ * 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.ujes.client
+
+import org.apache.commons.io.IOUtils
+import
org.apache.linkis.httpclient.dws.authentication.{StaticAuthenticationStrategy,
TokenAuthenticationStrategy}
+import org.apache.linkis.httpclient.dws.config.{DWSClientConfig,
DWSClientConfigBuilder}
+import org.apache.linkis.ujes.client.request.{EmsListAction, JobExecuteAction,
JobObserveAction, ResultSetAction}
+
+import java.util
+import java.util.concurrent.TimeUnit
+
+@Deprecated
+object JobObserveActionTest extends App {
+
+ val clientConfig = DWSClientConfigBuilder.newBuilder()
+ .addServerUrl("127.0.0.1:9001") // Change to test gateway address
+ .connectionTimeout(30000)
+ .discoveryEnabled(false)
+ .discoveryFrequency(1, TimeUnit.MINUTES)
+ .loadbalancerEnabled(false)
+ .maxConnectionSize(5)
+ .retryEnabled(false)
+ .readTimeout(30000)
+ .setAuthenticationStrategy(new TokenAuthenticationStrategy())
+ .setAuthTokenKey("BML-AUTH")
+ .setAuthTokenValue("BML-AUTH")
+ .setDWSVersion("v1")
+ .build()
+ val client = new UJESClientImpl(clientConfig)
+ val map = new util.HashMap[String, String]()
+ map.put("title", "ss");
+ map.put("detail", "ss");
+ val build = JobObserveAction.builder()
+ .setUser("hadoop")
+ .setTaskId("73695") // This needs a real ID
+ .setSubSystemId("4523")
+ .setMonitorLevel("minor")
+ .setReceiver("alexyang")
+ .setExtra(map)
+ .build
+ val result = client.addJobObserve(build)
+ println(result)
+ IOUtils.closeQuietly(client)
+}
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 dc4d783c0..d5d97aa36 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,8 @@ public class JobRequest {
/** result location */
private String resultLocation;
+ private String observeInfo;
+
private Map<String, Object> metrics = new HashMap<>();
public Long getId() {
@@ -195,6 +197,14 @@ public class JobRequest {
this.resultLocation = resultLocation;
}
+ public String getObserveInfo() {
+ return observeInfo;
+ }
+
+ public void setObserveInfo(String observeInfo) {
+ this.observeInfo = observeInfo;
+ }
+
@Override
public String toString() {
return "JobRequest{"
diff --git a/linkis-dist/package/db/upgrade/1.3.2_schema/mysql/linkis_dml.sql
b/linkis-dist/package/db/upgrade/1.3.2_schema/mysql/linkis_dml.sql
index fd67e716b..7ef7ac458 100644
--- a/linkis-dist/package/db/upgrade/1.3.2_schema/mysql/linkis_dml.sql
+++ b/linkis-dist/package/db/upgrade/1.3.2_schema/mysql/linkis_dml.sql
@@ -15,6 +15,9 @@
* limitations under the License.
*/
+
+ALTER TABLE `linkis_ps_job_history_group_history` ADD COLUMN `observe_info`
VARCHAR(500) NULL DEFAULT NULL ;
+
update linkis_cg_manager_label set label_value ="*-GlobalSettings,*-*" where
label_key ="combined_userCreator_engineType" and id = 1;
update linkis_ps_configuration_config_key set en_treeName ="QueueResources"
where treeName = '队列资源';
update linkis_ps_configuration_config_key set en_treeName
="SparkResourceSettings" where treeName = 'spark资源设置';
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 65b37eeb1..1403a29ed 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
@@ -103,4 +103,6 @@ public interface JobHistoryMapper {
@Param("startId") Long startId);
String selectJobHistoryStatusForUpdate(Long jobId);
+
+ void updateOberverById(@Param("taskid") Long taskid, @Param("observeInfo")
String observeInfo);
}
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/impl/JobHistoryMapper.xml
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/impl/JobHistoryMapper.xml
index 3a76d8a76..8ac85a7c4 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/impl/JobHistoryMapper.xml
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/impl/JobHistoryMapper.xml
@@ -40,6 +40,7 @@
<result property = "engineType" column = "engine_type" />
<result property = "executionCode" column = "execution_code" />
<result property = "resultLocation" column = "result_location" />
+ <result property = "observeInfo" column = "observe_info" />
</resultMap>
@@ -51,7 +52,7 @@
<sql id="insert_job_list">
`job_req_id`, `submit_user`, `execute_user`, `source`, `labels`,
`params`,
- `progress`, `status`, `log_path`, `error_code`, `error_desc`,
`created_time`, `updated_time`, `instances`, `metrics`,`engine_type`,
`execution_code`
+ `progress`, `status`, `log_path`, `error_code`, `error_desc`,
`created_time`, `updated_time`, `instances`, `metrics`,`engine_type`,
`execution_code`, `observe_info`
</sql>
<insert id="insertJobHistory" flushCache="true" useGeneratedKeys="true"
keyProperty="id" parameterType="org.apache.linkis.jobhistory.entity.JobHistory">
@@ -59,7 +60,7 @@
VALUES (#{jobReqId},#{submitUser},#{executeUser},#{source},
#{labels},#{params},#{progress},
#{status},#{logPath},#{errorCode},#{errorDesc},
- #{createdTime},
#{updateTimeMills},#{instances},#{metrics},#{engineType},#{executionCode})
+ #{createdTime},
#{updateTimeMills},#{instances},#{metrics},#{engineType},#{executionCode},#{observeInfo})
</insert>
@@ -162,6 +163,7 @@
<if test="metrics != null">metrics = #{metrics},</if>
<if test="engineType != null">engine_type = #{engineType},</if>
<if test="executionCode != null">execution_code =
#{executionCode},</if>
+ <if test="observeInfo != null">observe_info = #{observeInfo},</if>
</trim>
<![CDATA[
WHERE id = #{id} AND updated_time <= #{updateTimeMills}
@@ -216,4 +218,7 @@
</where>
</select>
+ <update id="updateOberverById">
+ update linkis_ps_job_history_group_history set observe_info =
#{observeInfo} where id = #{taskid}
+ </update>
</mapper>
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/JobHistory.java
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/JobHistory.java
index 2857d97aa..6aa661a2d 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/JobHistory.java
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/JobHistory.java
@@ -70,6 +70,8 @@ public class JobHistory {
/** result location */
private String resultLocation;
+ private String observeInfo;
+
public Long getId() {
return id;
}
@@ -226,6 +228,14 @@ public class JobHistory {
this.resultLocation = resultLocation;
}
+ public String getObserveInfo() {
+ return observeInfo;
+ }
+
+ public void setObserveInfo(String observeInfo) {
+ this.observeInfo = observeInfo;
+ }
+
@Override
public String toString() {
return "JobHistory{"
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/MonitorVO.java
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/MonitorVO.java
new file mode 100644
index 000000000..3d83cd36a
--- /dev/null
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/MonitorVO.java
@@ -0,0 +1,90 @@
+/*
+ * 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.jobhistory.entity;
+
+import java.util.Map;
+
+public class MonitorVO {
+
+ private Long taskId;
+ private String monitorLevel;
+ private String receiver;
+ private String subSystemId;
+ private Map<String, String> extra;
+
+ public MonitorVO() {}
+
+ public Long getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(Long taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getMonitorLevel() {
+ return monitorLevel;
+ }
+
+ public void setMonitorLevel(String monitorLevel) {
+ this.monitorLevel = monitorLevel;
+ }
+
+ public Map<String, String> getExtra() {
+ return extra;
+ }
+
+ public void setExtra(Map<String, String> extra) {
+ this.extra = extra;
+ }
+
+ public String getReceiver() {
+ return receiver;
+ }
+
+ public void setReceiver(String receiver) {
+ this.receiver = receiver;
+ }
+
+ public String getSubSystemId() {
+ return subSystemId;
+ }
+
+ public void setSubSystemId(String subSystemId) {
+ this.subSystemId = subSystemId;
+ }
+
+ @Override
+ public String toString() {
+ return "MonitorVO{"
+ + "taskId="
+ + taskId
+ + ", monitorLevel='"
+ + monitorLevel
+ + '\''
+ + ", receiver='"
+ + receiver
+ + '\''
+ + ", subSystemId='"
+ + subSystemId
+ + '\''
+ + ", extra="
+ + extra
+ + '}';
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/QueryTaskVO.java
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/QueryTaskVO.java
index e50445603..df2614212 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/QueryTaskVO.java
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/entity/QueryTaskVO.java
@@ -58,6 +58,8 @@ public class QueryTaskVO {
private boolean canRetry;
+ private String observeInfo;
+
public List<SubJobDetail> getSubJobs() {
return subJobs;
}
@@ -276,6 +278,14 @@ public class QueryTaskVO {
this.canRetry = canRetry;
}
+ public String getObserveInfo() {
+ return observeInfo;
+ }
+
+ public void setObserveInfo(String observeInfo) {
+ this.observeInfo = observeInfo;
+ }
+
public String getExecuteUser() {
return executeUser;
}
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/JobhistorySettingApi.java
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/JobhistorySettingApi.java
new file mode 100644
index 000000000..fa4001f67
--- /dev/null
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/JobhistorySettingApi.java
@@ -0,0 +1,126 @@
+/*
+ * 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.jobhistory.restful.api;
+
+import org.apache.linkis.jobhistory.conversions.TaskConversions;
+import org.apache.linkis.jobhistory.entity.JobHistory;
+import org.apache.linkis.jobhistory.entity.MonitorVO;
+import org.apache.linkis.jobhistory.service.JobHistoryQueryService;
+import org.apache.linkis.server.BDPJettyServerHelper;
+import org.apache.linkis.server.Message;
+import org.apache.linkis.server.utils.ModuleUserUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+import java.util.Map;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Api(tags = "query api")
+@RestController
+@RequestMapping(path = "/jobhistory/setting")
+public class JobhistorySettingApi {
+
+ @Autowired private JobHistoryQueryService jobHistoryQueryService;
+
+ private Logger log = LoggerFactory.getLogger(this.getClass());
+
+ /** Method list should not contain subjob, which may cause performance
problems. */
+ @ApiOperation(value = "addObserveInfo", notes = "add Observe Info", response
= Message.class)
+ @RequestMapping(path = "/addObserveInfo", method = RequestMethod.POST)
+ public Message addObserveInfo(HttpServletRequest req, @RequestBody MonitorVO
monitor) {
+ String username = ModuleUserUtils.getOperationUser(req, "addObserveInfo");
+ // Parameter verification
+ if (null == monitor.getTaskId()) return Message.error("TaskId can't be
empty ");
+ if (StringUtils.isBlank(monitor.getReceiver())) return
Message.error("Receiver can't be empty");
+ if (null == monitor.getExtra()) {
+ return Message.error("Extra can't be empty ");
+ } else {
+ Map<String, String> extra = monitor.getExtra();
+ if (StringUtils.isBlank(extra.getOrDefault("title", "")))
+ return Message.error("title can't be empty ");
+ if (StringUtils.isBlank(extra.getOrDefault("detail", "")))
+ return Message.error("detail can't be empty ");
+ }
+ if (StringUtils.isBlank(monitor.getMonitorLevel()))
+ return Message.error("MonitorLevel can't be empty ");
+ if (StringUtils.isBlank(monitor.getSubSystemId()))
+ return Message.error("SubSystemId can't be empty ");
+ // Get jobInfo according to ID
+ JobHistory jobHistory =
+ jobHistoryQueryService.getJobHistoryByIdAndName(monitor.getTaskId(),
null);
+ if (!username.equals(jobHistory.getSubmitUser())) {
+ return Message.error("Only submitUser can change");
+ }
+
+ // Map<String, Object> map =
+ // BDPJettyServerHelper.gson().fromJson(jobHistory.getParams(), new
+ // HashMap<>().getClass());
+ // Map<String, Object> runtimeMap = TaskUtils.getRuntimeMap(map);
+ // if (runtimeMap.containsKey("task.notification.conditions")) {
+ // Judge whether the task has been completed, and cannot be modified when
it is completed
+ if (TaskConversions.isJobFinished(jobHistory.getStatus())) {
+ // Task not completed, update job record
+ String observeInfoJson = BDPJettyServerHelper.gson().toJson(monitor);
+ jobHistory.setObserveInfo(observeInfoJson);
+ jobHistoryQueryService.changeObserveInfoById(jobHistory);
+ } else {
+ return Message.error("The task has been completed, and the alarm cannot
be set");
+ }
+ // }
+ return Message.ok();
+ }
+
+ @ApiOperation(
+ value = "deleteObserveInfo",
+ notes = "delete Observe Info",
+ response = Message.class)
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "taskId", required = false, dataType = "long",
value = "taskId")
+ })
+ @RequestMapping(path = "/deleteObserveInfo", method = RequestMethod.GET)
+ public Message deleteObserveInfo(HttpServletRequest req, Long taskId) {
+ String username = ModuleUserUtils.getOperationUser(req,
"deleteObserveInfo");
+ // Get jobInfo according to ID
+ JobHistory jobHistory =
jobHistoryQueryService.getJobHistoryByIdAndName(taskId, null);
+ if (!username.equals(jobHistory.getSubmitUser())) {
+ return Message.error("Only submitUser can change");
+ }
+ if (TaskConversions.isJobFinished(jobHistory.getStatus())) {
+ jobHistory.setObserveInfo("");
+ jobHistoryQueryService.changeObserveInfoById(jobHistory);
+ } else {
+ // The alarm task has been completed
+ return Message.error("The task has been completed, and the alarm cannot
be set");
+ }
+ return Message.ok();
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conf/JobhistoryConfiguration.scala
b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conf/JobhistoryConfiguration.scala
index faddcab51..817927f5c 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conf/JobhistoryConfiguration.scala
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conf/JobhistoryConfiguration.scala
@@ -36,4 +36,7 @@ object JobhistoryConfiguration {
val UNDONE_JOB_REFRESH_TIME_DAILY: CommonVars[String] =
CommonVars("wds.linkis.jobhistory.undone.job.refreshtime.daily", "00:15")
+ val DIRTY_DATA_UNFINISHED_JOB_STATUS =
+ "Inited,WaitForRetry,Scheduled,Running".split(",").map(s =>
s.toUpperCase())
+
}
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conversions/TaskConversions.scala
b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conversions/TaskConversions.scala
index 82d7d8612..e863be344 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conversions/TaskConversions.scala
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/conversions/TaskConversions.scala
@@ -104,6 +104,7 @@ object TaskConversions extends Logging {
jobReq.setResultLocation(job.getResultLocation)
QueryUtils.exchangeExecutionCode(job)
jobReq.setExecutionCode(job.getExecutionCode)
+ jobReq.setObserveInfo(job.getObserveInfo)
jobReq
}
@@ -145,6 +146,9 @@ object TaskConversions extends Logging {
val engineType = LabelUtil.getEngineType(jobReq.getLabels)
jobHistory.setEngineType(engineType)
jobHistory.setExecutionCode(jobReq.getExecutionCode)
+ if (null != jobReq.getObserveInfo) {
+ jobHistory.setObserveInfo(jobReq.getObserveInfo)
+ }
jobHistory
}
@@ -295,6 +299,7 @@ object TaskConversions extends Logging {
logger.warn("sourceJson deserialization failed, this task may be the
old data.")
}
}
+ taskVO.setObserveInfo(job.getObserveInfo)
taskVO
}
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/JobHistoryQueryService.java
b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/JobHistoryQueryService.java
index 3c1b7a830..b23873890 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/JobHistoryQueryService.java
+++
b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/JobHistoryQueryService.java
@@ -45,4 +45,6 @@ public interface JobHistoryQueryService {
JobHistory searchOne(Long jobId, Date sDate, Date eDate);
List<JobRequest> getQueryVOList(List<JobHistory> list);
+
+ void changeObserveInfoById(JobHistory jobHistory);
}
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 31929263c..3512d3fbf 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
@@ -424,4 +424,8 @@ class JobHistoryQueryServiceImpl extends
JobHistoryQueryService with Logging {
count
}
+ override def changeObserveInfoById(jobHistory: JobHistory): Unit = {
+ jobHistoryMapper.updateOberverById(jobHistory.getId,
jobHistory.getObserveInfo)
+ }
+
}
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/dao/JobHistoryMapperTest.java
b/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/dao/JobHistoryMapperTest.java
index 7a9da1d10..a2bded49f 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/dao/JobHistoryMapperTest.java
+++
b/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/dao/JobHistoryMapperTest.java
@@ -59,6 +59,7 @@ public class JobHistoryMapperTest extends BaseDaoTest {
jobHistory.setEngineType("spark");
jobHistory.setExecutionCode("show databases;");
jobHistory.setResultLocation("hdfs:///tmp/linkis/hadoop/linkis/20220714_185840/LINKISCLI/1");
+ jobHistory.setObserveInfo("");
return jobHistory;
}
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/service/JobHistoryDetailQueryServiceTest.java
b/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/service/JobHistoryDetailQueryServiceTest.java
index 19942e27a..d3adc52b1 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/service/JobHistoryDetailQueryServiceTest.java
+++
b/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/service/JobHistoryDetailQueryServiceTest.java
@@ -86,6 +86,7 @@ class JobHistoryDetailQueryServiceTest {
jobRequest.setUpdatedTime(new Date());
jobRequest.setInstances("");
jobRequest.setMetrics(Maps.newHashMap());
+ jobRequest.setObserveInfo("");
subJobInfo.setJobReq(jobRequest);
subJobInfo.setProgress(0.0F);
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/service/JobHistoryQueryServiceTest.java
b/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/service/JobHistoryQueryServiceTest.java
index 576ffa6f5..7b68e6a91 100644
---
a/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/service/JobHistoryQueryServiceTest.java
+++
b/linkis-public-enhancements/linkis-jobhistory/src/test/java/org/apache/linkis/jobhistory/service/JobHistoryQueryServiceTest.java
@@ -57,6 +57,7 @@ public class JobHistoryQueryServiceTest {
jobRequest.setMetrics(new HashMap<>());
jobRequest.setExecutionCode("show databases;");
jobRequest.setResultLocation("hdfs:///tmp/linkis/hadoop/linkis/20220714_185840/LINKISCLI/1");
+ jobRequest.setObserveInfo("");
return jobRequest;
}
diff --git
a/linkis-public-enhancements/linkis-jobhistory/src/test/resources/create.sql
b/linkis-public-enhancements/linkis-jobhistory/src/test/resources/create.sql
index a27c18406..8d7bd16fa 100644
--- a/linkis-public-enhancements/linkis-jobhistory/src/test/resources/create.sql
+++ b/linkis-public-enhancements/linkis-jobhistory/src/test/resources/create.sql
@@ -54,6 +54,7 @@ CREATE TABLE linkis_ps_job_history_group_history (
engine_type varchar(32) DEFAULT NULL COMMENT 'Engine type',
execution_code text COMMENT 'Job origin code or code path',
result_location varchar(500) DEFAULT NULL COMMENT 'File path of the
resultsets',
+ observe_info varchar(500) DEFAULT NULL COMMENT 'demo',
PRIMARY KEY (id),
KEY created_time (created_time),
KEY submit_user (submit_user)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]