Skip to content

Commit

Permalink
Solve conflict with develop branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
KomachiSion committed Dec 31, 2020
1 parent bdacd09 commit 7f3a17c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -134,6 +135,7 @@ public void registerInstance(String serviceName, Instance instance) throws Nacos

@Override
public void registerInstance(String serviceName, String groupName, Instance instance) throws NacosException {
NamingUtils.checkInstanceIsLegal(instance);
clientProxy.registerService(serviceName, groupName, instance);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
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;
Expand Down Expand Up @@ -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;
Expand All @@ -117,6 +118,8 @@ public NamingHttpClientProxy(String namespaceId, ServerListManager serverListMan
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() {
Expand Down Expand Up @@ -412,7 +415,7 @@ public String reqApi(String api, Map<String, String> params, Map<String, String>

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) {
Expand All @@ -423,7 +426,7 @@ public String reqApi(String api, Map<String, String> params, Map<String, String>
}
}
}

if (servers != null && !servers.isEmpty()) {

Random random = new Random(System.currentTimeMillis());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
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;
Expand Down Expand Up @@ -94,7 +94,7 @@ public void onEvent(Event event) {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
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;
Expand Down Expand Up @@ -182,7 +182,7 @@ private void reloadClusterInner(int reloadcount) {
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));
}
Expand Down Expand Up @@ -217,7 +217,7 @@ private Map<String, Object> getServerLoadMetrics() {

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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
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;
Expand Down Expand Up @@ -85,7 +85,7 @@ private void refresh(List<Member> members) throws NacosException {

//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);
}
Expand All @@ -94,7 +94,7 @@ private void refresh(List<Member> members) throws NacosException {
//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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,7 @@ public Object getServiceDetail(String namespaceId, String groupName, String serv

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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ public static List<String> pageServiceName(int pageNo, int pageSize, Collection<
if (start < 0) {
start = 0;
}
if (start >= result.size()) {
return result;
}
int end = start + pageSize;
if (end > result.size()) {
end = result.size();
Expand Down

0 comments on commit 7f3a17c

Please sign in to comment.