Skip to content

Commit

Permalink
bug fix ps server merege and configuration api
Browse files Browse the repository at this point in the history
  • Loading branch information
casionone committed Sep 13, 2023
1 parent 8ed86c5 commit 98425a9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ object RPCConfiguration {
"cs,contextservice,data-source-manager,metadataQuery,metadatamanager,query,jobhistory,application,configuration,filesystem,udf,variable,microservice,errorcode,bml,datasource,basedata-manager"
).getValue.split(",")

val METADATAQUERY_SERVICE_APPLICATION_NAME: CommonVars[String] =
CommonVars("wds.linkis.gateway.conf.metadataquery.name", "linkis-ps-metadataquery")

val METADATAQUERY_SERVICE_LIST: Array[String] = CommonVars(
"wds.linkis.gateway.conf.metadataquery.list",
"metadatamanager,metadataquery"
).getValue.split(",")

val LINKIS_MANAGER_SERVICE_NAME: CommonVars[String] =
CommonVars("wds.linkis.gateway.conf.linkismanager.name", "linkis-cg-linkismanager")

Expand All @@ -86,7 +78,7 @@ object RPCConfiguration {
val LINKIS_DATASOURCE_SERVICE_LIST: Array[String] =
CommonVars(
"linkis.gateway.conf.linkisdatasource.list",
"data-source-manager,metadataquery,datasource"
"data-source-manager,metadataquery,datasource,metadataQuery,metadatamanager"
).getValue
.split(",")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class RPCConfigurationTest {
val enablepublicservice = RPCConfiguration.ENABLE_PUBLIC_SERVICE.getValue
val publicserviceapplicationname = RPCConfiguration.PUBLIC_SERVICE_APPLICATION_NAME.getValue
val publicservicelist = RPCConfiguration.PUBLIC_SERVICE_LIST
val metadataqueryservicelist = RPCConfiguration.METADATAQUERY_SERVICE_LIST

Assertions.assertTrue(25 == bdprpcbroadcastthreadsize.intValue())
Assertions.assertTrue(400 == bdprpcreceiverasynconsumerthreadmax.intValue())
Expand All @@ -48,7 +47,6 @@ class RPCConfigurationTest {
Assertions.assertTrue(enablepublicservice)
Assertions.assertEquals("linkis-ps-publicservice", publicserviceapplicationname)
Assertions.assertTrue(publicservicelist.size > 0)
Assertions.assertTrue(metadataqueryservicelist.size > 0)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public enum LinkisConfigurationErrorCodeSummary implements LinkisErrorCode {
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(键或值不能为空)"),
KEY_CANNOT_EMPTY(14100, "Key cannot be null(Key 不能为空)"),
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 为空,无法添加)"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public Message getKeyValue(
@RequestParam(value = "creator", required = false, defaultValue = "*") String creator,
@RequestParam(value = "configKey") String configKey)
throws ConfigurationException {
String username = ModuleUserUtils.getOperationUser(req, "saveKey");
String username = ModuleUserUtils.getOperationUser(req, "getKeyValue");
if (engineType.equals("*") && !version.equals("*")) {
return Message.error("When engineType is any engine, the version must also be any version");
}
Expand Down Expand Up @@ -561,7 +561,7 @@ public Message saveKeyValue(HttpServletRequest req, @RequestBody Map<String, Obj
@RequestMapping(path = "/keyvalue", method = RequestMethod.DELETE)
public Message deleteKeyValue(HttpServletRequest req, @RequestBody Map<String, Object> json)
throws ConfigurationException {
String username = ModuleUserUtils.getOperationUser(req, "saveKey");
String username = ModuleUserUtils.getOperationUser(req, "deleteKeyValue");
String engineType = (String) json.getOrDefault("engineType", "*");
String version = (String) json.getOrDefault("version", "*");
String creator = (String) json.getOrDefault("creator", "*");
Expand Down Expand Up @@ -771,7 +771,7 @@ public Message getUserKeyValue(
@RequestParam(value = "pageNow", required = false, defaultValue = "1") Integer pageNow,
@RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize)
throws ConfigurationException {
checkAdmin(ModuleUserUtils.getOperationUser(req, "getUserKeyValue"));
String username = ModuleUserUtils.getOperationUser(req, "getUserKeyValue");
if (StringUtils.isBlank(engineType)) {
engineType = null;
}
Expand All @@ -784,6 +784,11 @@ public Message getUserKeyValue(
if (StringUtils.isBlank(user)) {
user = null;
}

if (!org.apache.linkis.common.conf.Configuration.isAdmin(username) && !username.equals(user)) {
return Message.error("Only admin can query other user configuration data");
}

PageHelper.startPage(pageNow, pageSize);
List<ConfigUserValue> list;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ public class ConfigKeyServiceImpl implements ConfigKeyService {
public ConfigValue saveConfigValue(ConfigKeyValue configKeyValue, List<Label<?>> labelList)
throws ConfigurationException {

if (StringUtils.isBlank(configKeyValue.getConfigValue())
|| StringUtils.isBlank(configKeyValue.getKey())) {
throw new ConfigurationException(KEY_OR_VALUE_CANNOT.getErrorDesc());
if (StringUtils.isBlank(configKeyValue.getKey())) {
throw new ConfigurationException(KEY_CANNOT_EMPTY.getErrorDesc());
}

LabelParameterParser.labelCheck(labelList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ class DefaultGatewayParser(gatewayParsers: Array[GatewayParser]) extends Abstrac
// In order to be compatible with metadata module name refactoring,this logic will be removed in subsequent versions
} else if (RPCConfiguration.LINKIS_DATASOURCE_SERVICE_LIST.contains(serviceId)) {
RPCConfiguration.LINKIS_DATASOURCE_SERVICE_NAME.getValue
} else if (RPCConfiguration.METADATAQUERY_SERVICE_LIST.contains(serviceId)) {
RPCConfiguration.METADATAQUERY_SERVICE_APPLICATION_NAME.getValue
} else if (RPCConfiguration.LINKIS_MANAGER_SERVICE_LIST.contains(serviceId)) {
RPCConfiguration.LINKIS_MANAGER_SERVICE_NAME.getValue
// After the complete merge is completed, it needs to be removed
Expand Down

0 comments on commit 98425a9

Please sign in to comment.