fix(系统设置): 配额检查

This commit is contained in:
shiziyuan9527 2022-04-14 19:12:09 +08:00 committed by 刘瑞斌
parent c34cfadb3a
commit 2cb988d66e
3 changed files with 11 additions and 0 deletions

View File

@ -7,10 +7,12 @@ import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.constants.ReportKeys;
import io.metersphere.commons.consumer.LoadTestFinishEvent;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.performance.base.VumProcessedStatus;
import io.metersphere.service.QuotaService;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component;
@ -55,6 +57,9 @@ public class LoadTestVumEvent implements LoadTestFinishEvent {
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
String projectId = report.getProjectId();
Project project = projectMapper.selectByPrimaryKey(projectId);
if (project == null || StringUtils.isBlank(project.getWorkspaceId())) {
MSException.throwException("project is null or workspace_id of project is null. project id: " + projectId);
}
RLock lock = redissonClient.getLock(project.getWorkspaceId());
if (quotaService != null) {
try {

View File

@ -172,6 +172,9 @@ public class PerformanceReportService {
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
String projectId = report.getProjectId();
Project project = projectMapper.selectByPrimaryKey(projectId);
if (project == null || StringUtils.isBlank(project.getWorkspaceId())) {
MSException.throwException("project is null or workspace_id of project is null. project id: " + projectId);
}
RLock lock = redissonClient.getLock(project.getWorkspaceId());
if (quotaService != null) {
try {

View File

@ -540,6 +540,9 @@ public class PerformanceTestService {
quotaService.checkLoadTestQuota(checkRequest, false);
String projectId = testReport.getProjectId();
Project project = projectMapper.selectByPrimaryKey(projectId);
if (project == null || StringUtils.isBlank(project.getWorkspaceId())) {
MSException.throwException("project is null or workspace_id of project is null. project id: " + projectId);
}
RLock lock = redissonClient.getLock(project.getWorkspaceId());
try {
lock.lock();