fix(系统设置): 配额检查
This commit is contained in:
parent
c34cfadb3a
commit
2cb988d66e
|
@ -7,10 +7,12 @@ import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
|
||||||
import io.metersphere.commons.constants.PerformanceTestStatus;
|
import io.metersphere.commons.constants.PerformanceTestStatus;
|
||||||
import io.metersphere.commons.constants.ReportKeys;
|
import io.metersphere.commons.constants.ReportKeys;
|
||||||
import io.metersphere.commons.consumer.LoadTestFinishEvent;
|
import io.metersphere.commons.consumer.LoadTestFinishEvent;
|
||||||
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.performance.base.VumProcessedStatus;
|
import io.metersphere.performance.base.VumProcessedStatus;
|
||||||
import io.metersphere.service.QuotaService;
|
import io.metersphere.service.QuotaService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.redisson.api.RLock;
|
import org.redisson.api.RLock;
|
||||||
import org.redisson.api.RedissonClient;
|
import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -55,6 +57,9 @@ public class LoadTestVumEvent implements LoadTestFinishEvent {
|
||||||
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
|
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
|
||||||
String projectId = report.getProjectId();
|
String projectId = report.getProjectId();
|
||||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
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());
|
RLock lock = redissonClient.getLock(project.getWorkspaceId());
|
||||||
if (quotaService != null) {
|
if (quotaService != null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -172,6 +172,9 @@ public class PerformanceReportService {
|
||||||
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
|
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
|
||||||
String projectId = report.getProjectId();
|
String projectId = report.getProjectId();
|
||||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
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());
|
RLock lock = redissonClient.getLock(project.getWorkspaceId());
|
||||||
if (quotaService != null) {
|
if (quotaService != null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -540,6 +540,9 @@ public class PerformanceTestService {
|
||||||
quotaService.checkLoadTestQuota(checkRequest, false);
|
quotaService.checkLoadTestQuota(checkRequest, false);
|
||||||
String projectId = testReport.getProjectId();
|
String projectId = testReport.getProjectId();
|
||||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
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());
|
RLock lock = redissonClient.getLock(project.getWorkspaceId());
|
||||||
try {
|
try {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
|
Loading…
Reference in New Issue