Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sumer-ospp 10376, to keep path with the newest commits in develop branch #10942

Merged
merged 30 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c7a20bd
[ISSUE #10734] Implement http request param check filter and http par…
Sunrisea Jul 11, 2023
a83e2cc
dump change check task submit (#10755)
shiyiyue1102 Jul 11, 2023
9069730
Refactor grpc tls (#10759)
KomachiSion Jul 11, 2023
8fa83ce
fix word spelling in `AuthenticationManagerDelegator` (#10777)
ZhangShenao Jul 13, 2023
156cd62
fix(#10427): When the execution of handleServerRequest() encounters a…
Bo-Qiu Jul 13, 2023
556e4cc
fix(#10585): selectInstances and selectOneHealthyInstance methods, if…
Bo-Qiu Jul 17, 2023
3374cf4
disable check port input when use registered port (#10799)
Joey777210 Jul 17, 2023
318892d
Add the handle to overload connection (#10783)
Daydreamer-ia Jul 17, 2023
f986916
[ISSUE #10662]Prometheus-sd add namespace and service api (#10663)
Joey777210 Jul 17, 2023
3b9880a
Service instance should display related color when healthy or unhealt…
maoling Jul 19, 2023
64774de
fix a couple of invaild props (#10810)
maoling Jul 19, 2023
9561db3
feat(#10539): When the operation configuration fails, log. (#10804)
Bo-Qiu Jul 19, 2023
e57b43c
[ISSUE #10744]feat:Add HealthControllerV2 and HealthControllerV2Test …
DiligenceLai Jul 19, 2023
8adca68
[ISSUE #10734] Refactor the ParamChecker and ParamExtractor (#10775)
Sunrisea Jul 19, 2023
95df397
Refactor Prometheus Module (#10827)
ZhangShenao Jul 25, 2023
65ad408
For #10734,fix the param check rule (#10826)
Sunrisea Jul 25, 2023
149c50f
[ISSUE #10792]When nacos client use endpoint, the registration center…
huhongjie2014 Jul 25, 2023
25ef67d
Reactor code in datasource-plugin (#10791)
ZhangShenao Jul 25, 2023
4321e77
bugfix for PersistentClientOperationServiceImpl log (#10825)
lu-xiaoshuang Jul 25, 2023
a76f077
For #10734,fix the param check rule (#10858)
Sunrisea Jul 28, 2023
910c205
fix(#10831): When using the deregisterInstance method to remove one o…
Bo-Qiu Jul 28, 2023
74e740c
UnsupportedFeatureError (#10860)
zt9788 Jul 28, 2023
fb5cfdd
fix(distro): fix issue#10880. (#10881)
stone-98 Aug 1, 2023
8370124
feat(#5608 && #10223): When the custom instance id is empty, the id w…
Bo-Qiu Aug 1, 2023
8ba3906
fix: test-code branch (#10904)
Wuyunfan-BUPT Aug 4, 2023
7d0101b
console-ui 新增 toml 语言支持,修复之前 properties 主题未生效的问题 (#10896)
DarrenLuo Aug 4, 2023
de87bb3
feat(10891): Provide a configuration item for the maximum number of p…
Bo-Qiu Aug 4, 2023
3fdcb5c
[ISSUE #10824] Remove udp port param for v1-client (#10914)
ZhangShenao Aug 4, 2023
f5c3a4b
Fix login failed when close auth.
KomachiSion Aug 7, 2023
03f2191
Merge pull request #10922 from KomachiSion/develop-fix-login-failed
xuechaos Aug 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
test-version: "${{ matrix.version }}"
test-code-git: "https:/nacos-group/nacos-e2e.git"
test-code-branch: "master"
test-code-branch: "main"
test-code-path: "java/nacos-2X"
test-cmd: 'mvn clean test -B'
job-id: ${{ strategy.job-index }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public enum ConfigType {
*/
YAML("yaml"),

/**
* config type is "toml".
*/
TOML("toml"),

/**
* not a real type.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
@SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule")
public class NacosNamingService implements NamingService {

private static final String DEFAULT_NAMING_LOG_FILE_PATH = "naming.log";
private static final String DEFAULT_NAMING_LOG_FILE_PATH = "naming.log";

private static final String UP = "UP";

Expand Down Expand Up @@ -93,13 +93,14 @@ private void init(Properties properties) throws NacosException {
InitUtils.initSerialization();
InitUtils.initWebRootContext(nacosClientProperties);
initLogName(nacosClientProperties);

this.notifierEventScope = UUID.randomUUID().toString();
this.changeNotifier = new InstancesChangeNotifier(this.notifierEventScope);
NotifyCenter.registerToPublisher(InstancesChangeEvent.class, 16384);
NotifyCenter.registerSubscriber(changeNotifier);
this.serviceInfoHolder = new ServiceInfoHolder(namespace, this.notifierEventScope, nacosClientProperties);
this.clientProxy = new NamingClientProxyDelegate(this.namespace, serviceInfoHolder, nacosClientProperties, changeNotifier);
this.clientProxy = new NamingClientProxyDelegate(this.namespace, serviceInfoHolder, nacosClientProperties,
changeNotifier);
}

private void initLogName(NacosClientProperties properties) {
Expand Down Expand Up @@ -241,7 +242,7 @@ public List<Instance> getAllInstances(String serviceName, String groupName, List
serviceInfo = clientProxy.subscribe(serviceName, groupName, clusterString);
}
} else {
serviceInfo = clientProxy.queryInstancesOfService(serviceName, groupName, clusterString, 0, false);
serviceInfo = clientProxy.queryInstancesOfService(serviceName, groupName, clusterString, false);
}
List<Instance> list;
if (serviceInfo == null || CollectionUtils.isEmpty(list = serviceInfo.getHosts())) {
Expand Down Expand Up @@ -298,11 +299,11 @@ public List<Instance> selectInstances(String serviceName, String groupName, List
String clusterString = StringUtils.join(clusters, ",");
if (subscribe) {
serviceInfo = serviceInfoHolder.getServiceInfo(serviceName, groupName, clusterString);
if (null == serviceInfo) {
if (null == serviceInfo || !clientProxy.isSubscribed(serviceName, groupName, clusterString)) {
serviceInfo = clientProxy.subscribe(serviceName, groupName, clusterString);
}
} else {
serviceInfo = clientProxy.queryInstancesOfService(serviceName, groupName, clusterString, 0, false);
serviceInfo = clientProxy.queryInstancesOfService(serviceName, groupName, clusterString, false);
}
return selectInstances(serviceInfo, healthy);
}
Expand Down Expand Up @@ -368,13 +369,12 @@ public Instance selectOneHealthyInstance(String serviceName, String groupName, L
String clusterString = StringUtils.join(clusters, ",");
if (subscribe) {
ServiceInfo serviceInfo = serviceInfoHolder.getServiceInfo(serviceName, groupName, clusterString);
if (null == serviceInfo) {
if (null == serviceInfo || !clientProxy.isSubscribed(serviceName, groupName, clusterString)) {
serviceInfo = clientProxy.subscribe(serviceName, groupName, clusterString);
}
return Balancer.RandomByWeight.selectHost(serviceInfo);
} else {
ServiceInfo serviceInfo = clientProxy
.queryInstancesOfService(serviceName, groupName, clusterString, 0, false);
ServiceInfo serviceInfo = clientProxy.queryInstancesOfService(serviceName, groupName, clusterString, false);
return Balancer.RandomByWeight.selectHost(serviceInfo);
}
}
Expand Down Expand Up @@ -467,6 +467,6 @@ public void shutDown() throws NacosException {
serviceInfoHolder.shutdown();
clientProxy.shutdown();
NotifyCenter.deregisterSubscriber(changeNotifier);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import com.alibaba.nacos.client.naming.utils.InitUtils;
import com.alibaba.nacos.client.naming.utils.NamingHttpUtil;
import com.alibaba.nacos.client.utils.ContextPathUtil;
import com.alibaba.nacos.client.utils.ParamUtil;
import com.alibaba.nacos.common.executor.NameThreadFactory;
import com.alibaba.nacos.common.http.HttpRestResult;
import com.alibaba.nacos.common.http.client.NacosRestTemplate;
Expand All @@ -50,7 +52,6 @@
import java.util.concurrent.atomic.AtomicInteger;

import static com.alibaba.nacos.client.utils.LogUtils.NAMING_LOGGER;
import static com.alibaba.nacos.common.constant.RequestUrlConstants.HTTP_PREFIX;

/**
* Server list manager.
Expand All @@ -74,6 +75,10 @@ public class ServerListManager implements ServerListFactory, Closeable {
private ScheduledExecutorService refreshServerListExecutor;

private String endpoint;

private String contentPath = ParamUtil.getDefaultContextPath();

private String serverListName = ParamUtil.getDefaultNodesPath();

private String nacosDomain;

Expand All @@ -96,6 +101,16 @@ public ServerListManager(NacosClientProperties properties, String namespace) {
private void initServerAddr(NacosClientProperties properties) {
this.endpoint = InitUtils.initEndpoint(properties);
if (StringUtils.isNotEmpty(endpoint)) {

String contentPathTmp = properties.getProperty(PropertyKeyConst.CONTEXT_PATH);
if (!StringUtils.isBlank(contentPathTmp)) {
this.contentPath = contentPathTmp;
}
String serverListNameTmp = properties.getProperty(PropertyKeyConst.CLUSTER_NAME);
if (!StringUtils.isBlank(serverListNameTmp)) {
this.serverListName = serverListNameTmp;
}

this.serversFromEndpoint = getServerListFromEndpoint();
refreshServerListExecutor = new ScheduledThreadPoolExecutor(1,
new NameThreadFactory("com.alibaba.nacos.client.naming.server.list.refresher"));
Expand All @@ -115,7 +130,10 @@ private void initServerAddr(NacosClientProperties properties) {

private List<String> getServerListFromEndpoint() {
try {
String urlString = HTTP_PREFIX + endpoint + "/nacos/serverlist";
StringBuilder addressServerUrlTem = new StringBuilder(
String.format("http://%s%s/%s", this.endpoint,
ContextPathUtil.normalizeContextPath(this.contentPath), this.serverListName));
String urlString = addressServerUrlTem.toString();
Header header = NamingHttpUtil.builderHeader();
Query query = StringUtils.isNotBlank(namespace)
? Query.newInstance().addParam("namespace", namespace)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ private boolean isAsyncQueryForSubscribeService(NacosClientProperties properties
if (properties == null || !properties.containsKey(PropertyKeyConst.NAMING_ASYNC_QUERY_SUBSCRIBE_SERVICE)) {
return false;
}
return ConvertUtils.toBoolean(properties.getProperty(PropertyKeyConst.NAMING_ASYNC_QUERY_SUBSCRIBE_SERVICE), false);
return ConvertUtils.toBoolean(properties.getProperty(PropertyKeyConst.NAMING_ASYNC_QUERY_SUBSCRIBE_SERVICE),
false);
}

private int initPollingThreadCount(NacosClientProperties properties) {
Expand Down Expand Up @@ -188,14 +189,14 @@ public void run() {

ServiceInfo serviceObj = serviceInfoHolder.getServiceInfoMap().get(serviceKey);
if (serviceObj == null) {
serviceObj = namingClientProxy.queryInstancesOfService(serviceName, groupName, clusters, 0, false);
serviceObj = namingClientProxy.queryInstancesOfService(serviceName, groupName, clusters, false);
serviceInfoHolder.processServiceInfo(serviceObj);
lastRefTime = serviceObj.getLastRefTime();
return;
}

if (serviceObj.getLastRefTime() <= lastRefTime) {
serviceObj = namingClientProxy.queryInstancesOfService(serviceName, groupName, clusters, 0, false);
serviceObj = namingClientProxy.queryInstancesOfService(serviceName, groupName, clusters, false);
serviceInfoHolder.processServiceInfo(serviceObj);
}
lastRefTime = serviceObj.getLastRefTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,12 @@ public interface NamingClientProxy extends Closeable {
* @param serviceName service name
* @param groupName group name
* @param clusters clusters
* @param udpPort udp port
* @param healthyOnly healthy only
* @return service info
* @throws NacosException nacos exception
*/
ServiceInfo queryInstancesOfService(String serviceName, String groupName, String clusters, int udpPort,
boolean healthyOnly) throws NacosException;
ServiceInfo queryInstancesOfService(String serviceName, String groupName, String clusters, boolean healthyOnly)
throws NacosException;

/**
* Query Service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public class NamingClientProxyDelegate implements NamingClientProxy {

private ScheduledExecutorService executorService;

public NamingClientProxyDelegate(String namespace, ServiceInfoHolder serviceInfoHolder, NacosClientProperties properties,
InstancesChangeNotifier changeNotifier) throws NacosException {
public NamingClientProxyDelegate(String namespace, ServiceInfoHolder serviceInfoHolder,
NacosClientProperties properties, InstancesChangeNotifier changeNotifier) throws NacosException {
this.serviceInfoUpdateService = new ServiceInfoUpdateService(properties, serviceInfoHolder, this,
changeNotifier);
this.serverListManager = new ServerListManager(properties, namespace);
Expand All @@ -88,9 +88,8 @@ private void initSecurityProxy(NacosClientProperties properties) {
});
final Properties nacosClientPropertiesView = properties.asProperties();
this.securityProxy.login(nacosClientPropertiesView);
this.executorService
.scheduleWithFixedDelay(() -> securityProxy.login(nacosClientPropertiesView), 0, SECURITY_INFO_REFRESH_INTERVAL_MILLS,
TimeUnit.MILLISECONDS);
this.executorService.scheduleWithFixedDelay(() -> securityProxy.login(nacosClientPropertiesView), 0,
SECURITY_INFO_REFRESH_INTERVAL_MILLS, TimeUnit.MILLISECONDS);
}

@Override
Expand Down Expand Up @@ -131,9 +130,9 @@ public void updateInstance(String serviceName, String groupName, Instance instan
}

@Override
public ServiceInfo queryInstancesOfService(String serviceName, String groupName, String clusters, int udpPort,
public ServiceInfo queryInstancesOfService(String serviceName, String groupName, String clusters,
boolean healthyOnly) throws NacosException {
return grpcClientProxy.queryInstancesOfService(serviceName, groupName, clusters, udpPort, healthyOnly);
return grpcClientProxy.queryInstancesOfService(serviceName, groupName, clusters, healthyOnly);
}

@Override
Expand Down Expand Up @@ -178,8 +177,8 @@ public ServiceInfo subscribe(String serviceName, String groupName, String cluste

@Override
public void unsubscribe(String serviceName, String groupName, String clusters) throws NacosException {
NAMING_LOGGER
.debug("[UNSUBSCRIBE-SERVICE] service:{}, group:{}, cluster:{} ", serviceName, groupName, clusters);
NAMING_LOGGER.debug("[UNSUBSCRIBE-SERVICE] service:{}, group:{}, cluster:{} ", serviceName, groupName,
clusters);
serviceInfoUpdateService.stopUpdateIfContain(serviceName, groupName, clusters);
grpcClientProxy.unsubscribe(serviceName, groupName, clusters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
import com.alibaba.nacos.common.remote.ConnectionType;
import com.alibaba.nacos.common.remote.client.RpcClient;
import com.alibaba.nacos.common.remote.client.RpcClientFactory;
import com.alibaba.nacos.common.remote.client.ServerListFactory;
import com.alibaba.nacos.common.remote.client.RpcClientTlsConfig;
import com.alibaba.nacos.common.remote.client.ServerListFactory;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.JacksonUtils;

Expand Down Expand Up @@ -139,8 +139,10 @@ public void batchRegisterService(String serviceName, String groupName, List<Inst
@Override
public void batchDeregisterService(String serviceName, String groupName, List<Instance> instances)
throws NacosException {
List<Instance> retainInstance = getRetainInstance(serviceName, groupName, instances);
batchRegisterService(serviceName, groupName, retainInstance);
synchronized (redoService.getRegisteredInstances()) {
List<Instance> retainInstance = getRetainInstance(serviceName, groupName, instances);
batchRegisterService(serviceName, groupName, retainInstance);
}
}

/**
Expand Down Expand Up @@ -218,11 +220,20 @@ public void doRegisterService(String serviceName, String groupName, Instance ins

@Override
public void deregisterService(String serviceName, String groupName, Instance instance) throws NacosException {
NAMING_LOGGER
.info("[DEREGISTER-SERVICE] {} deregistering service {} with instance: {}", namespaceId, serviceName,
instance);
redoService.instanceDeregister(serviceName, groupName);
doDeregisterService(serviceName, groupName, instance);
NAMING_LOGGER.info("[DEREGISTER-SERVICE] {} deregistering service {} with instance: {}", namespaceId,
serviceName, instance);
String key = NamingUtils.getGroupedName(serviceName, groupName);
InstanceRedoData instanceRedoData = redoService.getRegisteredInstancesByKey(key);
if (instanceRedoData instanceof BatchInstanceRedoData) {
List<Instance> instances = new ArrayList<>();
if (null != instance) {
instances.add(instance);
}
batchDeregisterService(serviceName, groupName, instances);
} else {
redoService.instanceDeregister(serviceName, groupName);
doDeregisterService(serviceName, groupName, instance);
}
}

/**
Expand All @@ -246,12 +257,11 @@ public void updateInstance(String serviceName, String groupName, Instance instan
}

@Override
public ServiceInfo queryInstancesOfService(String serviceName, String groupName, String clusters, int udpPort,
public ServiceInfo queryInstancesOfService(String serviceName, String groupName, String clusters,
boolean healthyOnly) throws NacosException {
ServiceQueryRequest request = new ServiceQueryRequest(namespaceId, serviceName, groupName);
request.setCluster(clusters);
request.setHealthyOnly(healthyOnly);
request.setUdpPort(udpPort);
QueryServiceResponse response = requestToServer(request, QueryServiceResponse.class);
return response.getServiceInfo();
}
Expand Down Expand Up @@ -321,8 +331,8 @@ public ServiceInfo doSubscribe(String serviceName, String groupName, String clus
@Override
public void unsubscribe(String serviceName, String groupName, String clusters) throws NacosException {
if (NAMING_LOGGER.isDebugEnabled()) {
NAMING_LOGGER
.debug("[GRPC-UNSUBSCRIBE] service:{}, group:{}, cluster:{} ", serviceName, groupName, clusters);
NAMING_LOGGER.debug("[GRPC-UNSUBSCRIBE] service:{}, group:{}, cluster:{} ", serviceName, groupName,
clusters);
}
redoService.subscriberDeregister(serviceName, groupName, clusters);
doUnsubscribe(serviceName, groupName, clusters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public NamingGrpcRedoService(NamingGrpcClientProxy clientProxy) {
DEFAULT_REDO_DELAY, TimeUnit.MILLISECONDS);
}

public ConcurrentMap<String, InstanceRedoData> getRegisteredInstances() {
return registeredInstances;
}

public boolean isConnected() {
return connected;
}
Expand Down
Loading
Loading