Commit 82add547 by fudahua

feat: 限制执行building个数

parent 06490cc2
......@@ -71,4 +71,9 @@ public interface DownloadTaskDao {
int updateTaskStatusError(@Param("idList") List<String> idList);
/** 获取等待申请通过状态的任务
* @return
*/
public int getCountDownloadTaskOfBuilding(@Param("queryDataSource") String queryDataSource);
}
......@@ -235,6 +235,13 @@ public class DownloadTaskServiceImpl implements IDownloadTaskService {
return downloadTaskDao.getDownloadTaskOfHasDownload(queryDataSource, num);
}
/** 获取在审核申请等待状态中的任务
* @return
*/
public int getCountDownloadTaskOfBuilding(String queryDataSource) {
return downloadTaskDao.getCountDownloadTaskOfBuilding(queryDataSource);
}
/** 获取指定申请编号的风险模式记录
* @param applyId
......
......@@ -682,8 +682,17 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
providerLocalTag.traceId = traceId;
logger.info("执行hivefile");
try{
String lockKey="data:hook:hive";
RedisUtil.lock(lockKey,2L);
RedisUtil.lock(lockKey,3L);
int curBuildingCount = DownloadTaskServiceImpl.getInstance().getCountDownloadTaskOfBuilding(QueryDataSource.FLAT_QUERY);
Config appConfig = ConfigService.getAppConfig();
Integer maxBuildingCount = appConfig.getIntProperty("buildingCount", 5);
if (maxBuildingCount<=curBuildingCount) {
RedisUtil.unlock(lockKey);
return;
}
List<DownloadTask> downloadTasks = DownloadTaskServiceImpl.getInstance().getDownloadTaskOfHasDownload(QueryDataSource.FLAT_QUERY,10);
if (CollectionUtils.isNotEmpty(downloadTasks)) {
for (DownloadTask downloadTask : downloadTasks) {
......
......@@ -220,4 +220,15 @@
</foreach>
</update>
<select id="getCountDownloadTaskOfBuilding" resultType="int">
SELECT count(*)
FROM
<include refid="queryTables"/>
<include refid="queryJoins"/>
WHERE
q.query_data_source = #{queryDataSource}
AND q.status = "building"
AND q.del_flag = '0'
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment