注册监控线程优化,降低死锁几率;

pull/10/head
xuxueli 6 years ago
parent ee8fb55e6d
commit 90eba3827d

@ -1518,6 +1518,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 7、[ING]cron在线生成工具
- 8、[ING]任务、执行器数据全量本地缓存;新增消息表广播通知;
- 9、[ING]任务触发组件优化常规1s预加载一次轮空时主动休眠4s
- 10、注册监控线程优化降低死锁几率
### TODO LIST

@ -71,8 +71,7 @@ CREATE TABLE `xxl_job_registry` (
`registry_value` varchar(255) NOT NULL,
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `i_g_k_v` (`registry_group`,`registry_key`,`registry_value`),
KEY `i_u` (`update_time`)
KEY `i_g_k_v` (`registry_group`,`registry_key`,`registry_value`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `xxl_job_group` (

@ -38,7 +38,10 @@ public class JobRegistryMonitorHelper {
if (groupList!=null && !groupList.isEmpty()) {
// remove dead address (admin/executor)
XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().removeDead(RegistryConfig.DEAD_TIMEOUT);
List<Integer> ids = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findDead(RegistryConfig.DEAD_TIMEOUT);
if (ids!=null && ids.size()>0) {
XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().removeDead(ids);
}
// fresh online address (admin/executor)
HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();

@ -12,7 +12,9 @@ import java.util.List;
@Mapper
public interface XxlJobRegistryDao {
public int removeDead(@Param("timeout") int timeout);
public List<Integer> findDead(@Param("timeout") int timeout);
public int removeDead(@Param("ids") List<Integer> ids);
public List<XxlJobRegistry> findAll(@Param("timeout") int timeout);

@ -18,10 +18,19 @@
t.registry_value,
t.update_time
</sql>
<select id="findDead" parameterType="java.lang.Integer" resultType="java.lang.Integer" >
SELECT t.id
FROM xxl_job_registry AS t
WHERE t.update_time <![CDATA[ < ]]> DATE_ADD(NOW(),INTERVAL -#{timeout} SECOND)
</select>
<delete id="removeDead" parameterType="java.lang.Integer" >
DELETE FROM xxl_job_registry
WHERE update_time <![CDATA[ < ]]> DATE_ADD(NOW(),INTERVAL -#{timeout} SECOND)
WHERE id in
<foreach collection="ids" item="item" open="(" close=")" separator="," >
#{item}
</foreach>
</delete>
<select id="findAll" parameterType="java.lang.Integer" resultMap="XxlJobRegistry">

@ -7,6 +7,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
@RunWith(SpringRunner.class)
@ -25,7 +26,7 @@ public class XxlJobRegistryDaoTest {
List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(1);
int ret2 = xxlJobRegistryDao.removeDead(1);
int ret2 = xxlJobRegistryDao.removeDead(Arrays.asList(1));
}
}

Loading…
Cancel
Save