#269 fix bug
This commit is contained in:
parent
af26af7e6e
commit
8c23f34806
@ -124,4 +124,6 @@ public class Constants {
|
|||||||
public static final String DEFAULT_NAMESPACE_ID = "public";
|
public static final String DEFAULT_NAMESPACE_ID = "public";
|
||||||
|
|
||||||
public static final int WRITE_REDIRECT_CODE = 307;
|
public static final int WRITE_REDIRECT_CODE = 307;
|
||||||
|
|
||||||
|
public static final String SERVICE_INFO_SPLITER = "@@";
|
||||||
}
|
}
|
||||||
|
@ -418,7 +418,7 @@ public interface NamingService {
|
|||||||
void subscribe(String serviceName, String groupName, EventListener listener) throws NacosException;
|
void subscribe(String serviceName, String groupName, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* subscribe service to receive events of instances alteration
|
* Subscribe service to receive events of instances alteration
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
@ -428,7 +428,7 @@ public interface NamingService {
|
|||||||
void subscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException;
|
void subscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* subscribe service to receive events of instances alteration
|
* Subscribe service to receive events of instances alteration
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
@ -439,7 +439,7 @@ public interface NamingService {
|
|||||||
void subscribe(String serviceName, String groupName, List<String> clusters, EventListener listener) throws NacosException;
|
void subscribe(String serviceName, String groupName, List<String> clusters, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unsubscribe event listener of service
|
* Unsubscribe event listener of service
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param listener event listener
|
* @param listener event listener
|
||||||
@ -458,7 +458,7 @@ public interface NamingService {
|
|||||||
void unsubscribe(String serviceName, String groupName, EventListener listener) throws NacosException;
|
void unsubscribe(String serviceName, String groupName, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unsubscribe event listener of service
|
* Unsubscribe event listener of service
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param clusters list of cluster
|
* @param clusters list of cluster
|
||||||
@ -468,7 +468,7 @@ public interface NamingService {
|
|||||||
void unsubscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException;
|
void unsubscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unsubscribe event listener of service
|
* Unsubscribe event listener of service
|
||||||
*
|
*
|
||||||
* @param serviceName name of service
|
* @param serviceName name of service
|
||||||
* @param groupName group of service
|
* @param groupName group of service
|
||||||
@ -479,7 +479,7 @@ public interface NamingService {
|
|||||||
void unsubscribe(String serviceName, String groupName, List<String> clusters, EventListener listener) throws NacosException;
|
void unsubscribe(String serviceName, String groupName, List<String> clusters, EventListener listener) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all service names from server
|
* Get all service names from server
|
||||||
*
|
*
|
||||||
* @param pageNo page index
|
* @param pageNo page index
|
||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
@ -489,7 +489,18 @@ public interface NamingService {
|
|||||||
ListView<String> getServicesOfServer(int pageNo, int pageSize) throws NacosException;
|
ListView<String> getServicesOfServer(int pageNo, int pageSize) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all subscribed services of current client
|
* Get all service names from server
|
||||||
|
*
|
||||||
|
* @param pageNo page index
|
||||||
|
* @param pageSize page size
|
||||||
|
* @param groupName group name
|
||||||
|
* @return list of service names
|
||||||
|
* @throws NacosException
|
||||||
|
*/
|
||||||
|
ListView<String> getServicesOfServer(int pageNo, int pageSize, String groupName) throws NacosException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all service names from server with selector
|
||||||
*
|
*
|
||||||
* @param pageNo page index
|
* @param pageNo page index
|
||||||
* @param pageSize page size
|
* @param pageSize page size
|
||||||
@ -500,6 +511,18 @@ public interface NamingService {
|
|||||||
*/
|
*/
|
||||||
ListView<String> getServicesOfServer(int pageNo, int pageSize, AbstractSelector selector) throws NacosException;
|
ListView<String> getServicesOfServer(int pageNo, int pageSize, AbstractSelector selector) throws NacosException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all service names from server with selector
|
||||||
|
*
|
||||||
|
* @param pageNo page index
|
||||||
|
* @param pageSize page size
|
||||||
|
* @param groupName group name
|
||||||
|
* @param selector selector to filter the resource
|
||||||
|
* @return list of service names
|
||||||
|
* @throws NacosException
|
||||||
|
*/
|
||||||
|
ListView<String> getServicesOfServer(int pageNo, int pageSize, String groupName, AbstractSelector selector) throws NacosException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all subscribed services of current client
|
* Get all subscribed services of current client
|
||||||
*
|
*
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package com.alibaba.nacos.api.naming.pojo;
|
package com.alibaba.nacos.api.naming.pojo;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
@ -37,6 +38,8 @@ public class ServiceInfo {
|
|||||||
@JSONField(name = "dom")
|
@JSONField(name = "dom")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
private String clusters;
|
private String clusters;
|
||||||
|
|
||||||
private long cacheMillis = 1000L;
|
private long cacheMillis = 1000L;
|
||||||
@ -67,7 +70,7 @@ public class ServiceInfo {
|
|||||||
int clusterIndex = 1;
|
int clusterIndex = 1;
|
||||||
int serviceNameIndex = 0;
|
int serviceNameIndex = 0;
|
||||||
|
|
||||||
String[] keys = key.split(SPLITER);
|
String[] keys = key.split(Constants.SERVICE_INFO_SPLITER);
|
||||||
if (keys.length >= maxIndex) {
|
if (keys.length >= maxIndex) {
|
||||||
this.name = keys[serviceNameIndex];
|
this.name = keys[serviceNameIndex];
|
||||||
this.clusters = keys[clusterIndex];
|
this.clusters = keys[clusterIndex];
|
||||||
@ -105,6 +108,14 @@ public class ServiceInfo {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGroupName() {
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupName(String groupName) {
|
||||||
|
this.groupName = groupName;
|
||||||
|
}
|
||||||
|
|
||||||
public void setLastRefTime(long lastRefTime) {
|
public void setLastRefTime(long lastRefTime) {
|
||||||
this.lastRefTime = lastRefTime;
|
this.lastRefTime = lastRefTime;
|
||||||
}
|
}
|
||||||
@ -178,13 +189,16 @@ public class ServiceInfo {
|
|||||||
@JSONField(serialize = false)
|
@JSONField(serialize = false)
|
||||||
public static ServiceInfo fromKey(String key) {
|
public static ServiceInfo fromKey(String key) {
|
||||||
ServiceInfo serviceInfo = new ServiceInfo();
|
ServiceInfo serviceInfo = new ServiceInfo();
|
||||||
|
int maxSegCount = 3;
|
||||||
if (key.contains(SPLITER)) {
|
String[] segs = key.split(Constants.SERVICE_INFO_SPLITER);
|
||||||
serviceInfo.setName(key.split(SPLITER)[0]);
|
if (segs.length == maxSegCount -1) {
|
||||||
serviceInfo.setClusters(key.split(SPLITER)[1]);
|
serviceInfo.setGroupName(segs[0]);
|
||||||
return serviceInfo;
|
serviceInfo.setName(segs[1]);
|
||||||
|
} else if (segs.length == maxSegCount) {
|
||||||
|
serviceInfo.setGroupName(segs[0]);
|
||||||
|
serviceInfo.setName(segs[1]);
|
||||||
|
serviceInfo.setClusters(segs[2]);
|
||||||
}
|
}
|
||||||
serviceInfo.setName(key);
|
|
||||||
return serviceInfo;
|
return serviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +206,7 @@ public class ServiceInfo {
|
|||||||
public static String getKey(String name, String clusters) {
|
public static String getKey(String name, String clusters) {
|
||||||
|
|
||||||
if (!isEmpty(clusters)) {
|
if (!isEmpty(clusters)) {
|
||||||
return name + SPLITER + clusters;
|
return name + Constants.SERVICE_INFO_SPLITER + clusters;
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
@ -241,12 +241,17 @@ public class NacosNamingService implements NamingService {
|
|||||||
@Override
|
@Override
|
||||||
public List<Instance> getAllInstances(String serviceName, List<String> clusters, boolean subscribe)
|
public List<Instance> getAllInstances(String serviceName, List<String> clusters, boolean subscribe)
|
||||||
throws NacosException {
|
throws NacosException {
|
||||||
|
return getAllInstances(serviceName, Constants.DEFAULT_GROUP, clusters, subscribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Instance> getAllInstances(String serviceName, String groupName, List<String> clusters, boolean subscribe) throws NacosException {
|
||||||
|
|
||||||
ServiceInfo serviceInfo;
|
ServiceInfo serviceInfo;
|
||||||
if (subscribe) {
|
if (subscribe) {
|
||||||
serviceInfo = hostReactor.getServiceInfo(serviceName, StringUtils.join(clusters, ","));
|
serviceInfo = hostReactor.getServiceInfo(groupName + Constants.SERVICE_INFO_SPLITER + serviceName, StringUtils.join(clusters, ","));
|
||||||
} else {
|
} else {
|
||||||
serviceInfo = hostReactor.getServiceInfoDirectlyFromServer(serviceName, StringUtils.join(clusters, ","));
|
serviceInfo = hostReactor.getServiceInfoDirectlyFromServer(groupName + Constants.SERVICE_INFO_SPLITER + serviceName, StringUtils.join(clusters, ","));
|
||||||
}
|
}
|
||||||
List<Instance> list;
|
List<Instance> list;
|
||||||
if (serviceInfo == null || CollectionUtils.isEmpty(list = serviceInfo.getHosts())) {
|
if (serviceInfo == null || CollectionUtils.isEmpty(list = serviceInfo.getHosts())) {
|
||||||
@ -255,11 +260,6 @@ public class NacosNamingService implements NamingService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Instance> getAllInstances(String serviceName, String groupName, List<String> clusters, boolean subscribe) throws NacosException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instance> selectInstances(String serviceName, boolean healthy) throws NacosException {
|
public List<Instance> selectInstances(String serviceName, boolean healthy) throws NacosException {
|
||||||
return selectInstances(serviceName, new ArrayList<String>(), healthy);
|
return selectInstances(serviceName, new ArrayList<String>(), healthy);
|
||||||
@ -267,7 +267,7 @@ public class NacosNamingService implements NamingService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instance> selectInstances(String serviceName, String groupName, boolean healthy) throws NacosException {
|
public List<Instance> selectInstances(String serviceName, String groupName, boolean healthy) throws NacosException {
|
||||||
return null;
|
return selectInstances(serviceName, groupName, healthy, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -278,7 +278,7 @@ public class NacosNamingService implements NamingService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instance> selectInstances(String serviceName, String groupName, boolean healthy, boolean subscribe) throws NacosException {
|
public List<Instance> selectInstances(String serviceName, String groupName, boolean healthy, boolean subscribe) throws NacosException {
|
||||||
return null;
|
return selectInstances(serviceName, groupName, new ArrayList<String>(), healthy, subscribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -289,24 +289,25 @@ public class NacosNamingService implements NamingService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instance> selectInstances(String serviceName, String groupName, List<String> clusters, boolean healthy) throws NacosException {
|
public List<Instance> selectInstances(String serviceName, String groupName, List<String> clusters, boolean healthy) throws NacosException {
|
||||||
return null;
|
return selectInstances(serviceName, groupName, clusters, healthy, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instance> selectInstances(String serviceName, List<String> clusters, boolean healthy,
|
public List<Instance> selectInstances(String serviceName, List<String> clusters, boolean healthy,
|
||||||
boolean subscribe) throws NacosException {
|
boolean subscribe) throws NacosException {
|
||||||
ServiceInfo serviceInfo;
|
return selectInstances(serviceName, Constants.DEFAULT_GROUP, clusters, healthy, subscribe);
|
||||||
if (subscribe) {
|
|
||||||
serviceInfo = hostReactor.getServiceInfo(serviceName, StringUtils.join(clusters, ","));
|
|
||||||
} else {
|
|
||||||
serviceInfo = hostReactor.getServiceInfoDirectlyFromServer(serviceName, StringUtils.join(clusters, ","));
|
|
||||||
}
|
|
||||||
return selectInstances(serviceInfo, healthy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Instance> selectInstances(String serviceName, String groupName, List<String> clusters, boolean healthy, boolean subscribe) throws NacosException {
|
public List<Instance> selectInstances(String serviceName, String groupName, List<String> clusters, boolean healthy, boolean subscribe) throws NacosException {
|
||||||
return null;
|
|
||||||
|
ServiceInfo serviceInfo;
|
||||||
|
if (subscribe) {
|
||||||
|
serviceInfo = hostReactor.getServiceInfo(groupName + Constants.SERVICE_INFO_SPLITER + serviceName, StringUtils.join(clusters, ","));
|
||||||
|
} else {
|
||||||
|
serviceInfo = hostReactor.getServiceInfoDirectlyFromServer(groupName + Constants.SERVICE_INFO_SPLITER + serviceName, StringUtils.join(clusters, ","));
|
||||||
|
}
|
||||||
|
return selectInstances(serviceInfo, healthy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -316,7 +317,7 @@ public class NacosNamingService implements NamingService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instance selectOneHealthyInstance(String serviceName, String groupName) throws NacosException {
|
public Instance selectOneHealthyInstance(String serviceName, String groupName) throws NacosException {
|
||||||
return null;
|
return selectOneHealthyInstance(serviceName, groupName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -326,7 +327,7 @@ public class NacosNamingService implements NamingService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instance selectOneHealthyInstance(String serviceName, String groupName, boolean subscribe) throws NacosException {
|
public Instance selectOneHealthyInstance(String serviceName, String groupName, boolean subscribe) throws NacosException {
|
||||||
return null;
|
return selectOneHealthyInstance(serviceName, groupName, new ArrayList<String>(), subscribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -336,78 +337,87 @@ public class NacosNamingService implements NamingService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instance selectOneHealthyInstance(String serviceName, String groupName, List<String> clusters) throws NacosException {
|
public Instance selectOneHealthyInstance(String serviceName, String groupName, List<String> clusters) throws NacosException {
|
||||||
return null;
|
return selectOneHealthyInstance(serviceName, groupName, clusters, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instance selectOneHealthyInstance(String serviceName, List<String> clusters, boolean subscribe)
|
public Instance selectOneHealthyInstance(String serviceName, List<String> clusters, boolean subscribe)
|
||||||
throws NacosException {
|
throws NacosException {
|
||||||
|
return selectOneHealthyInstance(serviceName, Constants.DEFAULT_GROUP, clusters, subscribe);
|
||||||
if (subscribe) {
|
|
||||||
return Balancer.RandomByWeight.selectHost(
|
|
||||||
hostReactor.getServiceInfo(serviceName, StringUtils.join(clusters, ",")));
|
|
||||||
} else {
|
|
||||||
return Balancer.RandomByWeight.selectHost(
|
|
||||||
hostReactor.getServiceInfoDirectlyFromServer(serviceName, StringUtils.join(clusters, ",")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instance selectOneHealthyInstance(String serviceName, String groupName, List<String> clusters, boolean subscribe) throws NacosException {
|
public Instance selectOneHealthyInstance(String serviceName, String groupName, List<String> clusters, boolean subscribe) throws NacosException {
|
||||||
return null;
|
|
||||||
|
if (subscribe) {
|
||||||
|
return Balancer.RandomByWeight.selectHost(
|
||||||
|
hostReactor.getServiceInfo(groupName + Constants.SERVICE_INFO_SPLITER + serviceName, StringUtils.join(clusters, ",")));
|
||||||
|
} else {
|
||||||
|
return Balancer.RandomByWeight.selectHost(
|
||||||
|
hostReactor.getServiceInfoDirectlyFromServer(groupName + Constants.SERVICE_INFO_SPLITER + serviceName, StringUtils.join(clusters, ",")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(String service, EventListener listener) {
|
public void subscribe(String serviceName, EventListener listener) throws NacosException {
|
||||||
eventDispatcher.addListener(hostReactor.getServiceInfo(service, StringUtils.EMPTY), StringUtils.EMPTY,
|
subscribe(serviceName, new ArrayList<String>(), listener);
|
||||||
listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(String serviceName, String groupName, EventListener listener) throws NacosException {
|
public void subscribe(String serviceName, String groupName, EventListener listener) throws NacosException {
|
||||||
|
subscribe(serviceName, groupName, new ArrayList<String>(), listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(String service, List<String> clusters, EventListener listener) {
|
public void subscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException {
|
||||||
eventDispatcher.addListener(hostReactor.getServiceInfo(service, StringUtils.join(clusters, ",")),
|
subscribe(serviceName, Constants.DEFAULT_GROUP, clusters, listener);
|
||||||
StringUtils.join(clusters, ","), listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(String serviceName, String groupName, List<String> clusters, EventListener listener) throws NacosException {
|
public void subscribe(String serviceName, String groupName, List<String> clusters, EventListener listener) throws NacosException {
|
||||||
|
eventDispatcher.addListener(hostReactor.getServiceInfo(groupName + Constants.SERVICE_INFO_SPLITER + serviceName,
|
||||||
|
StringUtils.join(clusters, ",")), StringUtils.join(clusters, ","), listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unsubscribe(String service, EventListener listener) {
|
public void unsubscribe(String serviceName, EventListener listener) throws NacosException {
|
||||||
eventDispatcher.removeListener(service, StringUtils.EMPTY, listener);
|
unsubscribe(serviceName, new ArrayList<String>(), listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unsubscribe(String serviceName, String groupName, EventListener listener) throws NacosException {
|
public void unsubscribe(String serviceName, String groupName, EventListener listener) throws NacosException {
|
||||||
|
unsubscribe(serviceName, groupName, new ArrayList<String>(), listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unsubscribe(String service, List<String> clusters, EventListener listener) {
|
public void unsubscribe(String serviceName, List<String> clusters, EventListener listener) throws NacosException {
|
||||||
eventDispatcher.removeListener(service, StringUtils.join(clusters, ","), listener);
|
unsubscribe(serviceName, Constants.DEFAULT_GROUP, clusters, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unsubscribe(String serviceName, String groupName, List<String> clusters, EventListener listener) throws NacosException {
|
public void unsubscribe(String serviceName, String groupName, List<String> clusters, EventListener listener) throws NacosException {
|
||||||
|
eventDispatcher.removeListener(groupName + Constants.SERVICE_INFO_SPLITER + serviceName, StringUtils.join(clusters, ","), listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListView<String> getServicesOfServer(int pageNo, int pageSize) throws NacosException {
|
public ListView<String> getServicesOfServer(int pageNo, int pageSize) throws NacosException {
|
||||||
return serverProxy.getServiceList(pageNo, pageSize);
|
return serverProxy.getServiceList(pageNo, pageSize, Constants.DEFAULT_GROUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListView<String> getServicesOfServer(int pageNo, int pageSize, String groupName) throws NacosException {
|
||||||
|
return getServicesOfServer(pageNo, pageSize, groupName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListView<String> getServicesOfServer(int pageNo, int pageSize, AbstractSelector selector)
|
public ListView<String> getServicesOfServer(int pageNo, int pageSize, AbstractSelector selector)
|
||||||
throws NacosException {
|
throws NacosException {
|
||||||
return serverProxy.getServiceList(pageNo, pageSize, selector);
|
return getServicesOfServer(pageNo, pageSize, Constants.DEFAULT_GROUP, selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListView<String> getServicesOfServer(int pageNo, int pageSize, String groupName, AbstractSelector selector) throws NacosException {
|
||||||
|
return serverProxy.getServiceList(pageNo, pageSize, groupName, selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package com.alibaba.nacos.client.naming.cache;
|
package com.alibaba.nacos.client.naming.cache;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||||
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
|
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
|
||||||
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
||||||
@ -44,7 +45,6 @@ public class DiskCache {
|
|||||||
makeSureCacheDirExists(dir);
|
makeSureCacheDirExists(dir);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File file = new File(dir, dom.getKeyEncoded());
|
File file = new File(dir, dom.getKeyEncoded());
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
// add another !file.exists() to avoid conflicted creating-new-file from multi-instances
|
// add another !file.exists() to avoid conflicted creating-new-file from multi-instances
|
||||||
@ -93,8 +93,8 @@ public class DiskCache {
|
|||||||
|
|
||||||
String fileName = URLDecoder.decode(file.getName(), "UTF-8");
|
String fileName = URLDecoder.decode(file.getName(), "UTF-8");
|
||||||
|
|
||||||
if (!(fileName.endsWith(ServiceInfo.SPLITER + "meta") || fileName.endsWith(
|
if (!(fileName.endsWith(Constants.SERVICE_INFO_SPLITER + "meta") || fileName.endsWith(
|
||||||
ServiceInfo.SPLITER + "special-url"))) {
|
Constants.SERVICE_INFO_SPLITER + "special-url"))) {
|
||||||
ServiceInfo dom = new ServiceInfo(fileName);
|
ServiceInfo dom = new ServiceInfo(fileName);
|
||||||
List<Instance> ips = new ArrayList<Instance>();
|
List<Instance> ips = new ArrayList<Instance>();
|
||||||
dom.setHosts(ips);
|
dom.setHosts(ips);
|
||||||
|
@ -251,16 +251,17 @@ public class NamingProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListView<String> getServiceList(int pageNo, int pageSize) throws NacosException {
|
public ListView<String> getServiceList(int pageNo, int pageSize, String groupName) throws NacosException {
|
||||||
return getServiceList(pageNo, pageSize, null);
|
return getServiceList(pageNo, pageSize, groupName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListView<String> getServiceList(int pageNo, int pageSize, AbstractSelector selector) throws NacosException {
|
public ListView<String> getServiceList(int pageNo, int pageSize, String groupName, AbstractSelector selector) throws NacosException {
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<String, String>(4);
|
Map<String, String> params = new HashMap<String, String>(4);
|
||||||
params.put("pageNo", String.valueOf(pageNo));
|
params.put("pageNo", String.valueOf(pageNo));
|
||||||
params.put("pageSize", String.valueOf(pageSize));
|
params.put("pageSize", String.valueOf(pageSize));
|
||||||
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
params.put(CommonParams.NAMESPACE_ID, namespaceId);
|
||||||
|
params.put(CommonParams.GROUP_NAME, groupName);
|
||||||
|
|
||||||
if (selector != null) {
|
if (selector != null) {
|
||||||
switch (SelectorType.valueOf(selector.getType())) {
|
switch (SelectorType.valueOf(selector.getType())) {
|
||||||
|
@ -204,9 +204,9 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<excludes>
|
<!--<excludes>-->
|
||||||
<exclude>application.properties</exclude>
|
<!--<exclude>application.properties</exclude>-->
|
||||||
</excludes>
|
<!--</excludes>-->
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.naming.acl;
|
package com.alibaba.nacos.naming.acl;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.CommonParams;
|
import com.alibaba.nacos.api.naming.CommonParams;
|
||||||
import com.alibaba.nacos.core.utils.WebUtils;
|
import com.alibaba.nacos.core.utils.WebUtils;
|
||||||
import com.alibaba.nacos.naming.core.Service;
|
import com.alibaba.nacos.naming.core.Service;
|
||||||
@ -67,7 +68,7 @@ public class AuthChecker {
|
|||||||
public void doAuth(Map<String, String[]> params, HttpServletRequest req) throws Exception {
|
public void doAuth(Map<String, String[]> params, HttpServletRequest req) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(req, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(req, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.optional(req, "name", "");
|
String serviceName = WebUtils.optional(req, "name", "");
|
||||||
if (StringUtils.isEmpty(serviceName)) {
|
if (StringUtils.isEmpty(serviceName)) {
|
||||||
serviceName = WebUtils.optional(req, "serviceName", "");
|
serviceName = WebUtils.optional(req, "serviceName", "");
|
||||||
|
@ -18,6 +18,7 @@ package com.alibaba.nacos.naming.consistency.persistent.raft;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.TypeReference;
|
import com.alibaba.fastjson.TypeReference;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.naming.consistency.ApplyAction;
|
import com.alibaba.nacos.naming.consistency.ApplyAction;
|
||||||
import com.alibaba.nacos.naming.consistency.Datum;
|
import com.alibaba.nacos.naming.consistency.Datum;
|
||||||
import com.alibaba.nacos.naming.consistency.KeyBuilder;
|
import com.alibaba.nacos.naming.consistency.KeyBuilder;
|
||||||
@ -145,11 +146,11 @@ public class RaftStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isBlank(serviceDatum.value.getGroupName())) {
|
if (StringUtils.isBlank(serviceDatum.value.getGroupName())) {
|
||||||
serviceDatum.value.setGroupName(UtilsAndCommons.DEFAULT_GROUP_NAME);
|
serviceDatum.value.setGroupName(Constants.DEFAULT_GROUP);
|
||||||
}
|
}
|
||||||
if (!serviceDatum.value.getName().contains(UtilsAndCommons.GROUP_SERVICE_CONNECTOR)) {
|
if (!serviceDatum.value.getName().contains(Constants.SERVICE_INFO_SPLITER)) {
|
||||||
serviceDatum.value.setName(UtilsAndCommons.DEFAULT_GROUP_NAME
|
serviceDatum.value.setName(Constants.DEFAULT_GROUP
|
||||||
+ UtilsAndCommons.GROUP_SERVICE_CONNECTOR + serviceDatum.value.getName());
|
+ Constants.SERVICE_INFO_SPLITER + serviceDatum.value.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return serviceDatum;
|
return serviceDatum;
|
||||||
|
@ -17,6 +17,7 @@ package com.alibaba.nacos.naming.controllers;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.CommonParams;
|
import com.alibaba.nacos.api.naming.CommonParams;
|
||||||
import com.alibaba.nacos.api.naming.pojo.Cluster;
|
import com.alibaba.nacos.api.naming.pojo.Cluster;
|
||||||
import com.alibaba.nacos.core.utils.WebUtils;
|
import com.alibaba.nacos.core.utils.WebUtils;
|
||||||
@ -52,7 +53,7 @@ public class CatalogController {
|
|||||||
public JSONObject serviceList(HttpServletRequest request) throws Exception {
|
public JSONObject serviceList(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
|
|
||||||
int page = Integer.parseInt(WebUtils.required(request, "startPg"));
|
int page = Integer.parseInt(WebUtils.required(request, "startPg"));
|
||||||
@ -99,7 +100,7 @@ public class CatalogController {
|
|||||||
public ServiceDetailView serviceDetail(HttpServletRequest request) throws Exception {
|
public ServiceDetailView serviceDetail(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
@ -133,7 +134,7 @@ public class CatalogController {
|
|||||||
public JSONObject instanceList(HttpServletRequest request) throws Exception {
|
public JSONObject instanceList(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
String clusterName = WebUtils.required(request, CommonParams.CLUSTER_NAME);
|
String clusterName = WebUtils.required(request, CommonParams.CLUSTER_NAME);
|
||||||
int page = Integer.parseInt(WebUtils.required(request, "startPg"));
|
int page = Integer.parseInt(WebUtils.required(request, "startPg"));
|
||||||
@ -176,7 +177,7 @@ public class CatalogController {
|
|||||||
public List<ServiceDetailInfo> listDetail(HttpServletRequest request) {
|
public List<ServiceDetailInfo> listDetail(HttpServletRequest request) {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
List<ServiceDetailInfo> serviceDetailInfoList = new ArrayList<>();
|
List<ServiceDetailInfo> serviceDetailInfoList = new ArrayList<>();
|
||||||
|
|
||||||
serviceManager
|
serviceManager
|
||||||
@ -203,7 +204,7 @@ public class CatalogController {
|
|||||||
public JSONObject rt4Service(HttpServletRequest request) {
|
public JSONObject rt4Service(HttpServletRequest request) {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
|
|
||||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||||
|
@ -17,6 +17,7 @@ package com.alibaba.nacos.naming.controllers;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.CommonParams;
|
import com.alibaba.nacos.api.naming.CommonParams;
|
||||||
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
||||||
import com.alibaba.nacos.core.utils.WebUtils;
|
import com.alibaba.nacos.core.utils.WebUtils;
|
||||||
@ -50,7 +51,7 @@ public class ClusterController {
|
|||||||
public String update(HttpServletRequest request) throws Exception {
|
public String update(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String clusterName = WebUtils.required(request, CommonParams.CLUSTER_NAME);
|
String clusterName = WebUtils.required(request, CommonParams.CLUSTER_NAME);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
String healthChecker = WebUtils.required(request, "healthChecker");
|
String healthChecker = WebUtils.required(request, "healthChecker");
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package com.alibaba.nacos.naming.controllers;
|
package com.alibaba.nacos.naming.controllers;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.CommonParams;
|
import com.alibaba.nacos.api.naming.CommonParams;
|
||||||
import com.alibaba.nacos.core.utils.WebUtils;
|
import com.alibaba.nacos.core.utils.WebUtils;
|
||||||
import com.alibaba.nacos.naming.boot.RunningConfig;
|
import com.alibaba.nacos.naming.boot.RunningConfig;
|
||||||
@ -71,7 +72,7 @@ public class HealthController {
|
|||||||
public String update(HttpServletRequest request) throws Exception {
|
public String update(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
String ip = WebUtils.required(request, "ip");
|
String ip = WebUtils.required(request, "ip");
|
||||||
int port = Integer.parseInt(WebUtils.required(request, "port"));
|
int port = Integer.parseInt(WebUtils.required(request, "port"));
|
||||||
|
@ -18,6 +18,7 @@ package com.alibaba.nacos.naming.controllers;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.CommonParams;
|
import com.alibaba.nacos.api.naming.CommonParams;
|
||||||
import com.alibaba.nacos.core.utils.WebUtils;
|
import com.alibaba.nacos.core.utils.WebUtils;
|
||||||
import com.alibaba.nacos.naming.boot.RunningConfig;
|
import com.alibaba.nacos.naming.boot.RunningConfig;
|
||||||
@ -95,7 +96,7 @@ public class InstanceController {
|
|||||||
public String register(HttpServletRequest request) throws Exception {
|
public String register(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, Constants.DEFAULT_NAMESPACE_ID);
|
||||||
|
|
||||||
serviceManager.registerInstance(namespaceId, serviceName, parseInstance(request));
|
serviceManager.registerInstance(namespaceId, serviceName, parseInstance(request));
|
||||||
return "ok";
|
return "ok";
|
||||||
@ -106,7 +107,7 @@ public class InstanceController {
|
|||||||
public String deregister(HttpServletRequest request) throws Exception {
|
public String deregister(HttpServletRequest request) throws Exception {
|
||||||
Instance instance = getIPAddress(request);
|
Instance instance = getIPAddress(request);
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
|
|
||||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||||
@ -119,10 +120,10 @@ public class InstanceController {
|
|||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = {"/instance/update", "instance"}, method = RequestMethod.PUT)
|
@RequestMapping(value = "/instance", method = RequestMethod.PUT)
|
||||||
public String update(HttpServletRequest request) throws Exception {
|
public String update(HttpServletRequest request) throws Exception {
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, Constants.DEFAULT_NAMESPACE_ID);
|
||||||
|
|
||||||
serviceManager.updateInstance(namespaceId, serviceName, parseInstance(request));
|
serviceManager.updateInstance(namespaceId, serviceName, parseInstance(request));
|
||||||
return "ok";
|
return "ok";
|
||||||
@ -132,7 +133,7 @@ public class InstanceController {
|
|||||||
public JSONObject list(HttpServletRequest request) throws Exception {
|
public JSONObject list(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
|
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
String agent = request.getHeader("Client-Version");
|
String agent = request.getHeader("Client-Version");
|
||||||
@ -158,7 +159,7 @@ public class InstanceController {
|
|||||||
public JSONObject detail(HttpServletRequest request) throws Exception {
|
public JSONObject detail(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
String cluster = WebUtils.optional(request, CommonParams.CLUSTER_NAME, UtilsAndCommons.DEFAULT_CLUSTER_NAME);
|
String cluster = WebUtils.optional(request, CommonParams.CLUSTER_NAME, UtilsAndCommons.DEFAULT_CLUSTER_NAME);
|
||||||
String ip = WebUtils.required(request, "ip");
|
String ip = WebUtils.required(request, "ip");
|
||||||
@ -209,7 +210,7 @@ public class InstanceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String beat = WebUtils.required(request, "beat");
|
String beat = WebUtils.required(request, "beat");
|
||||||
RsInfo clientBeat = JSON.parseObject(beat, RsInfo.class);
|
RsInfo clientBeat = JSON.parseObject(beat, RsInfo.class);
|
||||||
if (StringUtils.isBlank(clientBeat.getCluster())) {
|
if (StringUtils.isBlank(clientBeat.getCluster())) {
|
||||||
@ -291,7 +292,7 @@ public class InstanceController {
|
|||||||
namespaceId = key.split(UtilsAndCommons.NAMESPACE_SERVICE_CONNECTOR)[0];
|
namespaceId = key.split(UtilsAndCommons.NAMESPACE_SERVICE_CONNECTOR)[0];
|
||||||
serviceName = key.split(UtilsAndCommons.NAMESPACE_SERVICE_CONNECTOR)[1];
|
serviceName = key.split(UtilsAndCommons.NAMESPACE_SERVICE_CONNECTOR)[1];
|
||||||
} else {
|
} else {
|
||||||
namespaceId = UtilsAndCommons.DEFAULT_NAMESPACE_ID;
|
namespaceId = Constants.DEFAULT_NAMESPACE_ID;
|
||||||
serviceName = key;
|
serviceName = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ package com.alibaba.nacos.naming.controllers;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.CommonParams;
|
import com.alibaba.nacos.api.naming.CommonParams;
|
||||||
import com.alibaba.nacos.core.utils.SystemUtils;
|
import com.alibaba.nacos.core.utils.SystemUtils;
|
||||||
import com.alibaba.nacos.core.utils.WebUtils;
|
import com.alibaba.nacos.core.utils.WebUtils;
|
||||||
@ -154,7 +155,7 @@ public class OperatorController {
|
|||||||
@RequestMapping("/getResponsibleServer4Dom")
|
@RequestMapping("/getResponsibleServer4Dom")
|
||||||
public JSONObject getResponsibleServer4Dom(HttpServletRequest request) {
|
public JSONObject getResponsibleServer4Dom(HttpServletRequest request) {
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String dom = WebUtils.required(request, "dom");
|
String dom = WebUtils.required(request, "dom");
|
||||||
Service service = serviceManager.getService(namespaceId, dom);
|
Service service = serviceManager.getService(namespaceId, dom);
|
||||||
|
|
||||||
@ -181,7 +182,7 @@ public class OperatorController {
|
|||||||
@RequestMapping("/responsible")
|
@RequestMapping("/responsible")
|
||||||
public JSONObject responsible(HttpServletRequest request) {
|
public JSONObject responsible(HttpServletRequest request) {
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String dom = WebUtils.required(request, "dom");
|
String dom = WebUtils.required(request, "dom");
|
||||||
Service service = serviceManager.getService(namespaceId, dom);
|
Service service = serviceManager.getService(namespaceId, dom);
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package com.alibaba.nacos.naming.controllers;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.CommonParams;
|
import com.alibaba.nacos.api.naming.CommonParams;
|
||||||
import com.alibaba.nacos.api.selector.SelectorType;
|
import com.alibaba.nacos.api.selector.SelectorType;
|
||||||
import com.alibaba.nacos.core.utils.WebUtils;
|
import com.alibaba.nacos.core.utils.WebUtils;
|
||||||
@ -61,7 +62,7 @@ public class ServiceController {
|
|||||||
public String create(HttpServletRequest request) throws Exception {
|
public String create(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
|
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ public class ServiceController {
|
|||||||
public String remove(HttpServletRequest request) throws Exception {
|
public String remove(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
|
|
||||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||||
@ -120,7 +121,7 @@ public class ServiceController {
|
|||||||
public JSONObject detail(HttpServletRequest request) throws Exception {
|
public JSONObject detail(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
|
|
||||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||||
@ -156,7 +157,8 @@ public class ServiceController {
|
|||||||
int pageNo = NumberUtils.toInt(WebUtils.required(request, "pageNo"));
|
int pageNo = NumberUtils.toInt(WebUtils.required(request, "pageNo"));
|
||||||
int pageSize = NumberUtils.toInt(WebUtils.required(request, "pageSize"));
|
int pageSize = NumberUtils.toInt(WebUtils.required(request, "pageSize"));
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
|
String groupName = WebUtils.optional(request, CommonParams.GROUP_NAME, Constants.DEFAULT_GROUP);
|
||||||
String selectorString = WebUtils.optional(request, "selector", StringUtils.EMPTY);
|
String selectorString = WebUtils.optional(request, "selector", StringUtils.EMPTY);
|
||||||
|
|
||||||
List<String> serviceNameList = serviceManager.getAllServiceNameList(namespaceId);
|
List<String> serviceNameList = serviceManager.getAllServiceNameList(namespaceId);
|
||||||
@ -169,6 +171,15 @@ public class ServiceController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Iterator<String> iterator = serviceNameList.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
String serviceName = iterator.next();
|
||||||
|
if (!serviceName.startsWith(groupName + Constants.SERVICE_INFO_SPLITER)) {
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(selectorString)) {
|
if (StringUtils.isNotBlank(selectorString)) {
|
||||||
|
|
||||||
JSONObject selectorJson = JSON.parseObject(selectorString);
|
JSONObject selectorJson = JSON.parseObject(selectorString);
|
||||||
@ -211,6 +222,10 @@ public class ServiceController {
|
|||||||
end = serviceNameList.size();
|
end = serviceNameList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = start; i < end; i++) {
|
||||||
|
serviceNameList.add(i, serviceNameList.get(i).replace(groupName + Constants.SERVICE_INFO_SPLITER, ""));
|
||||||
|
}
|
||||||
|
|
||||||
result.put("doms", serviceNameList.subList(start, end));
|
result.put("doms", serviceNameList.subList(start, end));
|
||||||
result.put("count", serviceNameList.size());
|
result.put("count", serviceNameList.size());
|
||||||
|
|
||||||
@ -222,7 +237,7 @@ public class ServiceController {
|
|||||||
public String update(HttpServletRequest request) throws Exception {
|
public String update(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
float protectThreshold = NumberUtils.toFloat(WebUtils.required(request, "protectThreshold"));
|
float protectThreshold = NumberUtils.toFloat(WebUtils.required(request, "protectThreshold"));
|
||||||
String metadata = WebUtils.optional(request, "metadata", StringUtils.EMPTY);
|
String metadata = WebUtils.optional(request, "metadata", StringUtils.EMPTY);
|
||||||
@ -331,7 +346,7 @@ public class ServiceController {
|
|||||||
public JSONObject checksum(HttpServletRequest request) {
|
public JSONObject checksum(HttpServletRequest request) {
|
||||||
|
|
||||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||||
UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
Constants.DEFAULT_NAMESPACE_ID);
|
||||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package com.alibaba.nacos.naming.core;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
import com.alibaba.nacos.naming.cluster.ServerListManager;
|
import com.alibaba.nacos.naming.cluster.ServerListManager;
|
||||||
import com.alibaba.nacos.naming.cluster.ServerMode;
|
import com.alibaba.nacos.naming.cluster.ServerMode;
|
||||||
@ -112,12 +113,12 @@ public class ServiceManager implements RecordListener<Service> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean interests(String key) {
|
public boolean interests(String key) {
|
||||||
return KeyBuilder.matchServiceMetaKey(key);
|
return KeyBuilder.matchServiceMetaKey(key) && !KeyBuilder.matchSwitchKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchUnlistenKey(String key) {
|
public boolean matchUnlistenKey(String key) {
|
||||||
return KeyBuilder.matchServiceMetaKey(key);
|
return KeyBuilder.matchServiceMetaKey(key) && !KeyBuilder.matchSwitchKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -129,7 +130,7 @@ public class ServiceManager implements RecordListener<Service> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isBlank(service.getNamespaceId())) {
|
if (StringUtils.isBlank(service.getNamespaceId())) {
|
||||||
service.setNamespaceId(UtilsAndCommons.DEFAULT_NAMESPACE_ID);
|
service.setNamespaceId(Constants.DEFAULT_NAMESPACE_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
Loggers.RAFT.info("[RAFT-NOTIFIER] datum is changed, key: {}, value: {}", key, service);
|
Loggers.RAFT.info("[RAFT-NOTIFIER] datum is changed, key: {}, value: {}", key, service);
|
||||||
@ -332,7 +333,7 @@ public class ServiceManager implements RecordListener<Service> {
|
|||||||
service = new Service();
|
service = new Service();
|
||||||
service.setName(serviceName);
|
service.setName(serviceName);
|
||||||
service.setNamespaceId(namespaceId);
|
service.setNamespaceId(namespaceId);
|
||||||
service.setGroupName(UtilsAndCommons.DEFAULT_GROUP_NAME);
|
service.setGroupName(Constants.DEFAULT_GROUP);
|
||||||
// now validate the service. if failed, exception will be thrown
|
// now validate the service. if failed, exception will be thrown
|
||||||
service.setLastModifiedMillis(System.currentTimeMillis());
|
service.setLastModifiedMillis(System.currentTimeMillis());
|
||||||
service.recalculateChecksum();
|
service.recalculateChecksum();
|
||||||
@ -600,7 +601,7 @@ public class ServiceManager implements RecordListener<Service> {
|
|||||||
public Map<String, String> serviceName2Checksum = new HashMap<String, String>();
|
public Map<String, String> serviceName2Checksum = new HashMap<String, String>();
|
||||||
|
|
||||||
public ServiceChecksum() {
|
public ServiceChecksum() {
|
||||||
this.namespaceId = UtilsAndCommons.DEFAULT_NAMESPACE_ID;
|
this.namespaceId = Constants.DEFAULT_NAMESPACE_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceChecksum(String namespaceId) {
|
public ServiceChecksum(String namespaceId) {
|
||||||
|
@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.alibaba.nacos.api.exception.NacosException;
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
import com.alibaba.nacos.naming.cluster.ServerMode;
|
import com.alibaba.nacos.naming.cluster.ServerMode;
|
||||||
import com.alibaba.nacos.naming.consistency.ConsistencyService;
|
import com.alibaba.nacos.naming.consistency.ConsistencyService;
|
||||||
|
import com.alibaba.nacos.naming.consistency.KeyBuilder;
|
||||||
import com.alibaba.nacos.naming.consistency.RecordListener;
|
import com.alibaba.nacos.naming.consistency.RecordListener;
|
||||||
import com.alibaba.nacos.naming.consistency.Datum;
|
import com.alibaba.nacos.naming.consistency.Datum;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -400,12 +401,12 @@ public class SwitchManager implements RecordListener<SwitchDomain> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean interests(String key) {
|
public boolean interests(String key) {
|
||||||
return key.contains(UtilsAndCommons.SWITCH_DOMAIN_NAME);
|
return KeyBuilder.matchSwitchKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchUnlistenKey(String key) {
|
public boolean matchUnlistenKey(String key) {
|
||||||
return key.contains(UtilsAndCommons.SWITCH_DOMAIN_NAME);
|
return KeyBuilder.matchSwitchKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,6 +20,7 @@ import com.alibaba.fastjson.TypeReference;
|
|||||||
import com.alibaba.fastjson.parser.ParserConfig;
|
import com.alibaba.fastjson.parser.ParserConfig;
|
||||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
||||||
import com.alibaba.nacos.naming.exception.NacosException;
|
import com.alibaba.nacos.naming.exception.NacosException;
|
||||||
import com.alibaba.nacos.naming.healthcheck.JsonAdapter;
|
import com.alibaba.nacos.naming.healthcheck.JsonAdapter;
|
||||||
@ -111,16 +112,10 @@ public class UtilsAndCommons {
|
|||||||
|
|
||||||
public static final String NAMESPACE_SERVICE_CONNECTOR = "##";
|
public static final String NAMESPACE_SERVICE_CONNECTOR = "##";
|
||||||
|
|
||||||
public static final String GROUP_SERVICE_CONNECTOR = "@@";
|
|
||||||
|
|
||||||
public static final String UPDATE_INSTANCE_ACTION_ADD = "add";
|
public static final String UPDATE_INSTANCE_ACTION_ADD = "add";
|
||||||
|
|
||||||
public static final String UPDATE_INSTANCE_ACTION_REMOVE = "remove";
|
public static final String UPDATE_INSTANCE_ACTION_REMOVE = "remove";
|
||||||
|
|
||||||
public static final String DEFAULT_NAMESPACE_ID = "public";
|
|
||||||
|
|
||||||
public static final String DEFAULT_GROUP_NAME = "DEFAULT_GROUP";
|
|
||||||
|
|
||||||
public static final String DATA_BASE_DIR = NACOS_HOME + File.separator + "data" + File.separator + "naming";
|
public static final String DATA_BASE_DIR = NACOS_HOME + File.separator + "data" + File.separator + "naming";
|
||||||
|
|
||||||
public static final ScheduledExecutorService DOMAIN_SYNCHRONIZATION_EXECUTOR;
|
public static final ScheduledExecutorService DOMAIN_SYNCHRONIZATION_EXECUTOR;
|
||||||
@ -245,16 +240,16 @@ public class UtilsAndCommons {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getServiceName(String serviceNameWithGroup) {
|
public static String getServiceName(String serviceNameWithGroup) {
|
||||||
if (!serviceNameWithGroup.contains(GROUP_SERVICE_CONNECTOR)) {
|
if (!serviceNameWithGroup.contains(Constants.SERVICE_INFO_SPLITER)) {
|
||||||
return serviceNameWithGroup;
|
return serviceNameWithGroup;
|
||||||
}
|
}
|
||||||
return serviceNameWithGroup.split(GROUP_SERVICE_CONNECTOR)[1];
|
return serviceNameWithGroup.split(Constants.SERVICE_INFO_SPLITER)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getGroupName(String serviceNameWithGroup) {
|
public static String getGroupName(String serviceNameWithGroup) {
|
||||||
if (!serviceNameWithGroup.contains(GROUP_SERVICE_CONNECTOR)) {
|
if (!serviceNameWithGroup.contains(Constants.SERVICE_INFO_SPLITER)) {
|
||||||
return DEFAULT_GROUP_NAME;
|
return Constants.DEFAULT_GROUP;
|
||||||
}
|
}
|
||||||
return serviceNameWithGroup.split(GROUP_SERVICE_CONNECTOR)[0];
|
return serviceNameWithGroup.split(Constants.SERVICE_INFO_SPLITER)[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.naming.web;
|
package com.alibaba.nacos.naming.web;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.CommonParams;
|
import com.alibaba.nacos.api.naming.CommonParams;
|
||||||
import com.alibaba.nacos.naming.core.DistroMapper;
|
import com.alibaba.nacos.naming.core.DistroMapper;
|
||||||
import com.alibaba.nacos.naming.misc.HttpClient;
|
import com.alibaba.nacos.naming.misc.HttpClient;
|
||||||
@ -112,11 +113,13 @@ public class DistroFilter implements Filter {
|
|||||||
// user groupName@@serviceName as new service name:
|
// user groupName@@serviceName as new service name:
|
||||||
String groupName = req.getParameter(CommonParams.GROUP_NAME);
|
String groupName = req.getParameter(CommonParams.GROUP_NAME);
|
||||||
if (StringUtils.isBlank(groupName)) {
|
if (StringUtils.isBlank(groupName)) {
|
||||||
groupName = UtilsAndCommons.DEFAULT_GROUP_NAME;
|
groupName = Constants.DEFAULT_GROUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
OverrideParameterRequestWrapper requestWrapper = OverrideParameterRequestWrapper.buildRequest(req);
|
OverrideParameterRequestWrapper requestWrapper = OverrideParameterRequestWrapper.buildRequest(req);
|
||||||
requestWrapper.addParameter(CommonParams.SERVICE_NAME, groupName + UtilsAndCommons.GROUP_SERVICE_CONNECTOR + serviceName);
|
if (StringUtils.isNotBlank(serviceName) && !serviceName.contains(Constants.SERVICE_INFO_SPLITER)) {
|
||||||
|
requestWrapper.addParameter(CommonParams.SERVICE_NAME, groupName + Constants.SERVICE_INFO_SPLITER + serviceName);
|
||||||
|
}
|
||||||
filterChain.doFilter(requestWrapper, resp);
|
filterChain.doFilter(requestWrapper, resp);
|
||||||
} catch (AccessControlException e) {
|
} catch (AccessControlException e) {
|
||||||
resp.sendError(HttpServletResponse.SC_FORBIDDEN, "access denied: " + UtilsAndCommons.getAllExceptionMsg(e));
|
resp.sendError(HttpServletResponse.SC_FORBIDDEN, "access denied: " + UtilsAndCommons.getAllExceptionMsg(e));
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.naming.web;
|
package com.alibaba.nacos.naming.web;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.naming.boot.RunningConfig;
|
||||||
import com.alibaba.nacos.naming.controllers.*;
|
import com.alibaba.nacos.naming.controllers.*;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -50,7 +51,7 @@ public class FilterBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Method getMethod(String httpMethod, String path) {
|
public Method getMethod(String httpMethod, String path) {
|
||||||
String key = httpMethod + "-->" + path;
|
String key = httpMethod + "-->" + path.replace("/nacos", "");
|
||||||
return methodCache.get(key);
|
return methodCache.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public class TrafficReviseFilter implements Filter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.getWriter().write("service is " + serverStatusManager.getServerStatus().name() + " now, please try again later!");
|
resp.getWriter().write("server is " + serverStatusManager.getServerStatus().name() + " now, please try again later!");
|
||||||
resp.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
|
resp.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,3 +25,9 @@ server.tomcat.accesslog.enabled=true
|
|||||||
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
||||||
# default current work dir
|
# default current work dir
|
||||||
server.tomcat.basedir=
|
server.tomcat.basedir=
|
||||||
|
|
||||||
|
nacos.naming.partition.taskDispatchThreadCount=10
|
||||||
|
nacos.naming.partition.taskDispatchPeriod=200
|
||||||
|
nacos.naming.partition.batchSyncKeyCount=1000
|
||||||
|
nacos.naming.partition.initDataRatio=0.9
|
||||||
|
nacos.naming.partition.syncRetryDelay=5000
|
||||||
|
@ -18,6 +18,7 @@ package com.alibaba.nacos.naming.controllers;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.naming.BaseTest;
|
import com.alibaba.nacos.naming.BaseTest;
|
||||||
import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeerSet;
|
import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeerSet;
|
||||||
import com.alibaba.nacos.naming.core.Cluster;
|
import com.alibaba.nacos.naming.core.Cluster;
|
||||||
@ -84,7 +85,7 @@ public class InstanceControllerTest extends BaseTest {
|
|||||||
ipList.add(instance);
|
ipList.add(instance);
|
||||||
service.updateIPs(ipList, false);
|
service.updateIPs(ipList, false);
|
||||||
|
|
||||||
Mockito.when(serviceManager.getService(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.1")).thenReturn(service);
|
Mockito.when(serviceManager.getService(Constants.DEFAULT_NAMESPACE_ID, "nacos.test.1")).thenReturn(service);
|
||||||
|
|
||||||
MockHttpServletRequestBuilder builder =
|
MockHttpServletRequestBuilder builder =
|
||||||
MockMvcRequestBuilders.put("/naming/instance")
|
MockMvcRequestBuilders.put("/naming/instance")
|
||||||
@ -129,7 +130,7 @@ public class InstanceControllerTest extends BaseTest {
|
|||||||
ipList.add(instance);
|
ipList.add(instance);
|
||||||
service.updateIPs(ipList, false);
|
service.updateIPs(ipList, false);
|
||||||
|
|
||||||
Mockito.when(serviceManager.getService(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.1")).thenReturn(service);
|
Mockito.when(serviceManager.getService(Constants.DEFAULT_NAMESPACE_ID, "nacos.test.1")).thenReturn(service);
|
||||||
|
|
||||||
MockHttpServletRequestBuilder builder =
|
MockHttpServletRequestBuilder builder =
|
||||||
MockMvcRequestBuilders.get("/v1/ns/instances")
|
MockMvcRequestBuilders.get("/v1/ns/instances")
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.naming.core;
|
package com.alibaba.nacos.naming.core;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.naming.BaseTest;
|
import com.alibaba.nacos.naming.BaseTest;
|
||||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@ -44,7 +45,7 @@ public class DomainsManagerTest extends BaseTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void easyRemoveDom() throws Exception {
|
public void easyRemoveDom() throws Exception {
|
||||||
serviceManager.easyRemoveService(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.1");
|
serviceManager.easyRemoveService(Constants.DEFAULT_NAMESPACE_ID, "nacos.test.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -52,9 +53,9 @@ public class DomainsManagerTest extends BaseTest {
|
|||||||
Service service = new Service();
|
Service service = new Service();
|
||||||
service.setName("nacos.test.1");
|
service.setName("nacos.test.1");
|
||||||
|
|
||||||
serviceManager.chooseServiceMap(UtilsAndCommons.DEFAULT_NAMESPACE_ID).put("nacos.test.1", service);
|
serviceManager.chooseServiceMap(Constants.DEFAULT_NAMESPACE_ID).put("nacos.test.1", service);
|
||||||
|
|
||||||
List<Service> list = serviceManager.searchServices(UtilsAndCommons.DEFAULT_NAMESPACE_ID, "nacos.test.*");
|
List<Service> list = serviceManager.searchServices(Constants.DEFAULT_NAMESPACE_ID, "nacos.test.*");
|
||||||
Assert.assertNotNull(list);
|
Assert.assertNotNull(list);
|
||||||
Assert.assertEquals(1, list.size());
|
Assert.assertEquals(1, list.size());
|
||||||
Assert.assertEquals("nacos.test.1", list.get(0).getName());
|
Assert.assertEquals("nacos.test.1", list.get(0).getName());
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.test.naming;
|
package com.alibaba.nacos.test.naming;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.api.naming.NamingFactory;
|
import com.alibaba.nacos.api.naming.NamingFactory;
|
||||||
import com.alibaba.nacos.api.naming.NamingService;
|
import com.alibaba.nacos.api.naming.NamingService;
|
||||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||||
@ -55,10 +56,19 @@ public class AutoDeregisterInstance_ITCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
|
||||||
|
NamingBase.prepareServer(port);
|
||||||
|
|
||||||
if (naming == null) {
|
if (naming == null) {
|
||||||
//TimeUnit.SECONDS.sleep(10);
|
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
||||||
// naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
}
|
||||||
naming = NamingFactory.createNamingService("11.239.112.161:8848,11.239.113.204:8848,11.239.114.187:8848");
|
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +94,7 @@ public class AutoDeregisterInstance_ITCase {
|
|||||||
|
|
||||||
NacosNamingService namingServiceImpl = (NacosNamingService) naming;
|
NacosNamingService namingServiceImpl = (NacosNamingService) naming;
|
||||||
|
|
||||||
namingServiceImpl.getBeatReactor().removeBeatInfo(serviceName, "DEFAULT_GROUP", "127.0.0.1", TEST_PORT);
|
namingServiceImpl.getBeatReactor().removeBeatInfo(serviceName, Constants.DEFAULT_GROUP, "127.0.0.1", TEST_PORT);
|
||||||
|
|
||||||
verifyInstanceList(instances, 1, serviceName);
|
verifyInstanceList(instances, 1, serviceName);
|
||||||
instances = naming.getAllInstances(serviceName);
|
instances = naming.getAllInstances(serviceName);
|
||||||
|
@ -18,7 +18,6 @@ package com.alibaba.nacos.test.naming;
|
|||||||
import com.alibaba.nacos.api.naming.NamingFactory;
|
import com.alibaba.nacos.api.naming.NamingFactory;
|
||||||
import com.alibaba.nacos.api.naming.NamingService;
|
import com.alibaba.nacos.api.naming.NamingService;
|
||||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||||
import com.alibaba.nacos.client.naming.NacosNamingService;
|
|
||||||
import com.alibaba.nacos.naming.NamingApp;
|
import com.alibaba.nacos.naming.NamingApp;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -53,12 +52,20 @@ public class DeregisterInstance_ITCase {
|
|||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
|
||||||
NamingBase.setServerStatusUp(port);
|
NamingBase.prepareServer(port);
|
||||||
|
|
||||||
if (naming == null) {
|
if (naming == null) {
|
||||||
//TimeUnit.SECONDS.sleep(10);
|
//TimeUnit.SECONDS.sleep(10);
|
||||||
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +76,7 @@ public class DeregisterInstance_ITCase {
|
|||||||
@Test
|
@Test
|
||||||
public void dregDomTest() throws Exception {
|
public void dregDomTest() throws Exception {
|
||||||
String serviceName = randomDomainName();
|
String serviceName = randomDomainName();
|
||||||
|
System.out.println(serviceName);
|
||||||
naming.registerInstance(serviceName, "127.0.0.1", TEST_PORT);
|
naming.registerInstance(serviceName, "127.0.0.1", TEST_PORT);
|
||||||
naming.registerInstance(serviceName, "127.0.0.2", TEST_PORT);
|
naming.registerInstance(serviceName, "127.0.0.2", TEST_PORT);
|
||||||
|
|
||||||
@ -77,7 +84,7 @@ public class DeregisterInstance_ITCase {
|
|||||||
verifyInstanceList(instances, 2, serviceName);
|
verifyInstanceList(instances, 2, serviceName);
|
||||||
|
|
||||||
instances = naming.getAllInstances(serviceName);
|
instances = naming.getAllInstances(serviceName);
|
||||||
Assert.assertEquals(instances.size(), 2);
|
Assert.assertEquals(2, instances.size());
|
||||||
|
|
||||||
naming.deregisterInstance(serviceName, "127.0.0.1", TEST_PORT);
|
naming.deregisterInstance(serviceName, "127.0.0.1", TEST_PORT);
|
||||||
|
|
||||||
|
@ -44,7 +44,19 @@ public class MultiTenant_ITCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
|
||||||
|
NamingBase.prepareServer(port);
|
||||||
|
|
||||||
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.put(PropertyKeyConst.NAMESPACE, "namespace-1");
|
properties.put(PropertyKeyConst.NAMESPACE, "namespace-1");
|
||||||
properties.put(PropertyKeyConst.SERVER_ADDR, "127.0.0.1" + ":" + port);
|
properties.put(PropertyKeyConst.SERVER_ADDR, "127.0.0.1" + ":" + port);
|
||||||
|
@ -61,11 +61,22 @@ public class MultiTenant_InstanceAPI_ITCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
|
||||||
|
NamingBase.prepareServer(port);
|
||||||
|
|
||||||
String url = String.format("http://localhost:%d/", port);
|
String url = String.format("http://localhost:%d/", port);
|
||||||
this.base = new URL(url);
|
this.base = new URL(url);
|
||||||
|
|
||||||
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.put(PropertyKeyConst.NAMESPACE, "namespace-1");
|
properties.put(PropertyKeyConst.NAMESPACE, "namespace-1");
|
||||||
properties.put(PropertyKeyConst.SERVER_ADDR, "127.0.0.1" + ":" + port);
|
properties.put(PropertyKeyConst.SERVER_ADDR, "127.0.0.1" + ":" + port);
|
||||||
@ -221,10 +232,10 @@ public class MultiTenant_InstanceAPI_ITCase {
|
|||||||
.appendParam("serviceName", serviceName)
|
.appendParam("serviceName", serviceName)
|
||||||
.appendParam("ip", "33.33.33.33")
|
.appendParam("ip", "33.33.33.33")
|
||||||
.appendParam("port", "8888")
|
.appendParam("port", "8888")
|
||||||
.appendParam("namespaceId", "namespace-1") //新增
|
|
||||||
.done(),
|
.done(),
|
||||||
String.class,
|
String.class,
|
||||||
HttpMethod.PUT);
|
HttpMethod.PUT);
|
||||||
|
System.out.println(response.getBody());
|
||||||
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
|
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
|
||||||
|
|
||||||
response = request("/nacos/v1/ns/instance/list",
|
response = request("/nacos/v1/ns/instance/list",
|
||||||
@ -235,7 +246,7 @@ public class MultiTenant_InstanceAPI_ITCase {
|
|||||||
String.class);
|
String.class);
|
||||||
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
|
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
|
||||||
JSONObject json = JSON.parseObject(response.getBody());
|
JSONObject json = JSON.parseObject(response.getBody());
|
||||||
Assert.assertEquals(2, json.getJSONArray("hosts").size());
|
Assert.assertEquals(1, json.getJSONArray("hosts").size());
|
||||||
|
|
||||||
//namespace-2个数
|
//namespace-2个数
|
||||||
response = request("/nacos/v1/ns/instance/list",
|
response = request("/nacos/v1/ns/instance/list",
|
||||||
|
@ -156,7 +156,7 @@ public class NamingBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setServerStatusUp(int localPort) {
|
public static void prepareServer(int localPort) {
|
||||||
String url = "http://127.0.0.1:" + localPort + "/nacos/v1/ns/operator/switches?entry=overriddenServerStatus&value=UP";
|
String url = "http://127.0.0.1:" + localPort + "/nacos/v1/ns/operator/switches?entry=overriddenServerStatus&value=UP";
|
||||||
List<String> headers = new ArrayList<String>();
|
List<String> headers = new ArrayList<String>();
|
||||||
headers.add("User-Agent");
|
headers.add("User-Agent");
|
||||||
@ -165,5 +165,15 @@ public class NamingBase {
|
|||||||
HttpClient.request(url, headers, new HashMap<String, String>(), "UTF-8", "PUT");
|
HttpClient.request(url, headers, new HashMap<String, String>(), "UTF-8", "PUT");
|
||||||
|
|
||||||
Assert.assertEquals(HttpStatus.SC_OK, result.code);
|
Assert.assertEquals(HttpStatus.SC_OK, result.code);
|
||||||
|
|
||||||
|
|
||||||
|
url = "http://127.0.0.1:" + localPort + "/nacos/v1/ns/operator/switches?entry=serverMode&value=AP";
|
||||||
|
headers = new ArrayList<String>();
|
||||||
|
headers.add("User-Agent");
|
||||||
|
headers.add("Nacos-Server");
|
||||||
|
result =
|
||||||
|
HttpClient.request(url, headers, new HashMap<String, String>(), "UTF-8", "PUT");
|
||||||
|
|
||||||
|
Assert.assertEquals(HttpStatus.SC_OK, result.code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,10 +53,21 @@ public class RegisterInstance_ITCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
|
||||||
|
NamingBase.prepareServer(port);
|
||||||
|
|
||||||
if (naming == null) {
|
if (naming == null) {
|
||||||
TimeUnit.SECONDS.sleep(10);
|
TimeUnit.SECONDS.sleep(10);
|
||||||
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -508,7 +508,7 @@ public class RestAPI_ITCase {
|
|||||||
|
|
||||||
ResponseEntity<String> response = request("/nacos/v1/ns/api/reCalculateCheckSum4Dom",
|
ResponseEntity<String> response = request("/nacos/v1/ns/api/reCalculateCheckSum4Dom",
|
||||||
Params.newParams()
|
Params.newParams()
|
||||||
.appendParam(CommonParams.NAMESPACE_ID, UtilsAndCommons.DEFAULT_NAMESPACE_ID)
|
.appendParam(CommonParams.NAMESPACE_ID, Constants.DEFAULT_NAMESPACE_ID)
|
||||||
.appendParam("dom", NamingBase.TEST_DOM_1)
|
.appendParam("dom", NamingBase.TEST_DOM_1)
|
||||||
.done(),
|
.done(),
|
||||||
String.class);
|
String.class);
|
||||||
|
@ -56,10 +56,18 @@ public class SelectInstances_ITCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
NamingBase.prepareServer(port);
|
||||||
if (naming == null) {
|
if (naming == null) {
|
||||||
//TimeUnit.SECONDS.sleep(10);
|
//TimeUnit.SECONDS.sleep(10);
|
||||||
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
||||||
}
|
}
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,10 +50,18 @@ public class SelectOneHealthyInstance_ITCase {
|
|||||||
private int port;
|
private int port;
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception{
|
public void init() throws Exception{
|
||||||
|
NamingBase.prepareServer(port);
|
||||||
if (naming == null) {
|
if (naming == null) {
|
||||||
//TimeUnit.SECONDS.sleep(10);
|
//TimeUnit.SECONDS.sleep(10);
|
||||||
naming = NamingFactory.createNamingService("127.0.0.1"+":"+port);
|
naming = NamingFactory.createNamingService("127.0.0.1"+":"+port);
|
||||||
}
|
}
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,9 +57,17 @@ public class ServiceListTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
NamingBase.prepareServer(port);
|
||||||
if (naming == null) {
|
if (naming == null) {
|
||||||
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
||||||
}
|
}
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -54,11 +54,19 @@ public class SubscribeCluster_ITCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
NamingBase.prepareServer(port);
|
||||||
instances.clear();
|
instances.clear();
|
||||||
if (naming == null) {
|
if (naming == null) {
|
||||||
//TimeUnit.SECONDS.sleep(10);
|
//TimeUnit.SECONDS.sleep(10);
|
||||||
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
||||||
}
|
}
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private volatile List<Instance> instances = Collections.emptyList();
|
private volatile List<Instance> instances = Collections.emptyList();
|
||||||
|
@ -53,11 +53,19 @@ public class Subscribe_ITCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
NamingBase.prepareServer(port);
|
||||||
instances.clear();
|
instances.clear();
|
||||||
if (naming == null) {
|
if (naming == null) {
|
||||||
//TimeUnit.SECONDS.sleep(10);
|
//TimeUnit.SECONDS.sleep(10);
|
||||||
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
naming = NamingFactory.createNamingService("127.0.0.1" + ":" + port);
|
||||||
}
|
}
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private volatile List<Instance> instances = Collections.emptyList();
|
private volatile List<Instance> instances = Collections.emptyList();
|
||||||
|
@ -54,11 +54,19 @@ public class Unsubscribe_ITCase {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() throws Exception{
|
public void init() throws Exception{
|
||||||
|
NamingBase.prepareServer(port);
|
||||||
instances = Collections.emptyList();
|
instances = Collections.emptyList();
|
||||||
if (naming == null) {
|
if (naming == null) {
|
||||||
//TimeUnit.SECONDS.sleep(10);
|
//TimeUnit.SECONDS.sleep(10);
|
||||||
naming = NamingFactory.createNamingService("127.0.0.1"+":"+port);
|
naming = NamingFactory.createNamingService("127.0.0.1"+":"+port);
|
||||||
}
|
}
|
||||||
|
while (true) {
|
||||||
|
if (!"UP".equals(naming.getServerStatus())) {
|
||||||
|
Thread.sleep(1000L);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private volatile List<Instance> instances = Collections.emptyList();
|
private volatile List<Instance> instances = Collections.emptyList();
|
||||||
|
Loading…
Reference in New Issue
Block a user