feat(sj_1.0.0): 删除分区配置total-partition
This commit is contained in:
parent
0b928deda1
commit
a422f2e0a0
@ -37,11 +37,6 @@ public class SystemProperties {
|
|||||||
*/
|
*/
|
||||||
private int nettyPort = 1788;
|
private int nettyPort = 1788;
|
||||||
|
|
||||||
/**
|
|
||||||
* 分区数
|
|
||||||
*/
|
|
||||||
private int totalPartition = 32;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一个客户端每秒最多接收的重试数量指令
|
* 一个客户端每秒最多接收的重试数量指令
|
||||||
*/
|
*/
|
||||||
|
@ -68,7 +68,6 @@ snail-job:
|
|||||||
retry-pull-page-size: 1000 # 拉取重试数据的每批次的大小
|
retry-pull-page-size: 1000 # 拉取重试数据的每批次的大小
|
||||||
job-pull-page-size: 1000 # 拉取重试数据的每批次的大小
|
job-pull-page-size: 1000 # 拉取重试数据的每批次的大小
|
||||||
netty-port: 1788 # 服务端netty端口
|
netty-port: 1788 # 服务端netty端口
|
||||||
total-partition: 2 # 重试和死信表的分区总数
|
|
||||||
limiter: 1000 # 一个客户端每秒最多接收的重试数量指令
|
limiter: 1000 # 一个客户端每秒最多接收的重试数量指令
|
||||||
step: 100 # 号段模式下步长配置
|
step: 100 # 号段模式下步长配置
|
||||||
log-storage: 90 # 日志保存时间(单位: day)
|
log-storage: 90 # 日志保存时间(单位: day)
|
||||||
|
@ -94,12 +94,12 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
() -> new SnailJobServerException("GroupName已经存在 {}", groupConfigRequestVO.getGroupName()));
|
() -> new SnailJobServerException("GroupName已经存在 {}", groupConfigRequestVO.getGroupName()));
|
||||||
|
|
||||||
// 保存组配置
|
// 保存组配置
|
||||||
doSaveGroupConfig(systemUser, groupConfigRequestVO);
|
Boolean isSuccess = doSaveGroupConfig(systemUser, groupConfigRequestVO);
|
||||||
|
|
||||||
// 保存生成唯一id配置
|
// 保存生成唯一id配置
|
||||||
doSaveSequenceAlloc(systemUser, groupConfigRequestVO);
|
doSaveSequenceAlloc(systemUser, groupConfigRequestVO);
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return isSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,6 +123,11 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public Boolean updateGroup(GroupConfigRequestVO groupConfigRequestVO) {
|
public Boolean updateGroup(GroupConfigRequestVO groupConfigRequestVO) {
|
||||||
|
|
||||||
|
List<Integer> tablePartitionList = getTablePartitionList();
|
||||||
|
if (CollectionUtils.isEmpty(tablePartitionList)) {
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
String groupName = groupConfigRequestVO.getGroupName();
|
String groupName = groupConfigRequestVO.getGroupName();
|
||||||
String namespaceId = UserSessionUtils.currentUserSession().getNamespaceId();
|
String namespaceId = UserSessionUtils.currentUserSession().getNamespaceId();
|
||||||
|
|
||||||
@ -140,8 +145,8 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
// 使用@TableField(value = "version", update= "%s+1") 进行更新version, 这里必须初始化一个值
|
// 使用@TableField(value = "version", update= "%s+1") 进行更新version, 这里必须初始化一个值
|
||||||
groupConfig.setVersion(1);
|
groupConfig.setVersion(1);
|
||||||
groupConfig.setToken(null);
|
groupConfig.setToken(null);
|
||||||
Assert.isTrue(systemProperties.getTotalPartition() > groupConfigRequestVO.getGroupPartition(),
|
Assert.isTrue(tablePartitionList.contains(groupConfigRequestVO.getGroupPartition()),
|
||||||
() -> new SnailJobServerException("分区超过最大分区. [{}]", systemProperties.getTotalPartition() - 1));
|
() -> new SnailJobServerException("分区不存在. [{}]", tablePartitionList));
|
||||||
Assert.isTrue(groupConfigRequestVO.getGroupPartition() >= 0,
|
Assert.isTrue(groupConfigRequestVO.getGroupPartition() >= 0,
|
||||||
() -> new SnailJobServerException("分区不能是负数."));
|
() -> new SnailJobServerException("分区不能是负数."));
|
||||||
|
|
||||||
@ -223,7 +228,12 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
return pageResult;
|
return pageResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSaveGroupConfig(UserSessionVO systemUser, GroupConfigRequestVO groupConfigRequestVO) {
|
private boolean doSaveGroupConfig(UserSessionVO systemUser, GroupConfigRequestVO groupConfigRequestVO) {
|
||||||
|
List<Integer> tablePartitionList = getTablePartitionList();
|
||||||
|
if (CollectionUtils.isEmpty(tablePartitionList)) {
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
GroupConfig groupConfig = GroupConfigConverter.INSTANCE.convert(groupConfigRequestVO);
|
GroupConfig groupConfig = GroupConfigConverter.INSTANCE.convert(groupConfigRequestVO);
|
||||||
groupConfig.setCreateDt(LocalDateTime.now());
|
groupConfig.setCreateDt(LocalDateTime.now());
|
||||||
groupConfig.setVersion(1);
|
groupConfig.setVersion(1);
|
||||||
@ -233,10 +243,10 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
groupConfig.setDescription(Optional.ofNullable(groupConfigRequestVO.getDescription()).orElse(StrUtil.EMPTY));
|
groupConfig.setDescription(Optional.ofNullable(groupConfigRequestVO.getDescription()).orElse(StrUtil.EMPTY));
|
||||||
if (Objects.isNull(groupConfigRequestVO.getGroupPartition())) {
|
if (Objects.isNull(groupConfigRequestVO.getGroupPartition())) {
|
||||||
groupConfig.setGroupPartition(
|
groupConfig.setGroupPartition(
|
||||||
HashUtil.bkdrHash(groupConfigRequestVO.getGroupName()) % systemProperties.getTotalPartition());
|
HashUtil.bkdrHash(groupConfigRequestVO.getGroupName()) % tablePartitionList.size());
|
||||||
} else {
|
} else {
|
||||||
Assert.isTrue(systemProperties.getTotalPartition() > groupConfigRequestVO.getGroupPartition(),
|
Assert.isTrue(tablePartitionList.contains(groupConfigRequestVO.getGroupPartition()),
|
||||||
() -> new SnailJobServerException("分区超过最大分区. [{}]", systemProperties.getTotalPartition() - 1));
|
() -> new SnailJobServerException("分区不存在. [{}]", tablePartitionList));
|
||||||
Assert.isTrue(groupConfigRequestVO.getGroupPartition() >= 0,
|
Assert.isTrue(groupConfigRequestVO.getGroupPartition() >= 0,
|
||||||
() -> new SnailJobServerException("分区不能是负数."));
|
() -> new SnailJobServerException("分区不能是负数."));
|
||||||
}
|
}
|
||||||
@ -249,6 +259,8 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
|
|
||||||
// 校验retry_task_x和retry_dead_letter_x是否存在
|
// 校验retry_task_x和retry_dead_letter_x是否存在
|
||||||
checkGroupPartition(groupConfig, systemUser.getNamespaceId());
|
checkGroupPartition(groupConfig, systemUser.getNamespaceId());
|
||||||
|
|
||||||
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,7 +381,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return tableList.stream().map(ReUtil::getFirstNumber).filter(i ->
|
return tableList.stream().map(ReUtil::getFirstNumber).filter(i ->
|
||||||
!Objects.isNull(i) && i <= systemProperties.getTotalPartition()).distinct()
|
!Objects.isNull(i)).distinct()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} catch (SQLException ignored) {
|
} catch (SQLException ignored) {
|
||||||
} finally {
|
} finally {
|
||||||
@ -381,12 +393,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 兜底
|
return Lists.newArrayList();
|
||||||
List<Integer> tableList = Lists.newArrayList();
|
|
||||||
for (int i = 0; i < systemProperties.getTotalPartition(); i++) {
|
|
||||||
tableList.add(i);
|
|
||||||
}
|
|
||||||
return tableList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,10 @@ public class SceneConfigServiceImpl implements SceneConfigService {
|
|||||||
RetrySceneConfig retrySceneConfig = SceneConfigConverter.INSTANCE.toSceneConfigRequestVO(requestVO);
|
RetrySceneConfig retrySceneConfig = SceneConfigConverter.INSTANCE.toSceneConfigRequestVO(requestVO);
|
||||||
retrySceneConfig.setCreateDt(LocalDateTime.now());
|
retrySceneConfig.setCreateDt(LocalDateTime.now());
|
||||||
retrySceneConfig.setNamespaceId(namespaceId);
|
retrySceneConfig.setNamespaceId(namespaceId);
|
||||||
|
if (requestVO.getBackOff() == WaitStrategies.WaitStrategyEnum.DELAY_LEVEL.getType()) {
|
||||||
|
retrySceneConfig.setTriggerInterval(StrUtil.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
Assert.isTrue(1 == sceneConfigAccess.insert(retrySceneConfig),
|
Assert.isTrue(1 == sceneConfigAccess.insert(retrySceneConfig),
|
||||||
() -> new SnailJobServerException("failed to insert scene. retrySceneConfig:[{}]",
|
() -> new SnailJobServerException("failed to insert scene. retrySceneConfig:[{}]",
|
||||||
JsonUtil.toJsonString(retrySceneConfig)));
|
JsonUtil.toJsonString(retrySceneConfig)));
|
||||||
|
Loading…
Reference in New Issue
Block a user