Solve conflict with develop branch.

This commit is contained in:
KomachiSion 2020-12-31 14:24:41 +08:00
parent bdacd0958d
commit 7f3a17c620
7 changed files with 20 additions and 28 deletions

View File

@ -24,6 +24,7 @@ import com.alibaba.nacos.api.naming.listener.EventListener;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ListView;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.api.naming.utils.NamingUtils;
import com.alibaba.nacos.api.selector.AbstractSelector;
import com.alibaba.nacos.client.naming.cache.ServiceInfoHolder;
import com.alibaba.nacos.client.naming.core.Balancer;
@ -134,6 +135,7 @@ public class NacosNamingService implements NamingService {
@Override
public void registerInstance(String serviceName, String groupName, Instance instance) throws NacosException {
NamingUtils.checkInstanceIsLegal(instance);
clientProxy.registerService(serviceName, groupName, instance);
}

View File

@ -49,7 +49,6 @@ import com.alibaba.nacos.common.http.HttpRestResult;
import com.alibaba.nacos.common.http.client.NacosRestTemplate;
import com.alibaba.nacos.common.http.param.Header;
import com.alibaba.nacos.common.http.param.Query;
import com.alibaba.nacos.common.lifecycle.Closeable;
import com.alibaba.nacos.common.utils.ConvertUtils;
import com.alibaba.nacos.common.utils.HttpMethod;
import com.alibaba.nacos.common.utils.IPUtil;
@ -100,6 +99,8 @@ public class NamingHttpClientProxy implements NamingClientProxy {
private final PushReceiver pushReceiver;
private final int maxRetry;
private int serverPort = DEFAULT_SERVER_PORT;
private ScheduledExecutorService executorService;
@ -117,6 +118,8 @@ public class NamingHttpClientProxy implements NamingClientProxy {
this.initRefreshTask();
this.pushReceiver = new PushReceiver(serviceInfoHolder);
this.serviceInfoHolder = serviceInfoHolder;
this.maxRetry = ConvertUtils.toInt(properties.getProperty(PropertyKeyConst.NAMING_REQUEST_DOMAIN_RETRY_COUNT,
String.valueOf(UtilAndComs.REQUEST_DOMAIN_RETRY_COUNT)));
}
private void initRefreshTask() {
@ -412,7 +415,7 @@ public class NamingHttpClientProxy implements NamingClientProxy {
if (serverListManager.isDomain()) {
String nacosDomain = serverListManager.getNacosDomain();
for (int i = 0; i < UtilAndComs.REQUEST_DOMAIN_RETRY_COUNT; i++) {
for (int i = 0; i < maxRetry; i++) {
try {
return callServer(api, params, body, nacosDomain, method);
} catch (NacosException e) {
@ -423,7 +426,7 @@ public class NamingHttpClientProxy implements NamingClientProxy {
}
}
}
if (servers != null && !servers.isEmpty()) {
Random random = new Random(System.currentTimeMillis());

View File

@ -37,7 +37,7 @@ import com.alibaba.nacos.config.server.service.trace.ConfigTraceService;
import com.alibaba.nacos.config.server.utils.ConfigExecutor;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.core.cluster.Member;
import com.alibaba.nacos.core.cluster.MemberUtils;
import com.alibaba.nacos.core.cluster.MemberUtil;
import com.alibaba.nacos.core.cluster.ServerMemberManager;
import com.alibaba.nacos.sys.env.EnvUtil;
import com.alibaba.nacos.sys.utils.InetUtils;
@ -94,7 +94,7 @@ public class AsyncNotifyService {
Queue<NotifySingleRpcTask> rpcQueue = new LinkedList<NotifySingleRpcTask>();
for (Member member : ipList) {
if (MemberUtils.getSupportedConnectionType(member) == null) {
if (MemberUtil.getSupportedConnectionType(member) == null) {
httpQueue.add(new NotifySingleTask(dataId, group, tenant, tag, dumpTs, member.getAddress(),
evt.isBeta));
} else {

View File

@ -29,7 +29,7 @@ import com.alibaba.nacos.common.utils.StringUtils;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.console.security.nacos.NacosAuthConfig;
import com.alibaba.nacos.core.cluster.Member;
import com.alibaba.nacos.core.cluster.MemberUtils;
import com.alibaba.nacos.core.cluster.MemberUtil;
import com.alibaba.nacos.core.cluster.ServerMemberManager;
import com.alibaba.nacos.core.cluster.remote.ClusterRpcClientProxy;
import com.alibaba.nacos.core.remote.Connection;
@ -182,7 +182,7 @@ public class ServerLoaderController {
serverLoaderInfoRequest.setReloadCount(reloadcount);
int count = 0;
for (Member member : serverMemberManager.allMembersWithoutSelf()) {
if (MemberUtils.isSupportedLongCon(member)) {
if (MemberUtil.isSupportedLongCon(member)) {
count++;
completionService.submit(new ServerReLoaderRpcTask(serverLoaderInfoRequest, member));
}
@ -217,7 +217,7 @@ public class ServerLoaderController {
int count = 0;
for (Member member : serverMemberManager.allMembersWithoutSelf()) {
if (MemberUtils.isSupportedLongCon(member)) {
if (MemberUtil.isSupportedLongCon(member)) {
count++;
ServerLoaderInfoRequest serverLoaderInfoRequest = new ServerLoaderInfoRequest();
completionService.submit(new ServerLoaderInfoRpcTask(serverLoaderInfoRequest, member));

View File

@ -28,7 +28,7 @@ import com.alibaba.nacos.common.remote.client.RpcClientFactory;
import com.alibaba.nacos.common.remote.client.ServerListFactory;
import com.alibaba.nacos.core.cluster.Member;
import com.alibaba.nacos.core.cluster.MemberChangeListener;
import com.alibaba.nacos.core.cluster.MemberUtils;
import com.alibaba.nacos.core.cluster.MemberUtil;
import com.alibaba.nacos.core.cluster.MembersChangeEvent;
import com.alibaba.nacos.core.cluster.ServerMemberManager;
import com.alibaba.nacos.core.utils.Loggers;
@ -85,7 +85,7 @@ public class ClusterRpcClientProxy extends MemberChangeListener {
//ensure to create client of new members
for (Member member : members) {
ConnectionType supportedConnectionType = MemberUtils.getSupportedConnectionType(member);
ConnectionType supportedConnectionType = MemberUtil.getSupportedConnectionType(member);
if (supportedConnectionType != null) {
createRpcClientAndStart(member, supportedConnectionType);
}
@ -94,7 +94,7 @@ public class ClusterRpcClientProxy extends MemberChangeListener {
//shutdown and remove old members.
Set<Map.Entry<String, RpcClient>> allClientEntrys = RpcClientFactory.getAllClientEntrys();
Iterator<Map.Entry<String, RpcClient>> iterator = allClientEntrys.iterator();
List<String> newMemberKeys = members.stream().filter(a -> MemberUtils.isSupportedLongCon(a))
List<String> newMemberKeys = members.stream().filter(a -> MemberUtil.isSupportedLongCon(a))
.map(a -> memberClientKey(a)).collect(Collectors.toList());
while (iterator.hasNext()) {
Map.Entry<String, RpcClient> next1 = iterator.next();

View File

@ -67,23 +67,7 @@ public class CatalogServiceV1Impl implements CatalogService {
ObjectNode detailView = JacksonUtils.createEmptyJsonNode();
detailView.replace("service", serviceObject);
List<com.alibaba.nacos.api.naming.pojo.Cluster> clusters = new ArrayList<>();
for (com.alibaba.nacos.naming.core.Cluster cluster : detailedService.getClusterMap().values()) {
com.alibaba.nacos.api.naming.pojo.Cluster clusterView = new com.alibaba.nacos.api.naming.pojo.Cluster();
clusterView.setName(cluster.getName());
clusterView.setHealthChecker(cluster.getHealthChecker());
clusterView.setMetadata(cluster.getMetadata());
clusterView.setUseIPPort4Check(cluster.isUseIPPort4Check());
clusterView.setDefaultPort(cluster.getDefaultPort());
clusterView.setDefaultCheckPort(cluster.getDefaultCheckPort());
clusterView.setServiceName(cluster.getService().getName());
clusters.add(clusterView);
}
detailView.replace("clusters", JacksonUtils.transferToJsonNode(clusters));
detailView.replace("clusters", JacksonUtils.transferToJsonNode(detailedService.getClusterMap().values()));
return detailView;
}

View File

@ -154,6 +154,9 @@ public class ServiceUtil {
if (start < 0) {
start = 0;
}
if (start >= result.size()) {
return result;
}
int end = start + pageSize;
if (end > result.size()) {
end = result.size();