From 6affc4b2cfd2fcfd39a4e45164f34206499dde68 Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 11:57:05 +0800 Subject: [PATCH 01/22] The value configured by Linkis is trimmed. --- .../linkis/common/conf/BDPConfiguration.scala | 25 ++++++++++--------- .../apache/linkis/common/log/LogUtils.scala | 4 ++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/conf/BDPConfiguration.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/conf/BDPConfiguration.scala index 14febab63a..9bfa053b77 100644 --- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/conf/BDPConfiguration.scala +++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/conf/BDPConfiguration.scala @@ -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]] } diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/log/LogUtils.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/log/LogUtils.scala index 77c82f3883..e558e765be 100644 --- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/log/LogUtils.scala +++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/log/LogUtils.scala @@ -33,7 +33,7 @@ object LogUtils { } def generateERROR(rawLog: String): String = { - getTimeFormat + " " + "ERROR" + " " + rawLog + getTimeFormat + " " + ERROR_STR + " " + rawLog } def generateWarn(rawLog: String): String = { @@ -52,4 +52,6 @@ object LogUtils { getTimeFormat + " " + "SYSTEM-WARN" + " " + rawLog } + val ERROR_STR = "ERROR" + } From e1111ab54e33414140e9a5d98737e0506bd68cca Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 19:41:35 +0800 Subject: [PATCH 02/22] linkis-cli add version info to source map --- .../job/interactive/InteractiveJobDescBuilder.java | 11 ++++++++++- .../application/present/file/ResultFileWriter.java | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/interactor/job/interactive/InteractiveJobDescBuilder.java b/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/interactor/job/interactive/InteractiveJobDescBuilder.java index 0c8a3db539..2b0b20188a 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/interactor/job/interactive/InteractiveJobDescBuilder.java +++ b/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/interactor/job/interactive/InteractiveJobDescBuilder.java @@ -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; @@ -135,7 +136,12 @@ 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); @@ -143,6 +149,9 @@ public static InteractiveJobDesc build(CliCtx ctx) { 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); diff --git a/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/present/file/ResultFileWriter.java b/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/present/file/ResultFileWriter.java index 9a54699165..c2d47e2b7a 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/present/file/ResultFileWriter.java +++ b/linkis-computation-governance/linkis-client/linkis-cli/src/main/java/org/apache/linkis/cli/application/present/file/ResultFileWriter.java @@ -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 { @@ -47,6 +46,8 @@ public static void writeToFile( } } + File file = new File(dir.getAbsolutePath() + File.separator + fileName); + if (overWrite || !file.exists()) { try { file.createNewFile(); From 5aee61ca496a813a52f43be64a0a75b183092e22 Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 19:44:36 +0800 Subject: [PATCH 03/22] cs service supports active and standby configuration logic --- .../linkis-cs-server/pom.xml | 5 + .../cs/server/conf/ContextServerConf.java | 3 + .../server/label/CSInstanceLabelClient.java | 104 ++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/org/apache/linkis/cs/server/label/CSInstanceLabelClient.java diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/pom.xml index 8e44eefd8b..31bf7a38e5 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/pom.xml @@ -44,6 +44,11 @@ linkis-pes-rpc-client ${project.version} + + org.apache.linkis + linkis-ps-common-lock + ${project.version} + org.apache.linkis diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/org/apache/linkis/cs/server/conf/ContextServerConf.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/org/apache/linkis/cs/server/conf/ContextServerConf.java index 4892d6b090..3cf7d67a01 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/org/apache/linkis/cs/server/conf/ContextServerConf.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/org/apache/linkis/cs/server/conf/ContextServerConf.java @@ -34,4 +34,7 @@ public class ContextServerConf { public static final long CS_SCHEDULER_JOB_WAIT_MILLS = CommonVars.apply("wds.linkis.cs.job.wait.mills", 10000).getValue(); + + public static final String CS_LABEL_SUFFIX = + CommonVars.apply("wds.linkis.cs.label.suffix", "").getValue(); } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/org/apache/linkis/cs/server/label/CSInstanceLabelClient.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/org/apache/linkis/cs/server/label/CSInstanceLabelClient.java new file mode 100644 index 0000000000..7e3b671385 --- /dev/null +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/org/apache/linkis/cs/server/label/CSInstanceLabelClient.java @@ -0,0 +1,104 @@ +/* + * 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.cs.server.label; + +import org.apache.linkis.common.utils.Utils; +import org.apache.linkis.cs.server.conf.ContextServerConf; +import org.apache.linkis.instance.label.client.InstanceLabelClient; +import org.apache.linkis.manager.label.constant.LabelKeyConstant; +import org.apache.linkis.protocol.label.InsLabelRefreshRequest; +import org.apache.linkis.protocol.label.InsLabelRemoveRequest; +import org.apache.linkis.publicservice.common.lock.entity.CommonLock; +import org.apache.linkis.publicservice.common.lock.service.CommonLockService; +import org.apache.linkis.rpc.Sender; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.availability.AvailabilityChangeEvent; +import org.springframework.boot.availability.AvailabilityState; +import org.springframework.boot.availability.ReadinessState; +import org.springframework.context.event.ContextClosedEvent; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.springframework.boot.availability.ReadinessState.ACCEPTING_TRAFFIC; + +@Component +public class CSInstanceLabelClient { + private static final Logger logger = LoggerFactory.getLogger(CSInstanceLabelClient.class); + + @Autowired CommonLockService commonLockService; + + private String _LOCK = "_MASTER_PS_CS_LABEL_LOCK"; + CommonLock commonLock = new CommonLock(); + private boolean lock = false; + + @EventListener(classes = {AvailabilityChangeEvent.class}) + public void init(AvailabilityChangeEvent availabilityChangeEvent) { + AvailabilityState state = availabilityChangeEvent.getState(); + logger.info("CSInstanceLabelClient app state {}", state); + + if (state instanceof ReadinessState && state == ACCEPTING_TRAFFIC) { + Map labels = new HashMap<>(1); + commonLock.setLockObject(_LOCK); + commonLock.setCreateTime(new Date()); + commonLock.setUpdateTime(new Date()); + commonLock.setCreator(Utils.getJvmUser()); + commonLock.setLocker(Utils.getLocalHostname()); + commonLock.setUpdator(Utils.getJvmUser()); + lock = commonLockService.reentrantLock(commonLock, -1L); + String suffix = ContextServerConf.CS_LABEL_SUFFIX; + String confLabel; + + if (lock) { + // master node set cs_1_xxx label + logger.info("The master ps-cs node get lock by {}", _LOCK + "-" + commonLock.getLocker()); + confLabel = "cs_1_" + suffix; + } else { + confLabel = "cs_2_" + suffix; + } + logger.info("register label {} to ps-cs node.", confLabel); + labels.put(LabelKeyConstant.ROUTE_KEY, confLabel); + InsLabelRefreshRequest insLabelRefreshRequest = new InsLabelRefreshRequest(); + insLabelRefreshRequest.setLabels(labels); + insLabelRefreshRequest.setServiceInstance(Sender.getThisServiceInstance()); + InstanceLabelClient.getInstance().refreshLabelsToInstance(insLabelRefreshRequest); + } + } + + @EventListener(classes = {ContextClosedEvent.class}) + public void shutdown(ContextClosedEvent contextClosedEvent) { + logger.info("To remove labels for instance"); + InsLabelRemoveRequest insLabelRemoveRequest = new InsLabelRemoveRequest(); + insLabelRemoveRequest.setServiceInstance(Sender.getThisServiceInstance()); + InstanceLabelClient.getInstance().removeLabelsFromInstance(insLabelRemoveRequest); + logger.info("success to send clear label rpc request"); + if (lock) { + commonLockService.unlock(commonLock); + logger.info( + "The master ps-cs node has released lock {}.", + commonLock.getLockObject() + "-" + commonLock.getLocker()); + } + } +} From b8b82389a9c547c2d81a537e5dea31a56dcc5bb5 Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 19:45:28 +0800 Subject: [PATCH 04/22] Linkis base info support to return linkis cluster info --- .../apache/linkis/gateway/config/GatewayConfiguration.scala | 2 ++ .../org/apache/linkis/gateway/security/UserRestful.scala | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/config/GatewayConfiguration.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/config/GatewayConfiguration.scala index f7558fcad6..cace679033 100644 --- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/config/GatewayConfiguration.scala +++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/config/GatewayConfiguration.scala @@ -108,4 +108,6 @@ object GatewayConfiguration { val IS_DOWNLOAD = CommonVars("linkis.web.result.set.export.enable", true) + val LINKIS_CLUSTER_NAME = CommonVars("linkis.cluster.name", "") + } diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/security/UserRestful.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/security/UserRestful.scala index b0f42f9ad0..40b0630706 100644 --- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/security/UserRestful.scala +++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/security/UserRestful.scala @@ -73,7 +73,7 @@ abstract class AbstractUserRestful extends UserRestful with Logging { Utils.tryCatch { val loginUser = GatewaySSOUtils.getLoginUsername(gatewayContext) Message - .ok(loginUser + "Already logged in, please log out before signing in(已经登录,请先退出再进行登录)!") + .ok(loginUser + " already logged in, please log out before signing in(已经登录,请先退出再进行登录)!") .data("userName", loginUser) }(_ => login(gatewayContext)) case "token-login" => @@ -146,6 +146,8 @@ abstract class AbstractUserRestful extends UserRestful with Logging { Message .ok("get baseinfo success(获取成功)!") .data("resultSetExportEnable", GatewayConfiguration.IS_DOWNLOAD.getValue) + .data("linkisClusterName", GatewayConfiguration.LINKIS_CLUSTER_NAME.getValue) + } def publicKey(gatewayContext: GatewayContext): Message = { From b21ad6efe5ba72b7fa1b30981c2f3c476a52133c Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 19:49:01 +0800 Subject: [PATCH 05/22] [Feature][mg-eureka] List eureka service instance close #4884 --- .../label/restful/InstanceRestful.java | 44 ++++++++++++++----- .../service/impl/DefaultInsLabelService.java | 6 --- .../mapper/mysql/InsLabelRelationMapper.xml | 5 ++- .../postgresql/InsLabelRelationMapper.xml | 5 ++- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/java/org/apache/linkis/instance/label/restful/InstanceRestful.java b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/java/org/apache/linkis/instance/label/restful/InstanceRestful.java index 5b333cd6f6..db379f0853 100644 --- a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/java/org/apache/linkis/instance/label/restful/InstanceRestful.java +++ b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/java/org/apache/linkis/instance/label/restful/InstanceRestful.java @@ -37,19 +37,14 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.cloud.client.discovery.DiscoveryClient; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; import com.fasterxml.jackson.databind.JsonNode; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; @@ -74,6 +69,8 @@ public class InstanceRestful { @Autowired private DefaultInsLabelService insLabelService; + @Autowired private DiscoveryClient discoveryClient; + @ApiOperation( value = "listAllInstanceWithLabel", notes = "list all instance with label", @@ -172,4 +169,31 @@ public Message getServiceRegistryURL(HttpServletRequest request) throws Exceptio ModuleUserUtils.getOperationUser(request, "getServiceRegistryURL"); return Message.ok().data("url", serviceRegistryURL); } + + @ApiOperation(value = "getServiceInstances", response = Message.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "serviceName", required = false, dataType = "String"), + @ApiImplicitParam(name = "ip", required = false, dataType = "ip") + }) + @RequestMapping(path = "/serviceInstances", method = RequestMethod.GET) + public Message getServiceInstance( + HttpServletRequest request, + @RequestParam(value = "serviceName", required = false) String serviceName, + @RequestParam(value = "ip", required = false) String ip) { + Stream serviceStream = discoveryClient.getServices().stream(); + serviceStream = serviceStream.filter(s -> s.toUpperCase().contains("LINKIS")); + if (StringUtils.isNotBlank(serviceName)) { + serviceStream = + serviceStream.filter(s -> s.toUpperCase().contains(serviceName.toUpperCase())); + } + List instanceList = + serviceStream + .flatMap(serviceId -> discoveryClient.getInstances(serviceId).stream()) + .collect(Collectors.toList()); + if (StringUtils.isNotBlank(ip)) { + instanceList = + instanceList.stream().filter(s -> s.getHost().equals(ip)).collect(Collectors.toList()); + } + return Message.ok().data("list", instanceList); + } } diff --git a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/java/org/apache/linkis/instance/label/service/impl/DefaultInsLabelService.java b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/java/org/apache/linkis/instance/label/service/impl/DefaultInsLabelService.java index 5cc3bcc633..3b7aaf4c4b 100644 --- a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/java/org/apache/linkis/instance/label/service/impl/DefaultInsLabelService.java +++ b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/java/org/apache/linkis/instance/label/service/impl/DefaultInsLabelService.java @@ -140,12 +140,6 @@ public void refreshLabelsToInstance( List> labels, ServiceInstance serviceInstance) throws InstanceErrorException { List insLabels = toInsPersistenceLabels(labels); - // Label candidate to be removed - List labelsCandidateRemoved = - insLabelRelationDao.searchLabelsByInstance(serviceInstance.getInstance()); - if (!labelsCandidateRemoved.isEmpty()) { - labelsCandidateRemoved.removeAll(insLabels); - } LOG.info("Drop relationships related by instance: [" + serviceInstance.getInstance() + "]"); insLabelRelationDao.dropRelationsByInstance(serviceInstance.getInstance()); // Attach labels to instance diff --git a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/resources/mapper/mysql/InsLabelRelationMapper.xml b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/resources/mapper/mysql/InsLabelRelationMapper.xml index d3d0cfbe42..3263252d33 100644 --- a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/resources/mapper/mysql/InsLabelRelationMapper.xml +++ b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/resources/mapper/mysql/InsLabelRelationMapper.xml @@ -197,7 +197,10 @@ \ No newline at end of file diff --git a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/resources/mapper/postgresql/InsLabelRelationMapper.xml b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/resources/mapper/postgresql/InsLabelRelationMapper.xml index 9f19cdd14b..6d984aa1d6 100644 --- a/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/resources/mapper/postgresql/InsLabelRelationMapper.xml +++ b/linkis-public-enhancements/linkis-instance-label/linkis-instance-label-server/src/main/resources/mapper/postgresql/InsLabelRelationMapper.xml @@ -197,6 +197,9 @@ \ No newline at end of file From 3b2b1d2a58618d84beaf59ca81d3dfd32119b9c3 Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 20:00:11 +0800 Subject: [PATCH 06/22] The information returned by a running task should not contain error information --- .../restful/api/QueryRestfulApi.java | 73 ++++++++++++++----- .../impl/JobHistoryQueryServiceImpl.scala | 5 +- 2 files changed, 55 insertions(+), 23 deletions(-) diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java index f627fb6b15..a18da3a042 100644 --- a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java +++ b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java @@ -25,6 +25,7 @@ import org.apache.linkis.jobhistory.conversions.TaskConversions; import org.apache.linkis.jobhistory.entity.*; import org.apache.linkis.jobhistory.service.JobHistoryQueryService; +import org.apache.linkis.jobhistory.transitional.TaskStatus; import org.apache.linkis.jobhistory.util.QueryUtils; import org.apache.linkis.protocol.constants.TaskConstant; import org.apache.linkis.server.Message; @@ -101,6 +102,10 @@ public Message getTaskByID(HttpServletRequest req, @PathVariable("id") Long jobI return Message.error( "The corresponding job was not found, or there may be no permission to view the job" + "(没有找到对应的job,也可能是没有查看该job的权限)"); + } else if (taskVO.getStatus().equals(TaskStatus.Running.toString())) { + // 任务运行时不显示异常信息(Do not display exception information during task runtime) + taskVO.setErrCode(null); + taskVO.setErrDesc(null); } return Message.ok().data(TaskConstant.TASK, taskVO); @@ -227,14 +232,30 @@ public Message list( /** Method list should not contain subjob, which may cause performance problems. */ @ApiOperation(value = "listundonetasks", notes = "list undone tasks", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "startDate", dataType = "long"), - @ApiImplicitParam(name = "endDate", required = false, dataType = "long", value = "end date"), + @ApiImplicitParam( + name = "startDate", + required = false, + dataType = "Long", + value = "start date"), + @ApiImplicitParam(name = "endDate", required = false, dataType = "Long", value = "end date"), @ApiImplicitParam(name = "status", required = false, dataType = "String", value = "status"), @ApiImplicitParam(name = "pageNow", required = false, dataType = "Integer", value = "page now"), - @ApiImplicitParam(name = "pageSize", dataType = "Integer"), - @ApiImplicitParam(name = "creator", required = false, dataType = "String", value = "creator"), - @ApiImplicitParam(name = "engineType", dataType = "String"), - @ApiImplicitParam(name = "startTaskID", dataType = "long"), + @ApiImplicitParam( + name = "pageSize", + required = false, + dataType = "Integer", + value = "page size"), + @ApiImplicitParam( + name = "startTaskID", + required = false, + dataType = "Long", + value = "start task id"), + @ApiImplicitParam( + name = "engineType", + required = false, + dataType = "String", + value = "engine type"), + @ApiImplicitParam(name = "creator", required = false, dataType = "String", value = "creator") }) @RequestMapping(path = "/listundonetasks", method = RequestMethod.GET) public Message listundonetasks( @@ -321,13 +342,29 @@ public Message listundonetasks( @ApiOperation(value = "listundone", notes = "list undone", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "startDate", dataType = "long"), - @ApiImplicitParam(name = "endDate", required = false, dataType = "long", value = "end date"), - @ApiImplicitParam(name = "status", required = false, dataType = "String", value = "status"), + @ApiImplicitParam( + name = "startDate", + required = false, + dataType = "Long", + value = "start date"), + @ApiImplicitParam(name = "endDate", required = false, dataType = "Long", value = "end date"), @ApiImplicitParam(name = "pageNow", required = false, dataType = "Integer", value = "page now"), - @ApiImplicitParam(name = "creator", required = false, dataType = "String", value = "creator"), - @ApiImplicitParam(name = "engineType", dataType = "String"), - @ApiImplicitParam(name = "startTaskID", dataType = "long"), + @ApiImplicitParam( + name = "pageSize", + required = false, + dataType = "Integer", + value = "page size"), + @ApiImplicitParam( + name = "startTaskID", + required = false, + dataType = "Long", + value = "startTaskID"), + @ApiImplicitParam( + name = "engineType", + required = false, + dataType = "String", + value = "engineType"), + @ApiImplicitParam(name = "creator", required = false, dataType = "String", value = "creator") }) /** Method list should not contain subjob, which may cause performance problems. */ @RequestMapping(path = "/listundone", method = RequestMethod.GET) @@ -350,17 +387,13 @@ public Message listundone( } if (StringUtils.isEmpty(creator)) { creator = null; - } else { - if (!QueryUtils.checkNameValid(creator)) { - return Message.error("Invalid creator : " + creator); - } + } else if (!QueryUtils.checkNameValid(creator)) { + return Message.error("Invalid creator : " + creator); } if (StringUtils.isEmpty(engineType)) { engineType = null; - } else { - if (!QueryUtils.checkNameValid(engineType)) { - return Message.error("Invalid engienType: " + engineType); - } + } else if (!QueryUtils.checkNameValid(engineType)) { + return Message.error("Invalid engienType: " + engineType); } Date sDate = new Date(startDate); Date eDate = new Date(endDate); diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/impl/JobHistoryQueryServiceImpl.scala b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/impl/JobHistoryQueryServiceImpl.scala index f00abc5568..d906c60a8c 100644 --- a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/impl/JobHistoryQueryServiceImpl.scala +++ b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/service/impl/JobHistoryQueryServiceImpl.scala @@ -353,10 +353,9 @@ class JobHistoryQueryServiceImpl extends JobHistoryQueryService with Logging { startJobId: lang.Long ): Integer = { val cacheKey = - if (StringUtils.isNoneBlank(username, creator, engineType)) "" - else { + if (StringUtils.isNoneBlank(username, creator, engineType)) { s"${username}_${creator}_${engineType}" - } + } else "" if (StringUtils.isBlank(cacheKey)) { getCountUndoneTasks(username, creator, sDate, eDate, engineType, startJobId) } else { From f1f944d6c955679c109e612531872fd863e46611 Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 20:00:33 +0800 Subject: [PATCH 07/22] code optimize --- .../cache/impl/DefaultQueryCacheManager.java | 7 +----- .../jobhistory/dao/JobHistoryMapper.java | 6 ++--- .../mapper/mysql/JobHistoryMapper.xml | 6 ++--- .../jobhistory/dao/JobHistoryMapperTest.java | 7 ++++-- .../handler/LinkisErrorCodeHandler.java | 2 +- .../server/restful/ErrorCodeRestfulApi.java | 8 ++++-- .../restful/GatewayAuthTokenRestfulApi.java | 7 +++++- .../RmExternalResourceProviderRestfulApi.java | 9 +++++-- .../restful/api/BMLFsRestfulApi.java | 4 ++- .../label/client/InstanceLabelClient.scala | 25 ++++++++----------- 10 files changed, 43 insertions(+), 38 deletions(-) diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/cache/impl/DefaultQueryCacheManager.java b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/cache/impl/DefaultQueryCacheManager.java index c83d730b8b..7ff5aeb32d 100644 --- a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/cache/impl/DefaultQueryCacheManager.java +++ b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/cache/impl/DefaultQueryCacheManager.java @@ -195,12 +195,7 @@ public void refreshUndoneTask() { Date sDate = DateUtils.addDays(eDate, -1); queryTasks = jobHistoryMapper.searchWithIdOrderAsc( - undoneTaskMinId, - null, - Arrays.asList("Running", "Inited", "Scheduled"), - sDate, - eDate, - null); + sDate, eDate, undoneTaskMinId, Arrays.asList("Running", "Inited", "Scheduled")); } finally { PageHelper.clearPage(); } diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java index 7bb7656346..c25eee4a2e 100644 --- a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java +++ b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/JobHistoryMapper.java @@ -33,12 +33,10 @@ public interface JobHistoryMapper { void updateJobHistory(JobHistory jobReq); List searchWithIdOrderAsc( - @Param("id") Long id, - @Param("umUser") String username, - @Param("status") List status, @Param("startDate") Date startDate, @Param("endDate") Date endDate, - @Param("engineType") String engineType); + @Param("startId") Long startId, + @Param("status") List status); List search( @Param("id") Long id, diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/mysql/JobHistoryMapper.xml b/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/mysql/JobHistoryMapper.xml index 7a81b6c87a..c2a533a68b 100644 --- a/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/mysql/JobHistoryMapper.xml +++ b/linkis-public-enhancements/linkis-jobhistory/src/main/resources/mapper/mysql/JobHistoryMapper.xml @@ -98,13 +98,11 @@ @@ -114,9 +115,26 @@ SELECT - - FROM linkis_ps_udf_baseinfo - WHERE id IN - (SELECT udf_id FROM linkis_ps_udf_shared_info WHERE user_name=#{userName}) + info.id,info.`create_user`,info.`udf_name`,info.`udf_type`,info.`is_expire`,info.`is_shared`,info.`tree_id`,info.`create_time`,info.`update_time`, + info.`sys`,info.`cluster_name`, version_tmp.description + FROM + linkis_ps_udf_baseinfo info , + ( + SELECT + version_info.* + FROM + linkis_ps_udf_version version_info , ( + SELECT + udf_id , MAX(bml_resource_version) AS bml_resource_version + FROM + linkis_ps_udf_version + GROUP BY + udf_id + ) version_max + WHERE + version_max.udf_id = version_info.udf_id + AND version_max.bml_resource_version = version_info.bml_resource_version + ) version_tmp + WHERE + info.id = version_tmp.udf_id + AND info.id in (SELECT udf_id FROM linkis_ps_udf_shared_info WHERE user_name = #{userName}) @@ -118,9 +118,26 @@ SELECT - - from linkis_ps_udf_baseinfo - where id in - (select udf_id from linkis_ps_udf_shared_info where user_name=#{userName}) + info.id,info."create_user",info."udf_name",info."udf_type",info."is_expire",info."is_shared",info."tree_id",info."create_time",info."update_time", + info."sys",info."cluster_name", version_tmp.description + FROM + linkis_ps_udf_baseinfo info , + ( + SELECT + version_info.* + FROM + linkis_ps_udf_version version_info , ( + SELECT + udf_id , MAX(bml_resource_version) AS bml_resource_version + FROM + linkis_ps_udf_version + GROUP BY + udf_id + ) version_max + WHERE + version_max.udf_id = version_info.udf_id + AND version_max.bml_resource_version = version_info.bml_resource_version + ) version_tmp + WHERE + info.id = version_tmp.udf_id + AND info.id in (SELECT udf_id FROM linkis_ps_udf_shared_info WHERE user_name = #{userName}) - update linkis_ps_udf_user_load set user_name=#{newUser} where udf_id=#{udfId} and user_name=#{oldUser} + update linkis_ps_udf_user_load set user_name=#{newUser}, update_time =now() where udf_id=#{udfId} and user_name=#{oldUser} - update linkis_ps_udf_version set is_published=#{isPublished} where udf_id=#{udfId} and + update linkis_ps_udf_version set is_published=#{isPublished},update_time =now() where udf_id=#{udfId} and bml_resource_version=#{version} From 49bd9a21a97adc8bdb7af9a75b40c0d0cbd56461 Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 20:09:27 +0800 Subject: [PATCH 09/22] add new create file method support set owner --- .../linkis/storage/utils/FileSystemUtils.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/linkis-commons/linkis-storage/src/main/java/org/apache/linkis/storage/utils/FileSystemUtils.java b/linkis-commons/linkis-storage/src/main/java/org/apache/linkis/storage/utils/FileSystemUtils.java index 0f93cdb6ab..2809c83eec 100644 --- a/linkis-commons/linkis-storage/src/main/java/org/apache/linkis/storage/utils/FileSystemUtils.java +++ b/linkis-commons/linkis-storage/src/main/java/org/apache/linkis/storage/utils/FileSystemUtils.java @@ -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 * @@ -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 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; + } } From bdc7a5c55629b85f73df0e27ca27ebe058ee23a2 Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 20:11:32 +0800 Subject: [PATCH 10/22] Distributed lock optimization adds lock holding attributes to prevent repeated lock acquisition and unlocking errors. --- .../lock/CommonLockSpringConfiguration.java | 2 +- .../common/lock/dao/CommonLockMapper.java | 6 ++- .../common/lock/entity/CommonLock.java | 9 ++++ .../lock/service/CommonLockService.java | 2 + .../impl/DefaultCommonLockService.java | 24 +++++++++- .../mapper/common/CommonLockMapper.xml | 13 +++--- .../common/lock/dao/CommonLockMapperTest.java | 45 ++++++++++++++++++- 7 files changed, 88 insertions(+), 13 deletions(-) diff --git a/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/CommonLockSpringConfiguration.java b/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/CommonLockSpringConfiguration.java index 07ec34dbb8..92f11730bc 100644 --- a/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/CommonLockSpringConfiguration.java +++ b/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/CommonLockSpringConfiguration.java @@ -30,7 +30,7 @@ public class CommonLockSpringConfiguration { @Bean @ConditionalOnMissingBean - public CommonLockService getDefaultLockManagerPersistence(CommonLockMapper commonLockMapper) { + public CommonLockService getCommonLockService(CommonLockMapper commonLockMapper) { DefaultCommonLockService defaultCommonLockService = new DefaultCommonLockService(); defaultCommonLockService.setLockManagerMapper(commonLockMapper); return defaultCommonLockService; diff --git a/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/dao/CommonLockMapper.java b/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/dao/CommonLockMapper.java index 6fb435ab62..162341efd4 100644 --- a/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/dao/CommonLockMapper.java +++ b/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/dao/CommonLockMapper.java @@ -26,9 +26,11 @@ @Mapper public interface CommonLockMapper { - void lock(@Param("jsonObject") String jsonObject, @Param("timeOut") Long timeOut); + void lock(@Param("commonLock") CommonLock commonLock, @Param("timeOut") Long timeOut); - void unlock(@Param("jsonObject") String jsonObject); + void unlock(@Param("commonLock") CommonLock commonLock); List getAll(); + + CommonLock getLockByLocker(@Param("lockObject") String lockObject, @Param("locker") String host); } diff --git a/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/entity/CommonLock.java b/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/entity/CommonLock.java index 919c3ecc0f..49db1a710e 100644 --- a/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/entity/CommonLock.java +++ b/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/entity/CommonLock.java @@ -28,6 +28,7 @@ public class CommonLock { private Date createTime; private String updator; private String creator; + private String locker; public Integer getId() { return id; @@ -84,4 +85,12 @@ public String getCreator() { public void setCreator(String creator) { this.creator = creator; } + + public String getLocker() { + return locker; + } + + public void setLocker(String locker) { + this.locker = locker; + } } diff --git a/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/service/CommonLockService.java b/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/service/CommonLockService.java index caa78aa066..c93b4f6652 100644 --- a/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/service/CommonLockService.java +++ b/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/service/CommonLockService.java @@ -24,6 +24,8 @@ public interface CommonLockService { Boolean lock(CommonLock commonLock, Long timeOut); + Boolean reentrantLock(CommonLock commonLock, Long timeOut); + void unlock(CommonLock commonLock); List getAll(); diff --git a/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/service/impl/DefaultCommonLockService.java b/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/service/impl/DefaultCommonLockService.java index 6ea3ce7217..1fc6a293cc 100644 --- a/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/service/impl/DefaultCommonLockService.java +++ b/linkis-public-enhancements/linkis-ps-common-lock/src/main/java/org/apache/linkis/publicservice/common/lock/service/impl/DefaultCommonLockService.java @@ -57,9 +57,29 @@ public Boolean lock(CommonLock commonLock, Long timeOut) { return isLocked; } + @Override + public Boolean reentrantLock(CommonLock commonLock, Long timeOut) { + CommonLock oldLock = + commonLockMapper.getLockByLocker(commonLock.getLockObject(), commonLock.getLocker()); + if (oldLock != null) { + return true; + } + long startTime = System.currentTimeMillis(); + Boolean isLocked = tryLock(commonLock, timeOut); + while (!isLocked && System.currentTimeMillis() - startTime < timeOut) { + try { + Thread.sleep(1000); + isLocked = tryLock(commonLock, timeOut); + } catch (InterruptedException e) { + logger.warn("lock waiting interrupted", e); + } + } + return isLocked; + } + private boolean tryLock(CommonLock commonLock, Long timeOut) { try { - commonLockMapper.lock(commonLock.getLockObject(), timeOut); + commonLockMapper.lock(commonLock, timeOut); return true; } catch (DataAccessException e) { logger.warn("Failed to obtain lock:" + commonLock.getLockObject()); @@ -69,7 +89,7 @@ private boolean tryLock(CommonLock commonLock, Long timeOut) { @Override public void unlock(CommonLock commonLock) { - commonLockMapper.unlock(commonLock.getLockObject()); + commonLockMapper.unlock(commonLock); } @Override diff --git a/linkis-public-enhancements/linkis-ps-common-lock/src/main/resources/mapper/common/CommonLockMapper.xml b/linkis-public-enhancements/linkis-ps-common-lock/src/main/resources/mapper/common/CommonLockMapper.xml index 46bfdef960..a21818fc14 100644 --- a/linkis-public-enhancements/linkis-ps-common-lock/src/main/resources/mapper/common/CommonLockMapper.xml +++ b/linkis-public-enhancements/linkis-ps-common-lock/src/main/resources/mapper/common/CommonLockMapper.xml @@ -21,17 +21,18 @@ - INSERT INTO linkis_ps_common_lock (lock_object, time_out, update_time, create_time) - VALUES (#{jsonObject}, #{timeOut}, now(), now()) + insert into linkis_ps_common_lock (lock_object, locker, time_out, update_time, create_time) + values(#{commonLock.lockObject}, #{commonLock.locker}, #{timeOut}, now(), now()) - DELETE FROM linkis_ps_common_lock - WHERE lock_object = #{jsonObject} + delete from linkis_ps_common_lock where lock_object = #{commonLock.lockObject} and locker = #{commonLock.locker} + diff --git a/linkis-public-enhancements/linkis-ps-common-lock/src/test/java/org/apache/linkis/publicservice/common/lock/dao/CommonLockMapperTest.java b/linkis-public-enhancements/linkis-ps-common-lock/src/test/java/org/apache/linkis/publicservice/common/lock/dao/CommonLockMapperTest.java index 860ea76a7f..bcae6889b8 100644 --- a/linkis-public-enhancements/linkis-ps-common-lock/src/test/java/org/apache/linkis/publicservice/common/lock/dao/CommonLockMapperTest.java +++ b/linkis-public-enhancements/linkis-ps-common-lock/src/test/java/org/apache/linkis/publicservice/common/lock/dao/CommonLockMapperTest.java @@ -38,11 +38,45 @@ public void getAllTest() { Assertions.assertTrue(locks.size() == 1); } + public Boolean reentrantLock(CommonLock commonLock) { + CommonLock oldLock = + commonLockMapper.getLockByLocker(commonLock.getLockObject(), commonLock.getLocker()); + if (oldLock != null) { + return true; + } + + try { + commonLockMapper.lock(commonLock, -1L); + } catch (Exception e) { + return false; + } + return true; + } + + @Test + @DisplayName("reentrantLockTest") + public void reentrantLockTest() { + String lockObject = "hadoop-warehouse4"; + CommonLock commonLock = new CommonLock(); + commonLock.setLockObject(lockObject); + commonLock.setLocker("test"); + Boolean lock = reentrantLock(commonLock); + Assertions.assertTrue(lock); + lock = reentrantLock(commonLock); + Assertions.assertTrue(lock); + commonLock.setLocker("test1"); + lock = reentrantLock(commonLock); + Assertions.assertFalse(lock); + } + @Test @DisplayName("unlockTest") public void unlockTest() { String lockObject = "hadoop-warehouse"; - commonLockMapper.unlock(lockObject); + CommonLock commonLock = new CommonLock(); + commonLock.setLockObject(lockObject); + commonLock.setLocker("test"); + commonLockMapper.unlock(commonLock); List locks = commonLockMapper.getAll(); Assertions.assertTrue(locks.size() == 0); @@ -53,7 +87,14 @@ public void unlockTest() { public void lockTest() { String lockObject = "hadoop-warehouse2"; Long timeOut = 10000L; - commonLockMapper.lock(lockObject, timeOut); + CommonLock commonLock = new CommonLock(); + commonLock.setLockObject(lockObject); + + Assertions.assertThrows( + RuntimeException.class, () -> commonLockMapper.lock(commonLock, timeOut)); + + commonLock.setLocker("test"); + commonLockMapper.lock(commonLock, timeOut); List locks = commonLockMapper.getAll(); Assertions.assertTrue(locks.size() == 2); } From 1e70b84da9b6810819d5944fa31e00bfabbb3c82 Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 20:12:23 +0800 Subject: [PATCH 11/22] add clear map method --- .../linkis/protocol/utils/TaskUtils.scala | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/linkis-commons/linkis-protocol/src/main/scala/org/apache/linkis/protocol/utils/TaskUtils.scala b/linkis-commons/linkis-protocol/src/main/scala/org/apache/linkis/protocol/utils/TaskUtils.scala index 9b2be16ef7..3affc351d9 100644 --- a/linkis-commons/linkis-protocol/src/main/scala/org/apache/linkis/protocol/utils/TaskUtils.scala +++ b/linkis-commons/linkis-protocol/src/main/scala/org/apache/linkis/protocol/utils/TaskUtils.scala @@ -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 @@ -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) From 46589aed39f0dc9b183352b69a07264f3eab10ee Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 20:20:59 +0800 Subject: [PATCH 12/22] Basic data management adds UDF tree management --- .../server/conf/UdfTreeConf.java} | 19 +- .../server/dao/UdfBaseInfoMapper.java} | 16 +- .../server/domain/UdfBaseInfoEntity.java | 205 ++++++++++++++++++ .../server/domain/UdfManagerEntity.java | 23 ++ .../server/domain/UdfTreeEntity.java | 12 + .../server/restful/UdfManagerRestfulApi.java | 26 ++- .../server/restful/UdfTreeRestfulApi.java | 52 ++++- .../server/service/UdfBaseInfoService.java} | 15 +- .../service/impl/UdfBaseInfoServicelmpl.java} | 25 +-- .../server/utils/UdfTreeUtils.java | 93 ++++++++ 10 files changed, 435 insertions(+), 51 deletions(-) rename linkis-public-enhancements/{linkis-configuration/src/main/java/org/apache/linkis/configuration/util/CommonUtils.java => linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/conf/UdfTreeConf.java} (70%) rename linkis-public-enhancements/{linkis-configuration/src/main/java/org/apache/linkis/configuration/service/UserIpService.java => linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/dao/UdfBaseInfoMapper.java} (63%) create mode 100644 linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfBaseInfoEntity.java rename linkis-public-enhancements/{linkis-configuration/src/main/java/org/apache/linkis/configuration/service/TenantService.java => linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/service/UdfBaseInfoService.java} (67%) rename linkis-public-enhancements/{linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/UserIpMapper.java => linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/UdfBaseInfoServicelmpl.java} (59%) create mode 100644 linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/utils/UdfTreeUtils.java diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/CommonUtils.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/conf/UdfTreeConf.java similarity index 70% rename from linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/CommonUtils.java rename to linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/conf/UdfTreeConf.java index ed80f09a0a..ded1d7e434 100644 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/CommonUtils.java +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/conf/UdfTreeConf.java @@ -15,17 +15,12 @@ * limitations under the License. */ -package org.apache.linkis.configuration.util; +package org.apache.linkis.basedatamanager.server.conf; -public class CommonUtils { - public static boolean ipCheck(String str) { - if (str != null && !str.isEmpty()) { - String pattern = ConfigurationConfiguration.IPCHECK; - if (str.matches(pattern)) { - return true; - } - return false; - } - return false; - } +import org.apache.linkis.common.conf.CommonVars; + +public class UdfTreeConf { + + public static final CommonVars UDF_FUN_SYSTEM_CATEGORY = + CommonVars.apply("linkis.udf.fun.system.category", "user_name,sys,expire,share,bdp"); } diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/UserIpService.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/dao/UdfBaseInfoMapper.java similarity index 63% rename from linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/UserIpService.java rename to linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/dao/UdfBaseInfoMapper.java index c025e3f730..c2d585993b 100644 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/UserIpService.java +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/dao/UdfBaseInfoMapper.java @@ -15,13 +15,15 @@ * limitations under the License. */ -package org.apache.linkis.configuration.service; +package org.apache.linkis.basedatamanager.server.dao; -import org.apache.linkis.governance.common.protocol.conf.UserIpRequest; -import org.apache.linkis.governance.common.protocol.conf.UserIpResponse; -import org.apache.linkis.rpc.Sender; +import org.apache.linkis.basedatamanager.server.domain.UdfBaseInfoEntity; -public interface UserIpService { +import com.baomidou.mybatisplus.core.mapper.BaseMapper; - UserIpResponse getUserIpData(UserIpRequest request, Sender sender); -} +/** + * @description Database operation Mapper for the linkis_PS_UDF_tree table + * @createDate 2022-08-13 15:13:27 @Entity + * org.apache.linkis.basedatamanager.server.domain.LinkisPsUdfTree + */ +public interface UdfBaseInfoMapper extends BaseMapper {} diff --git a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfBaseInfoEntity.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfBaseInfoEntity.java new file mode 100644 index 0000000000..0c8776ed26 --- /dev/null +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfBaseInfoEntity.java @@ -0,0 +1,205 @@ +/* + * 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.basedatamanager.server.domain; + +import java.io.Serializable; +import java.util.Date; +import java.util.Objects; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** @TableName linkis_ps_udf_baseinfo */ +@TableName(value = "linkis_ps_udf_baseinfo") +@JsonIgnoreProperties(ignoreUnknown = true) +public class UdfBaseInfoEntity implements Serializable { + + @TableId(type = IdType.AUTO) + private Long id; + + private String createUser; + private String udfName; + private Integer udfType; + private Boolean isExpire; + private Boolean isShared; + private Long treeId; + private Date createTime; + private Date updateTime; + private String sys; + private String clusterName; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getCreateUser() { + return createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } + + public String getUdfName() { + return udfName; + } + + public void setUdfName(String udfName) { + this.udfName = udfName; + } + + public Integer getUdfType() { + return udfType; + } + + public void setUdfType(Integer udfType) { + this.udfType = udfType; + } + + public Boolean getExpire() { + return isExpire; + } + + public void setExpire(Boolean expire) { + isExpire = expire; + } + + public Boolean getShared() { + return isShared; + } + + public void setShared(Boolean shared) { + isShared = shared; + } + + public Long getTreeId() { + return treeId; + } + + public void setTreeId(Long treeId) { + this.treeId = treeId; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public String getSys() { + return sys; + } + + public void setSys(String sys) { + this.sys = sys; + } + + public String getClusterName() { + return clusterName; + } + + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UdfBaseInfoEntity that = (UdfBaseInfoEntity) o; + return Objects.equals(id, that.id) + && Objects.equals(createUser, that.createUser) + && Objects.equals(udfName, that.udfName) + && Objects.equals(udfType, that.udfType) + && Objects.equals(isExpire, that.isExpire) + && Objects.equals(isShared, that.isShared) + && Objects.equals(treeId, that.treeId) + && Objects.equals(createTime, that.createTime) + && Objects.equals(updateTime, that.updateTime) + && Objects.equals(sys, that.sys) + && Objects.equals(clusterName, that.clusterName); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + createUser, + udfName, + udfType, + isExpire, + isShared, + treeId, + createTime, + updateTime, + sys, + clusterName); + } + + @Override + public String toString() { + return "UdfBaseInfoEntity{" + + "id=" + + id + + ", createUser='" + + createUser + + '\'' + + ", udfName='" + + udfName + + '\'' + + ", udfType=" + + udfType + + ", isExpire=" + + isExpire + + ", isShared=" + + isShared + + ", treeId=" + + treeId + + ", createTime=" + + createTime + + ", updateTime=" + + updateTime + + ", sys='" + + sys + + '\'' + + ", clusterName='" + + clusterName + + '\'' + + '}'; + } +} diff --git a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfManagerEntity.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfManagerEntity.java index fa6db837e1..8c5abbeec1 100644 --- a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfManagerEntity.java +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfManagerEntity.java @@ -18,6 +18,7 @@ package org.apache.linkis.basedatamanager.server.domain; import java.io.Serializable; +import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; @@ -36,6 +37,12 @@ public class UdfManagerEntity implements Serializable { /** */ private String userName; + /** */ + private Date createTime; + + /** */ + private Date updateTime; + @TableField(exist = false) private static final long serialVersionUID = 1L; @@ -59,6 +66,22 @@ public void setUserName(String userName) { this.userName = userName; } + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + @Override public boolean equals(Object that) { if (this == that) { diff --git a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfTreeEntity.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfTreeEntity.java index 9d2a51d471..32615f095f 100644 --- a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfTreeEntity.java +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/domain/UdfTreeEntity.java @@ -19,6 +19,7 @@ import java.io.Serializable; import java.util.Date; +import java.util.List; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; @@ -58,6 +59,9 @@ public class UdfTreeEntity implements Serializable { @TableField(exist = false) private static final long serialVersionUID = 1L; + @TableField(exist = false) + private List childrenList; + /** */ public Long getId() { return id; @@ -138,6 +142,14 @@ public void setCategory(String category) { this.category = category; } + public List getChildrenList() { + return childrenList; + } + + public void setChildrenList(List childrenList) { + this.childrenList = childrenList; + } + @Override public boolean equals(Object that) { if (this == that) { diff --git a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/restful/UdfManagerRestfulApi.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/restful/UdfManagerRestfulApi.java index f6e684f837..588b0b6a26 100644 --- a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/restful/UdfManagerRestfulApi.java +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/restful/UdfManagerRestfulApi.java @@ -32,6 +32,8 @@ import javax.servlet.http.HttpServletRequest; +import java.util.Date; + import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; @@ -89,10 +91,12 @@ public Message add(HttpServletRequest request, @RequestBody UdfManagerEntity udf new QueryWrapper<>(udfManagerEntity).eq("user_name", udfManagerEntity.getUserName()); UdfManagerEntity udfManager = udfManagerService.getOne(queryWrapper); if (udfManager == null) { + udfManagerEntity.setCreateTime(new Date()); + udfManagerEntity.setUpdateTime(new Date()); boolean result = udfManagerService.save(udfManagerEntity); return Message.ok("").data("result", result); } else { - return Message.error("The username already exists,Please add again!"); + return Message.error("The " + udfManager.getUserName() + " already exists,Please add again!"); } } @@ -103,7 +107,12 @@ public Message add(HttpServletRequest request, @RequestBody UdfManagerEntity udf httpMethod = "DELETE") @RequestMapping(path = "/{id}", method = RequestMethod.DELETE) public Message remove(HttpServletRequest request, @PathVariable("id") Long id) { - ModuleUserUtils.getOperationUser(request, "Remove a UDF Manager Record,id:" + id.toString()); + String username = + ModuleUserUtils.getOperationUser( + request, "Remove a UDF Manager Record,id:" + id.toString()); + if (!Configuration.isAdmin(username)) { + return Message.error("User '" + username + "' is not admin user[非管理员用户]"); + } boolean result = udfManagerService.removeById(id); return Message.ok("").data("result", result); } @@ -121,7 +130,16 @@ public Message update( if (!Configuration.isAdmin(username)) { return Message.error("User '" + username + "' is not admin user[非管理员用户]"); } - boolean result = udfManagerService.updateById(udfManagerEntity); - return Message.ok("").data("result", result); + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("user_name", udfManagerEntity.getUserName()); + UdfManagerEntity udfManager = udfManagerService.getOne(queryWrapper); + if (udfManager == null) { + udfManagerEntity.setUpdateTime(new Date()); + boolean result = udfManagerService.updateById(udfManagerEntity); + return Message.ok("").data("result", result); + } else { + return Message.error( + "The " + udfManager.getUserName() + " already exists,Please update again!"); + } } } diff --git a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/restful/UdfTreeRestfulApi.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/restful/UdfTreeRestfulApi.java index e5c9cbc442..7b8f434236 100644 --- a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/restful/UdfTreeRestfulApi.java +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/restful/UdfTreeRestfulApi.java @@ -17,12 +17,18 @@ package org.apache.linkis.basedatamanager.server.restful; +import org.apache.linkis.basedatamanager.server.domain.UdfBaseInfoEntity; import org.apache.linkis.basedatamanager.server.domain.UdfTreeEntity; +import org.apache.linkis.basedatamanager.server.service.UdfBaseInfoService; import org.apache.linkis.basedatamanager.server.service.UdfTreeService; +import org.apache.linkis.basedatamanager.server.utils.UdfTreeUtils; import org.apache.linkis.common.conf.Configuration; import org.apache.linkis.server.Message; import org.apache.linkis.server.utils.ModuleUserUtils; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -32,8 +38,10 @@ import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; import java.util.List; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -47,6 +55,8 @@ public class UdfTreeRestfulApi { @Autowired UdfTreeService udfTreeService; + @Autowired UdfBaseInfoService udfBaseinfoService; + @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType = "string", name = "searchName"), @ApiImplicitParam(paramType = "query", dataType = "int", name = "currentPage"), @@ -62,12 +72,26 @@ public Message list( return Message.ok("").data("list", pageList); } + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "query", dataType = "string", name = "searchName"), + @ApiImplicitParam(paramType = "query", dataType = "string", name = "category") + }) @ApiOperation(value = "all", notes = "Query all data of UDF Tree", httpMethod = "GET") @RequestMapping(path = "/all", method = RequestMethod.GET) - public Message all(HttpServletRequest request, String searchName) { + public Message all(HttpServletRequest request, String searchName, String category) { ModuleUserUtils.getOperationUser( request, "Query all data of UDF Tree,search name:" + searchName); - List udfTreeEntityList = udfTreeService.list(); + List udfTreeEntityList = new ArrayList<>(); + if (StringUtils.isNotBlank(searchName) && StringUtils.isNotBlank(category)) { + UdfTreeEntity entity = new UdfTreeEntity(); + entity.setCategory(category); + entity.setUserName(searchName); + QueryWrapper queryWrapper = + new QueryWrapper<>(entity) + .eq("user_name", entity.getUserName()) + .eq("category", entity.getCategory()); + udfTreeEntityList = new UdfTreeUtils(udfTreeService.list(queryWrapper)).buildTree(); + } return Message.ok("").data("list", udfTreeEntityList); } @@ -100,9 +124,27 @@ public Message add(HttpServletRequest request, @RequestBody UdfTreeEntity udfTre @ApiOperation(value = "remove", notes = "Remove a UDF Tree Record by id", httpMethod = "DELETE") @RequestMapping(path = "/{id}", method = RequestMethod.DELETE) public Message remove(HttpServletRequest request, @PathVariable("id") Long id) { - ModuleUserUtils.getOperationUser(request, "Remove a UDF Tree Record,id:" + id.toString()); - boolean result = udfTreeService.removeById(id); - return Message.ok("").data("result", result); + String username = + ModuleUserUtils.getOperationUser(request, "Remove a UDF Tree Record,id:" + id.toString()); + if (!Configuration.isAdmin(username)) { + return Message.error("User '" + username + "' is not admin user[非管理员用户]"); + } + UdfTreeEntity entity = udfTreeService.getById(id); + if (null != entity && entity.getParent() == -1) { + return Message.error("The root directory is forbidden to delete[\"根目录禁止删除\"]"); + } + QueryWrapper queryWrapper = + new QueryWrapper<>(new UdfTreeEntity()).eq("parent", id); + List folderList = udfTreeService.list(queryWrapper); + QueryWrapper udfQueryWrapper = + new QueryWrapper<>(new UdfBaseInfoEntity()).eq("tree_id", id); + List functoinList = udfBaseinfoService.list(udfQueryWrapper); + if (CollectionUtils.isEmpty(folderList) && CollectionUtils.isEmpty(functoinList)) { + boolean result = udfTreeService.removeById(id); + return Message.ok("").data("result", result); + } else { + return Message.error("Please delete the subdirectory first[请先删除子目录]"); + } } @ApiImplicitParams({ diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/TenantService.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/service/UdfBaseInfoService.java similarity index 67% rename from linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/TenantService.java rename to linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/service/UdfBaseInfoService.java index df88923455..032c818b43 100644 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/TenantService.java +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/service/UdfBaseInfoService.java @@ -15,13 +15,14 @@ * limitations under the License. */ -package org.apache.linkis.configuration.service; +package org.apache.linkis.basedatamanager.server.service; -import org.apache.linkis.governance.common.protocol.conf.TenantRequest; -import org.apache.linkis.governance.common.protocol.conf.TenantResponse; -import org.apache.linkis.rpc.Sender; +import org.apache.linkis.basedatamanager.server.domain.UdfBaseInfoEntity; -public interface TenantService { +import com.baomidou.mybatisplus.extension.service.IService; - TenantResponse getTenantData(TenantRequest request, Sender sender); -} +/** + * @description Database operation Service for the [linkis_ps_udf_baseinfo] table + * @createDate 2022-08-13 15:13:27 + */ +public interface UdfBaseInfoService extends IService {} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/UserIpMapper.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/UdfBaseInfoServicelmpl.java similarity index 59% rename from linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/UserIpMapper.java rename to linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/UdfBaseInfoServicelmpl.java index fb6bf44fb2..c3c62854a1 100644 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/UserIpMapper.java +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/service/impl/UdfBaseInfoServicelmpl.java @@ -15,23 +15,16 @@ * limitations under the License. */ -package org.apache.linkis.configuration.dao; +package org.apache.linkis.basedatamanager.server.service.impl; -import org.apache.linkis.configuration.entity.UserIpVo; +import org.apache.linkis.basedatamanager.server.dao.UdfBaseInfoMapper; +import org.apache.linkis.basedatamanager.server.domain.UdfBaseInfoEntity; +import org.apache.linkis.basedatamanager.server.service.UdfBaseInfoService; -import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Service; -import java.util.List; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -public interface UserIpMapper { - - List queryUserIPList(@Param("user") String user, @Param("creator") String creator); - - void deleteUserIP(Integer id); - - void updateUserIP(UserIpVo userIpVo); - - void createUserIP(UserIpVo userIpVo); - - UserIpVo queryUserIP(@Param("user") String user, @Param("creator") String creator); -} +@Service +public class UdfBaseInfoServicelmpl extends ServiceImpl + implements UdfBaseInfoService {} diff --git a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/utils/UdfTreeUtils.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/utils/UdfTreeUtils.java new file mode 100644 index 0000000000..f7f2b19fca --- /dev/null +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/basedatamanager/server/utils/UdfTreeUtils.java @@ -0,0 +1,93 @@ +/* + * 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.basedatamanager.server.utils; + +import org.apache.linkis.basedatamanager.server.domain.UdfTreeEntity; + +import java.util.ArrayList; +import java.util.List; + +public class UdfTreeUtils { + + /** Build tree structure */ + public List udfTreeList = new ArrayList<>(); + + /** Construction method */ + public UdfTreeUtils(List udfTreeList) { + this.udfTreeList = udfTreeList; + } + + /** + * Obtain all root nodes (top-level nodes) that need to be built + * + * @return All Root Node List Collection + */ + public List getRootNode() { + // Save all root nodes (data for all root nodes) + List rootudfTreeList = new ArrayList<>(); + // UdfTreeEntity: Each piece of data (node) found in the query + for (UdfTreeEntity UdfTreeEntity : udfTreeList) { + // Determine whether the current node is a root node. Note here that if the parentId type is + // String, the equals() method should be used to determine. + if (-1 == UdfTreeEntity.getParent()) { + rootudfTreeList.add(UdfTreeEntity); + } + } + return rootudfTreeList; + } + + /** + * Build a tree structure according to each top-level node (root node) + * + * @return Build the entire tree + */ + public List buildTree() { + // UdfTreeEntities: Saves the complete tree structure constructed by a top-level node + List UdfTreeEntitys = new ArrayList(); + // GetRootNode(): Get all root nodes + for (UdfTreeEntity treeRootNode : getRootNode()) { + // Build subtrees from top-level nodes + treeRootNode = buildChildTree(treeRootNode); + // Complete the tree structure constructed by a top-level node and add it in + UdfTreeEntitys.add(treeRootNode); + } + return UdfTreeEntitys; + } + + /** + * Recursion ----- construct sub tree structure + * + * @param udfTreeEntity Root node (top-level node) + * @return Whole tree + */ + public UdfTreeEntity buildChildTree(UdfTreeEntity udfTreeEntity) { + List childTree = new ArrayList(); + // udfTreeList:All node sets (all data) + for (UdfTreeEntity UdfTreeEntity : udfTreeList) { + // Determine whether the parent node ID of the current node is equal to the ID of the root + // node, that is, if the current node is a child node under it + if (UdfTreeEntity.getParent().equals(udfTreeEntity.getId())) { + // Recursively judge the current node's situation and call its own method + childTree.add(buildChildTree(UdfTreeEntity)); + } + } + // Recursively judge the current node's situation and call its own method + udfTreeEntity.setChildrenList(childTree); + return udfTreeEntity; + } +} From 8c59c621f2d4b75f2296e13ea64420bee795cf46 Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 20:22:21 +0800 Subject: [PATCH 13/22] fix csv file with utf-8 with bom chart[] --- .../filesystem/restful/api/FsRestfulApi.java | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/filesystem/restful/api/FsRestfulApi.java b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/filesystem/restful/api/FsRestfulApi.java index ae7e19106c..189ab711fd 100644 --- a/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/filesystem/restful/api/FsRestfulApi.java +++ b/linkis-public-enhancements/linkis-pes-publicservice/src/main/java/org/apache/linkis/filesystem/restful/api/FsRestfulApi.java @@ -20,6 +20,7 @@ import org.apache.linkis.common.conf.Configuration; import org.apache.linkis.common.io.FsPath; import org.apache.linkis.common.io.FsWriter; +import org.apache.linkis.common.utils.ResultSetUtils; import org.apache.linkis.filesystem.conf.WorkSpaceConfiguration; import org.apache.linkis.filesystem.entity.DirFileTree; import org.apache.linkis.filesystem.entity.LogLevel; @@ -42,6 +43,7 @@ import org.apache.linkis.storage.utils.StorageUtils; import org.apache.commons.io.IOUtils; +import org.apache.commons.io.input.BOMInputStream; import org.apache.commons.math3.util.Pair; import org.apache.http.Consts; @@ -88,16 +90,15 @@ public class FsRestfulApi { * @param userName * @return */ - private boolean checkIsUsersDirectory(String requestPath, String userName) { + private boolean checkIsUsersDirectory(String requestPath, String userName, Boolean withAdmin) { + // 配置文件默认关闭检查,withadmin默认true,特殊情况传false 开启权限检查( + // The configuration file defaults to disable checking, with admin defaulting to true, and in + // special cases, false is passed to enable permission checking) boolean ownerCheck = WorkSpaceConfiguration.FILESYSTEM_PATH_CHECK_OWNER.getValue(); - if (!ownerCheck) { + if (!ownerCheck && withAdmin) { LOGGER.debug("not check filesystem owner."); return true; } - if (requestPath.contains(WorkspaceUtil.suffixTuning(HDFS_USER_ROOT_PATH_PREFIX.getValue())) - || Configuration.isAdmin(userName)) { - return true; - } requestPath = requestPath.toLowerCase().trim() + "/"; String hdfsUserRootPathPrefix = WorkspaceUtil.suffixTuning(HDFS_USER_ROOT_PATH_PREFIX.getValue()); @@ -106,7 +107,11 @@ private boolean checkIsUsersDirectory(String requestPath, String userName) { String workspacePath = hdfsUserRootPathPrefix + userName + hdfsUserRootPathSuffix; String enginconnPath = localUserRootPath + userName; - if (Configuration.isJobHistoryAdmin(userName)) { + // 管理员修改其他用户文件目录时,会导致用户无法使用文件,故此优化管理员不能修改(When administrators modify the file directory of other + // users, + // it will cause users to be unable to use the file, so the optimization administrator cannot + // modify it) + if (withAdmin && Configuration.isJobHistoryAdmin(userName)) { workspacePath = hdfsUserRootPathPrefix; enginconnPath = localUserRootPath; } @@ -117,6 +122,10 @@ private boolean checkIsUsersDirectory(String requestPath, String userName) { return (requestPath.contains(workspacePath)) || (requestPath.contains(enginconnPath)); } + private boolean checkIsUsersDirectory(String requestPath, String userName) { + return checkIsUsersDirectory(requestPath, userName, true); + } + @ApiOperation(value = "getUserRootPath", notes = "get user root path", response = Message.class) @ApiImplicitParams({ @ApiImplicitParam(name = "pathType", required = false, dataType = "String", value = "path type") @@ -233,7 +242,7 @@ public Message rename(HttpServletRequest req, @RequestBody JsonNode json) PathValidator$.MODULE$.validate(oldDest, userName); PathValidator$.MODULE$.validate(newDest, userName); } - if (!checkIsUsersDirectory(newDest, userName)) { + if (!checkIsUsersDirectory(newDest, userName, false)) { throw WorkspaceExceptionManager.createException(80010, userName, newDest); } if (StringUtils.isEmpty(oldDest)) { @@ -561,6 +570,7 @@ public Message openFile( @RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "pageSize", defaultValue = "5000") Integer pageSize, @RequestParam(value = "charset", defaultValue = "utf-8") String charset, + @RequestParam(value = "nullValue", defaultValue = "") String nullValue, @RequestParam(value = "limitBytes", defaultValue = "0") Long limitBytes, @RequestParam(value = "limitColumnLength", defaultValue = "0") Integer limitColumnLength) throws IOException, WorkSpaceException { @@ -582,7 +592,13 @@ public Message openFile( FileSource fileSource = null; try { fileSource = FileSource.create(fsPath, fileSystem); + if (nullValue != null && BLANK.equalsIgnoreCase(nullValue)) { + nullValue = ""; + } if (FileSource.isResultSet(fsPath.getPath())) { + if (!StringUtils.isEmpty(nullValue)) { + fileSource.addParams("nullValue", nullValue); + } fileSource = fileSource.page(page, pageSize); } if (limitBytes > 0) { @@ -853,7 +869,12 @@ public void resultsetsToExcel( if (fsPathListWithError == null) { throw WorkspaceExceptionManager.createException(80029); } - FsPath[] fsPaths = fsPathListWithError.getFsPaths().toArray(new FsPath[] {}); + + List fsPathList = fsPathListWithError.getFsPaths(); + // sort asc by _num.dolphin of num + ResultSetUtils.sortByNameNum(fsPathList); + FsPath[] fsPaths = fsPathList.toArray(new FsPath[] {}); + boolean isLimitDownloadSize = RESULT_SET_DOWNLOAD_IS_LIMIT.getValue(); Integer excelDownloadSize = RESULT_SET_DOWNLOAD_MAX_SIZE_EXCEL.getValue(); if (limit > 0) { @@ -867,7 +888,9 @@ public void resultsetsToExcel( response.setCharacterEncoding(StandardCharsets.UTF_8.name()); outputStream = response.getOutputStream(); // 前台传""会自动转为null - if (nullValue != null && BLANK.equalsIgnoreCase(nullValue)) nullValue = ""; + if (nullValue != null && BLANK.equalsIgnoreCase(nullValue)) { + nullValue = ""; + } fileSource = FileSource.create(fsPaths, fileSystem).addParams("nullValue", nullValue); if (!FileSource.isTableResultSet(fileSource)) { throw WorkspaceExceptionManager.createException(80024); @@ -952,7 +975,10 @@ public Message formate( res.put("sheetName", info.get(0)); } else { String[][] column = null; - BufferedReader reader = new BufferedReader(new InputStreamReader(in, encoding)); + // fix csv file with utf-8 with bom chart[] + BOMInputStream bomIn = new BOMInputStream(in, false); // don't include the BOM + BufferedReader reader = new BufferedReader(new InputStreamReader(bomIn, encoding)); + String header = reader.readLine(); if (StringUtils.isEmpty(header)) { throw WorkspaceExceptionManager.createException(80016); From b91ec0fc571bf27e75503e876f2b9d87a325326f Mon Sep 17 00:00:00 2001 From: peacewong Date: Tue, 24 Oct 2023 20:48:06 +0800 Subject: [PATCH 14/22] [Feature]New configuration management function added to the management console #4842 [Feature]New user configuration function added to the management console #4841 --- .../configuration/dao/ConfigMapper.java | 4 +- .../configuration/dao/UserTenantMapper.java | 40 --- .../linkis/configuration/entity/TenantVo.java | 143 --------- .../linkis/configuration/entity/UserIpVo.java | 143 --------- .../LinkisConfigurationErrorCodeSummary.java | 69 ----- .../exception/ConfigurationException.java | 8 +- .../restful/api/ConfigurationRestfulApi.java | 240 +++++++++------ .../api/TenantConfigrationRestfulApi.java | 270 ----------------- .../api/UserIpConfigrationRestfulApi.java | 230 --------------- .../service/TenantConfigService.java | 39 --- .../service/UserIpConfigService.java | 39 --- .../service/impl/ConfigKeyServiceImpl.java | 24 +- .../service/impl/TenantConfigServiceImpl.java | 188 ------------ .../service/impl/TenantServiceImpl.java | 54 ---- .../service/impl/UserIpConfigServiceImpl.java | 154 ---------- .../service/impl/UserIpServiceImpl.java | 53 ---- .../util/ConfigurationConfiguration.java | 6 - .../linkis/configuration/util/HttpsUtil.java | 114 ------- .../configuration/util/LabelEntityParser.java | 6 +- .../resources/mapper/common/LabelMapper.xml | 23 +- .../mapper/mysql/AcrossClusterRuleMapper.xml | 130 ++++++++ .../mysql/ConfigKeyLimitForUserMapper.xml | 145 +++++++++ .../resources/mapper/mysql/ConfigMapper.xml | 243 ++++++++++++++- .../mapper/mysql/TemplateConfigKeyMapper.xml | 161 ++++++++++ .../postgresql/AcrossClusterRuleMapper.xml | 130 ++++++++ .../ConfigKeyLimitForUserMapper.xml | 145 +++++++++ .../mapper/postgresql/ConfigMapper.xml | 278 ++++++++++++++++-- .../postgresql/TemplateConfigKeyMapper.xml | 161 ++++++++++ .../configuration/conf/Configuration.scala | 5 - .../configuration/constant/Constants.scala | 49 --- .../service/CategoryService.scala | 25 +- .../service/ConfigurationService.scala | 41 +-- .../util/LabelParameterParser.scala | 13 +- .../validate/FloatValidator.scala | 3 +- .../validate/NumericalValidator.scala | 3 +- .../configuration/dao/ConfigMapperTest.java | 26 +- .../configuration/dao/LabelMapperTest.java | 32 +- .../configuration/dao/UserIpMapperTest.java | 91 ------ .../dao/UserTenantMapperTest.java | 84 ------ .../exception/ConfigurationExceptionTest.java | 17 -- 40 files changed, 1575 insertions(+), 2054 deletions(-) delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/UserTenantMapper.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/entity/TenantVo.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/entity/UserIpVo.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/errorcode/LinkisConfigurationErrorCodeSummary.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/restful/api/TenantConfigrationRestfulApi.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/restful/api/UserIpConfigrationRestfulApi.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/TenantConfigService.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/UserIpConfigService.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/TenantConfigServiceImpl.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/TenantServiceImpl.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/UserIpConfigServiceImpl.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/UserIpServiceImpl.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/HttpsUtil.java create mode 100644 linkis-public-enhancements/linkis-configuration/src/main/resources/mapper/mysql/AcrossClusterRuleMapper.xml create mode 100644 linkis-public-enhancements/linkis-configuration/src/main/resources/mapper/mysql/ConfigKeyLimitForUserMapper.xml create mode 100644 linkis-public-enhancements/linkis-configuration/src/main/resources/mapper/mysql/TemplateConfigKeyMapper.xml create mode 100644 linkis-public-enhancements/linkis-configuration/src/main/resources/mapper/postgresql/AcrossClusterRuleMapper.xml create mode 100644 linkis-public-enhancements/linkis-configuration/src/main/resources/mapper/postgresql/ConfigKeyLimitForUserMapper.xml create mode 100644 linkis-public-enhancements/linkis-configuration/src/main/resources/mapper/postgresql/TemplateConfigKeyMapper.xml delete mode 100644 linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/constant/Constants.scala delete mode 100644 linkis-public-enhancements/linkis-configuration/src/test/java/org/apache/linkis/configuration/dao/UserIpMapperTest.java delete mode 100644 linkis-public-enhancements/linkis-configuration/src/test/java/org/apache/linkis/configuration/dao/UserTenantMapperTest.java diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/ConfigMapper.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/ConfigMapper.java index 6b6b15a65c..54e694ee4e 100644 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/ConfigMapper.java +++ b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/ConfigMapper.java @@ -55,7 +55,7 @@ List getConfigByEngineUserCreator( ConfigKey selectKeyByKeyID(@Param("id") Long keyID); - List selectKeyByKeyName(@Param("keyName") String keyName); + List seleteKeyByKeyName(@Param("keyName") String keyName); List listKeyByStringValue(@Param("stringValue") String stringValue); @@ -72,6 +72,4 @@ List getConfigByEngineUserCreator( void updateCategory(CategoryLabel categoryLabel); void insertKey(ConfigKey key); - - List getConfigEnKeyValueByLabelId(@Param("labelId") Integer labelId); } diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/UserTenantMapper.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/UserTenantMapper.java deleted file mode 100644 index c141738ced..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/dao/UserTenantMapper.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.configuration.dao; - -import org.apache.linkis.configuration.entity.TenantVo; - -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -public interface UserTenantMapper { - - List queryTenantList( - @Param("user") String user, - @Param("creator") String creator, - @Param("tenant_value") String tenant); - - void deleteTenant(@Param("id") Integer id); - - void updateTenant(TenantVo tenantVo); - - void createTenant(TenantVo tenantVo); - - TenantVo queryTenant(@Param("user") String user, @Param("creator") String creator); -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/entity/TenantVo.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/entity/TenantVo.java deleted file mode 100644 index c2399ff9b6..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/entity/TenantVo.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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.configuration.entity; - -import java.util.Date; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -@ApiModel -public class TenantVo { - - @ApiModelProperty("id") - private String id; - - @ApiModelProperty("user") - private String user; - - @ApiModelProperty("creator") - private String creator; - - @ApiModelProperty("tenantValue") - private String tenantValue; - - @ApiModelProperty("createTime") - private Date createTime; - - @ApiModelProperty("updateTime") - private Date updateTime; - - @ApiModelProperty("desc") - private String desc; - - @ApiModelProperty("bussinessUser") - private String bussinessUser; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - - public String getCreator() { - return creator; - } - - public void setCreator(String creator) { - this.creator = creator; - } - - public String getTenantValue() { - return tenantValue; - } - - public void setTenantValue(String tenantValue) { - this.tenantValue = tenantValue; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public String getBussinessUser() { - return bussinessUser; - } - - public void setBussinessUser(String bussinessUser) { - this.bussinessUser = bussinessUser; - } - - @Override - public String toString() { - return "TenantVo{" - + "id='" - + id - + '\'' - + ", user='" - + user - + '\'' - + ", creator='" - + creator - + '\'' - + ", tenantValue='" - + tenantValue - + '\'' - + ", createTime=" - + createTime - + ", updateTime=" - + updateTime - + ", desc='" - + desc - + '\'' - + ", bussinessUser='" - + bussinessUser - + '\'' - + '}'; - } -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/entity/UserIpVo.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/entity/UserIpVo.java deleted file mode 100644 index 05ec8046fd..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/entity/UserIpVo.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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.configuration.entity; - -import java.util.Date; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -@ApiModel -public class UserIpVo { - - @ApiModelProperty("id") - private String id; - - @ApiModelProperty("user") - private String user; - - @ApiModelProperty("creator") - private String creator; - - @ApiModelProperty("ipList") - private String ipList; - - @ApiModelProperty("createTime") - private Date createTime; - - @ApiModelProperty("updateTime") - private Date updateTime; - - @ApiModelProperty("desc") - private String desc; - - @ApiModelProperty("bussinessUser") - private String bussinessUser; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getUser() { - return user; - } - - public void setUser(String user) { - this.user = user; - } - - public String getCreator() { - return creator; - } - - public void setCreator(String creator) { - this.creator = creator; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public String getBussinessUser() { - return bussinessUser; - } - - public void setBussinessUser(String bussinessUser) { - this.bussinessUser = bussinessUser; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } - - public String getIpList() { - return ipList; - } - - public void setIpList(String ips) { - this.ipList = ips; - } - - @Override - public String toString() { - return "UserIpVo{" - + "id='" - + id - + '\'' - + ", user='" - + user - + '\'' - + ", creator='" - + creator - + '\'' - + ", ipList='" - + ipList - + '\'' - + ", createTime=" - + createTime - + ", updateTime=" - + updateTime - + ", desc='" - + desc - + '\'' - + ", bussinessUser='" - + bussinessUser - + '\'' - + '}'; - } -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/errorcode/LinkisConfigurationErrorCodeSummary.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/errorcode/LinkisConfigurationErrorCodeSummary.java deleted file mode 100644 index f02e0398f5..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/errorcode/LinkisConfigurationErrorCodeSummary.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.configuration.errorcode; - -import org.apache.linkis.common.errorcode.ErrorCodeUtils; -import org.apache.linkis.common.errorcode.LinkisErrorCode; - -public enum LinkisConfigurationErrorCodeSummary implements LinkisErrorCode { - BUILD_LABEL_ID(14100, ""), - CONFIGURATION_NOT_TYPE(14100, "Configuration does not support engine type:{0}(配置暂不支持{0}引擎类型)"), - CORRESPONDING_ENGINE_TYPE( - 14100, "The corresponding engine type is not matched:{0}(没有匹配到对应的引擎类型:{0})"), - FAILED_TO_BUILD_LABEL(14100, "Failed to build label(建立标签失败)"), - BUILD_LABEL_IS_NULL(14100, "Failed to build label ,label is null(建立标签失败,标签为空)"), - CONFIGKEY_CANNOT_BE_NULL(14100, "ConfigKey cannot be null(configKey 不能为空)"), - CONFIG_KEY_NOT_EXISTS(14100, "Config key not exists:{0}(配置键不存在:{0})"), - LABEL_NOT_EXISTS(14100, "Label not exists:{0}(标签不存在{0})"), - KEY_OR_VALUE_CANNOT(14100, "Key or value cannot be null(键或值不能为空)"), - PARAMS_CANNOT_BE_EMPTY(14100, "Params cannot be empty!(参数不能为空!)"), - TOKEN_IS_ERROR(14100, "Token is error(令牌是错误的)"), - IS_NULL_CANNOT_BE_ADDED(14100, "CategoryName is null, cannot be added(categoryName 为空,无法添加)"), - CANNOT_BE_INCLUDED(14100, "CategoryName cannot be included '-'(类别名称不能包含 '-')"), - CREATOR_IS_NULL_CANNOT_BE_ADDED(14100, "Creator is null, cannot be added(创建者为空,无法添加)"), - ENGINE_TYPE_IS_NULL(14100, "Engine type is null, cannot be added(引擎类型为空,无法添加)"), - INCORRECT_FIXED_SUCH( - 14100, - "The saved engine type parameter is incorrect, please send it in a fixed format, such as spark-3.2.1(保存的引擎类型参数有误,请按照固定格式传送,例如spark-3.2.1)"), - INCOMPLETE_RECONFIRM(14100, "Incomplete request parameters, please reconfirm(请求参数不完整,请重新确认)"), - ONLY_ADMIN_CAN_MODIFY(14100, "Only admin can modify category(只有管理员才能修改目录)"), - THE_LABEL_PARAMETER_IS_EMPTY(14100, " The label parameter is empty(标签参数为空)"), - ERROR_VALIDATOR_RANGE(14100, "Error validator range!(错误验证器范围!)"), - TYPE_OF_LABEL_NOT_SUPPORTED(14100, "This type of label is not supported:{0}(不支持这种类型的标签:{0})"); - - /** 错误码 */ - private final int errorCode; - /** 错误描述 */ - private final String errorDesc; - /** 错误可能出现的原因 */ - LinkisConfigurationErrorCodeSummary(int errorCode, String errorDesc) { - ErrorCodeUtils.validateErrorCode(errorCode, 10000, 24999); - this.errorCode = errorCode; - this.errorDesc = errorDesc; - } - - @Override - public int getErrorCode() { - return errorCode; - } - - @Override - public String getErrorDesc() { - return errorDesc; - } -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/exception/ConfigurationException.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/exception/ConfigurationException.java index d90bc6f455..37fa203eec 100644 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/exception/ConfigurationException.java +++ b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/exception/ConfigurationException.java @@ -19,16 +19,16 @@ import org.apache.linkis.common.exception.ErrorException; -import static org.apache.linkis.configuration.errorcode.LinkisConfigurationErrorCodeSummary.BUILD_LABEL_ID; - public class ConfigurationException extends ErrorException { + public static final int CONFIGURATION_ERROR_CODE = 14100; + public ConfigurationException(String message) { - super(BUILD_LABEL_ID.getErrorCode(), message); + super(14100, message); } public ConfigurationException(String message, Throwable throwable) { - super(BUILD_LABEL_ID.getErrorCode(), message); + super(14100, message); initCause(throwable); } } diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/restful/api/ConfigurationRestfulApi.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/restful/api/ConfigurationRestfulApi.java index 283960d5df..f407fcb614 100644 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/restful/api/ConfigurationRestfulApi.java +++ b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/restful/api/ConfigurationRestfulApi.java @@ -17,7 +17,7 @@ package org.apache.linkis.configuration.restful.api; -import org.apache.linkis.configuration.conf.Configuration; +import org.apache.linkis.common.conf.Configuration; import org.apache.linkis.configuration.entity.*; import org.apache.linkis.configuration.exception.ConfigurationException; import org.apache.linkis.configuration.service.CategoryService; @@ -41,7 +41,6 @@ import javax.servlet.http.HttpServletRequest; import java.io.IOException; -import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -56,8 +55,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.apache.linkis.configuration.errorcode.LinkisConfigurationErrorCodeSummary.*; - @Api(tags = "parameter configuration") @RestController @RequestMapping(path = "/configuration") @@ -77,7 +74,11 @@ public class ConfigurationRestfulApi { @ApiOperation(value = "addKeyForEngine", notes = "add key for engine", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "engineType", dataType = "String"), + @ApiImplicitParam( + name = "engineType", + required = false, + dataType = "String", + value = "engine type"), @ApiImplicitParam(name = "version", required = false, dataType = "String", value = "version"), @ApiImplicitParam(name = "token, required = false", dataType = "String", value = "token"), @ApiImplicitParam(name = "keyJson", required = false, dataType = "String", value = "key json") @@ -93,15 +94,11 @@ public Message addKeyForEngine( if (StringUtils.isBlank(engineType) || StringUtils.isBlank(version) || StringUtils.isBlank(token)) { - throw new ConfigurationException(PARAMS_CANNOT_BE_EMPTY.getErrorDesc()); + throw new ConfigurationException("params cannot be empty!"); } - ModuleUserUtils.getOperationUser( - req, - MessageFormat.format( - "addKeyForEngine,engineType:{0},version:{1},token:{2}", engineType, version, token)); // todo 检验token if (!token.equals(ConfigurationConfiguration.COPYKEYTOKEN)) { - throw new ConfigurationException(TOKEN_IS_ERROR.getErrorDesc()); + throw new ConfigurationException("token is error"); } ConfigKey configKey = BDPJettyServerHelper.gson().fromJson(keyJson, ConfigKey.class); configurationService.addKeyForEngine(engineType, version, configKey); @@ -114,9 +111,13 @@ public Message addKeyForEngine( notes = "get full trees by app name", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "engineType", dataType = "String"), - @ApiImplicitParam(name = "version", dataType = "String", value = "version"), - @ApiImplicitParam(name = "creator", dataType = "String", value = "creator") + @ApiImplicitParam( + name = "engineType", + required = false, + dataType = "String", + value = "engine type"), + @ApiImplicitParam(name = "version", required = false, dataType = "String", value = "version"), + @ApiImplicitParam(name = "creator", required = false, dataType = "String", value = "creator") }) @RequestMapping(path = "/getFullTreesByAppName", method = RequestMethod.GET) public Message getFullTreesByAppName( @@ -125,33 +126,24 @@ public Message getFullTreesByAppName( @RequestParam(value = "version", required = false) String version, @RequestParam(value = "creator", required = false) String creator) throws ConfigurationException { - if (creator != null - && (creator.equals(Configuration.GLOBAL_CONF_CHN_NAME()) - || creator.equals(Configuration.GLOBAL_CONF_CHN_OLDNAME()) - || creator.equals(Configuration.GLOBAL_CONF_CHN_EN_NAME()))) { + String username = ModuleUserUtils.getOperationUser(req, "getFullTreesByAppName"); + if (creator != null && (creator.equals("通用设置") || creator.equals("全局设置"))) { engineType = "*"; version = "*"; creator = "*"; } - String username = - ModuleUserUtils.getOperationUser( - req, - MessageFormat.format( - "ConfigurationException,engineType:{0},version:{1}", engineType, version)); List labelList = LabelEntityParser.generateUserCreatorEngineTypeLabelList( username, creator, engineType, version); ArrayList configTrees = - configurationService.getFullTreeByLabelList( - labelList, true, req.getHeader("Content-Language")); + configurationService.getFullTreeByLabelList(labelList, true); return Message.ok().data("fullTree", configTrees); } @ApiOperation(value = "getCategory", notes = "get category", response = Message.class) @RequestMapping(path = "/getCategory", method = RequestMethod.GET) public Message getCategory(HttpServletRequest req) { - List categoryLabelList = - categoryService.getAllCategory(req.getHeader("Content-Language")); + List categoryLabelList = categoryService.getAllCategory(); return Message.ok().data("Category", categoryLabelList); } @@ -160,8 +152,18 @@ public Message getCategory(HttpServletRequest req) { notes = "create first category", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "categoryName", required = true, dataType = "String"), - @ApiImplicitParam(name = "description", required = true, dataType = "String"), + @ApiImplicitParam( + name = "categoryName", + required = true, + dataType = "String", + value = "category name", + example = "name"), + @ApiImplicitParam( + name = "description", + required = true, + dataType = "STring", + value = "description", + example = "description"), }) @ApiOperationSupport(ignoreParameters = {"jsonNode"}) @RequestMapping(path = "/createFirstCategory", method = RequestMethod.POST) @@ -172,10 +174,10 @@ public Message createFirstCategory(HttpServletRequest request, @RequestBody Json String categoryName = jsonNode.get("categoryName").asText(); String description = jsonNode.get("description").asText(); if (StringUtils.isEmpty(categoryName) || categoryName.equals(NULL)) { - throw new ConfigurationException(IS_NULL_CANNOT_BE_ADDED.getErrorDesc()); + throw new ConfigurationException("categoryName is null, cannot be added"); } if (StringUtils.isEmpty(categoryName) || categoryName.contains("-")) { - throw new ConfigurationException(CANNOT_BE_INCLUDED.getErrorDesc()); + throw new ConfigurationException("categoryName cannot be included '-'"); } categoryService.createFirstCategory(categoryName, description); return Message.ok(); @@ -183,7 +185,12 @@ public Message createFirstCategory(HttpServletRequest request, @RequestBody Json @ApiOperation(value = "deleteCategory", notes = "delete category", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "categoryId", required = true, dataType = "String", example = "54") + @ApiImplicitParam( + name = "categoryId", + required = true, + dataType = "String", + value = "category id", + example = "54") }) @ApiOperationSupport(ignoreParameters = "jsonNode") @RequestMapping(path = "/deleteCategory", method = RequestMethod.POST) @@ -201,10 +208,29 @@ public Message deleteCategory(HttpServletRequest request, @RequestBody JsonNode notes = "create second category", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "categoryId", required = true, dataType = "String", example = "39"), - @ApiImplicitParam(name = "engineType", required = true, dataType = "String", example = "hive"), - @ApiImplicitParam(name = "version", required = true, dataType = "String", example = "1.2.0"), - @ApiImplicitParam(name = "description", required = true, dataType = "String"), + @ApiImplicitParam( + name = "categoryId", + required = true, + dataType = "String", + value = "category id", + example = "39"), + @ApiImplicitParam( + name = "engineType", + required = true, + dataType = "String", + value = "engine type", + example = "hive"), + @ApiImplicitParam( + name = "version", + required = true, + dataType = "String", + value = "Version", + example = "1.2.0"), + @ApiImplicitParam( + name = "description", + required = true, + dataType = "String", + value = "description"), }) @ApiOperationSupport(ignoreParameters = {"jsonNode"}) @RequestMapping(path = "/createSecondCategory", method = RequestMethod.POST) @@ -217,10 +243,10 @@ public Message createSecondCategory(HttpServletRequest request, @RequestBody Jso String version = jsonNode.get("version").asText(); String description = jsonNode.get("description").asText(); if (categoryId <= 0) { - throw new ConfigurationException(CREATOR_IS_NULL_CANNOT_BE_ADDED.getErrorDesc()); + throw new ConfigurationException("creator is null, cannot be added"); } if (StringUtils.isEmpty(engineType) || engineType.toLowerCase().equals(NULL)) { - throw new ConfigurationException(ENGINE_TYPE_IS_NULL.getErrorDesc()); + throw new ConfigurationException("engine type is null, cannot be added"); } if (StringUtils.isEmpty(version) || version.toLowerCase().equals(NULL)) { version = LabelUtils.COMMON_VALUE; @@ -231,11 +257,25 @@ public Message createSecondCategory(HttpServletRequest request, @RequestBody Jso @ApiOperation(value = "saveFullTree", notes = "save full tree", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "creator", required = true, dataType = "String", example = "xwzTest"), - @ApiImplicitParam(name = "engineType", required = true, dataType = "String", example = "hive"), + @ApiImplicitParam( + name = "creator", + required = true, + dataType = "String", + value = "creator", + example = "xwzTest"), + @ApiImplicitParam( + name = "engineType", + required = true, + dataType = "String", + value = "engine type", + example = "python-ss"), @ApiImplicitParam(name = "fullTree", required = true, dataType = "List", value = "full tree"), @ApiImplicitParam(name = "name", required = true, dataType = "String", value = "name"), - @ApiImplicitParam(name = "description", required = true, dataType = "String"), + @ApiImplicitParam( + name = "description", + required = true, + dataType = "String", + value = "description"), @ApiImplicitParam(name = "settings", required = true, dataType = "List", value = "settings") }) @ApiOperationSupport(ignoreParameters = {"json"}) @@ -245,10 +285,7 @@ public Message saveFullTree(HttpServletRequest req, @RequestBody JsonNode json) List fullTrees = mapper.treeToValue(json.get("fullTree"), List.class); String creator = JsonNodeUtil.getStringValue(json.get("creator")); String engineType = JsonNodeUtil.getStringValue(json.get("engineType")); - if (creator != null - && (creator.equals(Configuration.GLOBAL_CONF_CHN_NAME()) - || creator.equals(Configuration.GLOBAL_CONF_CHN_OLDNAME()) - || creator.equals(Configuration.GLOBAL_CONF_CHN_EN_NAME()))) { + if (creator != null && (creator.equals("通用设置") || creator.equals("全局设置"))) { creator = "*"; } String username = ModuleUserUtils.getOperationUser(req, "saveFullTree"); @@ -269,45 +306,16 @@ public Message saveFullTree(HttpServletRequest req, @RequestBody JsonNode json) if (engineType != null) { String[] tmpString = engineType.split("-"); if (tmpString.length != 2) { - throw new ConfigurationException(INCORRECT_FIXED_SUCH.getErrorDesc()); + throw new ConfigurationException( + "The saved engine type parameter is incorrect, please send it in a fixed format, such as spark-2.4.3(保存的引擎类型参数有误,请按照固定格式传送,例如spark-2.4.3)"); } engine = tmpString[0]; version = tmpString[1]; } configurationService.updateUserValue(createList, updateList); - // TODO: Add a refresh cache interface later - if (StringUtils.isNotBlank(creator) && creator.equals("*")) { - List allCategory = categoryService.getAllCategory(null); - List categoryLabelVos = - allCategory.stream() - .filter(s -> s.getCategoryName().equals(Configuration.REMOVE_APPLICATION_CACHE())) - .map(CategoryLabelVo::getChildCategory) - .findFirst() - .get(); - categoryLabelVos.stream() - .map(CategoryLabelVo::getCategoryName) - .filter(StringUtils::isNotBlank) - .forEach( - info -> { - String[] tmpString = info.split("-"); - if (tmpString.length == 2) { - String engineName = tmpString[0]; - String engineVersion = tmpString[1]; - logger.info( - "Config remove engine cache:engineName:{},engineVersion:{}", - engineName, - engineVersion); - configurationService.clearAMCacheConf( - username, - Configuration.REMOVE_APPLICATION_CACHE(), - engineName, - engineVersion); - } - }); - } else { - configurationService.clearAMCacheConf(username, creator, engine, version); - } - return Message.ok(); + configurationService.clearAMCacheConf(username, creator, engine, version); + Message message = Message.ok(); + return message; } @ApiOperation( @@ -325,8 +333,16 @@ public Message listAllEngineType(HttpServletRequest request) { notes = "update category info", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "description", required = true, dataType = "String"), - @ApiImplicitParam(name = "categoryId", required = true, dataType = "String") + @ApiImplicitParam( + name = "description", + required = true, + dataType = "String", + value = "description"), + @ApiImplicitParam( + name = "categoryId", + required = true, + dataType = "String", + value = "category id") }) @ApiOperationSupport(ignoreParameters = {"jsonNode"}) @RequestMapping(path = "/updateCategoryInfo", method = RequestMethod.POST) @@ -340,7 +356,7 @@ public Message updateCategoryInfo(HttpServletRequest request, @RequestBody JsonN description = jsonNode.get("description").asText(); categoryId = jsonNode.get("categoryId").asInt(); } catch (Exception e) { - throw new ConfigurationException(INCOMPLETE_RECONFIRM.getErrorDesc()); + throw new ConfigurationException("请求参数不完整,请重新确认"); } if (description != null) { categoryService.updateCategory(categoryId, description); @@ -350,9 +366,17 @@ public Message updateCategoryInfo(HttpServletRequest request, @RequestBody JsonN @ApiOperation(value = "rpcTest", notes = "rpc test", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "creator", dataType = "String", value = "creator"), - @ApiImplicitParam(name = "engineType", dataType = "String"), - @ApiImplicitParam(name = "username", dataType = "String"), + @ApiImplicitParam(name = "creator", required = false, dataType = "String", value = "creator"), + @ApiImplicitParam( + name = "engineType", + required = false, + dataType = "String", + value = "engine type"), + @ApiImplicitParam( + name = "username", + required = false, + dataType = "String", + value = "user name"), @ApiImplicitParam(name = "version", required = false, dataType = "String", value = "version") }) @RequestMapping(path = "/rpcTest", method = RequestMethod.GET) @@ -375,16 +399,24 @@ public Message rpcTest( } private void checkAdmin(String userName) throws ConfigurationException { - if (!org.apache.linkis.common.conf.Configuration.isAdmin(userName)) { - throw new ConfigurationException(ONLY_ADMIN_CAN_MODIFY.getErrorDesc()); + if (!Configuration.isAdmin(userName)) { + throw new ConfigurationException("only admin can modify category(只有管理员才能修改目录)"); } } @ApiOperation(value = "getKeyValue", notes = "get key value", response = Message.class) @ApiImplicitParams({ @ApiImplicitParam(name = "creator", required = false, dataType = "String", value = "creator"), - @ApiImplicitParam(name = "engineType", dataType = "String"), - @ApiImplicitParam(name = "configKey", dataType = "String"), + @ApiImplicitParam( + name = "engineType", + required = false, + dataType = "String", + value = "engine type"), + @ApiImplicitParam( + name = "configKey", + required = false, + dataType = "String", + value = "config key"), @ApiImplicitParam(name = "version", required = false, dataType = "String", value = "version") }) @RequestMapping(path = "/keyvalue", method = RequestMethod.GET) @@ -414,11 +446,23 @@ public Message getKeyValue( @ApiOperation(value = "saveKeyValue", notes = "save key value", response = Message.class) @ApiImplicitParams({ - @ApiImplicitParam(name = "engineType", required = true, dataType = "String"), + @ApiImplicitParam( + name = "engineType", + required = true, + dataType = "String", + value = "engine type"), @ApiImplicitParam(name = "version", required = true, dataType = "String", value = "version"), @ApiImplicitParam(name = "creator", required = true, dataType = "String", value = "creator"), - @ApiImplicitParam(name = "configKey", required = true, dataType = "String"), - @ApiImplicitParam(name = "configValue", required = true, dataType = "String") + @ApiImplicitParam( + name = "configKey", + required = true, + dataType = "String", + value = "config key"), + @ApiImplicitParam( + name = "configValue", + required = true, + dataType = "String", + value = "config value") }) @ApiOperationSupport(ignoreParameters = {"json"}) @RequestMapping(path = "/keyvalue", method = RequestMethod.POST) @@ -451,10 +495,18 @@ public Message saveKeyValue(HttpServletRequest req, @RequestBody Map resultMap = - tenantConfigService.queryTenantList(user, creator, tenantValue, pageNow, pageSize); - return Message.ok() - .data("tenantList", resultMap.get("tenantList")) - .data(JobRequestConstants.TOTAL_PAGE(), resultMap.get(JobRequestConstants.TOTAL_PAGE())); - } - - @ApiImplicitParams({ - @ApiImplicitParam( - paramType = "query", - dataType = "HttpServletRequest", - name = "req", - value = ""), - @ApiImplicitParam(paramType = "query", dataType = "string", name = "user", value = "user"), - @ApiImplicitParam( - paramType = "query", - dataType = "string", - name = "creator", - value = "creator"), - @ApiImplicitParam( - paramType = "query", - dataType = "string", - name = "tenantValue", - value = "tenantValue") - }) - @ApiOperation( - value = "check-user-creator", - notes = "check user creator", - httpMethod = "GET", - response = Message.class) - @RequestMapping(path = "/check-user-creator", method = RequestMethod.GET) - public Message checkUserCreator( - HttpServletRequest req, - @RequestParam(value = "user", required = false) String user, - @RequestParam(value = "creator", required = false) String creator) { - Boolean result = false; - try { - // Parameter verification - if (StringUtils.isBlank(creator)) { - throw new ConfigurationException("Application Name can't be empty "); - } - if (StringUtils.isBlank(user)) { - throw new ConfigurationException("User Name can't be empty "); - } - String userName = ModuleUserUtils.getOperationUser(req, "checkUserCreator"); - if (!Configuration.isAdmin(userName)) { - return Message.error("Failed to check-user-creator,msg: only administrators can configure"); - } - result = tenantConfigService.isExist(user, creator); - } catch (ConfigurationException e) { - return Message.error("Failed to check-user-creator,msg:" + e.getMessage()); - } - return Message.ok().data("exist", result); - } - - private void parameterVerification(TenantVo tenantVo) throws ConfigurationException { - // Parameter verification - if (StringUtils.isBlank(tenantVo.getCreator())) { - throw new ConfigurationException("Application name can't be empty "); - } - if (StringUtils.isBlank(tenantVo.getUser())) { - throw new ConfigurationException("User name can't be empty "); - } - if (StringUtils.isBlank(tenantVo.getBussinessUser())) { - throw new ConfigurationException("Creat user can't be empty "); - } - if (StringUtils.isBlank(tenantVo.getDesc())) { - throw new ConfigurationException("Description can't be empty "); - } - if (StringUtils.isBlank(tenantVo.getTenantValue())) { - throw new ConfigurationException("Tenant tag can't be empty "); - } - if (tenantVo.getCreator().equals("*") && tenantVo.getUser().equals("*")) { - throw new ConfigurationException("User && Creator cannot be both *"); - } - } -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/restful/api/UserIpConfigrationRestfulApi.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/restful/api/UserIpConfigrationRestfulApi.java deleted file mode 100644 index 78e7003d49..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/restful/api/UserIpConfigrationRestfulApi.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * 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.configuration.restful.api; - -import org.apache.linkis.common.conf.Configuration; -import org.apache.linkis.configuration.entity.UserIpVo; -import org.apache.linkis.configuration.exception.ConfigurationException; -import org.apache.linkis.configuration.service.UserIpConfigService; -import org.apache.linkis.governance.common.constant.job.JobRequestConstants; -import org.apache.linkis.server.Message; -import org.apache.linkis.server.utils.ModuleUserUtils; - -import org.apache.commons.lang.StringUtils; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DuplicateKeyException; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletRequest; - -import java.util.Map; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Api -@RestController -@RequestMapping(path = "/configuration/user-ip-mapping") -public class UserIpConfigrationRestfulApi { - - private static final Logger logger = LoggerFactory.getLogger(UserIpConfigrationRestfulApi.class); - - @Autowired private UserIpConfigService userIpConfigService; - - @ApiImplicitParams({ - @ApiImplicitParam( - paramType = "query", - dataType = "HttpServletRequest", - name = "req", - value = ""), - @ApiImplicitParam( - paramType = "body", - dataType = "UserIpVo", - name = "userIpVo", - value = "userIpVo") - }) - @ApiOperation(value = "create-user-ip", notes = "create user ip", httpMethod = "POST") - @RequestMapping(path = "/create-user-ip", method = RequestMethod.POST) - public Message createUserIp(HttpServletRequest req, @RequestBody UserIpVo userIpVo) { - try { - String userName = ModuleUserUtils.getOperationUser(req, "execute createUserIP"); - if (!Configuration.isAdmin(userName)) { - return Message.error("Failed to create-user-ip,msg: only administrators can configure"); - } - if (userIpConfigService.userExists(userIpVo.getUser(), userIpVo.getCreator())) { - throw new ConfigurationException("User-creator is existed"); - } - parameterVerification(userIpVo); - userIpConfigService.createUserIP(userIpVo); - } catch (DuplicateKeyException e) { - return Message.error("Failed to create-user-ip,msg:create user-creator is existed"); - } catch (ConfigurationException e) { - return Message.error("Failed to create-user-ip,msg:" + e.getMessage()); - } - return Message.ok(); - } - - @ApiImplicitParams({ - @ApiImplicitParam( - paramType = "query", - dataType = "HttpServletRequest", - name = "req", - value = ""), - @ApiImplicitParam( - paramType = "body", - dataType = "UserIpVo", - name = "UserIpVo", - value = "UserIpVo") - }) - @ApiOperation(value = "update-user-ip", notes = "update user ip", httpMethod = "POST") - @RequestMapping(path = "/update-user-ip", method = RequestMethod.POST) - public Message updateUserIp(HttpServletRequest req, @RequestBody UserIpVo userIpVo) { - try { - String userName = ModuleUserUtils.getOperationUser(req, "execute updateUserIP"); - if (!Configuration.isAdmin(userName)) { - return Message.error("Failed to update-user-ip,msg: only administrators can configure "); - } - // if (!userIpConfigService.checkUserCteator(userIpVo.getUser(), userIpVo.getCreator())) - // { - // throw new ConfigurationException("User-creator is not existed"); - // } - parameterVerification(userIpVo); - userIpConfigService.updateUserIP(userIpVo); - } catch (ConfigurationException e) { - return Message.error("Failed to update-user-ip,msg:" + e.getMessage()); - } - return Message.ok(); - } - - @ApiImplicitParams({ - @ApiImplicitParam( - paramType = "query", - dataType = "HttpServletRequest", - name = "req", - value = ""), - @ApiImplicitParam(paramType = "query", dataType = "int", name = "id", value = "id") - }) - @ApiOperation(value = "delete-user-ip", notes = "delete user ip", httpMethod = "GET") - @RequestMapping(path = "/delete-user-ip", method = RequestMethod.GET) - public Message deleteUserIp(HttpServletRequest req, @RequestParam(value = "id") Integer id) { - try { - String userName = ModuleUserUtils.getOperationUser(req, "execute deleteUserIp,id: " + id); - if (!Configuration.isAdmin(userName)) { - return Message.error("Failed to delete-user-ip,msg: only administrators can configure"); - } - userIpConfigService.deleteUserIP(id); - } catch (ConfigurationException e) { - return Message.error("Failed to check-user-creator,msg:" + e.getMessage()); - } - return Message.ok(); - } - - @ApiImplicitParams({ - @ApiImplicitParam( - paramType = "query", - dataType = "HttpServletRequest", - name = "req", - value = ""), - @ApiImplicitParam(paramType = "query", dataType = "string", name = "user", value = "user"), - @ApiImplicitParam(paramType = "query", dataType = "string", name = "creator", value = "creator") - }) - @ApiOperation(value = "query-user-ip-list", notes = "query user ip list", httpMethod = "GET") - @RequestMapping(path = "/query-user-ip-list", method = RequestMethod.GET) - public Message queryUserIpList( - HttpServletRequest req, - @RequestParam(value = "user", required = false) String user, - @RequestParam(value = "creator", required = false) String creator, - @RequestParam(value = "pageNow") Integer pageNow, - @RequestParam(value = "pageSize") Integer pageSize) { - String userName = ModuleUserUtils.getOperationUser(req, "queryUserIPList"); - if (!Configuration.isAdmin(userName)) { - return Message.error("Failed to query-user-ip-list,msg: only administrators can configure"); - } - if (StringUtils.isBlank(user)) user = null; - if (StringUtils.isBlank(creator)) creator = null; - if (null == pageNow) pageNow = 1; - if (null == pageSize) pageSize = 20; - Map resultMap = - userIpConfigService.queryUserIPList(user, creator, pageNow, pageSize); - return Message.ok() - .data("userIpList", resultMap.get("userIpList")) - .data(JobRequestConstants.TOTAL_PAGE(), resultMap.get(JobRequestConstants.TOTAL_PAGE())); - } - - @ApiImplicitParams({ - @ApiImplicitParam( - paramType = "query", - dataType = "HttpServletRequest", - name = "req", - value = ""), - @ApiImplicitParam(paramType = "query", dataType = "string", name = "user", value = "user"), - @ApiImplicitParam(paramType = "query", dataType = "string", name = "creator", value = "creator") - }) - @ApiOperation(value = "check-user-creator", notes = " check user creator", httpMethod = "GET") - @RequestMapping(path = "/check-user-creator", method = RequestMethod.GET) - public Message checkUserCreator( - HttpServletRequest req, - @RequestParam(value = "user") String user, - @RequestParam(value = "creator") String creator) { - boolean result = false; - try { - String userName = ModuleUserUtils.getOperationUser(req, "checkUserCreator"); - if (!Configuration.isAdmin(userName)) { - return Message.error("Failed to check-user-creator,msg: only administrators can configure"); - } - // Parameter verification - if (StringUtils.isBlank(creator)) { - throw new ConfigurationException("Application Name couldn't be empty "); - } - if (StringUtils.isBlank(user)) { - throw new ConfigurationException("User Name couldn't be empty "); - } - if (creator.equals("*")) { - throw new ConfigurationException("Application Name couldn't be '*' "); - } - result = userIpConfigService.userExists(user, creator); - } catch (ConfigurationException e) { - return Message.error("Failed to check-user-creator,msg:" + e.getMessage()); - } - return Message.ok().data("exist", result); - } - - private void parameterVerification(UserIpVo userIpVo) throws ConfigurationException { - // Parameter verification - if (StringUtils.isBlank(userIpVo.getCreator())) { - throw new ConfigurationException("Application Name couldn't be empty "); - } - if (StringUtils.isBlank(userIpVo.getUser())) { - throw new ConfigurationException("User Name couldn't be empty "); - } - if (StringUtils.isBlank(userIpVo.getBussinessUser())) { - throw new ConfigurationException("Creat User couldn't be empty "); - } - if (StringUtils.isBlank(userIpVo.getIpList())) { - throw new ConfigurationException("Ip List couldn't be empty "); - } - if (StringUtils.isBlank(userIpVo.getDesc())) { - throw new ConfigurationException("Description couldn't be empty "); - } - } -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/TenantConfigService.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/TenantConfigService.java deleted file mode 100644 index 87b14a9c5e..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/TenantConfigService.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.configuration.service; - -import org.apache.linkis.configuration.entity.TenantVo; -import org.apache.linkis.configuration.exception.ConfigurationException; - -import java.util.Map; - -public interface TenantConfigService { - - Map queryTenantList( - String user, String creator, String tenantValue, Integer pageNow, Integer pageSize); - - void deleteTenant(Integer id) throws ConfigurationException; - - void updateTenant(TenantVo tenantVo) throws ConfigurationException; - - void createTenant(TenantVo tenantVo) throws ConfigurationException; - - Boolean isExist(String user, String creator) throws ConfigurationException; - - TenantVo queryTenant(String user, String creator); -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/UserIpConfigService.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/UserIpConfigService.java deleted file mode 100644 index 6d292d6813..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/UserIpConfigService.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.configuration.service; - -import org.apache.linkis.configuration.entity.UserIpVo; -import org.apache.linkis.configuration.exception.ConfigurationException; - -import java.util.Map; - -public interface UserIpConfigService { - - void createUserIP(UserIpVo userIpVo) throws ConfigurationException; - - void updateUserIP(UserIpVo userIpVo) throws ConfigurationException; - - void deleteUserIP(Integer id) throws ConfigurationException; - - Map queryUserIPList( - String user, String creator, Integer pageNow, Integer pageSize); - - boolean userExists(String user, String creator); - - UserIpVo queryUserIP(String user, String creator); -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/ConfigKeyServiceImpl.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/ConfigKeyServiceImpl.java index 6811b5e7e2..0b28ae3267 100644 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/ConfigKeyServiceImpl.java +++ b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/ConfigKeyServiceImpl.java @@ -39,15 +39,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.apache.linkis.configuration.errorcode.LinkisConfigurationErrorCodeSummary.*; - @Service public class ConfigKeyServiceImpl implements ConfigKeyService { @@ -65,14 +62,13 @@ public ConfigValue saveConfigValue(ConfigKeyValue configKeyValue, List> if (StringUtils.isBlank(configKeyValue.getConfigValue()) || StringUtils.isBlank(configKeyValue.getKey())) { - throw new ConfigurationException(KEY_OR_VALUE_CANNOT.getErrorDesc()); + throw new ConfigurationException("key or value cannot be null"); } LabelParameterParser.labelCheck(labelList); - List configKeys = configMapper.selectKeyByKeyName(configKeyValue.getKey()); + List configKeys = configMapper.seleteKeyByKeyName(configKeyValue.getKey()); if (null == configKeys || configKeys.isEmpty()) { - throw new ConfigurationException( - MessageFormat.format(CONFIG_KEY_NOT_EXISTS.getErrorDesc(), configKeyValue.getKey())); + throw new ConfigurationException("config key not exists: " + configKeyValue.getKey()); } ConfigKey configKey = configKeys.get(0); EngineTypeLabel engineTypeLabel = LabelUtil.getEngineTypeLabel(labelList); @@ -121,10 +117,10 @@ private CombinedLabel getCombinedLabel(List> labelList) throws Configur try { combinedLabel = (CombinedLabel) combinedLabelBuilder.build("", labelList); } catch (LabelErrorException e) { - throw new ConfigurationException(FAILED_TO_BUILD_LABEL.getErrorDesc(), e); + throw new ConfigurationException("Failed to build label", e); } if (null == combinedLabel) { - throw new ConfigurationException(BUILD_LABEL_IS_NULL.getErrorDesc()); + throw new ConfigurationException("Failed to build label ,label is null"); } return combinedLabel; } @@ -133,22 +129,20 @@ private CombinedLabel getCombinedLabel(List> labelList) throws Configur public List getConfigValue(String key, List> labelList) throws ConfigurationException { if (StringUtils.isBlank(key)) { - throw new ConfigurationException(CONFIGKEY_CANNOT_BE_NULL.getErrorDesc()); + throw new ConfigurationException("configKey cannot be null"); } LabelParameterParser.labelCheck(labelList); - List configKeys = configMapper.selectKeyByKeyName(key); + List configKeys = configMapper.seleteKeyByKeyName(key); if (null == configKeys || configKeys.isEmpty()) { - throw new ConfigurationException( - MessageFormat.format(CONFIG_KEY_NOT_EXISTS.getErrorDesc(), key)); + throw new ConfigurationException("config key not exists: " + key); } CombinedLabel combinedLabel = getCombinedLabel(labelList); ConfigLabel configLabel = labelMapper.getLabelByKeyValue(combinedLabel.getLabelKey(), combinedLabel.getStringValue()); if (null == configLabel || configLabel.getId() < 0) { - throw new ConfigurationException( - MessageFormat.format(LABEL_NOT_EXISTS.getErrorDesc(), combinedLabel.getStringValue())); + throw new ConfigurationException("label not exists: " + combinedLabel.getStringValue()); } List configValues = new ArrayList<>(); for (ConfigKey configKey : configKeys) { diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/TenantConfigServiceImpl.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/TenantConfigServiceImpl.java deleted file mode 100644 index bf9755a307..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/TenantConfigServiceImpl.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * 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.configuration.service.impl; - -import org.apache.linkis.configuration.dao.UserTenantMapper; -import org.apache.linkis.configuration.entity.TenantVo; -import org.apache.linkis.configuration.exception.ConfigurationException; -import org.apache.linkis.configuration.service.TenantConfigService; -import org.apache.linkis.configuration.util.HttpsUtil; -import org.apache.linkis.governance.common.constant.job.JobRequestConstants; - -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang.StringUtils; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.io.IOException; -import java.util.*; -import java.util.concurrent.atomic.AtomicReference; - -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Service -public class TenantConfigServiceImpl implements TenantConfigService { - - private static final Logger logger = LoggerFactory.getLogger(TenantConfigServiceImpl.class); - - @Autowired private UserTenantMapper userTenantMapper; - - /** - * * Querying the tenant configuration table - * - * @param user - * @param creator - * @param tenantValue - * @param pageNow - * @param pageSize - * @return List - */ - @Override - public Map queryTenantList( - String user, String creator, String tenantValue, Integer pageNow, Integer pageSize) { - Map result = new HashMap<>(2); - List tenantVos = null; - if (Objects.isNull(pageNow)) { - pageNow = 1; - } - if (Objects.isNull(pageSize)) { - pageSize = 20; - } - PageHelper.startPage(pageNow, pageSize); - try { - tenantVos = userTenantMapper.queryTenantList(user, creator, tenantValue); - } finally { - PageHelper.clearPage(); - } - PageInfo pageInfo = new PageInfo<>(tenantVos); - result.put("tenantList", tenantVos); - result.put(JobRequestConstants.TOTAL_PAGE(), pageInfo.getTotal()); - return result; - } - - /** - * Delete tenant By ID - * - * @param id - */ - @Override - public void deleteTenant(Integer id) throws ConfigurationException { - logger.info("deleteUserIP : id:{}", id); - if (StringUtils.isBlank(id.toString())) { - throw new ConfigurationException("id can't be empty "); - } - userTenantMapper.deleteTenant(id); - } - - /** - * Update tenant - * - * @param tenantVo - */ - @Override - public void updateTenant(TenantVo tenantVo) throws ConfigurationException { - if (StringUtils.isBlank(tenantVo.getId())) { - throw new ConfigurationException("id can't be empty "); - } - dataProcessing(tenantVo); - TenantVo tenantVoLowerCase = toLowerCase(tenantVo); - logger.info("updateTenant : {}", tenantVoLowerCase); - userTenantMapper.updateTenant(tenantVoLowerCase); - } - - /** - * Insert tenant - * - * @param tenantVo - */ - @Override - public void createTenant(TenantVo tenantVo) throws ConfigurationException { - dataProcessing(tenantVo); - TenantVo tenantVoLowerCase = toLowerCase(tenantVo); - tenantVoLowerCase.setCreateTime(new Date()); - logger.info("createTenant : {}", tenantVoLowerCase); - userTenantMapper.createTenant(tenantVo); - } - - private void dataProcessing(TenantVo tenantVo) throws ConfigurationException { - if (!tenantVo.getCreator().equals("*")) { - AtomicReference tenantResult = new AtomicReference<>(false); - // Obtain the tenant information of the ECM list - Map ecmListResult = null; - try { - ecmListResult = HttpsUtil.sendHttp(null, null); - logger.info("Request ecm list response {}:", ecmListResult); - } catch (IOException e) { - logger.warn("failed to get ecmResource data"); - } - Map>> data = MapUtils.getMap(ecmListResult, "data"); - List> emNodeVoList = data.get("EMs"); - // Compare ECM list tenant labels for task - emNodeVoList.forEach( - ecmInfo -> { - List> labels = (List>) ecmInfo.get("labels"); - labels.stream() - .filter(labelmap -> labelmap.containsKey("tenant")) - .forEach( - map -> { - String tenant = map.get("tenant").toString().toLowerCase(); - if (tenant.equals(tenantVo.getTenantValue().toLowerCase())) { - tenantResult.set(true); - } - }); - }); - // Compare the value of ecm tenant - if (!tenantResult.get()) - throw new ConfigurationException("The ECM with the corresponding label was not found"); - // The beginning of tenantValue needs to contain creator - String creator = tenantVo.getCreator().toLowerCase(); - String[] tenantArray = tenantVo.getTenantValue().toLowerCase().split("_"); - if (tenantArray.length > 1 && !creator.equals(tenantArray[0])) { - throw new ConfigurationException("tenantValue should contain creator first"); - } - } - } - - @Override - public Boolean isExist(String user, String creator) { - boolean result = true; - Map resultMap = - queryTenantList(user.toLowerCase(), creator.toLowerCase(), null, 1, 20); - Object tenantList = resultMap.getOrDefault(JobRequestConstants.TOTAL_PAGE(), 0); - int total = Integer.parseInt(tenantList.toString()); - if (total == 0) result = false; - return result; - } - - @Override - public TenantVo queryTenant(String user, String creator) { - return userTenantMapper.queryTenant(user, creator); - } - - public TenantVo toLowerCase(TenantVo tenantVo) { - tenantVo.setTenantValue(tenantVo.getTenantValue().toLowerCase()); - tenantVo.setCreator(tenantVo.getCreator().toLowerCase()); - tenantVo.setUser(tenantVo.getUser().toLowerCase()); - tenantVo.setUpdateTime(new Date()); - return tenantVo; - } -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/TenantServiceImpl.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/TenantServiceImpl.java deleted file mode 100644 index 25d272c121..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/TenantServiceImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.configuration.service.impl; - -import org.apache.linkis.configuration.entity.TenantVo; -import org.apache.linkis.configuration.service.TenantConfigService; -import org.apache.linkis.configuration.service.TenantService; -import org.apache.linkis.governance.common.protocol.conf.TenantRequest; -import org.apache.linkis.governance.common.protocol.conf.TenantResponse; -import org.apache.linkis.rpc.Sender; -import org.apache.linkis.rpc.message.annotation.Receiver; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Service -public class TenantServiceImpl implements TenantService { - - private static final Logger logger = LoggerFactory.getLogger(TenantService.class); - - @Autowired private TenantConfigService tenantConfigService; - - @Receiver - @Override - public TenantResponse getTenantData(TenantRequest request, Sender sender) { - TenantVo tenantVo = tenantConfigService.queryTenant(request.user(), request.creator()); - if (null == tenantVo) { - logger.warn( - "TenantCache user {} creator {} data loading failed", request.user(), request.creator()); - return new TenantResponse(request.user(), request.creator(), ""); - } else { - return new TenantResponse( - tenantVo.getUser(), tenantVo.getCreator(), tenantVo.getTenantValue()); - } - } -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/UserIpConfigServiceImpl.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/UserIpConfigServiceImpl.java deleted file mode 100644 index 9c96121156..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/UserIpConfigServiceImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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.configuration.service.impl; - -import org.apache.linkis.configuration.dao.UserIpMapper; -import org.apache.linkis.configuration.entity.UserIpVo; -import org.apache.linkis.configuration.exception.ConfigurationException; -import org.apache.linkis.configuration.service.UserIpConfigService; -import org.apache.linkis.configuration.util.CommonUtils; -import org.apache.linkis.governance.common.constant.job.JobRequestConstants; - -import org.apache.commons.lang.StringUtils; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; - -import com.github.pagehelper.PageHelper; -import com.github.pagehelper.PageInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Service -public class UserIpConfigServiceImpl implements UserIpConfigService { - - private static final Logger logger = LoggerFactory.getLogger(UserIpConfigServiceImpl.class); - - @Autowired private UserIpMapper userIpMapper; - - /** - * * createUserIP - * - * @param userIpVo - * @return - */ - @Override - public void createUserIP(UserIpVo userIpVo) throws ConfigurationException { - dataProcessing(userIpVo); - UserIpVo userIpVoLowerCase = toLowerCase(userIpVo); - userIpVoLowerCase.setCreateTime(new Date()); - userIpVoLowerCase.setUpdateTime(new Date()); - userIpMapper.createUserIP(userIpVoLowerCase); - } - - /** - * updateUserIP - * - * @param userIpVo - */ - @Override - public void updateUserIP(UserIpVo userIpVo) throws ConfigurationException { - if (StringUtils.isBlank(userIpVo.getId())) { - throw new ConfigurationException("id couldn't be empty "); - } - dataProcessing(userIpVo); - UserIpVo userIpVoLowerCase = toLowerCase(userIpVo); - userIpVoLowerCase.setUpdateTime(new Date()); - logger.info("updateUserIP : {}", userIpVoLowerCase); - userIpMapper.updateUserIP(userIpVoLowerCase); - } - - /** - * deleteUserIP - * - * @param id - */ - @Override - @Transactional(rollbackFor = Throwable.class) - public void deleteUserIP(Integer id) throws ConfigurationException { - logger.info("deleteUserIP : id:{}", id); - if (StringUtils.isBlank(id.toString())) { - throw new ConfigurationException("id couldn't be empty "); - } - userIpMapper.deleteUserIP(id); - } - - /** - * Query IP Collection - * - * @return List - * @param user - * @param creator - * @param pageNow - * @param pageSize - */ - @Override - public Map queryUserIPList( - String user, String creator, Integer pageNow, Integer pageSize) { - Map result = new HashMap<>(2); - List userIpVos = null; - PageHelper.startPage(pageNow, pageSize); - try { - userIpVos = userIpMapper.queryUserIPList(user, creator); - } finally { - PageHelper.clearPage(); - } - PageInfo pageInfo = new PageInfo<>(userIpVos); - result.put("userIpList", userIpVos); - result.put(JobRequestConstants.TOTAL_PAGE(), pageInfo.getTotal()); - return result; - } - - private void dataProcessing(UserIpVo userIpVo) throws ConfigurationException { - // Ip rule verification - String ipList = userIpVo.getIpList(); - if (!ipList.equals("*")) { - String[] split = ipList.split(","); - StringJoiner joiner = new StringJoiner(","); - Arrays.stream(split) - .distinct() - .filter(ipStr -> !CommonUtils.ipCheck(ipStr)) - .forEach(joiner::add); - if (StringUtils.isNotBlank(joiner.toString())) { - throw new ConfigurationException(joiner + ",Illegal IP address "); - } - } - } - - @Override - public boolean userExists(String user, String creator) { - Map resultMap = - queryUserIPList(user.toLowerCase(), creator.toLowerCase(), 1, 20); - Object userIpList = resultMap.getOrDefault(JobRequestConstants.TOTAL_PAGE(), 0); - return Integer.parseInt(String.valueOf(userIpList)) > 0; - } - - @Override - public UserIpVo queryUserIP(String user, String creator) { - return userIpMapper.queryUserIP(user, creator); - } - - private UserIpVo toLowerCase(UserIpVo userIpVo) { - userIpVo.setCreator(userIpVo.getCreator().toLowerCase()); - userIpVo.setUser(userIpVo.getUser().toLowerCase()); - return userIpVo; - } -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/UserIpServiceImpl.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/UserIpServiceImpl.java deleted file mode 100644 index 40128cc5be..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/service/impl/UserIpServiceImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.configuration.service.impl; - -import org.apache.linkis.configuration.entity.UserIpVo; -import org.apache.linkis.configuration.service.UserIpConfigService; -import org.apache.linkis.configuration.service.UserIpService; -import org.apache.linkis.governance.common.protocol.conf.UserIpRequest; -import org.apache.linkis.governance.common.protocol.conf.UserIpResponse; -import org.apache.linkis.rpc.Sender; -import org.apache.linkis.rpc.message.annotation.Receiver; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Service -public class UserIpServiceImpl implements UserIpService { - - private static final Logger logger = LoggerFactory.getLogger(UserIpService.class); - - @Autowired private UserIpConfigService userIpConfigService; - - @Receiver - @Override - public UserIpResponse getUserIpData(UserIpRequest request, Sender sender) { - UserIpVo userIpVo = userIpConfigService.queryUserIP(request.user(), request.creator()); - if (null == userIpVo) { - logger.warn( - "UserIpCache user {} creator {} data loading failed", request.user(), request.creator()); - return new UserIpResponse(request.user(), request.creator(), ""); - } else { - return new UserIpResponse(userIpVo.getUser(), userIpVo.getCreator(), userIpVo.getIpList()); - } - } -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/ConfigurationConfiguration.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/ConfigurationConfiguration.java index b69f20cdb5..515d8320d4 100644 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/ConfigurationConfiguration.java +++ b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/ConfigurationConfiguration.java @@ -30,12 +30,6 @@ public class ConfigurationConfiguration { public static final String COPYKEYTOKEN = CommonVars$.MODULE$.apply("wds.linkis.configuration.copykey.token", "e8724-e").getValue(); - public static final String IPCHECK = - CommonVars$.MODULE$ - .apply( - "linkis.configuration.ipcheck.pattern", - "^(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}$") - .getValue(); static { PERMIT_LABEL_TYPE.add(new UserCreatorLabel()); diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/HttpsUtil.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/HttpsUtil.java deleted file mode 100644 index 57fd7035da..0000000000 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/HttpsUtil.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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.configuration.util; - -import org.apache.linkis.common.conf.Configuration; -import org.apache.linkis.configuration.constant.Constants; -import org.apache.linkis.httpclient.dws.authentication.TokenAuthenticationStrategy; -import org.apache.linkis.httpclient.dws.config.DWSClientConfig; -import org.apache.linkis.httpclient.dws.config.DWSClientConfigBuilder; -import org.apache.linkis.ujes.client.UJESClientImpl; -import org.apache.linkis.ujes.client.request.EmsListAction; -import org.apache.linkis.ujes.client.response.EmsListResult; - -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class HttpsUtil { - - private static final Logger logger = LoggerFactory.getLogger(HttpsUtil.class); - - public static DWSClientConfig dwsClientConfig = createClientConfig(null, null); - - public static UJESClientImpl client = new UJESClientImpl(dwsClientConfig); - - public static Map sendHttp(String url, Map properties) - throws IOException { - if (null == dwsClientConfig) { - dwsClientConfig = createClientConfig(url, properties); - } - if (null == client) { - client = new UJESClientImpl(dwsClientConfig); - } - EmsListAction build = EmsListAction.newBuilder().setUser("hadoop").build(); - EmsListResult result = client.listECM(build); - return result.getResultMap(); - } - - private static DWSClientConfig createClientConfig(String url, Map properties) { - String realUrl = ""; - if (StringUtils.isBlank(url)) { - realUrl = Configuration.getGateWayURL(); - } else { - realUrl = url; - } - Map parms = new HashMap<>(); - if (MapUtils.isNotEmpty(properties)) { - parms = properties; - } - int maxConnection = - (int) - parms.getOrDefault( - Constants.CONNECTION_MAX_SIZE_SHORT_NAME(), - Constants.CONNECTION_MAX_SIZE().getValue()); - int connectTimeout = - (int) - parms.getOrDefault( - Constants.CONNECTION_TIMEOUT_SHORT_NAME(), - Constants.CONNECTION_TIMEOUT().getValue()); - int readTimeout = - (int) - parms.getOrDefault( - Constants.CONNECTION_READ_TIMEOUT_SHORT_NAME(), - Constants.CONNECTION_READ_TIMEOUT().getValue()); - String tokenKey = - (String) - parms.getOrDefault( - Constants.AUTH_TOKEN_KEY_SHORT_NAME(), Constants.AUTH_TOKEN_KEY().getValue()); - String tokenValue = - (String) - parms.getOrDefault( - Constants.AUTH_TOKEN_VALUE_SHORT_NAME(), Constants.AUTH_TOKEN_VALUE().getValue()); - - DWSClientConfig clientConfig = - ((DWSClientConfigBuilder) - (DWSClientConfigBuilder.newBuilder() - .addServerUrl(realUrl) - .connectionTimeout(connectTimeout) - .discoveryEnabled(false) - .discoveryFrequency(1, TimeUnit.MINUTES) - .loadbalancerEnabled(false) - .maxConnectionSize(maxConnection) - .retryEnabled(false) - .readTimeout(readTimeout) - .setAuthenticationStrategy(new TokenAuthenticationStrategy()) - .setAuthTokenKey(tokenKey) - .setAuthTokenValue(tokenValue))) - .setDWSVersion("v1") - .build(); - return clientConfig; - } -} diff --git a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/LabelEntityParser.java b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/LabelEntityParser.java index cfd180e0fa..a808dcb0b4 100644 --- a/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/LabelEntityParser.java +++ b/linkis-public-enhancements/linkis-configuration/src/main/java/org/apache/linkis/configuration/util/LabelEntityParser.java @@ -62,7 +62,7 @@ public static ArrayList