forked from DataLinkDC/dinky
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature-2981][admin] Preview data in execution history (DataLinkDC#3572
) Co-authored-by: suxinshuo <suxinshuo@itiger.com> Co-authored-by: suxinshuo <suxinshuo@users.noreply.github.com>
- Loading branch information
1 parent
72c765d
commit 2b9f627
Showing
27 changed files
with
567 additions
and
50 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
dinky-admin/src/main/java/org/dinky/job/JobShutdownConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* | ||
* 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.dinky.job; | ||
|
||
import org.dinky.context.TenantContextHolder; | ||
import org.dinky.data.result.ResultPool; | ||
|
||
import java.util.List; | ||
|
||
import javax.annotation.PreDestroy; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import cn.hutool.core.collection.CollectionUtil; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* JobShutdownConfig. | ||
* | ||
* @since 2024/6/3 18:09 | ||
*/ | ||
@Slf4j | ||
@Component | ||
public class JobShutdownConfig { | ||
|
||
@PreDestroy | ||
public void destroy() { | ||
log.info("Job shutdown."); | ||
List<String> jobIds = ResultPool.getJobIds(); | ||
if (CollectionUtil.isEmpty(jobIds)) { | ||
log.info("Result pool is empty."); | ||
return; | ||
} | ||
// set job result status to destroyed | ||
jobIds.stream().map(ResultPool::get).forEach(jobResult -> jobResult.setDestroyed(Boolean.TRUE)); | ||
JobHandler jobHandler = JobHandler.build(); | ||
TenantContextHolder.ignoreTenant(); | ||
jobHandler.persistResultData(jobIds); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
dinky-admin/src/main/java/org/dinky/job/handler/JobReadMysqlHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* | ||
* 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.dinky.job.handler; | ||
|
||
import org.dinky.context.SpringContextUtils; | ||
import org.dinky.data.model.job.History; | ||
import org.dinky.data.result.SelectResult; | ||
import org.dinky.job.JobReadHandler; | ||
import org.dinky.service.HistoryService; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.util.Objects; | ||
|
||
import org.springframework.context.annotation.DependsOn; | ||
|
||
import cn.hutool.json.JSONUtil; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* JobReadMysqlHandler. | ||
* | ||
* @since 2024/5/31 11:41 | ||
*/ | ||
@Slf4j | ||
@DependsOn("springContextUtils") | ||
public class JobReadMysqlHandler implements JobReadHandler { | ||
|
||
private static final HistoryService historyService; | ||
|
||
static { | ||
historyService = SpringContextUtils.getBean("historyServiceImpl", HistoryService.class); | ||
} | ||
|
||
/** | ||
* Read result data from mysql. | ||
* | ||
* @param jobId job id | ||
* @return result data | ||
*/ | ||
@Override | ||
public SelectResult readResultDataFromStorage(Integer jobId) { | ||
History history = historyService.getById(jobId); | ||
if (Objects.isNull(history)) { | ||
return SelectResult.buildFailed(); | ||
} | ||
String result = history.getResult(); | ||
if (StringUtils.isBlank(result)) { | ||
return SelectResult.buildFailed(); | ||
} | ||
return JSONUtil.toBean(result, SelectResult.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
dinky-common/src/main/java/org/dinky/data/constant/MysqlConstant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* | ||
* 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.dinky.data.constant; | ||
|
||
/** | ||
* MysqlConstant | ||
* | ||
* @since 2024/5/30 15:36 | ||
*/ | ||
public class MysqlConstant { | ||
|
||
public static final Long MEDIUMTEXT_MAX_LENGTH = 16777215L; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.