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

This commit is contained in:
shiziyuan9527 2022-04-14 16:41:37 +08:00 committed by 刘瑞斌
parent 4e2f7dce20
commit 60076f10e1
3 changed files with 11 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package io.metersphere.performance.service;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.LoadTestReportMapper;
import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
import io.metersphere.commons.constants.PerformanceTestStatus;
import io.metersphere.commons.constants.ReportKeys;
@ -28,6 +29,8 @@ public class LoadTestVumEvent implements LoadTestFinishEvent {
private ExtLoadTestReportMapper extLoadTestReportMapper;
@Resource
private RedissonClient redissonClient;
@Resource
private ProjectMapper projectMapper;
private void handleVum(LoadTestReport report) {
if (report == null) {
@ -51,7 +54,8 @@ public class LoadTestVumEvent implements LoadTestFinishEvent {
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
String projectId = report.getProjectId();
RLock lock = redissonClient.getLock(projectId);
Project project = projectMapper.selectByPrimaryKey(projectId);
RLock lock = redissonClient.getLock(project.getWorkspaceId());
if (quotaService != null) {
try {
lock.lock();

View File

@ -80,6 +80,8 @@ public class PerformanceReportService {
private TestResourcePoolMapper testResourcePoolMapper;
@Resource
private RedissonClient redissonClient;
@Resource
private ProjectMapper projectMapper;
public List<ReportDTO> getRecentReportList(ReportRequest request) {
List<OrderRequest> orders = new ArrayList<>();
@ -169,7 +171,8 @@ public class PerformanceReportService {
LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(report.getTestId());
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
String projectId = report.getProjectId();
RLock lock = redissonClient.getLock(projectId);
Project project = projectMapper.selectByPrimaryKey(projectId);
RLock lock = redissonClient.getLock(project.getWorkspaceId());
if (quotaService != null) {
try {
lock.lock();

View File

@ -539,7 +539,8 @@ public class PerformanceTestService {
if (quotaService != null) {
quotaService.checkLoadTestQuota(checkRequest, false);
String projectId = testReport.getProjectId();
RLock lock = redissonClient.getLock(projectId);
Project project = projectMapper.selectByPrimaryKey(projectId);
RLock lock = redissonClient.getLock(project.getWorkspaceId());
try {
lock.lock();
BigDecimal toUsed = quotaService.checkVumUsed(checkRequest, projectId);