forked from alibaba/nacos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into develop-apexsoft
* develop: (137 commits) Develop refactor topn (alibaba#11352) Develop fill ut common (alibaba#11335) Optimize MapperManager (alibaba#11195) Simplify the validate method for serviceinfo (alibaba#11312) add startup conditions (alibaba#11305) Fix some typos (alibaba#11269) fix: rename tar name (alibaba#11281) 优化节点显示,添加mode (alibaba#11275) [ISSUE alibaba#11253]To fix the triggering of the listener upon failover con… (alibaba#11254) Add description for new plugin. (alibaba#11268) Upgrade to 2.3.0-BETA. (alibaba#11262) [ISSUE alibaba#11255]Update PathEncoderManagerTest#testEncodeWithNonExistOs. (alibaba#11256) Fill ut for common module (alibaba#11247) Optimize ThreadPoolManager (alibaba#11206) Fix npe when setup ack response in GrpcClient (alibaba#11210) [ISSUE#11192] batchRegisterInstance add recalculateRevision (alibaba#11232) feat(alibaba#11236): Remove invalid assertion in com.alibaba.nacos.config.server.service.ConfigCacheService#dumpChange. (alibaba#11237) feat(11115): http support cas publish. (alibaba#11120) [ISSUE alibaba#11231]Optimize the handleSpringBinder method in PropertiesUtil. (alibaba#11240) ISSUE alibaba#11212 (alibaba#11213) ... # Conflicts: # console-ui/package-lock.json # console-ui/package.json # console-ui/src/pages/Login/Login.jsx # core/src/main/java/com/alibaba/nacos/core/listener/StartingApplicationListener.java # pom.xml
- Loading branch information
Showing
512 changed files
with
20,337 additions
and
16,795 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 179 additions & 0 deletions
179
api/src/main/java/com/alibaba/nacos/api/ability/constant/AbilityKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/* | ||
* Copyright 1999-2022 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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 com.alibaba.nacos.api.ability.constant; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.HashMap; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Ability key constant. It is used to constrain the ability key.<br/> | ||
* <strong>Ensure that return value of {@link AbilityKey#getName()} is unique under one specify {@link AbilityMode}</strong>. | ||
* | ||
* @author Daydreamer | ||
* @date 2022/8/31 12:27 | ||
**/ | ||
public enum AbilityKey { | ||
|
||
/** | ||
* For Test temporarily. | ||
*/ | ||
SERVER_TEST_1("test_1", "just for junit test", AbilityMode.SERVER), | ||
|
||
/** | ||
* For Test temporarily. | ||
*/ | ||
SERVER_TEST_2("test_2", "just for junit test", AbilityMode.SERVER), | ||
|
||
/** | ||
* For Test temporarily. | ||
*/ | ||
SDK_CLIENT_TEST_1("test_1", "just for junit test", AbilityMode.SDK_CLIENT), | ||
|
||
/** | ||
* For Test temporarily. | ||
*/ | ||
CLUSTER_CLIENT_TEST_1("test_1", "just for junit test", AbilityMode.CLUSTER_CLIENT); | ||
|
||
/** | ||
* the name of a certain ability. | ||
*/ | ||
private final String keyName; | ||
|
||
/** | ||
* description or comment about this ability. | ||
*/ | ||
private final String description; | ||
|
||
/** | ||
* ability mode, which endpoint hold this ability. | ||
*/ | ||
private final AbilityMode mode; | ||
|
||
AbilityKey(String keyName, String description, AbilityMode mode) { | ||
this.keyName = keyName; | ||
this.description = description; | ||
this.mode = mode; | ||
} | ||
|
||
public String getName() { | ||
return keyName; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public AbilityMode getMode() { | ||
return mode; | ||
} | ||
|
||
/** | ||
* All key set. | ||
*/ | ||
private static final Map<AbilityMode, Map<String, AbilityKey>> ALL_ABILITIES = new HashMap<>(); | ||
|
||
/** | ||
* Get all keys. | ||
* | ||
* @return all keys | ||
*/ | ||
public static Collection<AbilityKey> getAllValues(AbilityMode mode) { | ||
return Collections.unmodifiableCollection(ALL_ABILITIES.get(mode).values()); | ||
} | ||
|
||
/** | ||
* Get all names. | ||
* | ||
* @return all names | ||
*/ | ||
public static Collection<String> getAllNames(AbilityMode mode) { | ||
return Collections.unmodifiableCollection(ALL_ABILITIES.get(mode).keySet()); | ||
} | ||
|
||
/** | ||
* Whether contains this name. | ||
* | ||
* @param name key name | ||
* @return whether contains | ||
*/ | ||
public static boolean isLegalKey(AbilityMode mode, String name) { | ||
return ALL_ABILITIES.get(mode).containsKey(name); | ||
} | ||
|
||
/** | ||
* Map the string key to enum. | ||
* | ||
* @param abilities map | ||
* @return enum map | ||
*/ | ||
public static Map<AbilityKey, Boolean> mapEnum(AbilityMode mode, Map<String, Boolean> abilities) { | ||
if (abilities == null || abilities.isEmpty()) { | ||
return Collections.emptyMap(); | ||
} | ||
return abilities.entrySet() | ||
.stream() | ||
.filter(entry -> isLegalKey(mode, entry.getKey())) | ||
.collect(Collectors.toMap((entry) -> getEnum(mode, entry.getKey()), Map.Entry::getValue)); | ||
} | ||
|
||
/**. | ||
* Map the string key to enum | ||
* | ||
* @param abilities map | ||
* @return enum map | ||
*/ | ||
public static Map<String, Boolean> mapStr(Map<AbilityKey, Boolean> abilities) { | ||
if (abilities == null || abilities.isEmpty()) { | ||
return Collections.emptyMap(); | ||
} | ||
return abilities.entrySet() | ||
.stream() | ||
.collect(Collectors.toMap((entry) -> entry.getKey().getName(), Map.Entry::getValue)); | ||
} | ||
|
||
/**. | ||
* getter to obtain enum | ||
* | ||
* @param key string key | ||
* @return enum | ||
*/ | ||
public static AbilityKey getEnum(AbilityMode mode, String key) { | ||
return ALL_ABILITIES.get(mode).get(key); | ||
} | ||
|
||
static { | ||
// check for developer | ||
// ensure that name filed is unique under a AbilityMode | ||
try { | ||
for (AbilityKey value : AbilityKey.values()) { | ||
AbilityMode mode = value.getMode(); | ||
Map<String, AbilityKey> map = ALL_ABILITIES.getOrDefault(mode, new HashMap<>()); | ||
AbilityKey previous = map.putIfAbsent(value.getName(), value); | ||
if (previous != null) { | ||
throw new IllegalStateException("Duplicate key name field " + value + " and " + previous + " under mode: " + mode); | ||
} | ||
ALL_ABILITIES.put(mode, map); | ||
} | ||
} catch (Throwable t) { | ||
// for developer checking | ||
t.printStackTrace(); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
api/src/main/java/com/alibaba/nacos/api/ability/constant/AbilityMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 1999-2023 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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 com.alibaba.nacos.api.ability.constant; | ||
|
||
/** | ||
* Ability mode. | ||
* | ||
* @author Daydreamer | ||
* @date 2023/9/25 12:32 | ||
**/ | ||
public enum AbilityMode { | ||
|
||
/** | ||
* for server ability. | ||
*/ | ||
SERVER, | ||
|
||
/** | ||
* for sdk client. | ||
*/ | ||
SDK_CLIENT, | ||
|
||
/** | ||
* for cluster client. | ||
*/ | ||
CLUSTER_CLIENT; | ||
} |
40 changes: 40 additions & 0 deletions
40
api/src/main/java/com/alibaba/nacos/api/ability/constant/AbilityStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 1999-2022 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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 com.alibaba.nacos.api.ability.constant; | ||
|
||
/**. | ||
* @author Daydreamer | ||
* @description It is used to know a certain ability whether supporting. | ||
* @date 2022/8/31 12:27 | ||
**/ | ||
public enum AbilityStatus { | ||
|
||
/**. | ||
* Support a certain ability | ||
*/ | ||
SUPPORTED, | ||
|
||
/**. | ||
* Not support a certain ability | ||
*/ | ||
NOT_SUPPORTED, | ||
|
||
/**. | ||
* Cannot find ability table, unknown | ||
*/ | ||
UNKNOWN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
* | ||
* @author xiweng.yy | ||
*/ | ||
@Deprecated | ||
public interface AbilityInitializer<A> { | ||
|
||
/** | ||
|
40 changes: 40 additions & 0 deletions
40
api/src/main/java/com/alibaba/nacos/api/ability/initializer/AbilityPostProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 1999-2023 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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 com.alibaba.nacos.api.ability.initializer; | ||
|
||
import com.alibaba.nacos.api.ability.constant.AbilityKey; | ||
import com.alibaba.nacos.api.ability.constant.AbilityMode; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Nacos ability post processor, load by spi. | ||
* | ||
* @author Daydreamer-ia | ||
*/ | ||
public interface AbilityPostProcessor { | ||
|
||
|
||
/** | ||
* process before loading by <code>Ability Controller </code>. | ||
* | ||
* @param mode mode: sdk client, server or cluster client | ||
* @param abilities abilities | ||
*/ | ||
void process(AbilityMode mode, Map<AbilityKey, Boolean> abilities); | ||
|
||
} |
Oops, something went wrong.