Skip to content

Commit

Permalink
optimization & format code
Browse files Browse the repository at this point in the history
  • Loading branch information
aiceflower committed Aug 16, 2024
1 parent 7910a94 commit 6fa215b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public enum LinkisRpcErrorCodeSummary implements LinkisErrorCode {
CORRESPONDING_TO_INITIALIZE(
10004, "The corresponding anti-sequence class:{0} failed to initialize(对应的反序列类:{0} 初始化失败)"),
CORRESPONDING_CLASS_ILLEGAL(
10005,
"The corresponding anti-sequence class:{0} is illegal (对应的反序列类:{0} 不合法)"),
10005, "The corresponding anti-sequence class:{0} is illegal (对应的反序列类:{0} 不合法)"),
APPLICATION_IS_NOT_EXISTS(
10051, "The instance:{0} of application {1} does not exist(应用程序:{0} 的实例:{1} 不存在)."),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,5 @@ object RPCConfiguration {

val ENABLE_RPC_OBJECT_PREFIX_WHITE_LIST_CHECK: Boolean =
CommonVars("wds.linkis.rpc.object.class.prefix.whitelist.check.enable", true).getValue

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ package org.apache.linkis.rpc.transform
import org.apache.linkis.common.exception.ExceptionManager
import org.apache.linkis.common.utils.Utils
import org.apache.linkis.rpc.conf.RPCConfiguration
import org.apache.linkis.rpc.errorcode.LinkisRpcErrorCodeSummary.CORRESPONDING_CLASS_ILLEGAL
import org.apache.linkis.rpc.errorcode.LinkisRpcErrorCodeSummary.CORRESPONDING_NOT_FOUND
import org.apache.linkis.rpc.errorcode.LinkisRpcErrorCodeSummary.CORRESPONDING_TO_INITIALIZE
import org.apache.linkis.rpc.errorcode.LinkisRpcErrorCodeSummary.CORRESPONDING_CLASS_ILLEGAL
import org.apache.linkis.rpc.exception.DWCURIException
import org.apache.linkis.rpc.serializer.ProtostuffSerializeUtil
import org.apache.linkis.server.{EXCEPTION_MSG, JMap, Message}

import java.text.MessageFormat

import scala.runtime.BoxedUnit

import org.slf4j.LoggerFactory

private[linkis] trait RPCConsumer {
Expand All @@ -51,7 +53,10 @@ private[linkis] object RPCConsumer {
val objectStr = data.get(OBJECT_VALUE).toString
val objectClass = data.get(CLASS_VALUE).toString
logger.debug("The corresponding anti-sequence is class {}", objectClass)
if (RPCConfiguration.ENABLE_RPC_OBJECT_PREFIX_WHITE_LIST_CHECK && !RPCConfiguration.RPC_OBJECT_PREFIX_WHITE_LIST.exists(prefix => objectClass.startsWith(prefix))) {
if (
RPCConfiguration.ENABLE_RPC_OBJECT_PREFIX_WHITE_LIST_CHECK && !RPCConfiguration.RPC_OBJECT_PREFIX_WHITE_LIST
.exists(prefix => objectClass.startsWith(prefix))
) {
throw new DWCURIException(
CORRESPONDING_CLASS_ILLEGAL.getErrorCode,
MessageFormat.format(CORRESPONDING_CLASS_ILLEGAL.getErrorDesc, objectClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ object ResultSetAction {
this.columnPage = columnPage
this
}

def setColumnPageSize(columnPageSize: Int): Builder = {
this.columnPageSize = columnPageSize
this
}


def build(): ResultSetAction = {
if (user == null) throw new UJESClientBuilderException("user is needed!")
if (path == null) throw new UJESClientBuilderException("path is needed!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.linkis.manager.am.service.engine

import org.apache.commons.lang3.StringUtils
import org.apache.linkis.common.ServiceInstance
import org.apache.linkis.common.exception.LinkisRetryException
import org.apache.linkis.common.utils.{ByteTimeUtils, Logging, Utils}
Expand All @@ -25,10 +26,6 @@ import org.apache.linkis.governance.common.conf.GovernanceCommonConf
import org.apache.linkis.governance.common.conf.GovernanceCommonConf.ENGINE_CONN_MANAGER_SPRING_NAME
import org.apache.linkis.governance.common.utils.JobUtils
import org.apache.linkis.manager.am.conf.{AMConfiguration, EngineConnConfigurationService}
import org.apache.linkis.manager.am.conf.AMConfiguration.{
HIVE_CLUSTER_EC_EXECUTE_ONCE_RULE_ENABLE,
SUPPORT_CLUSTER_RULE_EC_TYPES
}
import org.apache.linkis.manager.am.exception.AMErrorException
import org.apache.linkis.manager.am.label.EngineReuseLabelChooser
import org.apache.linkis.manager.am.selector.{ECAvailableRule, NodeSelector}
Expand All @@ -39,34 +36,26 @@ import org.apache.linkis.manager.common.entity.node.{EMNode, EngineNode}
import org.apache.linkis.manager.common.entity.resource.NodeResource
import org.apache.linkis.manager.common.protocol.engine.{EngineCreateRequest, EngineStopRequest}
import org.apache.linkis.manager.common.utils.ManagerUtils
import org.apache.linkis.manager.engineplugin.common.launch.entity.{
EngineConnBuildRequestImpl,
EngineConnCreationDescImpl
}
import org.apache.linkis.manager.engineplugin.common.launch.entity.{EngineConnBuildRequestImpl, EngineConnCreationDescImpl}
import org.apache.linkis.manager.engineplugin.common.resource.TimeoutEngineResourceRequest
import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactoryContext
import org.apache.linkis.manager.label.entity.{EngineNodeLabel, Label}
import org.apache.linkis.manager.label.entity.engine.EngineTypeLabel
import org.apache.linkis.manager.label.entity.entrance.ExecuteOnceLabel
import org.apache.linkis.manager.label.entity.node.AliasServiceInstanceLabel
import org.apache.linkis.manager.label.entity.{EngineNodeLabel, Label}
import org.apache.linkis.manager.label.service.{NodeLabelService, UserLabelService}
import org.apache.linkis.manager.label.utils.{LabelUtil, LabelUtils}
import org.apache.linkis.manager.label.utils.LabelUtils
import org.apache.linkis.manager.persistence.NodeMetricManagerPersistence
import org.apache.linkis.manager.rm.{AvailableResource, NotEnoughResource}
import org.apache.linkis.manager.rm.service.ResourceManager
import org.apache.linkis.manager.rm.{AvailableResource, NotEnoughResource}
import org.apache.linkis.manager.service.common.label.{LabelChecker, LabelFilter}
import org.apache.linkis.rpc.Sender
import org.apache.linkis.rpc.message.annotation.Receiver
import org.apache.linkis.server.BDPJettyServerHelper

import org.apache.commons.lang3.StringUtils

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

import java.util
import java.util.concurrent.{TimeoutException, TimeUnit}

import java.util.concurrent.{TimeUnit, TimeoutException}
import scala.collection.JavaConverters._
import scala.concurrent.duration.Duration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,14 @@ abstract class RequestResourceService(labelResourceService: LabelResourceService
if (props != null) {
acrossClusterTask = props.getOrDefault(AMConfiguration.ACROSS_CLUSTER_TASK, "false").toBoolean
}

// hive cluster check
if (
externalResourceService != null && StringUtils.isNotBlank(
engineType
) && SUPPORT_CLUSTER_RULE_EC_TYPES.contains(
engineType
) && props != null && acrossClusterTask
) && props != null && acrossClusterTask && !"spark".equals(engineType)
) {
val queueName = props.getOrDefault(YARN_QUEUE_NAME_CONFIG_KEY, "default")
logger.info(s"hive cluster check with queue: $queueName")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@

package org.apache.linkis.cs.condition.construction;

import org.apache.commons.lang3.StringUtils;
import org.apache.linkis.cs.condition.Condition;
import org.apache.linkis.cs.condition.impl.ContextValueTypeCondition;
import org.apache.linkis.cs.conf.CSConfiguration;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.linkis.cs.conf.CSConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -41,10 +42,10 @@ public Condition parse(Map<Object, Object> conditionMap) {
try {
String valueType = (String) conditionMap.get("contextValueType");
List<String> contextValueTypeWhiteList =
Arrays.asList(CSConfiguration.CONTEXT_VALUE_TYPE_PREFIX_WHITE_LIST.getValue()
.split(","));
Arrays.asList(CSConfiguration.CONTEXT_VALUE_TYPE_PREFIX_WHITE_LIST.getValue().split(","));
if (CSConfiguration.ENABLE_CONTEXT_VALUE_TYPE_PREFIX_WHITE_LIST_CHECK.getValue()) {
if (contextValueTypeWhiteList.stream().anyMatch(ele -> StringUtils.startsWith(valueType, ele))) {
if (contextValueTypeWhiteList.stream()
.anyMatch(ele -> StringUtils.startsWith(valueType, ele))) {
contextValueType = Class.forName(valueType);
} else {
logger.error("ContextValueType: {} is illegal", valueType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
/*
* 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.conf;

import org.apache.linkis.common.conf.CommonVars;

public class CSConfiguration {
public static final CommonVars<String> CONTEXT_VALUE_TYPE_PREFIX_WHITE_LIST =
CommonVars.apply("linkis.context.value.type.prefix.whitelist", "org.apache.linkis");
public static final CommonVars<String> CONTEXT_VALUE_TYPE_PREFIX_WHITE_LIST =
CommonVars.apply("linkis.context.value.type.prefix.whitelist", "org.apache.linkis");

public static final CommonVars<Boolean> ENABLE_CONTEXT_VALUE_TYPE_PREFIX_WHITE_LIST_CHECK =
CommonVars.apply("linkis.context.value.type.prefix.whitelist.check.enable", true);
public static final CommonVars<Boolean> ENABLE_CONTEXT_VALUE_TYPE_PREFIX_WHITE_LIST_CHECK =
CommonVars.apply("linkis.context.value.type.prefix.whitelist.check.enable", true);
}

0 comments on commit 6fa215b

Please sign in to comment.