Unverified Commit 268f085b authored by ZackYoung's avatar ZackYoung Committed by GitHub

[fix][git] fix git front web & mp tenant get is npe (#2020)

* fix git front web & mp tenant get is npe * optimize ds config
parent b3936f7a
......@@ -74,7 +74,7 @@ public class MybatisPlusConfig {
"dinky_savepoints",
"dinky_task",
"dinky_task_statement",
// "dinky_git_project",
"dinky_git_project",
"dinky_task_version");
@Bean
......
......@@ -22,7 +22,7 @@ package org.dinky.context;
/** TenantContextHolder */
public class TenantContextHolder {
private static final ThreadLocal<Object> TENANT_CONTEXT = new ThreadLocal<>();
private static final ThreadLocal<Object> TENANT_CONTEXT = new InheritableThreadLocal<>();
public static void set(Object value) {
TENANT_CONTEXT.set(value);
......
......@@ -29,6 +29,7 @@ import org.dinky.data.model.Tenant;
import org.dinky.function.constant.PathConstant;
import org.dinky.function.pool.UdfCodePool;
import org.dinky.job.FlinkJobTask;
import org.dinky.process.exception.DinkyException;
import org.dinky.scheduler.client.ProjectClient;
import org.dinky.scheduler.exception.SchedulerException;
import org.dinky.scheduler.model.Project;
......@@ -54,6 +55,7 @@ import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
/**
......@@ -106,6 +108,16 @@ public class SystemInit implements ApplicationRunner {
c -> {
if (c == systemConfiguration.getDolphinschedulerEnable()) {
if (systemConfiguration.getDolphinschedulerEnable().getValue()) {
if (StrUtil.hasBlank(
systemConfiguration.getDolphinschedulerUrl().getValue(),
systemConfiguration.getDolphinschedulerProjectName().getValue(),
systemConfiguration.getDolphinschedulerToken().getValue())) {
sysConfigService.updateSysConfigByKv(
systemConfiguration.getDolphinschedulerEnable().getKey(),
"false");
throw new DinkyException(
"Before starting dolphinscheduler docking, please fill in the relevant configuration");
}
try {
project = projectClient.getDinkyProject();
if (Asserts.isNull(project)) {
......@@ -113,6 +125,7 @@ public class SystemInit implements ApplicationRunner {
}
} catch (Exception e) {
log.error("Error in DolphinScheduler: ", e);
throw new DinkyException(e);
}
}
}
......
......@@ -24,6 +24,7 @@ import org.dinky.data.model.SysConfig;
import org.dinky.data.model.SystemConfiguration;
import org.dinky.mapper.SysConfigMapper;
import org.dinky.mybatis.service.impl.SuperServiceImpl;
import org.dinky.process.exception.DinkyException;
import org.dinky.service.SysConfigService;
import java.util.HashMap;
......@@ -39,6 +40,7 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
/**
* SysConfigServiceImpl
......@@ -85,8 +87,19 @@ public class SysConfigServiceImpl extends SuperServiceImpl<SysConfigMapper, SysC
public void updateSysConfigByKv(String key, String value) {
SysConfig config = getOne(new QueryWrapper<SysConfig>().eq("name", key));
config.setValue(value);
config.updateById();
SystemConfiguration systemConfiguration = SystemConfiguration.getInstances();
SystemConfiguration.getInstances().setConfiguration(MapUtil.of(key, value));
if (key.equals(systemConfiguration.getDolphinschedulerEnable().getKey())
&& Convert.toBool(value)) {
if (StrUtil.hasBlank(
systemConfiguration.getDolphinschedulerUrl().getValue(),
systemConfiguration.getDolphinschedulerProjectName().getValue(),
systemConfiguration.getDolphinschedulerToken().getValue())) {
throw new DinkyException(
"Before starting dolphinscheduler docking, please fill in the relevant configuration");
}
}
systemConfiguration.setConfiguration(MapUtil.of(key, value));
config.updateById();
}
}
......@@ -88,7 +88,7 @@ public class MavenStepSse extends StepSse {
getLogFile().getAbsolutePath(),
CollUtil.newArrayList("clean", "package"),
StrUtil.split(gitProject.getBuildArgs(), " "),
this::addMsg);
this::addFileMsgLog);
params.put("pom", pom);
Assert.isTrue(state, "maven build failed");
}
......
......@@ -99,14 +99,15 @@ public class MavenUtil {
}
String mavenCommandLine =
getMavenCommandLine(pom, mavenHome, localRepositoryDirectory, setting, goals, args);
Opt.ofNullable(consumer)
.ifPresent(c -> c.accept("Executing command: " + mavenCommandLine + "\n"));
int waitValue =
RuntimeUtils.run(
mavenCommandLine,
s -> {
s = DateUtil.date().toMsStr() + " - " + s;
s = DateUtil.date().toMsStr() + " - " + s + "\n";
consumer.accept(s);
FileUtil.writeUtf8String(s, logFile);
},
log::error);
return waitValue == 0;
......
......@@ -156,8 +156,9 @@ public class SystemConfiguration {
item.setValue(value);
});
// initRun
CONFIGURATION_LIST.forEach(
c -> Opt.ofNullable(this.initMethod).ifPresent(x -> x.accept(c)));
for (Configuration<?> configuration : CONFIGURATION_LIST) {
Opt.ofNullable(this.initMethod).ifPresent(x -> x.accept(configuration));
}
}
public Map<String, List<Configuration<?>>> getAllConfiguration() {
......
......@@ -100,9 +100,20 @@ public class ProjectClient {
.execute()
.body();
return MyJSONUtil.toPageBeanAndFindByName(
Project pageBeanAndFindByName = null;
try {
pageBeanAndFindByName =
MyJSONUtil.toPageBeanAndFindByName(
content,
SystemConfiguration.getInstances().getDolphinschedulerProjectName().getValue(),
SystemConfiguration.getInstances()
.getDolphinschedulerProjectName()
.getValue(),
Project.class);
} catch (Exception e) {
SystemConfiguration.getInstances().getDolphinschedulerEnable().setValue(false);
throw new RuntimeException(content);
}
return pageBeanAndFindByName;
}
}
......@@ -83,6 +83,7 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
let stepNum: number = 1;
let showDataStep = -1;
let showData = "";
let finish = false;
//sse listen event message
eventSource.onmessage = e => {
......@@ -108,9 +109,9 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
title: renderTitle(item.step),
status: renderStatus(item.status),
description: item.startTime,
disabled: item.status === -1 || status === 1,
disabled: true,
onClick: () => {
if (item.status !== -1 && status !== 1) {
if (finish) {
if (item.step === showDataStep) {
setShowList(true)
setLog(showData)
......@@ -138,9 +139,8 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
} else if (type === 2) {
showDataStep = currentStep;
showData = JSON.parse(data);
}else if (type===3){
stepArray[currentStep].description=data;
return
} else if (type === 3) {
stepArray[currentStep].description = data;
}
if (currentStep >= globalCurrentStep) {
......@@ -148,11 +148,17 @@ export const BuildSteps: React.FC<BuildStepsProps> = (props) => {
setPercent(parseInt(String(100 / stepNum * currentStep)));
stepArray[currentStep - 1].status = renderStatus(status)
}
if ((status === 2 || status === 0) && history === false) {
if ((status === 2 || status === 0) && currentStep === stepNum) {
if (currentStep === stepNum) {
stepArray.forEach(d => d.disabled = false)
}
finish = true;
eventSource.close();
return;
}
}
} catch (e) {
finish = true;
eventSource.close();
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment