fix: 解决数据库连接池报错

This commit is contained in:
chenjianxing 2021-08-12 16:52:18 +08:00 committed by jianxing
parent 67a528c01a
commit 7354d310a6
23 changed files with 47 additions and 2 deletions

View File

@ -30,6 +30,7 @@ import org.apache.jorphan.collections.HashTree;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
@ -39,6 +40,7 @@ import java.io.InputStream;
import java.lang.reflect.Field;
@Service
@Transactional(rollbackFor = Exception.class)
public class JMeterService {
private static final String BASE_URL = "http://%s:%d";
@Resource

View File

@ -10,10 +10,12 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@Service
@Transactional(rollbackFor = Exception.class)
public class MsKafkaListener {
public static final String TOPICS = "ms-api-exec-topic";
public static final String CONSUME_ID = "ms-api-exec-consume";

View File

@ -12,6 +12,7 @@ import io.metersphere.commons.exception.MSException;
import io.metersphere.dto.NodeDTO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
@ -19,6 +20,7 @@ import java.util.List;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class ResourcePoolCalculation {
@Resource
TestResourcePoolMapper testResourcePoolMapper;

View File

@ -20,6 +20,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jorphan.collections.HashTree;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
@ -30,6 +31,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@Service
@Transactional(rollbackFor = Exception.class)
public class ApiJmeterFileService {
@Resource

View File

@ -11,6 +11,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jorphan.exec.SystemCommand;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedReader;
@ -19,6 +20,7 @@ import java.io.InputStreamReader;
import java.util.*;
@Service
@Transactional(rollbackFor = Exception.class)
public class CommandService {
public List<KeyStoreEntry> get(String password, MultipartFile file) {

View File

@ -12,6 +12,7 @@ import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterVariables;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sun.security.util.Cache;
import java.util.*;
@ -19,6 +20,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class MsResultService {
// 零时存放实时结果
private Cache cache = Cache.newHardMemoryCache(0, 3600 * 2);

View File

@ -10,10 +10,12 @@ import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.reflections8.Reflections;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Set;
@Service
@Transactional(rollbackFor = Exception.class)
public class LoadTestConsumer {
public static final String CONSUME_ID = "load-test-data";

View File

@ -16,12 +16,14 @@ import io.metersphere.performance.service.PerformanceTestService;
import io.metersphere.service.TestResourcePoolService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@Service
@Transactional(rollbackFor = Exception.class)
public class ConsulService {
private final Map<String, List<String>> cache = new ConcurrentHashMap<>();
@Resource

View File

@ -21,6 +21,7 @@ import org.springframework.ldap.core.support.DefaultDirObjectFactory;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.ldap.query.SearchScope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.naming.directory.DirContext;
@ -32,6 +33,7 @@ import java.util.Map;
import static org.springframework.ldap.query.LdapQueryBuilder.query;
@Service
@Transactional(rollbackFor = Exception.class)
public class LdapService {
@Resource

View File

@ -13,6 +13,7 @@ import io.metersphere.dto.LoadTestDTO;
import io.metersphere.performance.request.QueryTestPlanRequest;
import io.metersphere.service.ScheduleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
@ -21,6 +22,7 @@ import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class ApiAndPerformanceHelper {
@Resource
private ExtLoadTestMapper extLoadTestMapper;

View File

@ -26,6 +26,7 @@ import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.reflections8.Reflections;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -47,6 +48,7 @@ import java.util.*;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class EngineFactory {
private static FileService fileService;
private static PerformanceTestService performanceTestService;

View File

@ -11,6 +11,7 @@ import io.metersphere.commons.utils.LogUtil;
import io.metersphere.performance.engine.EngineContext;
import io.metersphere.performance.engine.EngineFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
@ -22,6 +23,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@Service
@Transactional(rollbackFor = Exception.class)
public class JmeterFileService {
@Resource

View File

@ -11,12 +11,14 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class BaseDisplayService {
@Resource
private SystemParameterMapper systemParameterMapper;

View File

@ -10,6 +10,7 @@ import io.metersphere.i18n.Translator;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
@ -17,6 +18,7 @@ import java.util.Set;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class CheckPermissionService {
@Resource
private ExtApiTestMapper extApiTestMapper;

View File

@ -8,6 +8,7 @@ import io.metersphere.commons.constants.FileType;
import io.metersphere.commons.exception.MSException;
import io.metersphere.performance.request.QueryProjectFileRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile;
@ -22,6 +23,7 @@ import java.util.UUID;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class FileService {
@Resource
private FileMetadataMapper fileMetadataMapper;
@ -215,4 +217,4 @@ public class FileService {
example.createCriteria().andIdIn(fileIds);
return fileMetadataMapper.selectByExample(example);
}
}
}

View File

@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
@ -27,6 +28,7 @@ import java.util.stream.Collectors;
import static io.metersphere.commons.constants.ResourceStatusEnum.VALID;
@Service
@Transactional(rollbackFor = Exception.class)
public class NodeResourcePoolService {
private final static String nodeControllerUrl = "http://%s:%s/status";

View File

@ -8,6 +8,7 @@ import io.metersphere.commons.exception.MSException;
import io.metersphere.i18n.Translator;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
@ -15,6 +16,7 @@ import java.util.List;
import java.util.UUID;
@Service
@Transactional(rollbackFor = Exception.class)
public class UserKeyService {
@Resource

View File

@ -5,12 +5,14 @@ import io.metersphere.task.dto.TaskCenterDTO;
import io.metersphere.task.dto.TaskCenterRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class TaskService {
@Resource
private ExtTaskMapper extTaskMapper;

View File

@ -7,9 +7,12 @@ import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.consumer.LoadTestFinishEvent;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@Component
@Transactional(rollbackFor = Exception.class)
public class LoadReportStatusEvent implements LoadTestFinishEvent {
@Resource

View File

@ -10,6 +10,7 @@ import io.metersphere.commons.utils.LogUtil;
import io.metersphere.track.dto.TestPlanLoadCaseEventDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@ -19,6 +20,7 @@ import javax.annotation.Resource;
* @Description
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class TestPlanLoadCaseEvent implements LoadTestFinishEvent {
@Resource
TestPlanReportService testPlanReportService;

View File

@ -6,6 +6,7 @@ import io.metersphere.base.mapper.TestPlanReportResourceMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanReportResourceMapper;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.HashMap;
@ -17,6 +18,7 @@ import java.util.Map;
* @Date 2021/8/2 1:57 下午
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class TestPlanReportResourceService {
@Resource
private TestPlanReportResourceMapper testPlanReportResourceMapper;

View File

@ -34,6 +34,7 @@ import org.apache.ibatis.session.SqlSessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
@ -47,6 +48,7 @@ import java.util.stream.Collectors;
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class TestPlanReportService {
Logger testPlanLog = LoggerFactory.getLogger("testPlanExecuteLog");

@ -1 +1 @@
Subproject commit 884175a5ebc7fdebe31d307c0e000c45f7f96e81
Subproject commit fe8e2987719827cc64ca68a65772f6315ffb1719