add AbilityPostProcessor param to know abilities init detail, sdk client, server or cluster client
This commit is contained in:
parent
41a3f13a66
commit
6bce3bda7b
@ -1,6 +1,7 @@
|
||||
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;
|
||||
|
||||
@ -15,8 +16,9 @@ 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(Map<AbilityKey, Boolean> abilities);
|
||||
void process(AbilityMode mode, Map<AbilityKey, Boolean> abilities);
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.alibaba.nacos.client.ability;
|
||||
|
||||
import com.alibaba.nacos.api.ability.constant.AbilityKey;
|
||||
import com.alibaba.nacos.api.ability.constant.AbilityMode;
|
||||
import com.alibaba.nacos.api.ability.register.impl.ClientAbilities;
|
||||
import com.alibaba.nacos.common.ability.AbstractAbilityControlManager;
|
||||
|
||||
@ -36,7 +37,12 @@ public class ClientAbilityControlManager extends AbstractAbilityControlManager {
|
||||
protected Map<AbilityKey, Boolean> initCurrentNodeAbilities() {
|
||||
return ClientAbilities.getStaticAbilities();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected AbilityMode initializeMode() {
|
||||
return AbilityMode.SDK_CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
// if server ability manager exist, you should choose the server one
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.alibaba.nacos.common.ability;
|
||||
|
||||
import com.alibaba.nacos.api.ability.constant.AbilityKey;
|
||||
import com.alibaba.nacos.api.ability.constant.AbilityMode;
|
||||
import com.alibaba.nacos.api.ability.initializer.AbilityPostProcessor;
|
||||
import com.alibaba.nacos.common.notify.Event;
|
||||
import com.alibaba.nacos.common.notify.NotifyCenter;
|
||||
@ -60,9 +61,10 @@ public abstract class AbstractAbilityControlManager {
|
||||
// get processors
|
||||
Collection<AbilityPostProcessor> processors = NacosServiceLoader.load(AbilityPostProcessor.class);
|
||||
Map<AbilityKey, Boolean> abilities = initCurrentNodeAbilities();
|
||||
AbilityMode mode = initializeMode();
|
||||
// get abilities
|
||||
for (AbilityPostProcessor processor : processors) {
|
||||
processor.process(abilities);
|
||||
processor.process(mode, abilities);
|
||||
}
|
||||
return AbilityKey.mapStr(abilities);
|
||||
}
|
||||
@ -111,6 +113,13 @@ public abstract class AbstractAbilityControlManager {
|
||||
* @return current node abilities
|
||||
*/
|
||||
protected abstract Map<AbilityKey, Boolean> initCurrentNodeAbilities();
|
||||
|
||||
/**
|
||||
* initialize mode.
|
||||
*
|
||||
* @return mode.
|
||||
*/
|
||||
protected abstract AbilityMode initializeMode();
|
||||
|
||||
/**.
|
||||
* Return the abilities current node
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.alibaba.nacos.core.ability.control;
|
||||
|
||||
import com.alibaba.nacos.api.ability.constant.AbilityKey;
|
||||
import com.alibaba.nacos.api.ability.constant.AbilityMode;
|
||||
import com.alibaba.nacos.api.ability.register.impl.ServerAbilities;
|
||||
import com.alibaba.nacos.common.ability.AbstractAbilityControlManager;
|
||||
import com.alibaba.nacos.core.ability.config.AbilityConfigs;
|
||||
@ -65,7 +66,12 @@ public class ServerAbilityControlManager extends AbstractAbilityControlManager {
|
||||
unIncludedInConfig.forEach(abilityKey -> abilityTable.put(abilityKey, staticAbilities.get(abilityKey)));
|
||||
return abilityTable;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected AbilityMode initializeMode() {
|
||||
return AbilityMode.SERVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user