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