test
youys 3 years ago
parent 066d39344a
commit 2f8921fd26

@ -14,7 +14,7 @@ public class ThreadPoolConfig {
@Primary
public ExecutorService sonarScannerPool() {
ThreadFactory sonarScannerPool = new CustomizableThreadFactory("sonarScanner-pool-");
return new ThreadPoolExecutor(20, 20, 0,
return new ThreadPoolExecutor(10, 10, 0,
TimeUnit.SECONDS, new ArrayBlockingQueue<>(10000), sonarScannerPool,
new ThreadPoolExecutor.AbortPolicy());
}
@ -23,7 +23,7 @@ public class ThreadPoolConfig {
@Bean("sonarQueryResultPool")
public ExecutorService queryResultPool() {
ThreadFactory sonarQueryResultPool = new CustomizableThreadFactory("sonarQueryResult-pool-");
return new ThreadPoolExecutor(10, 10, 0,
return new ThreadPoolExecutor(5, 5, 0,
TimeUnit.SECONDS, new ArrayBlockingQueue<>(10000),
sonarQueryResultPool,
new ThreadPoolExecutor.AbortPolicy());

@ -63,7 +63,9 @@ public class SonarService {
"-Dsonar.java.binaries=./ " +
"-Dsonar.projectBaseDir=" + param.getProjectPath();
SystemUtil.executeAndGetExitStatus(command);
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
log.info("java语言:command{},result:{}",command,executeResp.getOutput());
});
concurrentHashMap.put(Constant.PYTHON, param -> {
String command = "sonar-scanner " +
@ -72,7 +74,8 @@ public class SonarService {
"-Dsonar.projectKey=" + param.getProjectKey() + " " +
"-Dsonar.projectBaseDir=" + param.getProjectPath();
SystemUtil.executeAndGetExitStatus(command);
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
log.info("python语言:command{},result:{}",command,executeResp.getOutput());
});
concurrentHashMap.put(Constant.C, param -> {
String command = "cppcheck --xml --xml-version=2 --enable=all " + param.getProjectPath() + " 2> " + param.getCppCheckReportPath() +
@ -82,7 +85,8 @@ public class SonarService {
"-Dsonar.projectKey=" + param.getProjectKey() + " " +
"-Dsonar.cxx.cppcheck.reportPath=" + param.getCppCheckReportPath() + " " +
"-Dsonar.projectBaseDir=" + param.getProjectPath();
SystemUtil.executeAndGetExitStatus(command);
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
log.info("c语言:command{},result:{}",command,executeResp.getOutput());
});
concurrentHashMap.put(Constant.CXX, param -> {
String command = "cppcheck --xml --xml-version=2 --enable=all " + param.getProjectPath() + " 2> " + param.getCppCheckReportPath() +
@ -93,7 +97,7 @@ public class SonarService {
"-Dsonar.cxx.cppcheck.reportPath=" + param.getCppCheckReportPath() + " " +
"-Dsonar.projectBaseDir=" + param.getProjectPath();
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus(command);
log.info("command:{}, result:{}", command, executeResp.getOutput());
log.info("c++: command:{}, result:{}", command, executeResp.getOutput());
});
}

@ -1,7 +1,6 @@
package net.educoder.ecsonar.task;
import net.educoder.ecsonar.services.DbOperateService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -31,10 +30,10 @@ public class SonarQueryResultRunnable implements Runnable {
int count = 0;
String status;
while((status = dbOperateService.queryCeActivityStatus(projectName)) == null && count++ <=120){
while((status = dbOperateService.queryCeActivityStatus(projectName)) == null && count++ <= 60){
LOGGER.info("detailId:[{}],sonar还未执行完,次数:{}", detailId, count);
try {
Thread.sleep(1000);
Thread.sleep(2000);
} catch (InterruptedException e) {}
}
// 查询

Loading…
Cancel
Save