For checkstyle.
This commit is contained in:
parent
c684809337
commit
4522cbcccb
@ -24,19 +24,31 @@ 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/>.
|
||||
* <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);
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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;
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.register.impl;
|
||||
|
||||
import com.alibaba.nacos.api.ability.constant.AbilityKey;
|
||||
|
@ -36,7 +36,7 @@ public class ClientAbilityControlManager extends AbstractAbilityControlManager {
|
||||
|
||||
@Override
|
||||
protected Map<AbilityMode, Map<AbilityKey, Boolean>> initCurrentNodeAbilities() {
|
||||
Map<AbilityMode, Map<AbilityKey, Boolean>> abilities = new HashMap<>();
|
||||
Map<AbilityMode, Map<AbilityKey, Boolean>> abilities = new HashMap<>(1);
|
||||
abilities.put(AbilityMode.SDK_CLIENT, SdkClientAbilities.getStaticAbilities());
|
||||
return abilities;
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ import com.alibaba.nacos.common.spi.NacosServiceLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -41,7 +41,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public abstract class AbstractAbilityControlManager {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAbilityControlManager.class);
|
||||
|
||||
|
||||
/**
|
||||
* current node support abilities.
|
||||
*/
|
||||
@ -51,7 +51,7 @@ public abstract class AbstractAbilityControlManager {
|
||||
NotifyCenter.registerToPublisher(AbilityUpdateEvent.class, 16384);
|
||||
initAbilityTable();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* initialize abilities.
|
||||
*
|
||||
@ -71,9 +71,12 @@ public abstract class AbstractAbilityControlManager {
|
||||
// check for developer
|
||||
for (AbilityKey abilityKey : abilitiesTable.keySet()) {
|
||||
if (!mode.equals(abilityKey.getMode())) {
|
||||
LOGGER.error("You should not contain a other mode: {} in a specify mode: {} abilities set, error key: {}, please check again.",
|
||||
LOGGER.error(
|
||||
"You should not contain a other mode: {} in a specify mode: {} abilities set, error key: {}, please check again.",
|
||||
abilityKey.getMode(), mode, abilityKey);
|
||||
throw new IllegalStateException("Except mode: " + mode + " but " + abilityKey + " mode: " + abilityKey.getMode() + ", please check again.");
|
||||
throw new IllegalStateException(
|
||||
"Except mode: " + mode + " but " + abilityKey + " mode: " + abilityKey.getMode()
|
||||
+ ", please check again.");
|
||||
}
|
||||
}
|
||||
Collection<AbilityPostProcessor> processors = NacosServiceLoader.load(AbilityPostProcessor.class);
|
||||
@ -85,7 +88,8 @@ public abstract class AbstractAbilityControlManager {
|
||||
Set<AbilityMode> abilityModes = abilities.keySet();
|
||||
LOGGER.info("Ready to initialize current node abilities, support modes: {}", abilityModes);
|
||||
for (AbilityMode abilityMode : abilityModes) {
|
||||
this.currentNodeAbilities.put(abilityMode, new ConcurrentHashMap<>(AbilityKey.mapStr(abilities.get(abilityMode))));
|
||||
this.currentNodeAbilities
|
||||
.put(abilityMode, new ConcurrentHashMap<>(AbilityKey.mapStr(abilities.get(abilityMode))));
|
||||
}
|
||||
LOGGER.info("Initialize current abilities finish...");
|
||||
}
|
||||
@ -101,7 +105,7 @@ public abstract class AbstractAbilityControlManager {
|
||||
doTurn(abilities, abilityKey, true, abilityKey.getMode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void doTurn(Map<String, Boolean> abilities, AbilityKey key, boolean turn, AbilityMode mode) {
|
||||
if (!key.getMode().equals(mode)) {
|
||||
throw new IllegalStateException("Except " + mode + " but " + key.getMode());
|
||||
@ -128,8 +132,8 @@ public abstract class AbstractAbilityControlManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**.
|
||||
* Whether current node support
|
||||
/**
|
||||
* . Whether current node support
|
||||
*
|
||||
* @param abilityKey ability key from {@link AbilityKey}
|
||||
* @return whether support
|
||||
@ -145,15 +149,15 @@ public abstract class AbstractAbilityControlManager {
|
||||
return AbilityStatus.UNKNOWN;
|
||||
}
|
||||
|
||||
/**.
|
||||
* Init current node abilities
|
||||
/**
|
||||
* . Init current node abilities
|
||||
*
|
||||
* @return current node abilities
|
||||
*/
|
||||
protected abstract Map<AbilityMode, Map<AbilityKey, Boolean>> initCurrentNodeAbilities();
|
||||
|
||||
/**.
|
||||
* Return the abilities current node
|
||||
/**
|
||||
* . Return the abilities current node
|
||||
*
|
||||
* @return current abilities
|
||||
*/
|
||||
@ -166,13 +170,13 @@ public abstract class AbstractAbilityControlManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* A legal nacos application has a ability control manager.
|
||||
* If there are more than one, the one with higher priority is preferred
|
||||
* A legal nacos application has a ability control manager. If there are more than one, the one with higher priority
|
||||
* is preferred
|
||||
*
|
||||
* @return priority
|
||||
*/
|
||||
public abstract int getPriority();
|
||||
|
||||
|
||||
/**
|
||||
* notify when current node ability changing.
|
||||
*/
|
||||
@ -185,13 +189,14 @@ public abstract class AbstractAbilityControlManager {
|
||||
private boolean isOn;
|
||||
|
||||
private Map<String, Boolean> table;
|
||||
|
||||
private AbilityUpdateEvent(){}
|
||||
|
||||
|
||||
private AbilityUpdateEvent() {
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getAbilityTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
public void setTable(Map<String, Boolean> abilityTable) {
|
||||
this.table = abilityTable;
|
||||
}
|
||||
@ -199,15 +204,15 @@ public abstract class AbstractAbilityControlManager {
|
||||
public AbilityKey getAbilityKey() {
|
||||
return abilityKey;
|
||||
}
|
||||
|
||||
|
||||
public void setAbilityKey(AbilityKey abilityKey) {
|
||||
this.abilityKey = abilityKey;
|
||||
}
|
||||
|
||||
|
||||
public boolean isOn() {
|
||||
return isOn;
|
||||
}
|
||||
|
||||
|
||||
public void setOn(boolean on) {
|
||||
isOn = on;
|
||||
}
|
||||
|
@ -59,13 +59,13 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
||||
private int healthCheckRetryTimes;
|
||||
|
||||
private long healthCheckTimeOut;
|
||||
|
||||
|
||||
private long capabilityNegotiationTimeout;
|
||||
|
||||
private Map<String, String> labels;
|
||||
|
||||
|
||||
private RpcClientTlsConfig tlsConfig = new RpcClientTlsConfig();
|
||||
|
||||
|
||||
/**
|
||||
* constructor.
|
||||
*
|
||||
@ -92,7 +92,8 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
||||
this.healthCheckTimeOut = loadLongConfig(GrpcConstants.GRPC_HEALTHCHECK_TIMEOUT, builder.healthCheckTimeOut);
|
||||
this.channelKeepAliveTimeout = loadLongConfig(GrpcConstants.GRPC_CHANNEL_KEEP_ALIVE_TIMEOUT,
|
||||
builder.channelKeepAliveTimeout);
|
||||
this.capabilityNegotiationTimeout = loadLongConfig(GrpcConstants.GRPC_CHANNEL_CAPABILITY_NEGOTIATION_TIMEOUT, builder.capabilityNegotiationTimeout);
|
||||
this.capabilityNegotiationTimeout = loadLongConfig(GrpcConstants.GRPC_CHANNEL_CAPABILITY_NEGOTIATION_TIMEOUT,
|
||||
builder.capabilityNegotiationTimeout);
|
||||
this.labels = builder.labels;
|
||||
this.labels.put("tls.enable", "false");
|
||||
if (Objects.nonNull(builder.tlsConfig)) {
|
||||
@ -170,31 +171,31 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
||||
public long channelKeepAliveTimeout() {
|
||||
return channelKeepAliveTimeout;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RpcClientTlsConfig tlsConfig() {
|
||||
return tlsConfig;
|
||||
}
|
||||
|
||||
|
||||
public void setTlsConfig(RpcClientTlsConfig tlsConfig) {
|
||||
this.tlsConfig = tlsConfig;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long capabilityNegotiationTimeout() {
|
||||
return this.capabilityNegotiationTimeout;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int healthCheckRetryTimes() {
|
||||
return healthCheckRetryTimes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long healthCheckTimeOut() {
|
||||
return healthCheckTimeOut;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, String> labels() {
|
||||
return this.labels;
|
||||
@ -233,13 +234,13 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
||||
private int healthCheckRetryTimes = 3;
|
||||
|
||||
private long healthCheckTimeOut = 3000L;
|
||||
|
||||
|
||||
private long capabilityNegotiationTimeout = 5000L;
|
||||
|
||||
private Map<String, String> labels = new HashMap<>();
|
||||
|
||||
|
||||
private RpcClientTlsConfig tlsConfig = new RpcClientTlsConfig();
|
||||
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
@ -260,51 +261,51 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
||||
this.timeOutMills = Long.parseLong(properties.getProperty(GrpcConstants.GRPC_TIMEOUT_MILLS));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_CONNECT_KEEP_ALIVE_TIME)) {
|
||||
this.connectionKeepAlive = Long.parseLong(
|
||||
properties.getProperty(GrpcConstants.GRPC_CONNECT_KEEP_ALIVE_TIME));
|
||||
this.connectionKeepAlive = Long
|
||||
.parseLong(properties.getProperty(GrpcConstants.GRPC_CONNECT_KEEP_ALIVE_TIME));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_THREADPOOL_KEEPALIVETIME)) {
|
||||
this.threadPoolKeepAlive = Long.parseLong(
|
||||
properties.getProperty(GrpcConstants.GRPC_THREADPOOL_KEEPALIVETIME));
|
||||
this.threadPoolKeepAlive = Long
|
||||
.parseLong(properties.getProperty(GrpcConstants.GRPC_THREADPOOL_KEEPALIVETIME));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_THREADPOOL_CORE_SIZE)) {
|
||||
this.threadPoolCoreSize = Integer.parseInt(
|
||||
properties.getProperty(GrpcConstants.GRPC_THREADPOOL_CORE_SIZE));
|
||||
this.threadPoolCoreSize = Integer
|
||||
.parseInt(properties.getProperty(GrpcConstants.GRPC_THREADPOOL_CORE_SIZE));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_THREADPOOL_MAX_SIZE)) {
|
||||
this.threadPoolMaxSize = Integer.parseInt(
|
||||
properties.getProperty(GrpcConstants.GRPC_THREADPOOL_MAX_SIZE));
|
||||
this.threadPoolMaxSize = Integer
|
||||
.parseInt(properties.getProperty(GrpcConstants.GRPC_THREADPOOL_MAX_SIZE));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_SERVER_CHECK_TIMEOUT)) {
|
||||
this.serverCheckTimeOut = Long.parseLong(
|
||||
properties.getProperty(GrpcConstants.GRPC_SERVER_CHECK_TIMEOUT));
|
||||
this.serverCheckTimeOut = Long
|
||||
.parseLong(properties.getProperty(GrpcConstants.GRPC_SERVER_CHECK_TIMEOUT));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_QUEUESIZE)) {
|
||||
this.threadPoolQueueSize = Integer.parseInt(properties.getProperty(GrpcConstants.GRPC_QUEUESIZE));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_MAX_INBOUND_MESSAGE_SIZE)) {
|
||||
this.maxInboundMessageSize = Integer.parseInt(
|
||||
properties.getProperty(GrpcConstants.GRPC_MAX_INBOUND_MESSAGE_SIZE));
|
||||
this.maxInboundMessageSize = Integer
|
||||
.parseInt(properties.getProperty(GrpcConstants.GRPC_MAX_INBOUND_MESSAGE_SIZE));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_CHANNEL_KEEP_ALIVE_TIME)) {
|
||||
this.channelKeepAlive = Integer.parseInt(
|
||||
properties.getProperty(GrpcConstants.GRPC_CHANNEL_KEEP_ALIVE_TIME));
|
||||
this.channelKeepAlive = Integer
|
||||
.parseInt(properties.getProperty(GrpcConstants.GRPC_CHANNEL_KEEP_ALIVE_TIME));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_CHANNEL_CAPABILITY_NEGOTIATION_TIMEOUT)) {
|
||||
this.capabilityNegotiationTimeout = Integer.parseInt(
|
||||
properties.getProperty(GrpcConstants.GRPC_CHANNEL_CAPABILITY_NEGOTIATION_TIMEOUT));
|
||||
this.capabilityNegotiationTimeout = Integer
|
||||
.parseInt(properties.getProperty(GrpcConstants.GRPC_CHANNEL_CAPABILITY_NEGOTIATION_TIMEOUT));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_HEALTHCHECK_RETRY_TIMES)) {
|
||||
this.healthCheckRetryTimes = Integer.parseInt(
|
||||
properties.getProperty(GrpcConstants.GRPC_HEALTHCHECK_RETRY_TIMES));
|
||||
this.healthCheckRetryTimes = Integer
|
||||
.parseInt(properties.getProperty(GrpcConstants.GRPC_HEALTHCHECK_RETRY_TIMES));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_HEALTHCHECK_TIMEOUT)) {
|
||||
this.healthCheckTimeOut = Long.parseLong(
|
||||
properties.getProperty(GrpcConstants.GRPC_HEALTHCHECK_TIMEOUT));
|
||||
this.healthCheckTimeOut = Long
|
||||
.parseLong(properties.getProperty(GrpcConstants.GRPC_HEALTHCHECK_TIMEOUT));
|
||||
}
|
||||
if (properties.contains(GrpcConstants.GRPC_CHANNEL_KEEP_ALIVE_TIMEOUT)) {
|
||||
this.channelKeepAliveTimeout = Integer.parseInt(
|
||||
properties.getProperty(GrpcConstants.GRPC_CHANNEL_KEEP_ALIVE_TIMEOUT));
|
||||
this.channelKeepAliveTimeout = Integer
|
||||
.parseInt(properties.getProperty(GrpcConstants.GRPC_CHANNEL_KEEP_ALIVE_TIMEOUT));
|
||||
}
|
||||
this.tlsConfig = RpcClientTlsConfig.properties(properties);
|
||||
return this;
|
||||
@ -412,11 +413,11 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
||||
this.channelKeepAliveTimeout = channelKeepAliveTimeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public void setCapabilityNegotiationTimeout(long capabilityNegotiationTimeout) {
|
||||
this.capabilityNegotiationTimeout = capabilityNegotiationTimeout;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set healthCheckRetryTimes.
|
||||
*/
|
||||
@ -440,7 +441,7 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
||||
this.labels.putAll(labels);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set tlsConfig.
|
||||
*
|
||||
@ -451,7 +452,7 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
||||
this.tlsConfig = tlsConfig;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* build GrpcClientConfig.
|
||||
*/
|
||||
@ -459,5 +460,5 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
||||
return new DefaultGrpcClientConfig(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class ServerAbilityControlManager extends AbstractAbilityControlManager {
|
||||
@Override
|
||||
protected Map<AbilityMode, Map<AbilityKey, Boolean>> initCurrentNodeAbilities() {
|
||||
// init client abilities
|
||||
Map<AbilityMode, Map<AbilityKey, Boolean>> res = new HashMap<>();
|
||||
Map<AbilityMode, Map<AbilityKey, Boolean>> res = new HashMap<>(2);
|
||||
res.put(AbilityMode.CLUSTER_CLIENT, initClusterClientAbilities());
|
||||
res.put(AbilityMode.SDK_CLIENT, initSdkClientAbilities());
|
||||
|
||||
|
@ -18,12 +18,12 @@ package com.alibaba.nacos.core.listener;
|
||||
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.api.exception.runtime.NacosRuntimeException;
|
||||
import com.alibaba.nacos.common.ability.discover.NacosAbilityManagerHolder;
|
||||
import com.alibaba.nacos.common.event.ServerConfigChangeEvent;
|
||||
import com.alibaba.nacos.common.executor.ExecutorFactory;
|
||||
import com.alibaba.nacos.common.executor.NameThreadFactory;
|
||||
import com.alibaba.nacos.common.executor.ThreadPoolManager;
|
||||
import com.alibaba.nacos.common.notify.NotifyCenter;
|
||||
import com.alibaba.nacos.common.event.ServerConfigChangeEvent;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.alibaba.nacos.sys.env.EnvUtil;
|
||||
import com.alibaba.nacos.sys.file.FileChangeEvent;
|
||||
import com.alibaba.nacos.sys.file.FileWatcher;
|
||||
@ -31,7 +31,6 @@ import com.alibaba.nacos.sys.file.WatchFileCenter;
|
||||
import com.alibaba.nacos.sys.utils.ApplicationUtils;
|
||||
import com.alibaba.nacos.sys.utils.DiskUtils;
|
||||
import com.alibaba.nacos.sys.utils.InetUtils;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.env.OriginTrackedMapPropertySource;
|
||||
@ -116,12 +115,12 @@ public class StartingApplicationListener implements NacosApplicationListener {
|
||||
|
||||
logStarting();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void contextLoaded(ConfigurableApplicationContext context) {
|
||||
EnvUtil.customEnvironment();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void started(ConfigurableApplicationContext context) {
|
||||
starting = false;
|
||||
@ -237,8 +236,8 @@ public class StartingApplicationListener implements NacosApplicationListener {
|
||||
private void logStarting() {
|
||||
if (!EnvUtil.getStandaloneMode()) {
|
||||
|
||||
scheduledExecutorService = ExecutorFactory.newSingleScheduledExecutorService(
|
||||
new NameThreadFactory("com.alibaba.nacos.core.nacos-starting"));
|
||||
scheduledExecutorService = ExecutorFactory
|
||||
.newSingleScheduledExecutorService(new NameThreadFactory("com.alibaba.nacos.core.nacos-starting"));
|
||||
|
||||
scheduledExecutorService.scheduleWithFixedDelay(() -> {
|
||||
if (starting) {
|
||||
|
@ -110,12 +110,13 @@ public class GrpcBiStreamRequestAcceptor extends BiRequestStreamGrpc.BiRequestSt
|
||||
if (labels != null && labels.containsKey(Constants.APPNAME)) {
|
||||
appName = labels.get(Constants.APPNAME);
|
||||
}
|
||||
|
||||
|
||||
ConnectionMeta metaInfo = new ConnectionMeta(connectionId, payload.getMetadata().getClientIp(),
|
||||
remoteIp, remotePort, localPort, ConnectionType.GRPC.getType(),
|
||||
setUpRequest.getClientVersion(), appName, setUpRequest.getLabels());
|
||||
metaInfo.setTenant(setUpRequest.getTenant());
|
||||
Connection connection = new GrpcConnection(metaInfo, responseObserver, GrpcServerConstants.CONTEXT_KEY_CHANNEL.get());
|
||||
Connection connection = new GrpcConnection(metaInfo, responseObserver,
|
||||
GrpcServerConstants.CONTEXT_KEY_CHANNEL.get());
|
||||
// null if supported
|
||||
if (setUpRequest.getAbilityTable() != null) {
|
||||
// map to table
|
||||
@ -139,10 +140,11 @@ public class GrpcBiStreamRequestAcceptor extends BiRequestStreamGrpc.BiRequestSt
|
||||
} else {
|
||||
try {
|
||||
// finish register, tell client has set up successfully
|
||||
connection.request(new SetupAckRequest(NacosAbilityManagerHolder.getInstance().getCurrentNodeAbilities(AbilityMode.SERVER)), 3000L);
|
||||
connection.request(new SetupAckRequest(NacosAbilityManagerHolder.getInstance()
|
||||
.getCurrentNodeAbilities(AbilityMode.SERVER)), 3000L);
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ import java.util.Set;
|
||||
|
||||
@SpringBootTest
|
||||
public class AbilityControlManagerTest {
|
||||
|
||||
|
||||
private TestServerAbilityControlManager serverAbilityControlManager = new TestServerAbilityControlManager();
|
||||
|
||||
|
||||
@Before
|
||||
public void inject() {
|
||||
Map<String, Boolean> newTable = new HashMap<>();
|
||||
@ -44,16 +44,20 @@ public class AbilityControlManagerTest {
|
||||
public void testCurrentNodeAbility() {
|
||||
Set<String> keySet = serverAbilityControlManager.getCurrentNodeAbilities(AbilityMode.SERVER).keySet();
|
||||
// diable all
|
||||
keySet.forEach(key -> serverAbilityControlManager.disableCurrentNodeAbility(AbilityKey.getEnum(AbilityMode.SERVER, key)));
|
||||
keySet.forEach(key -> serverAbilityControlManager
|
||||
.disableCurrentNodeAbility(AbilityKey.getEnum(AbilityMode.SERVER, key)));
|
||||
// get all
|
||||
keySet.forEach(key -> {
|
||||
Assert.assertNotEquals(serverAbilityControlManager.isCurrentNodeAbilityRunning(AbilityKey.getEnum(AbilityMode.SERVER, key)), AbilityStatus.SUPPORTED);
|
||||
Assert.assertNotEquals(serverAbilityControlManager
|
||||
.isCurrentNodeAbilityRunning(AbilityKey.getEnum(AbilityMode.SERVER, key)), AbilityStatus.SUPPORTED);
|
||||
});
|
||||
// enable all
|
||||
keySet.forEach(key -> serverAbilityControlManager.enableCurrentNodeAbility(AbilityKey.getEnum(AbilityMode.SERVER, key)));
|
||||
keySet.forEach(key -> serverAbilityControlManager
|
||||
.enableCurrentNodeAbility(AbilityKey.getEnum(AbilityMode.SERVER, key)));
|
||||
// get all
|
||||
keySet.forEach(key -> {
|
||||
Assert.assertEquals(serverAbilityControlManager.isCurrentNodeAbilityRunning(AbilityKey.getEnum(AbilityMode.SERVER, key)), AbilityStatus.SUPPORTED);
|
||||
Assert.assertEquals(serverAbilityControlManager
|
||||
.isCurrentNodeAbilityRunning(AbilityKey.getEnum(AbilityMode.SERVER, key)), AbilityStatus.SUPPORTED);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.test.ability;
|
||||
|
||||
import com.alibaba.nacos.Nacos;
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.test.ability.component;
|
||||
|
||||
import com.alibaba.nacos.api.ability.constant.AbilityKey;
|
||||
|
Loading…
Reference in New Issue
Block a user