Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]New user configuration function added to the management console #4948 #4954

Merged
merged 23 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6affc4b
The value configured by Linkis is trimmed.
peacewong Oct 24, 2023
e1111ab
linkis-cli add version info to source map
peacewong Oct 24, 2023
5aee61c
cs service supports active and standby configuration logic
peacewong Oct 24, 2023
b8b8238
Linkis base info support to return linkis cluster info
peacewong Oct 24, 2023
b21ad6e
[Feature][mg-eureka] List eureka service instance close #4884
peacewong Oct 24, 2023
3b2b1d2
The information returned by a running task should not contain error i…
peacewong Oct 24, 2023
f1f944d
code optimize
peacewong Oct 24, 2023
22497f7
UDF info add desc info return
peacewong Oct 24, 2023
49bd9a2
add new create file method support set owner
peacewong Oct 24, 2023
bdc7a5c
Distributed lock optimization adds lock holding attributes to prevent…
peacewong Oct 24, 2023
1e70b84
add clear map method
peacewong Oct 24, 2023
46589ae
Basic data management adds UDF tree management
peacewong Oct 24, 2023
8c59c62
fix csv file with utf-8 with bom chart[&#xFEFF]
peacewong Oct 24, 2023
b91ec0f
[Feature]New configuration management function added to the managemen…
peacewong Oct 24, 2023
9556669
Add cross-cluster rule configuration
peacewong Oct 24, 2023
f838aa1
add template conf feature
peacewong Oct 25, 2023
d61915d
add template conf and cross cluster ddl
peacewong Oct 25, 2023
293356e
Fix build error
peacewong Oct 26, 2023
2a66bf6
add instancio-junit module
peacewong Oct 27, 2023
8225429
Merge remote-tracking branch 'upstream/master' into master-pes
peacewong Nov 7, 2023
08795ec
Fix integration test bug
peacewong Nov 8, 2023
f8936ce
Fix integration test bug
peacewong Nov 8, 2023
234c38e
Fix integration test bug
peacewong Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,20 @@ private[conf] object BDPConfiguration extends Logging {

private[common] def formatValue[T](defaultValue: T, value: Option[String]): Option[T] = {
if (value.isEmpty || value.exists(StringUtils.isEmpty)) return Option(defaultValue)
val trimValue = value.map(_.trim)
val formattedValue = defaultValue match {
case _: String => value
case _: Byte => value.map(_.toByte)
case _: Short => value.map(_.toShort)
case _: Char => value.map(_.toCharArray.apply(0))
case _: Int => value.map(_.toInt)
case _: Long => value.map(_.toLong)
case _: Float => value.map(_.toFloat)
case _: Double => value.map(_.toDouble)
case _: Boolean => value.map(_.toBoolean)
case _: TimeType => value.map(new TimeType(_))
case _: ByteType => value.map(new ByteType(_))
case null => value
case _: String => trimValue
case _: Byte => trimValue.map(_.toByte)
case _: Short => trimValue.map(_.toShort)
case _: Char => trimValue.map(_.toCharArray.apply(0))
case _: Int => trimValue.map(_.toInt)
case _: Long => trimValue.map(_.toLong)
case _: Float => trimValue.map(_.toFloat)
case _: Double => trimValue.map(_.toDouble)
case _: Boolean => trimValue.map(_.toBoolean)
case _: TimeType => trimValue.map(new TimeType(_))
case _: ByteType => trimValue.map(new ByteType(_))
case null => trimValue
}
formattedValue.asInstanceOf[Option[T]]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object LogUtils {
}

def generateERROR(rawLog: String): String = {
getTimeFormat + " " + "ERROR" + " " + rawLog
getTimeFormat + " " + ERROR_STR + " " + rawLog
}

def generateWarn(rawLog: String): String = {
Expand All @@ -52,4 +52,6 @@ object LogUtils {
getTimeFormat + " " + "SYSTEM-WARN" + " " + rawLog
}

val ERROR_STR = "ERROR"

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ object TaskUtils {
}
} else params.put(key, waitToAdd)

private def clearMap(params: util.Map[String, AnyRef], key: String): Unit =
if (params != null && params.containsKey(key)) {
params.get(key) match {
case map: util.Map[String, AnyRef] => map.clear()
case _ => params.put(key, new util.HashMap[String, AnyRef]())
}
}

private def getConfigurationMap(
params: util.Map[String, AnyRef],
key: String
Expand Down Expand Up @@ -84,13 +92,20 @@ object TaskUtils {
def addStartupMap(params: util.Map[String, AnyRef], startupMap: util.Map[String, AnyRef]): Unit =
addConfigurationMap(params, startupMap, TaskConstant.PARAMS_CONFIGURATION_STARTUP)

def clearStartupMap(params: util.Map[String, AnyRef]): Unit = {
val configurationMap = getMap(params, TaskConstant.PARAMS_CONFIGURATION)
if (!configurationMap.isEmpty) {
clearMap(configurationMap, TaskConstant.PARAMS_CONFIGURATION_STARTUP)
}
}

def addRuntimeMap(params: util.Map[String, AnyRef], runtimeMap: util.Map[String, AnyRef]): Unit =
addConfigurationMap(params, runtimeMap, TaskConstant.PARAMS_CONFIGURATION_RUNTIME)

def addSpecialMap(params: util.Map[String, AnyRef], specialMap: util.Map[String, AnyRef]): Unit =
addConfigurationMap(params, specialMap, TaskConstant.PARAMS_CONFIGURATION_SPECIAL)

// tdoo
// todo
def getLabelsMap(params: util.Map[String, AnyRef]): util.Map[String, AnyRef] =
getMap(params, TaskConstant.LABELS)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,30 @@ public static void createNewFileWithFileSystem(
}
}

/**
* create new file and set file owner by FileSystem
*
* @param fileSystem
* @param filePath
* @param user
* @param createParentWhenNotExists
*/
public static void createNewFileAndSetOwnerWithFileSystem(
FileSystem fileSystem, FsPath filePath, String user, boolean createParentWhenNotExists)
throws Exception {
if (!fileSystem.exists(filePath)) {
if (!fileSystem.exists(filePath.getParent())) {
if (!createParentWhenNotExists) {
throw new IOException(
"parent dir " + filePath.getParent().getPath() + " dose not exists.");
}
mkdirs(fileSystem, filePath.getParent(), user);
}
fileSystem.createNewFile(filePath);
fileSystem.setOwner(filePath, user);
}
}

/**
* Recursively create a directory
*
Expand Down Expand Up @@ -133,4 +157,39 @@ public static boolean mkdirs(FileSystem fileSystem, FsPath dest, String user) th
}
return true;
}

/**
* Recursively create a directory(递归创建目录) add owner info
*
* @param fileSystem
* @param dest
* @param user
* @throws IOException
* @return
*/
public static boolean mkdirsAndSetOwner(FileSystem fileSystem, FsPath dest, String user)
throws IOException {
FsPath parentPath = dest.getParent();
Stack<FsPath> dirsToMake = new Stack<>();
dirsToMake.push(dest);
while (!fileSystem.exists(parentPath)) {
dirsToMake.push(parentPath);

if (Objects.isNull(parentPath.getParent())) {
// parent path of root is null
break;
}

parentPath = parentPath.getParent();
}
if (!fileSystem.canExecute(parentPath)) {
throw new IOException("You have not permission to access path " + dest.getPath());
}
while (!dirsToMake.empty()) {
FsPath path = dirsToMake.pop();
fileSystem.mkdir(path);
fileSystem.setOwner(path, user);
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.linkis.cli.application.operator.ujes.LinkisJobOper;
import org.apache.linkis.cli.application.operator.ujes.UJESClientFactory;
import org.apache.linkis.cli.application.utils.CliUtils;
import org.apache.linkis.cli.application.utils.LoggerManager;

import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -135,14 +136,22 @@ public static InteractiveJobDesc build(CliCtx ctx) {
}

if (StringUtils.isBlank(code) && StringUtils.isNotBlank(codePath)) {
code = CliUtils.readFile(codePath);
try {
code = CliUtils.readFile(codePath);
} catch (Exception e) {
LoggerManager.getInformationLogger().error("Failed to read file", e);
throw e;
}
}

executionMap.put(LinkisKeys.KEY_CODE, code);
labelMap.put(LinkisKeys.KEY_ENGINETYPE, engineType);
labelMap.put(LinkisKeys.KEY_CODETYPE, runType);
labelMap.put(LinkisKeys.KEY_USER_CREATOR, proxyUsr + "-" + creator);
sourceMap.put(LinkisKeys.KEY_SCRIPT_PATH, scriptPath);
if (ctx.getExtraMap().containsKey(CliKeys.VERSION)) {
sourceMap.put(LinkisKeys.CLI_VERSION, ctx.getExtraMap().get(CliKeys.VERSION));
}
runtimeMap.put(LinkisKeys.KEY_HIVE_RESULT_DISPLAY_TBALE, true);

desc.setCreator(creator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public static void writeToFile(
String pathName, String fileName, String content, Boolean overWrite) {

File dir = new File(pathName);
File file = new File(fileName);

if (!dir.exists()) {
try {
Expand All @@ -47,6 +46,8 @@ public static void writeToFile(
}
}

File file = new File(dir.getAbsolutePath() + File.separator + fileName);

if (overWrite || !file.exists()) {
try {
file.createNewFile();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.linkis.governance.common.entity;

public class TemplateConfKey {

private String templateUuid;

private String key;

private String templateName;

private String configValue;

public String getTemplateUuid() {
return templateUuid;
}

public void setTemplateUuid(String templateUuid) {
this.templateUuid = templateUuid;
}

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

public String getTemplateName() {
return templateName;
}

public void setTemplateName(String templateName) {
this.templateName = templateName;
}

public String getConfigValue() {
return configValue;
}

public void setConfigValue(String configValue) {
this.configValue = configValue;
}

@Override
public String toString() {
return "TemplateKey{"
+ "templateUuid='"
+ templateUuid
+ '\''
+ ", key='"
+ key
+ '\''
+ ", templateName='"
+ templateName
+ '\''
+ ", configValue='"
+ configValue
+ '\''
+ '}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.linkis.governance.common.protocol.conf;

import org.apache.linkis.protocol.message.RequestProtocol;

public class TemplateConfRequest implements RequestProtocol {

private String templateUuid;

private String templateName;

public TemplateConfRequest(String templateUuid, String templateName) {
this.templateUuid = templateUuid;
this.templateName = templateName;
}

public TemplateConfRequest(String templateUuid) {
this.templateUuid = templateUuid;
}

public String getTemplateUuid() {
return templateUuid;
}

public void setTemplateUuid(String templateUuid) {
this.templateUuid = templateUuid;
}

public String getTemplateName() {
return templateName;
}

public void setTemplateName(String templateName) {
this.templateName = templateName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.linkis.governance.common.protocol.conf;

import org.apache.linkis.governance.common.entity.TemplateConfKey;

import java.util.ArrayList;
import java.util.List;

public class TemplateConfResponse {

private List<TemplateConfKey> list = new ArrayList<>();

public List<TemplateConfKey> getList() {
return list;
}

public void setList(List<TemplateConfKey> list) {
this.list = list;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,4 @@ object GovernanceCommonConf {
val EC_APP_MANAGE_MODE =
CommonVars("linkis.ec.app.manage.mode", "attach")

val SCALA_PARSE_APPEND_CODE_ENABLED =
CommonVars("linkis.scala.parse.append.code.enable", true).getValue

val SCALA_PARSE_APPEND_CODE =
CommonVars("linkis.scala.parse.append.code", "val linkisVar=1").getValue

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.linkis.governance.common.exception

import org.apache.linkis.common.exception.{ErrorException, ExceptionLevel, LinkisRuntimeException}
import org.apache.linkis.common.exception.{ExceptionLevel, LinkisRuntimeException}

class GovernanceErrorException(errorCode: Int, errorMsg: String)
extends LinkisRuntimeException(errorCode, errorMsg) {
Expand Down
Loading
Loading