Merge branch 'develop' into charset
This commit is contained in:
commit
fac3dc8a23
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,7 +3,6 @@
|
||||
.project
|
||||
.settings
|
||||
target
|
||||
.project
|
||||
.idea
|
||||
.vscode
|
||||
.DS_Store
|
||||
|
@ -91,6 +91,11 @@ public @interface NacosProperties {
|
||||
*/
|
||||
String MAX_RETRY = "maxRetry";
|
||||
|
||||
/**
|
||||
* The property name of "enableRemoteSyncConfig"
|
||||
*/
|
||||
String ENABLE_REMOTE_SYNC_CONFIG = "enableRemoteSyncConfig";
|
||||
|
||||
/**
|
||||
* The placeholder of endpoint, the value is <code>"${nacos.endpoint:}"</code>
|
||||
*/
|
||||
@ -146,6 +151,11 @@ public @interface NacosProperties {
|
||||
*/
|
||||
String MAX_RETRY_PLACEHOLDER = "${" + PREFIX + MAX_RETRY + ":}";
|
||||
|
||||
/**
|
||||
* The placeholder of {@link NacosProperties#ENABLE_REMOTE_SYNC_CONFIG enableRemoteSyncConfig}, the value is <code>"${nacos.enableRemoteSyncConfig:}"</code>
|
||||
*/
|
||||
String ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER = "${" + PREFIX + ENABLE_REMOTE_SYNC_CONFIG + "}";
|
||||
|
||||
/**
|
||||
* The property of "endpoint"
|
||||
*
|
||||
@ -234,4 +244,12 @@ public @interface NacosProperties {
|
||||
*/
|
||||
String maxRetry() default MAX_RETRY_PLACEHOLDER;
|
||||
|
||||
/**
|
||||
* The property of "enableRemoteSyncConfig"
|
||||
*
|
||||
* @return empty as default value
|
||||
* @see #ENABLE_REMOTE_SYNC_CONFIG
|
||||
*/
|
||||
String enableRemoteSyncConfig() default ENABLE_REMOTE_SYNC_CONFIG_PLACEHOLDER;
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.alibaba.nacos.api.common;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Constant
|
||||
*
|
||||
@ -143,6 +145,12 @@ public class Constants {
|
||||
|
||||
public static final String DEFAULT_CLUSTER_NAME = "DEFAULT";
|
||||
|
||||
public static final long DEFAULT_HEART_BEAT_TIMEOUT = TimeUnit.SECONDS.toMillis(15);
|
||||
|
||||
public static final long DEFAULT_IP_DELETE_TIMEOUT = TimeUnit.SECONDS.toMillis(30);
|
||||
|
||||
public static final long DEFAULT_HEART_BEAT_INTERVAL = TimeUnit.SECONDS.toMillis(5);
|
||||
|
||||
public static final String DEFAULT_NAMESPACE_ID = "public";
|
||||
|
||||
public static final boolean DEFAULT_USE_CLOUD_NAMESPACE_PARSING = true;
|
||||
@ -152,4 +160,6 @@ public class Constants {
|
||||
public static final String SERVICE_INFO_SPLITER = "@@";
|
||||
|
||||
public static final String NULL_STRING = "null";
|
||||
|
||||
public static final String NUMBER_PATTERN = "^\\d+$";
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class ConfigFactory {
|
||||
ConfigService vendorImpl = (ConfigService) constructor.newInstance(properties);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(-400, e.getMessage());
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,9 @@
|
||||
*/
|
||||
package com.alibaba.nacos.api.exception;
|
||||
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Nacos Exception
|
||||
*
|
||||
@ -31,6 +34,8 @@ public class NacosException extends Exception {
|
||||
|
||||
private String errMsg;
|
||||
|
||||
private Throwable causeThrowable;
|
||||
|
||||
public NacosException() {
|
||||
}
|
||||
|
||||
@ -40,12 +45,31 @@ public class NacosException extends Exception {
|
||||
this.errMsg = errMsg;
|
||||
}
|
||||
|
||||
public NacosException(int errCode, Throwable throwable) {
|
||||
super(throwable);
|
||||
this.errCode = errCode;
|
||||
setCauseThrowable(throwable);
|
||||
}
|
||||
|
||||
public NacosException(int errCode, String errMsg, Throwable throwable) {
|
||||
super(errMsg, throwable);
|
||||
this.errCode = errCode;
|
||||
this.errMsg = errMsg;
|
||||
setCauseThrowable(throwable);
|
||||
}
|
||||
|
||||
public int getErrCode() {
|
||||
return errCode;
|
||||
}
|
||||
|
||||
public String getErrMsg() {
|
||||
return errMsg;
|
||||
if (!StringUtils.isBlank(this.errMsg)) {
|
||||
return errMsg;
|
||||
}
|
||||
if (this.causeThrowable != null) {
|
||||
return causeThrowable.getMessage();
|
||||
}
|
||||
return Constants.NULL;
|
||||
}
|
||||
|
||||
public void setErrCode(int errCode) {
|
||||
@ -56,9 +80,20 @@ public class NacosException extends Exception {
|
||||
this.errMsg = errMsg;
|
||||
}
|
||||
|
||||
public void setCauseThrowable(Throwable throwable) {
|
||||
this.causeThrowable = getCauseThrowable(throwable);
|
||||
}
|
||||
|
||||
private Throwable getCauseThrowable(Throwable t) {
|
||||
if (t.getCause() == null) {
|
||||
return t;
|
||||
}
|
||||
return getCauseThrowable(t.getCause());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ErrCode:" + errCode + ",ErrMsg:" + errMsg;
|
||||
return "ErrCode:" + getErrCode() + ", ErrMsg:" + getErrMsg();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ public class NamingFactory {
|
||||
NamingService vendorImpl = (NamingService)constructor.newInstance(serverList);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(-400, e.getMessage());
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class NamingFactory {
|
||||
NamingService vendorImpl = (NamingService)constructor.newInstance(properties);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(-400, e.getMessage());
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class NamingMaintainFactory {
|
||||
NamingMaintainService vendorImpl = (NamingMaintainService)constructor.newInstance(serverList);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(-400, e.getMessage());
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class NamingMaintainFactory {
|
||||
NamingMaintainService vendorImpl = (NamingMaintainService)constructor.newInstance(properties);
|
||||
return vendorImpl;
|
||||
} catch (Throwable e) {
|
||||
throw new NacosException(-400, e.getMessage());
|
||||
throw new NacosException(NacosException.CLIENT_INVALID_PARAM, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,10 @@ import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.api.naming.listener.EventListener;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.api.naming.pojo.ListView;
|
||||
import com.alibaba.nacos.api.naming.pojo.Service;
|
||||
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
|
||||
import com.alibaba.nacos.api.selector.AbstractSelector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Naming Service
|
||||
|
@ -27,4 +27,10 @@ public class PreservedMetadataKeys {
|
||||
* The key to indicate the registry source of service instance, such as Dubbo, SpringCloud, etc.
|
||||
*/
|
||||
public static final String REGISTER_SOURCE = "preserved.register.source";
|
||||
|
||||
public static final String HEART_BEAT_TIMEOUT = "preserved.heart.beat.timeout";
|
||||
|
||||
public static final String IP_DELETE_TIMEOUT = "preserved.ip.delete.timeout";
|
||||
|
||||
public static final String HEART_BEAT_INTERVAL = "preserved.heart.beat.interval";
|
||||
}
|
||||
|
@ -16,11 +16,15 @@
|
||||
package com.alibaba.nacos.api.naming.pojo;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.alibaba.nacos.api.common.Constants.NUMBER_PATTERN;
|
||||
|
||||
/**
|
||||
* Instance
|
||||
*
|
||||
@ -193,4 +197,27 @@ public class Instance {
|
||||
return str1 == null ? str2 == null : str1.equals(str2);
|
||||
}
|
||||
|
||||
public long getInstanceHeartBeatInterval() {
|
||||
return getMetaDataByKeyWithDefault(PreservedMetadataKeys.HEART_BEAT_INTERVAL, Constants.DEFAULT_HEART_BEAT_INTERVAL);
|
||||
}
|
||||
|
||||
public long getInstanceHeartBeatTimeOut() {
|
||||
return getMetaDataByKeyWithDefault(PreservedMetadataKeys.HEART_BEAT_TIMEOUT, Constants.DEFAULT_HEART_BEAT_TIMEOUT);
|
||||
}
|
||||
|
||||
public long getIpDeleteTimeout() {
|
||||
return getMetaDataByKeyWithDefault(PreservedMetadataKeys.IP_DELETE_TIMEOUT, Constants.DEFAULT_IP_DELETE_TIMEOUT);
|
||||
}
|
||||
|
||||
private long getMetaDataByKeyWithDefault( String key, long defaultValue) {
|
||||
if (getMetadata() == null || getMetadata().isEmpty()) {
|
||||
return defaultValue;
|
||||
}
|
||||
String value = getMetadata().get(key);
|
||||
if (!StringUtils.isEmpty(value) && value.matches(NUMBER_PATTERN)) {
|
||||
return Long.valueOf(value);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -111,6 +111,11 @@
|
||||
<artifactId>simpleclient</artifactId>
|
||||
<version>0.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
@ -27,7 +27,6 @@ import com.alibaba.nacos.client.config.filter.impl.ConfigResponse;
|
||||
import com.alibaba.nacos.client.config.http.HttpAgent;
|
||||
import com.alibaba.nacos.client.config.http.MetricsHttpAgent;
|
||||
import com.alibaba.nacos.client.config.http.ServerHttpAgent;
|
||||
import com.alibaba.nacos.client.config.impl.CacheData;
|
||||
import com.alibaba.nacos.client.config.impl.ClientWorker;
|
||||
import com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult;
|
||||
import com.alibaba.nacos.client.config.impl.LocalConfigInfoProcessor;
|
||||
|
@ -78,7 +78,7 @@ public class ServerHttpAgent implements HttpAgent {
|
||||
newHeaders.addAll(headers);
|
||||
}
|
||||
HttpResult result = HttpSimpleClient.httpGet(
|
||||
getUrl(currentServerAddr, path, isSSL), newHeaders, paramValues, encoding,
|
||||
getUrl(currentServerAddr, path), newHeaders, paramValues, encoding,
|
||||
readTimeoutMs, isSSL);
|
||||
if (result.code == HttpURLConnection.HTTP_INTERNAL_ERROR
|
||||
|| result.code == HttpURLConnection.HTTP_BAD_GATEWAY
|
||||
@ -133,7 +133,7 @@ public class ServerHttpAgent implements HttpAgent {
|
||||
}
|
||||
|
||||
HttpResult result = HttpSimpleClient.httpPost(
|
||||
getUrl(currentServerAddr, path, isSSL), newHeaders, paramValues, encoding,
|
||||
getUrl(currentServerAddr, path), newHeaders, paramValues, encoding,
|
||||
readTimeoutMs, isSSL);
|
||||
if (result.code == HttpURLConnection.HTTP_INTERNAL_ERROR
|
||||
|| result.code == HttpURLConnection.HTTP_BAD_GATEWAY
|
||||
@ -186,7 +186,7 @@ public class ServerHttpAgent implements HttpAgent {
|
||||
newHeaders.addAll(headers);
|
||||
}
|
||||
HttpResult result = HttpSimpleClient.httpDelete(
|
||||
getUrl(currentServerAddr, path, isSSL), newHeaders, paramValues, encoding,
|
||||
getUrl(currentServerAddr, path), newHeaders, paramValues, encoding,
|
||||
readTimeoutMs, isSSL);
|
||||
if (result.code == HttpURLConnection.HTTP_INTERNAL_ERROR
|
||||
|| result.code == HttpURLConnection.HTTP_BAD_GATEWAY
|
||||
@ -223,12 +223,8 @@ public class ServerHttpAgent implements HttpAgent {
|
||||
throw new ConnectException("no available server");
|
||||
}
|
||||
|
||||
private String getUrl(String serverAddr, String relativePath, boolean isSSL) {
|
||||
String httpPrefix = "http://";
|
||||
if (isSSL) {
|
||||
httpPrefix = "https://";
|
||||
}
|
||||
return httpPrefix + serverAddr + "/" + serverListMgr.getContentPath() + relativePath;
|
||||
private String getUrl(String serverAddr, String relativePath) {
|
||||
return serverAddr + "/" + serverListMgr.getContentPath() + relativePath;
|
||||
}
|
||||
|
||||
public static String getAppname() {
|
||||
|
@ -237,7 +237,7 @@ public class ClientWorker {
|
||||
"[%s] [sub-server] get server config exception, dataId=%s, group=%s, tenant=%s", agent.getName(),
|
||||
dataId, group, tenant);
|
||||
LOGGER.error(message, e);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, e.getMessage());
|
||||
throw new NacosException(NacosException.SERVER_ERROR, e);
|
||||
}
|
||||
|
||||
switch (result.code) {
|
||||
|
@ -33,11 +33,11 @@ import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.client.config.impl.EventDispatcher.ServerlistChangeEvent;
|
||||
import com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult;
|
||||
import com.alibaba.nacos.client.config.utils.IOUtils;
|
||||
import com.alibaba.nacos.client.utils.EnvUtil;
|
||||
import com.alibaba.nacos.client.utils.LogUtils;
|
||||
import com.alibaba.nacos.client.utils.ParamUtil;
|
||||
import com.alibaba.nacos.client.utils.StringUtils;
|
||||
import com.alibaba.nacos.client.utils.TemplateUtils;
|
||||
|
||||
import com.alibaba.nacos.client.identify.Constants;
|
||||
import com.alibaba.nacos.client.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -49,6 +49,8 @@ import org.slf4j.Logger;
|
||||
public class ServerListManager {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.logger(ServerListManager.class);
|
||||
private static final String HTTPS = "https://";
|
||||
private static final String HTTP = "http://";
|
||||
|
||||
public ServerListManager() {
|
||||
isFixed = false;
|
||||
@ -128,12 +130,16 @@ public class ServerListManager {
|
||||
isFixed = true;
|
||||
List<String> serverAddrs = new ArrayList<String>();
|
||||
String[] serverAddrsArr = serverAddrsStr.split(",");
|
||||
for (String serverAddr : serverAddrsArr) {
|
||||
String[] serverAddrArr = serverAddr.split(":");
|
||||
if (serverAddrArr.length == 1) {
|
||||
serverAddrs.add(serverAddrArr[0] + ":" + ParamUtil.getDefaultServerPort());
|
||||
} else {
|
||||
for (String serverAddr: serverAddrsArr) {
|
||||
if (serverAddr.startsWith(HTTPS) || serverAddr.startsWith(HTTP)) {
|
||||
serverAddrs.add(serverAddr);
|
||||
} else {
|
||||
String[] serverAddrArr = serverAddr.split(":");
|
||||
if (serverAddrArr.length == 1) {
|
||||
serverAddrs.add(HTTP + serverAddrArr[0] + ":" + ParamUtil.getDefaultServerPort());
|
||||
} else {
|
||||
serverAddrs.add(HTTP + serverAddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
serverUrls = serverAddrs;
|
||||
@ -325,6 +331,7 @@ public class ServerListManager {
|
||||
String split = "";
|
||||
for (String serverIp : serverIps) {
|
||||
sb.append(split);
|
||||
serverIp = serverIp.replaceAll("http(s)?://", "");
|
||||
sb.append(serverIp.replaceAll(":", "_"));
|
||||
split = "-";
|
||||
}
|
||||
|
@ -24,5 +24,5 @@ public interface CredentialListener {
|
||||
/**
|
||||
* update Credential
|
||||
*/
|
||||
public void onUpdateCredential();
|
||||
void onUpdateCredential();
|
||||
}
|
||||
|
@ -26,12 +26,12 @@ public interface SpasCredential {
|
||||
*
|
||||
* @return AccessKey
|
||||
*/
|
||||
public String getAccessKey();
|
||||
String getAccessKey();
|
||||
|
||||
/**
|
||||
* get SecretKey
|
||||
*
|
||||
* @return SecretKey
|
||||
*/
|
||||
public String getSecretKey();
|
||||
String getSecretKey();
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import com.alibaba.nacos.api.PropertyKeyConst;
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
|
||||
import com.alibaba.nacos.api.naming.listener.EventListener;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.api.naming.pojo.ListView;
|
||||
@ -39,6 +40,7 @@ import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author nkorange
|
||||
@ -46,6 +48,7 @@ import java.util.*;
|
||||
@SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule")
|
||||
public class NacosNamingService implements NamingService {
|
||||
private static final String DEFAULT_PORT = "8080";
|
||||
private static final long DEFAULT_HEART_BEAT_INTERVAL = TimeUnit.SECONDS.toMillis(5);
|
||||
|
||||
/**
|
||||
* Each Naming instance should have different namespace.
|
||||
@ -193,6 +196,8 @@ public class NacosNamingService implements NamingService {
|
||||
beatInfo.setWeight(instance.getWeight());
|
||||
beatInfo.setMetadata(instance.getMetadata());
|
||||
beatInfo.setScheduled(false);
|
||||
long instanceInterval = instance.getInstanceHeartBeatInterval();
|
||||
beatInfo.setPeriod(instanceInterval == 0 ? DEFAULT_HEART_BEAT_INTERVAL : instanceInterval);
|
||||
|
||||
beatReactor.addBeatInfo(NamingUtils.getGroupedName(serviceName, groupName), beatInfo);
|
||||
}
|
||||
@ -200,6 +205,7 @@ public class NacosNamingService implements NamingService {
|
||||
serverProxy.registerService(NamingUtils.getGroupedName(serviceName, groupName), groupName, instance);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deregisterInstance(String serviceName, String ip, int port) throws NacosException {
|
||||
deregisterInstance(serviceName, ip, port, Constants.DEFAULT_CLUSTER_NAME);
|
||||
|
@ -31,6 +31,8 @@ public class BeatInfo {
|
||||
private String cluster;
|
||||
private Map<String, String> metadata;
|
||||
private volatile boolean scheduled;
|
||||
private volatile long period;
|
||||
private volatile boolean stopped;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@ -92,4 +94,20 @@ public class BeatInfo {
|
||||
public void setScheduled(boolean scheduled) {
|
||||
this.scheduled = scheduled;
|
||||
}
|
||||
|
||||
public long getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
public void setPeriod(long period) {
|
||||
this.period = period;
|
||||
}
|
||||
|
||||
public boolean isStopped() {
|
||||
return stopped;
|
||||
}
|
||||
|
||||
public void setStopped(boolean stopped) {
|
||||
this.stopped = stopped;
|
||||
}
|
||||
}
|
||||
|
@ -54,48 +54,27 @@ public class BeatReactor {
|
||||
return thread;
|
||||
}
|
||||
});
|
||||
|
||||
executorService.schedule(new BeatProcessor(), 0, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void addBeatInfo(String serviceName, BeatInfo beatInfo) {
|
||||
NAMING_LOGGER.info("[BEAT] adding beat: {} to beat map.", beatInfo);
|
||||
dom2Beat.put(buildKey(serviceName, beatInfo.getIp(), beatInfo.getPort()), beatInfo);
|
||||
executorService.schedule(new BeatTask(beatInfo), 0, TimeUnit.MILLISECONDS);
|
||||
MetricsMonitor.getDom2BeatSizeMonitor().set(dom2Beat.size());
|
||||
}
|
||||
|
||||
public void removeBeatInfo(String serviceName, String ip, int port) {
|
||||
NAMING_LOGGER.info("[BEAT] removing beat: {}:{}:{} from beat map.", serviceName, ip, port);
|
||||
dom2Beat.remove(buildKey(serviceName, ip, port));
|
||||
BeatInfo beatInfo = dom2Beat.remove(buildKey(serviceName, ip, port));
|
||||
beatInfo.setStopped(true);
|
||||
MetricsMonitor.getDom2BeatSizeMonitor().set(dom2Beat.size());
|
||||
}
|
||||
|
||||
public String buildKey(String serviceName, String ip, int port) {
|
||||
private String buildKey(String serviceName, String ip, int port) {
|
||||
return serviceName + Constants.NAMING_INSTANCE_ID_SPLITTER
|
||||
+ ip + Constants.NAMING_INSTANCE_ID_SPLITTER + port;
|
||||
}
|
||||
|
||||
class BeatProcessor implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (Map.Entry<String, BeatInfo> entry : dom2Beat.entrySet()) {
|
||||
BeatInfo beatInfo = entry.getValue();
|
||||
if (beatInfo.isScheduled()) {
|
||||
continue;
|
||||
}
|
||||
beatInfo.setScheduled(true);
|
||||
executorService.schedule(new BeatTask(beatInfo), 0, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
NAMING_LOGGER.error("[CLIENT-BEAT] Exception while scheduling beat.", e);
|
||||
} finally {
|
||||
executorService.schedule(this, clientBeatInterval, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BeatTask implements Runnable {
|
||||
|
||||
BeatInfo beatInfo;
|
||||
@ -107,10 +86,11 @@ public class BeatReactor {
|
||||
@Override
|
||||
public void run() {
|
||||
long result = serverProxy.sendBeat(beatInfo);
|
||||
beatInfo.setScheduled(false);
|
||||
if (result > 0) {
|
||||
clientBeatInterval = result;
|
||||
if (beatInfo.isStopped()) {
|
||||
return;
|
||||
}
|
||||
long nextTime = result > 0 ? result : beatInfo.getPeriod();
|
||||
executorService.schedule(new BeatTask(beatInfo), nextTime, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import com.alibaba.nacos.api.selector.AbstractSelector;
|
||||
import com.alibaba.nacos.api.selector.ExpressionSelector;
|
||||
import com.alibaba.nacos.api.selector.SelectorType;
|
||||
import com.alibaba.nacos.client.config.impl.SpasAdapter;
|
||||
import com.alibaba.nacos.client.identify.Constants;
|
||||
import com.alibaba.nacos.client.monitor.MetricsMonitor;
|
||||
import com.alibaba.nacos.client.naming.beat.BeatInfo;
|
||||
import com.alibaba.nacos.client.naming.utils.*;
|
||||
@ -397,13 +398,15 @@ public class NamingProxy {
|
||||
List<String> headers = builderHeaders();
|
||||
|
||||
String url;
|
||||
|
||||
if (!curServer.contains(UtilAndComs.SERVER_ADDR_IP_SPLITER)) {
|
||||
curServer = curServer + UtilAndComs.SERVER_ADDR_IP_SPLITER + serverPort;
|
||||
if (curServer.startsWith(UtilAndComs.HTTPS) || curServer.startsWith(UtilAndComs.HTTP)) {
|
||||
url = curServer + api;
|
||||
} else {
|
||||
if (!curServer.contains(UtilAndComs.SERVER_ADDR_IP_SPLITER)) {
|
||||
curServer = curServer + UtilAndComs.SERVER_ADDR_IP_SPLITER + serverPort;
|
||||
}
|
||||
url = HttpClient.getPrefix() + curServer + api;
|
||||
}
|
||||
|
||||
url = HttpClient.getPrefix() + curServer + api;
|
||||
|
||||
HttpClient.HttpResult result = HttpClient.request(url, headers, params, UtilAndComs.ENCODING, method);
|
||||
end = System.currentTimeMillis();
|
||||
|
||||
@ -418,8 +421,8 @@ public class NamingProxy {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "failed to req API:" + HttpClient.getPrefix() + curServer
|
||||
+ api + ". code:"
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "failed to req API:"
|
||||
+ curServer + api + ". code:"
|
||||
+ result.code + " msg: " + result.content);
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ public class CollectionUtils {
|
||||
return (coll == null || coll.isEmpty());
|
||||
}
|
||||
|
||||
private static final int getFreq(final Object obj, final Map freqMap) {
|
||||
private static int getFreq(final Object obj, final Map freqMap) {
|
||||
Integer count = (Integer)freqMap.get(obj);
|
||||
if (count != null) {
|
||||
return count.intValue();
|
||||
|
@ -37,7 +37,7 @@ public class InitUtils {
|
||||
* @param properties
|
||||
* @return
|
||||
*/
|
||||
public static final String initNamespaceForNaming(Properties properties) {
|
||||
public static String initNamespaceForNaming(Properties properties) {
|
||||
String tmpNamespace = null;
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ public class InitUtils {
|
||||
return tmpNamespace;
|
||||
}
|
||||
|
||||
public static final void initWebRootContext() {
|
||||
public static void initWebRootContext() {
|
||||
// support the web context with ali-yun if the app deploy by EDAS
|
||||
final String webContext = System.getProperty(SystemPropertyKeyConst.NAMING_WEB_CONTEXT);
|
||||
TemplateUtils.stringNotEmptyAndThenExecute(webContext, new Runnable() {
|
||||
@ -105,7 +105,7 @@ public class InitUtils {
|
||||
});
|
||||
}
|
||||
|
||||
public static final String initEndpoint(final Properties properties) {
|
||||
public static String initEndpoint(final Properties properties) {
|
||||
if (properties == null) {
|
||||
|
||||
return "";
|
||||
|
@ -55,4 +55,9 @@ public class UtilAndComs {
|
||||
public static final int DEFAULT_POLLING_THREAD_COUNT = Runtime.getRuntime()
|
||||
.availableProcessors() > 1 ? Runtime.getRuntime().availableProcessors() / 2
|
||||
: 1;
|
||||
|
||||
public static final String HTTP = "http://";
|
||||
|
||||
public static final String HTTPS = "https://";
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import java.util.concurrent.Callable;
|
||||
*/
|
||||
public class TemplateUtils {
|
||||
|
||||
public static final void stringNotEmptyAndThenExecute(String source, Runnable runnable) {
|
||||
public static void stringNotEmptyAndThenExecute(String source, Runnable runnable) {
|
||||
|
||||
if (StringUtils.isNotEmpty(source)) {
|
||||
|
||||
@ -35,7 +35,7 @@ public class TemplateUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static final String stringEmptyAndThenExecute(String source, Callable<String> callable) {
|
||||
public static String stringEmptyAndThenExecute(String source, Callable<String> callable) {
|
||||
|
||||
if (StringUtils.isEmpty(source)) {
|
||||
|
||||
@ -49,7 +49,7 @@ public class TemplateUtils {
|
||||
return source.trim();
|
||||
}
|
||||
|
||||
public static final String stringBlankAndThenExecute(String source, Callable<String> callable) {
|
||||
public static String stringBlankAndThenExecute(String source, Callable<String> callable) {
|
||||
|
||||
if (StringUtils.isBlank(source)) {
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
package com.alibaba.nacos.client;
|
||||
|
||||
import com.alibaba.nacos.client.naming.beat.BeatInfo;
|
||||
import com.alibaba.nacos.client.naming.beat.BeatReactor;
|
||||
import com.alibaba.nacos.client.naming.net.NamingProxy;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* @author caoyixiong
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class BeatReactorTest {
|
||||
|
||||
@Mock
|
||||
private NamingProxy namingProxy;
|
||||
|
||||
@Test
|
||||
public void test() throws NoSuchFieldException, IllegalAccessException, InterruptedException {
|
||||
BeatReactor beatReactor = new BeatReactor(namingProxy);
|
||||
|
||||
BeatInfo beatInfo = new BeatInfo();
|
||||
beatInfo.setServiceName("test");
|
||||
beatInfo.setIp("11.11.11.11");
|
||||
beatInfo.setPort(1234);
|
||||
beatInfo.setCluster("clusterName");
|
||||
beatInfo.setWeight(1);
|
||||
beatInfo.setMetadata(new HashMap<String, String>());
|
||||
beatInfo.setScheduled(false);
|
||||
beatInfo.setPeriod(1000L);
|
||||
|
||||
Mockito.doReturn(0L).when(namingProxy).sendBeat(beatInfo);
|
||||
beatReactor.addBeatInfo("testService", beatInfo);
|
||||
|
||||
Assert.assertEquals(1, getActiveThread(beatReactor));
|
||||
Thread.sleep(1100L);
|
||||
beatReactor.removeBeatInfo("testService", beatInfo.getIp(), beatInfo.getPort());
|
||||
Thread.sleep(3100L);
|
||||
Assert.assertEquals(0, getActiveThread(beatReactor));
|
||||
}
|
||||
|
||||
private int getActiveThread(BeatReactor beatReactor) throws NoSuchFieldException, IllegalAccessException {
|
||||
Field field = BeatReactor.class.getDeclaredField("executorService");
|
||||
field.setAccessible(true);
|
||||
ScheduledThreadPoolExecutor scheduledExecutorService = (ScheduledThreadPoolExecutor) field.get(beatReactor);
|
||||
return scheduledExecutorService.getQueue().size();
|
||||
}
|
||||
|
||||
}
|
@ -17,11 +17,9 @@ package com.alibaba.nacos.client;
|
||||
|
||||
import com.alibaba.nacos.api.NacosFactory;
|
||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.api.naming.pojo.ListView;
|
||||
import com.alibaba.nacos.api.selector.ExpressionSelector;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -34,36 +34,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
@RequestMapping(UtilsAndCommons.NACOS_CMDB_CONTEXT + "/ops")
|
||||
public class OperationController {
|
||||
|
||||
@Autowired
|
||||
private SwitchAndOptions switches;
|
||||
|
||||
@Autowired
|
||||
private CmdbProvider cmdbProvider;
|
||||
|
||||
@RequestMapping(value = "/switch", method = RequestMethod.PUT)
|
||||
public String updateSwitch(HttpServletRequest request) throws Exception {
|
||||
|
||||
String entry = WebUtils.required(request, "entry");
|
||||
String value = WebUtils.required(request, "value");
|
||||
|
||||
switch (entry) {
|
||||
case "dumpTaskInterval":
|
||||
switches.setDumpTaskInterval(Integer.parseInt(value));
|
||||
break;
|
||||
case "eventTaskInterval":
|
||||
switches.setEventTaskInterval(Integer.parseInt(value));
|
||||
break;
|
||||
case "loadDataAtStart":
|
||||
switches.setLoadDataAtStart(Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "labelTaskInterval":
|
||||
switches.setLabelTaskInterval(Integer.parseInt(value));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/label", method = RequestMethod.GET)
|
||||
public String queryLabel(HttpServletRequest request) throws Exception {
|
||||
String entry = WebUtils.required(request, "entry");
|
||||
|
@ -25,47 +25,31 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class SwitchAndOptions {
|
||||
|
||||
@Value("${nacos.cmdb.dumpTaskInterval}")
|
||||
@Value("${nacos.cmdb.dumpTaskInterval:3600}")
|
||||
private int dumpTaskInterval;
|
||||
|
||||
@Value("${nacos.cmdb.eventTaskInterval}")
|
||||
@Value("${nacos.cmdb.eventTaskInterval:10}")
|
||||
private int eventTaskInterval;
|
||||
|
||||
@Value("${nacos.cmdb.labelTaskInterval}")
|
||||
@Value("${nacos.cmdb.labelTaskInterval:300}")
|
||||
private int labelTaskInterval;
|
||||
|
||||
@Value("${nacos.cmdb.loadDataAtStart}")
|
||||
@Value("${nacos.cmdb.loadDataAtStart:false}")
|
||||
private boolean loadDataAtStart;
|
||||
|
||||
public int getDumpTaskInterval() {
|
||||
return dumpTaskInterval;
|
||||
}
|
||||
|
||||
public void setDumpTaskInterval(int dumpTaskInterval) {
|
||||
this.dumpTaskInterval = dumpTaskInterval;
|
||||
}
|
||||
|
||||
public int getEventTaskInterval() {
|
||||
return eventTaskInterval;
|
||||
}
|
||||
|
||||
public void setEventTaskInterval(int eventTaskInterval) {
|
||||
this.eventTaskInterval = eventTaskInterval;
|
||||
}
|
||||
|
||||
public int getLabelTaskInterval() {
|
||||
return labelTaskInterval;
|
||||
}
|
||||
|
||||
public void setLabelTaskInterval(int labelTaskInterval) {
|
||||
this.labelTaskInterval = labelTaskInterval;
|
||||
}
|
||||
|
||||
public boolean isLoadDataAtStart() {
|
||||
return loadDataAtStart;
|
||||
}
|
||||
|
||||
public void setLoadDataAtStart(boolean loadDataAtStart) {
|
||||
this.loadDataAtStart = loadDataAtStart;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.alibaba.nacos.config.server.utils.LogUtil.memoryLog;
|
||||
|
||||
|
@ -443,8 +443,6 @@ public class PersistService {
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
static final class TenantInfoRowMapper implements RowMapper<TenantInfo> {
|
||||
@Override
|
||||
public TenantInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
|
@ -113,7 +113,7 @@ public class EventDispatcher {
|
||||
|
||||
static final CopyOnWriteArrayList<Entry> LISTENER_HUB = new CopyOnWriteArrayList<Entry>();
|
||||
|
||||
static public interface Event {
|
||||
public interface Event {
|
||||
}
|
||||
|
||||
static public abstract class AbstractEventListener {
|
||||
|
@ -25,6 +25,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ -45,11 +47,11 @@ public class AggrWhitelistTest {
|
||||
list.add("com.taobao.tae.AppListOnGrid-*");
|
||||
service.compile(list);
|
||||
|
||||
assertEquals(false, service.isAggrDataId("com.abc"));
|
||||
assertEquals(false, service.isAggrDataId("com.taobao.jiuren"));
|
||||
assertEquals(false, service.isAggrDataId("com.taobao.jiurenABC"));
|
||||
assertEquals(true, service.isAggrDataId("com.taobao.jiuren.abc"));
|
||||
assertEquals(true, service.isAggrDataId("NS_NACOS_SUBSCRIPTION_TOPIC_abc"));
|
||||
assertEquals(true, service.isAggrDataId("com.taobao.tae.AppListOnGrid-abc"));
|
||||
assertFalse(service.isAggrDataId("com.abc"));
|
||||
assertFalse(service.isAggrDataId("com.taobao.jiuren"));
|
||||
assertFalse(service.isAggrDataId("com.taobao.jiurenABC"));
|
||||
assertTrue(service.isAggrDataId("com.taobao.jiuren.abc"));
|
||||
assertTrue(service.isAggrDataId("NS_NACOS_SUBSCRIPTION_TOPIC_abc"));
|
||||
assertTrue(service.isAggrDataId("com.taobao.tae.AppListOnGrid-abc"));
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -7,8 +7,6 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest
|
||||
@WebAppConfiguration
|
||||
|
@ -16,6 +16,8 @@
|
||||
package com.alibaba.nacos.config.server.utils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -31,19 +33,19 @@ public class SimpleReadWriteLockTest {
|
||||
@Test
|
||||
public void test_双重读锁_全部释放_加写锁() {
|
||||
SimpleReadWriteLock lock = new SimpleReadWriteLock();
|
||||
assertEquals(true, lock.tryReadLock());
|
||||
assertEquals(true, lock.tryReadLock());
|
||||
assertTrue(lock.tryReadLock());
|
||||
assertTrue(lock.tryReadLock());
|
||||
|
||||
lock.releaseReadLock();
|
||||
lock.releaseReadLock();
|
||||
|
||||
assertEquals(true, lock.tryWriteLock());
|
||||
assertTrue(lock.tryWriteLock());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_加写锁() {
|
||||
SimpleReadWriteLock lock = new SimpleReadWriteLock();
|
||||
assertEquals(true, lock.tryWriteLock());
|
||||
assertTrue(lock.tryWriteLock());
|
||||
lock.releaseWriteLock();
|
||||
}
|
||||
|
||||
@ -51,26 +53,26 @@ public class SimpleReadWriteLockTest {
|
||||
public void test_双重写锁() {
|
||||
SimpleReadWriteLock lock = new SimpleReadWriteLock();
|
||||
|
||||
assertEquals(true, lock.tryWriteLock());
|
||||
assertEquals(false, lock.tryWriteLock());
|
||||
assertTrue(lock.tryWriteLock());
|
||||
assertFalse(lock.tryWriteLock());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_先读锁后写锁() {
|
||||
SimpleReadWriteLock lock = new SimpleReadWriteLock();
|
||||
|
||||
assertEquals(true, lock.tryReadLock());
|
||||
assertEquals(false, lock.tryWriteLock());
|
||||
assertTrue(lock.tryReadLock());
|
||||
assertFalse(lock.tryWriteLock());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_双重读锁_释放一个_加写锁失败() {
|
||||
SimpleReadWriteLock lock = new SimpleReadWriteLock();
|
||||
assertEquals(true, lock.tryReadLock());
|
||||
assertEquals(true, lock.tryReadLock());
|
||||
assertTrue(lock.tryReadLock());
|
||||
assertTrue(lock.tryReadLock());
|
||||
|
||||
lock.releaseReadLock();
|
||||
|
||||
assertEquals(false, lock.tryWriteLock());
|
||||
assertFalse(lock.tryWriteLock());
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,7 @@ package com.alibaba.nacos.console.controller;
|
||||
import com.alibaba.nacos.console.config.WebSecurityConfig;
|
||||
import com.alibaba.nacos.config.server.model.RestResult;
|
||||
import com.alibaba.nacos.console.utils.JwtTokenUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
|
@ -35,8 +35,6 @@ public class NamespaceAllInfo extends Namespace {
|
||||
public NamespaceAllInfo() {
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public NamespaceAllInfo(String namespace, String namespaceShowName, int quota, int configCount, int type,
|
||||
String namespaceDesc) {
|
||||
super(namespace, namespaceShowName, quota, configCount, type);
|
||||
|
@ -65,10 +65,4 @@ server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
||||
# default current work dir
|
||||
server.tomcat.basedir=
|
||||
|
||||
nacos.naming.distro.taskDispatchThreadCount=1
|
||||
nacos.naming.distro.taskDispatchPeriod=200
|
||||
nacos.naming.distro.batchSyncKeyCount=1000
|
||||
nacos.naming.distro.initDataRatio=0.9
|
||||
nacos.naming.distro.syncRetryDelay=5000
|
||||
nacos.naming.data.warmup=false
|
||||
nacos.naming.expireInstance=true
|
||||
|
||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
@ -20,3 +20,6 @@ export const LANGUAGE_SWITCH = 'LANGUAGE_SWITCH';
|
||||
export const REDUX_DEVTOOLS = '__REDUX_DEVTOOLS_EXTENSION__';
|
||||
|
||||
export const GET_STATE = 'GET_STATE';
|
||||
|
||||
export const GET_SUBSCRIBERS = 'GET_SUBSCRIBERS';
|
||||
export const REMOVE_SUBSCRIBERS = 'REMOVE_SUBSCRIBERS';
|
||||
|
@ -41,6 +41,7 @@ import ListeningToQuery from './pages/ConfigurationManagement/ListeningToQuery';
|
||||
import ConfigurationManagement from './pages/ConfigurationManagement/ConfigurationManagement';
|
||||
import ServiceList from './pages/ServiceManagement/ServiceList';
|
||||
import ServiceDetail from './pages/ServiceManagement/ServiceDetail';
|
||||
import SubscriberList from './pages/ServiceManagement/SubscriberList';
|
||||
import ClusterNodeList from './pages/ClusterManagement/ClusterNodeList';
|
||||
|
||||
import reducers from './reducers';
|
||||
@ -82,6 +83,7 @@ const MENU = [
|
||||
{ path: '/configurationManagement', component: ConfigurationManagement },
|
||||
{ path: '/serviceManagement', component: ServiceList },
|
||||
{ path: '/serviceDetail', component: ServiceDetail },
|
||||
{ path: '/subscriberList', component: SubscriberList },
|
||||
{ path: '/clusterManagement', component: ClusterNodeList },
|
||||
];
|
||||
|
||||
|
@ -83,7 +83,7 @@ class Header extends React.Component {
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<img
|
||||
src="img/TB118jPv_mWBKNjSZFBXXXxUFXa-2000-390.svg"
|
||||
src="img/logo-2000-390.svg"
|
||||
className="logo"
|
||||
alt={siteConfig.name}
|
||||
title={siteConfig.name}
|
||||
|
@ -44,6 +44,7 @@ const I18N_CONF = {
|
||||
listeningToQuery: 'Listening Query',
|
||||
serviceManagementVirtual: 'ServiceManagement',
|
||||
serviceManagement: 'Service List',
|
||||
subscriberList: 'Subscribers',
|
||||
serviceDetail: 'Service Details',
|
||||
namespace: 'Namespace',
|
||||
clusterManagementVirtual: 'ClusterManagement',
|
||||
@ -92,6 +93,19 @@ const I18N_CONF = {
|
||||
promptDelete: 'Do you want to delete the service?',
|
||||
create: 'Create Service',
|
||||
},
|
||||
SubscriberList: {
|
||||
subscriberList: 'Subscriber List',
|
||||
serviceName: 'Service Name',
|
||||
serviceNamePlaceholder: 'Enter Service Name',
|
||||
groupName: 'Group Name',
|
||||
groupNamePlaceholder: 'Enter Group Name',
|
||||
query: 'Search',
|
||||
pubNoData: 'No results found.',
|
||||
address: 'Address',
|
||||
clientVersion: 'Client Version',
|
||||
appName: 'Application Name',
|
||||
searchServiceNamePrompt: 'Service name required!',
|
||||
},
|
||||
ClusterNodeList: {
|
||||
clusterNodeList: 'Node List',
|
||||
nodeIp: 'NodeIp',
|
||||
|
@ -44,6 +44,7 @@ const I18N_CONF = {
|
||||
listeningToQuery: '监听查询',
|
||||
serviceManagementVirtual: '服务管理',
|
||||
serviceManagement: '服务列表',
|
||||
subscriberList: '订阅者列表',
|
||||
serviceDetail: '服务详情',
|
||||
namespace: '命名空间',
|
||||
clusterManagementVirtual: '集群管理',
|
||||
@ -92,6 +93,19 @@ const I18N_CONF = {
|
||||
promptDelete: '确定要删除当前服务吗?',
|
||||
create: '创建服务',
|
||||
},
|
||||
SubscriberList: {
|
||||
subscriberList: '订阅者列表',
|
||||
serviceName: '服务名称',
|
||||
serviceNamePlaceholder: '请输入服务名称',
|
||||
groupName: '分组名称',
|
||||
groupNamePlaceholder: '请输入分组名称',
|
||||
query: '查询',
|
||||
pubNoData: '没有数据',
|
||||
address: '地址',
|
||||
clientVersion: '客户端版本',
|
||||
appName: '应用名',
|
||||
searchServiceNamePrompt: '请输入服务名称!',
|
||||
},
|
||||
ClusterNodeList: {
|
||||
clusterNodeList: '节点列表',
|
||||
nodeIp: '节点Ip',
|
||||
|
@ -209,6 +209,21 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
isExtend: false,
|
||||
name: '订阅者列表',
|
||||
title: '订阅者列表',
|
||||
isVirtual: false,
|
||||
projectName: 'nacos',
|
||||
serviceName: 'subscriberList',
|
||||
link: 'subscriberList',
|
||||
hasFusion: true,
|
||||
template: '',
|
||||
registerName: 'com.alibaba.nacos.page.subscriberList',
|
||||
useRouter: false,
|
||||
id: 'subscriberList',
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -109,13 +109,7 @@ class ClusterNodeList extends React.Component {
|
||||
|
||||
render() {
|
||||
const { locale = {} } = this.props;
|
||||
const {
|
||||
pubNoData,
|
||||
clusterNodeList,
|
||||
nodeIp,
|
||||
nodeIpPlaceholder,
|
||||
query,
|
||||
} = locale;
|
||||
const { pubNoData, clusterNodeList, nodeIp, nodeIpPlaceholder, query } = locale;
|
||||
const { keyword, nowNamespaceName, nowNamespaceId } = this.state;
|
||||
const { init, getValue } = this.field;
|
||||
this.init = init;
|
||||
@ -159,7 +153,9 @@ class ClusterNodeList extends React.Component {
|
||||
<FormItem label="">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => this.setState({ currentPage: 1 }, () => this.queryClusterStateList())}
|
||||
onClick={() =>
|
||||
this.setState({ currentPage: 1 }, () => this.queryClusterStateList())
|
||||
}
|
||||
style={{ marginRight: 10 }}
|
||||
>
|
||||
{query}
|
||||
|
@ -17,7 +17,6 @@ import { request } from '../../../globalLib';
|
||||
import { Dialog, Form, Input, Switch, Select, Message, ConfigProvider } from '@alifd/next';
|
||||
import { DIALOG_FORM_LAYOUT, METADATA_SEPARATOR, METADATA_ENTER } from './constant';
|
||||
import MonacoEditor from 'components/MonacoEditor';
|
||||
import { replaceEnter, processMetaData } from 'utils/nacosutil';
|
||||
|
||||
@ConfigProvider.config
|
||||
class EditClusterDialog extends React.Component {
|
||||
@ -42,7 +41,9 @@ class EditClusterDialog extends React.Component {
|
||||
show(_editCluster) {
|
||||
let editCluster = _editCluster;
|
||||
const { metadata = {} } = editCluster;
|
||||
editCluster.metadataText = processMetaData(METADATA_ENTER)(metadata);
|
||||
if (Object.keys(metadata).length) {
|
||||
editCluster.metadataText = JSON.stringify(metadata, null, '\t');
|
||||
}
|
||||
this.setState({
|
||||
editCluster,
|
||||
editClusterDialogVisible: true,
|
||||
@ -69,7 +70,7 @@ class EditClusterDialog extends React.Component {
|
||||
data: {
|
||||
serviceName,
|
||||
clusterName: name,
|
||||
metadata: replaceEnter(METADATA_SEPARATOR)(metadataText),
|
||||
metadata: metadataText,
|
||||
checkPort: defaultCheckPort,
|
||||
useInstancePort4Check: useIPPort4Check,
|
||||
healthChecker: JSON.stringify(healthChecker),
|
||||
@ -163,7 +164,7 @@ class EditClusterDialog extends React.Component {
|
||||
]}
|
||||
<Form.Item label={`${locale.metadata}:`}>
|
||||
<MonacoEditor
|
||||
language={'properties'}
|
||||
language="json"
|
||||
width={'100%'}
|
||||
height={200}
|
||||
value={metadataText}
|
||||
|
@ -17,7 +17,6 @@ import { request } from '../../../globalLib';
|
||||
import { Dialog, Form, Input, Switch, Message, ConfigProvider } from '@alifd/next';
|
||||
import { DIALOG_FORM_LAYOUT, METADATA_ENTER, METADATA_SEPARATOR } from './constant';
|
||||
import MonacoEditor from 'components/MonacoEditor';
|
||||
import { replaceEnter, processMetaData } from 'utils/nacosutil';
|
||||
|
||||
@ConfigProvider.config
|
||||
class EditInstanceDialog extends React.Component {
|
||||
@ -45,7 +44,7 @@ class EditInstanceDialog extends React.Component {
|
||||
let editInstance = _editInstance;
|
||||
const { metadata = {} } = editInstance;
|
||||
if (Object.keys(metadata).length) {
|
||||
editInstance.metadataText = processMetaData(METADATA_ENTER)(metadata);
|
||||
editInstance.metadataText = JSON.stringify(metadata, null, '\t');
|
||||
}
|
||||
this.setState({ editInstance, editInstanceDialogVisible: true });
|
||||
}
|
||||
@ -68,7 +67,7 @@ class EditInstanceDialog extends React.Component {
|
||||
ephemeral,
|
||||
weight,
|
||||
enabled,
|
||||
metadata: replaceEnter(METADATA_SEPARATOR)(metadataText),
|
||||
metadata: metadataText,
|
||||
},
|
||||
dataType: 'text',
|
||||
beforeSend: () => openLoading(),
|
||||
@ -127,7 +126,7 @@ class EditInstanceDialog extends React.Component {
|
||||
</Form.Item>
|
||||
<Form.Item label={`${locale.metadata}:`}>
|
||||
<MonacoEditor
|
||||
language={'properties'}
|
||||
language="json"
|
||||
width={'100%'}
|
||||
height={200}
|
||||
value={editInstance.metadataText}
|
||||
|
@ -17,7 +17,6 @@ import { request } from '../../../globalLib';
|
||||
import { Dialog, Form, Input, Select, Message, ConfigProvider } from '@alifd/next';
|
||||
import { DIALOG_FORM_LAYOUT, METADATA_SEPARATOR, METADATA_ENTER } from './constant';
|
||||
import MonacoEditor from 'components/MonacoEditor';
|
||||
import { replaceEnter, processMetaData } from 'utils/nacosutil';
|
||||
|
||||
@ConfigProvider.config
|
||||
class EditServiceDialog extends React.Component {
|
||||
@ -44,7 +43,7 @@ class EditServiceDialog extends React.Component {
|
||||
let editService = _editService;
|
||||
const { metadata = {}, name } = editService;
|
||||
if (Object.keys(metadata).length) {
|
||||
editService.metadataText = processMetaData(METADATA_ENTER)(metadata);
|
||||
editService.metadataText = JSON.stringify(metadata, null, '\t');
|
||||
}
|
||||
this.setState({ editService, editServiceDialogVisible: true, isCreate: !name });
|
||||
}
|
||||
@ -85,7 +84,7 @@ class EditServiceDialog extends React.Component {
|
||||
serviceName: name,
|
||||
groupName: groupName || 'DEFAULT_GROUP',
|
||||
protectThreshold,
|
||||
metadata: replaceEnter(METADATA_SEPARATOR)(metadataText),
|
||||
metadata: metadataText,
|
||||
selector: JSON.stringify(selector),
|
||||
},
|
||||
dataType: 'text',
|
||||
@ -181,7 +180,7 @@ class EditServiceDialog extends React.Component {
|
||||
</Form.Item>
|
||||
<Form.Item label={`${locale.metadata}:`} {...formItemLayout}>
|
||||
<MonacoEditor
|
||||
language={'properties'}
|
||||
language="json"
|
||||
width={'100%'}
|
||||
height={200}
|
||||
value={metadataText}
|
||||
|
@ -18,7 +18,7 @@ import { Input, Button, Card, ConfigProvider, Form, Loading, Message } from '@al
|
||||
import EditServiceDialog from './EditServiceDialog';
|
||||
import EditClusterDialog from './EditClusterDialog';
|
||||
import InstanceTable from './InstanceTable';
|
||||
import { getParameter, processMetaData } from 'utils/nacosutil';
|
||||
import { getParameter } from 'utils/nacosutil';
|
||||
import MonacoEditor from 'components/MonacoEditor';
|
||||
import { MONACO_READONLY_OPTIONS, METADATA_ENTER } from './constant';
|
||||
import './ServiceDetail.scss';
|
||||
@ -95,7 +95,10 @@ class ServiceDetail extends React.Component {
|
||||
const { locale = {} } = this.props;
|
||||
const { serviceName, groupName, loading, service = {}, clusters } = this.state;
|
||||
const { metadata = {}, selector = {} } = service;
|
||||
const metadataText = processMetaData(METADATA_ENTER)(metadata);
|
||||
let metadataText = '';
|
||||
if (Object.keys(metadata).length) {
|
||||
metadataText = JSON.stringify(metadata, null, '\t');
|
||||
}
|
||||
return (
|
||||
<div className="main-container service-detail">
|
||||
<Loading
|
||||
@ -140,7 +143,7 @@ class ServiceDetail extends React.Component {
|
||||
</FormItem>
|
||||
<FormItem label={`${locale.metadata}:`}>
|
||||
<MonacoEditor
|
||||
language={'properties'}
|
||||
language="json"
|
||||
width={'100%'}
|
||||
height={200}
|
||||
value={metadataText}
|
||||
|
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
Button,
|
||||
Field,
|
||||
Form,
|
||||
Grid,
|
||||
Input,
|
||||
Loading,
|
||||
Pagination,
|
||||
Table,
|
||||
Dialog,
|
||||
Message,
|
||||
ConfigProvider,
|
||||
} from '@alifd/next';
|
||||
import { connect } from 'react-redux';
|
||||
import { getSubscribers, removeSubscribers } from '../../../reducers/subscribers';
|
||||
import { request } from '../../../globalLib';
|
||||
import RegionGroup from '../../../components/RegionGroup';
|
||||
|
||||
import './SubscriberList.scss';
|
||||
|
||||
const FormItem = Form.Item;
|
||||
const { Row, Col } = Grid;
|
||||
const { Column } = Table;
|
||||
|
||||
@connect(
|
||||
state => ({ subscriberData: state.subscribers }),
|
||||
{ getSubscribers, removeSubscribers }
|
||||
)
|
||||
@ConfigProvider.config
|
||||
class SubscriberList extends React.Component {
|
||||
static displayName = 'SubscriberList';
|
||||
|
||||
static propTypes = {
|
||||
locale: PropTypes.object,
|
||||
getSubscribers: PropTypes.func,
|
||||
removeSubscribers: PropTypes.func,
|
||||
subscriberData: PropTypes.object,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
loading: false,
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
pageNo: 1,
|
||||
search: {
|
||||
serviceName: '',
|
||||
groupName: '',
|
||||
},
|
||||
};
|
||||
this.field = new Field(this);
|
||||
}
|
||||
|
||||
openLoading() {
|
||||
this.setState({ loading: true });
|
||||
}
|
||||
|
||||
closeLoading() {
|
||||
this.setState({ loading: false });
|
||||
}
|
||||
|
||||
querySubscriberList() {
|
||||
const { searchServiceNamePrompt } = this.props.locale;
|
||||
const { search, pageSize, pageNo, nowNamespaceId = '' } = this.state;
|
||||
if (!search.serviceName) {
|
||||
Message.error(searchServiceNamePrompt);
|
||||
return;
|
||||
}
|
||||
this.props.getSubscribers({
|
||||
...search,
|
||||
pageSize,
|
||||
pageNo,
|
||||
namespaceId: nowNamespaceId,
|
||||
});
|
||||
}
|
||||
|
||||
switchNamespace = () => {
|
||||
this.setState({ search: { serviceName: '', groupName: '' } });
|
||||
this.props.removeSubscribers();
|
||||
};
|
||||
|
||||
setNowNameSpace = (nowNamespaceName, nowNamespaceId) =>
|
||||
this.setState({
|
||||
nowNamespaceName,
|
||||
nowNamespaceId,
|
||||
});
|
||||
|
||||
render() {
|
||||
const { locale = {}, subscriberData = {} } = this.props;
|
||||
const { count = 0, subscribers = [] } = subscriberData;
|
||||
const {
|
||||
pubNoData,
|
||||
subscriberList,
|
||||
serviceName,
|
||||
serviceNamePlaceholder,
|
||||
groupName,
|
||||
groupNamePlaceholder,
|
||||
query,
|
||||
} = locale;
|
||||
const { search, nowNamespaceName, nowNamespaceId } = this.state;
|
||||
const { init, getValue } = this.field;
|
||||
this.init = init;
|
||||
this.getValue = getValue;
|
||||
return (
|
||||
<div className="main-container subscriber-list">
|
||||
<Loading
|
||||
shape="flower"
|
||||
style={{
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
}}
|
||||
visible={this.state.loading}
|
||||
tip="Loading..."
|
||||
color="#333"
|
||||
>
|
||||
<div style={{ marginTop: -15 }}>
|
||||
<RegionGroup
|
||||
setNowNameSpace={this.setNowNameSpace}
|
||||
namespaceCallBack={this.switchNamespace}
|
||||
/>
|
||||
</div>
|
||||
<h3 className="page-title">
|
||||
<span className="title-item">{subscriberList}</span>
|
||||
<span className="title-item">|</span>
|
||||
<span className="title-item">{nowNamespaceName}</span>
|
||||
<span className="title-item">{nowNamespaceId}</span>
|
||||
</h3>
|
||||
<Row
|
||||
className="demo-row"
|
||||
style={{
|
||||
marginBottom: 10,
|
||||
padding: 0,
|
||||
}}
|
||||
>
|
||||
<Col span="24">
|
||||
<Form inline field={this.field}>
|
||||
<FormItem label={serviceName}>
|
||||
<Input
|
||||
placeholder={serviceNamePlaceholder}
|
||||
style={{ width: 200 }}
|
||||
value={search.serviceName}
|
||||
onChange={serviceName => this.setState({ search: { ...search, serviceName } })}
|
||||
onPressEnter={() =>
|
||||
this.setState({ pageNo: 1 }, () => this.querySubscriberList())
|
||||
}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label={groupName}>
|
||||
<Input
|
||||
placeholder={groupNamePlaceholder}
|
||||
style={{ width: 200 }}
|
||||
value={search.groupName}
|
||||
onChange={groupName => this.setState({ search: { ...search, groupName } })}
|
||||
onPressEnter={() =>
|
||||
this.setState({ pageNo: 1 }, () => this.querySubscriberList())
|
||||
}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => this.setState({ pageNo: 1 }, () => this.querySubscriberList())}
|
||||
style={{ marginRight: 10 }}
|
||||
>
|
||||
{query}
|
||||
</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row style={{ padding: 0 }}>
|
||||
<Col span="24" style={{ padding: 0 }}>
|
||||
<Table dataSource={subscribers} locale={{ empty: pubNoData }}>
|
||||
<Column title={locale.address} dataIndex="addrStr" />
|
||||
<Column title={locale.clientVersion} dataIndex="agent" />
|
||||
<Column title={locale.appName} dataIndex="app" />
|
||||
</Table>
|
||||
</Col>
|
||||
</Row>
|
||||
{count > this.state.pageSize && (
|
||||
<div
|
||||
style={{
|
||||
marginTop: 10,
|
||||
textAlign: 'right',
|
||||
}}
|
||||
>
|
||||
<Pagination
|
||||
current={this.state.pageNo}
|
||||
total={count}
|
||||
pageSize={this.state.pageSize}
|
||||
onChange={pageNo => this.setState({ pageNo }, () => this.querySubscriberList())}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Loading>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default SubscriberList;
|
@ -0,0 +1,30 @@
|
||||
|
||||
/*
|
||||
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
.subscriber-list {
|
||||
.page-title {
|
||||
height: 30px;
|
||||
width: 100%;
|
||||
line-height: 30px;
|
||||
margin: 0 0 20px;
|
||||
padding: 0 0 0 10px;
|
||||
border-left: 3px solid #09c;
|
||||
color: #ccc;
|
||||
}
|
||||
.title-item {
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import SubscriberList from './SubscriberList';
|
||||
|
||||
export default SubscriberList;
|
@ -13,5 +13,6 @@
|
||||
|
||||
import locale from './locale';
|
||||
import base from './base';
|
||||
import subscribers from './subscribers';
|
||||
|
||||
export default { locale, base };
|
||||
export default { locale, base, subscribers };
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import request from '../utils/request';
|
||||
import { GET_SUBSCRIBERS, REMOVE_SUBSCRIBERS } from '../constants';
|
||||
|
||||
const initialState = {
|
||||
subscribers: {},
|
||||
};
|
||||
|
||||
const getSubscribers = params => dispatch =>
|
||||
request.get('v1/ns/service/subscribers', { params }).then(data => {
|
||||
dispatch({
|
||||
type: GET_SUBSCRIBERS,
|
||||
data,
|
||||
});
|
||||
});
|
||||
const removeSubscribers = () => dispatch => dispatch({ type: REMOVE_SUBSCRIBERS });
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case GET_SUBSCRIBERS:
|
||||
return { ...state, ...action.data };
|
||||
case REMOVE_SUBSCRIBERS:
|
||||
return { ...state, subscribers: {} };
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export { getSubscribers, removeSubscribers };
|
@ -46,31 +46,3 @@ export const getParameter = (search, name) => {
|
||||
const [, value = ''] = hit.split('=');
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
* 将回车符和空格替换
|
||||
* @param {*} separator 替换符
|
||||
*/
|
||||
export const replaceEnter = (separator = ',') => text => {
|
||||
if (typeof text !== 'string') {
|
||||
return text;
|
||||
}
|
||||
|
||||
return text
|
||||
.replace(/\r\n/g, separator)
|
||||
.replace(/[\r\n]/g, separator)
|
||||
.replace(/[\t\s]/g, '');
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理metaData对象生成可显示对象
|
||||
*/
|
||||
export const processMetaData = (separator = ',') => (metadata = {}) => {
|
||||
if (Object.prototype.toString.call(metadata) !== '[object Object]') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return Object.keys(metadata)
|
||||
.map(key => `${key}=${metadata[key]}`)
|
||||
.join(separator);
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
ls ~/nvm || git clone https://github.com/creationix/nvm.git ~/nvm
|
||||
source ~/nvm/nvm.sh
|
||||
nvm install v7.10.0
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -39,10 +39,8 @@ server.tomcat.basedir=
|
||||
|
||||
nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/**
|
||||
|
||||
nacos.naming.distro.taskDispatchThreadCount=1
|
||||
nacos.naming.distro.taskDispatchPeriod=200
|
||||
nacos.naming.distro.batchSyncKeyCount=1000
|
||||
nacos.naming.distro.initDataRatio=0.9
|
||||
nacos.naming.distro.syncRetryDelay=5000
|
||||
nacos.naming.data.warmup=true
|
||||
nacos.naming.expireInstance=true
|
||||
|
@ -19,7 +19,6 @@ import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.core.utils.SystemUtils;
|
||||
import com.alibaba.nacos.naming.cluster.ServerListManager;
|
||||
import com.alibaba.nacos.naming.cluster.ServerMode;
|
||||
import com.alibaba.nacos.naming.cluster.ServerStatus;
|
||||
import com.alibaba.nacos.naming.cluster.servers.Server;
|
||||
import com.alibaba.nacos.naming.cluster.transport.Serializer;
|
||||
|
@ -51,7 +51,7 @@ public class RaftConsistencyServiceImpl implements PersistentConsistencyService
|
||||
raftCore.signalPublish(key, value);
|
||||
} catch (Exception e) {
|
||||
Loggers.RAFT.error("Raft put failed.", e);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft put failed, key:" + key + ", value:" + value);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft put failed, key:" + key + ", value:" + value, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ public class RaftConsistencyServiceImpl implements PersistentConsistencyService
|
||||
raftCore.unlistenAll(key);
|
||||
} catch (Exception e) {
|
||||
Loggers.RAFT.error("Raft remove failed.", e);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft remove failed, key:" + key);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft remove failed, key:" + key, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ public class RaftConsistencyServiceImpl implements PersistentConsistencyService
|
||||
raftCore.onPublish(datum, source);
|
||||
} catch (Exception e) {
|
||||
Loggers.RAFT.error("Raft onPut failed.", e);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft onPut failed, datum:" + datum + ", source: " + source);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft onPut failed, datum:" + datum + ", source: " + source, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public class RaftConsistencyServiceImpl implements PersistentConsistencyService
|
||||
raftCore.onDelete(datum.key, source);
|
||||
} catch (Exception e) {
|
||||
Loggers.RAFT.error("Raft onRemove failed.", e);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft onRemove failed, datum:" + datum + ", source: " + source);
|
||||
throw new NacosException(NacosException.SERVER_ERROR, "Raft onRemove failed, datum:" + datum + ", source: " + source, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class RaftCore {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
datums = raftStore.loadDatums(notifier);
|
||||
raftStore.loadDatums(notifier, datums);
|
||||
|
||||
setTerm(NumberUtils.toLong(raftStore.loadMeta().getProperty("term"), 0L));
|
||||
|
||||
|
@ -41,7 +41,7 @@ import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* @author nacos
|
||||
@ -55,9 +55,8 @@ public class RaftStore {
|
||||
|
||||
private String cacheDir = UtilsAndCommons.DATA_BASE_DIR + File.separator + "data";
|
||||
|
||||
public synchronized ConcurrentHashMap<String, Datum> loadDatums(RaftCore.Notifier notifier) throws Exception {
|
||||
public synchronized void loadDatums(RaftCore.Notifier notifier, ConcurrentMap<String, Datum> datums) throws Exception {
|
||||
|
||||
ConcurrentHashMap<String, Datum> datums = new ConcurrentHashMap<>(32);
|
||||
Datum datum;
|
||||
long start = System.currentTimeMillis();
|
||||
for (File cache : listCaches()) {
|
||||
@ -78,7 +77,6 @@ public class RaftStore {
|
||||
}
|
||||
|
||||
Loggers.RAFT.info("finish loading all datums, size: {} cost {} ms.", datums.size(), (System.currentTimeMillis() - start));
|
||||
return datums;
|
||||
}
|
||||
|
||||
public synchronized Properties loadMeta() throws Exception {
|
||||
|
@ -16,14 +16,11 @@
|
||||
package com.alibaba.nacos.naming.controllers;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
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.pojo.AbstractHealthChecker;
|
||||
import com.alibaba.nacos.core.utils.WebUtils;
|
||||
import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeer;
|
||||
import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeerSet;
|
||||
import com.alibaba.nacos.naming.core.Cluster;
|
||||
import com.alibaba.nacos.naming.core.Service;
|
||||
import com.alibaba.nacos.naming.core.ServiceManager;
|
||||
@ -31,8 +28,7 @@ import com.alibaba.nacos.naming.exception.NacosException;
|
||||
import com.alibaba.nacos.naming.healthcheck.HealthCheckType;
|
||||
import com.alibaba.nacos.naming.misc.Loggers;
|
||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||
import com.alibaba.nacos.naming.pojo.ClusterStateView;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
@ -42,9 +38,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nkorange
|
||||
|
@ -18,7 +18,6 @@ package com.alibaba.nacos.naming.controllers;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.alibaba.nacos.core.utils.WebUtils;
|
||||
import com.alibaba.nacos.naming.cluster.ServerMode;
|
||||
import com.alibaba.nacos.naming.cluster.transport.Serializer;
|
||||
import com.alibaba.nacos.naming.consistency.Datum;
|
||||
import com.alibaba.nacos.naming.consistency.KeyBuilder;
|
||||
|
@ -22,7 +22,6 @@ import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.naming.CommonParams;
|
||||
import com.alibaba.nacos.api.naming.utils.NamingUtils;
|
||||
import com.alibaba.nacos.core.utils.WebUtils;
|
||||
import com.alibaba.nacos.naming.cluster.ServerMode;
|
||||
import com.alibaba.nacos.naming.core.DistroMapper;
|
||||
import com.alibaba.nacos.naming.core.Instance;
|
||||
import com.alibaba.nacos.naming.core.Service;
|
||||
@ -263,7 +262,7 @@ public class InstanceController {
|
||||
}
|
||||
|
||||
service.processClientBeat(clientBeat);
|
||||
|
||||
result.put("clientBeatInterval", instance.getInstanceHeartBeatInterval());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,6 @@ import com.alibaba.nacos.naming.web.NeedAuth;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
@ -376,6 +376,10 @@ public class ServiceController {
|
||||
*/
|
||||
@RequestMapping(value = "/subscribers", method = RequestMethod.GET)
|
||||
public JSONObject subscribers(HttpServletRequest request) {
|
||||
|
||||
int pageNo = NumberUtils.toInt(WebUtils.required(request, "pageNo"));
|
||||
int pageSize = NumberUtils.toInt(WebUtils.required(request, "pageSize"));
|
||||
|
||||
String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
|
||||
Constants.DEFAULT_NAMESPACE_ID);
|
||||
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
|
||||
@ -385,7 +389,23 @@ public class ServiceController {
|
||||
|
||||
try {
|
||||
List<Subscriber> subscribers = subscribeManager.getSubscribers(serviceName, namespaceId, aggregation);
|
||||
result.put("subscribers", subscribers);
|
||||
|
||||
int start = (pageNo - 1) * pageSize;
|
||||
int end = start + pageSize;
|
||||
|
||||
int count = subscribers.size();
|
||||
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
if (end > count) {
|
||||
end = count;
|
||||
}
|
||||
|
||||
result.put("subscribers", subscribers.subList(start, end));
|
||||
result.put("count", count);
|
||||
|
||||
return result;
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
|
@ -21,7 +21,6 @@ import com.alibaba.nacos.naming.boot.RunningConfig;
|
||||
import com.alibaba.nacos.naming.cluster.ServerListManager;
|
||||
import com.alibaba.nacos.naming.cluster.servers.Server;
|
||||
import com.alibaba.nacos.naming.misc.HttpClient;
|
||||
import com.alibaba.nacos.naming.misc.Loggers;
|
||||
import com.alibaba.nacos.naming.misc.NetUtils;
|
||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||
import com.alibaba.nacos.naming.pojo.Subscriber;
|
||||
|
@ -17,6 +17,8 @@ package com.alibaba.nacos.naming.healthcheck;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
|
||||
import com.alibaba.nacos.naming.boot.RunningConfig;
|
||||
import com.alibaba.nacos.naming.boot.SpringContext;
|
||||
import com.alibaba.nacos.naming.core.DistroMapper;
|
||||
@ -26,9 +28,14 @@ import com.alibaba.nacos.naming.misc.*;
|
||||
import com.alibaba.nacos.naming.push.PushService;
|
||||
import com.ning.http.client.AsyncCompletionHandler;
|
||||
import com.ning.http.client.Response;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.alibaba.nacos.naming.misc.UtilsAndCommons.NUMBER_PATTERN;
|
||||
|
||||
|
||||
/**
|
||||
* Check and update statues of ephemeral instances, remove them if they have been expired.
|
||||
@ -73,13 +80,13 @@ public class ClientBeatCheckTask implements Runnable {
|
||||
|
||||
// first set health status of instances:
|
||||
for (Instance instance : instances) {
|
||||
if (System.currentTimeMillis() - instance.getLastBeat() > ClientBeatProcessor.CLIENT_BEAT_TIMEOUT) {
|
||||
if (System.currentTimeMillis() - instance.getLastBeat() > instance.getInstanceHeartBeatTimeOut()) {
|
||||
if (!instance.isMarked()) {
|
||||
if (instance.isHealthy()) {
|
||||
instance.setHealthy(false);
|
||||
Loggers.EVT_LOG.info("{POS} {IP-DISABLED} valid: {}:{}@{}@{}, region: {}, msg: client timeout after {}, last beat: {}",
|
||||
instance.getIp(), instance.getPort(), instance.getClusterName(), service.getName(),
|
||||
UtilsAndCommons.LOCALHOST_SITE, ClientBeatProcessor.CLIENT_BEAT_TIMEOUT, instance.getLastBeat());
|
||||
UtilsAndCommons.LOCALHOST_SITE, instance.getInstanceHeartBeatTimeOut(), instance.getLastBeat());
|
||||
getPushService().serviceChanged(service.getNamespaceId(), service.getName());
|
||||
}
|
||||
}
|
||||
@ -92,7 +99,7 @@ public class ClientBeatCheckTask implements Runnable {
|
||||
|
||||
// then remove obsolete instances:
|
||||
for (Instance instance : instances) {
|
||||
if (System.currentTimeMillis() - instance.getLastBeat() > service.getIpDeleteTimeout()) {
|
||||
if (System.currentTimeMillis() - instance.getLastBeat() > instance.getIpDeleteTimeout()) {
|
||||
// delete instance
|
||||
Loggers.SRV_LOG.info("[AUTO-DELETE-IP] service: {}, ip: {}", service.getName(), JSON.toJSONString(instance));
|
||||
deleteIP(instance);
|
||||
@ -105,6 +112,7 @@ public class ClientBeatCheckTask implements Runnable {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void deleteIP(Instance instance) {
|
||||
|
||||
try {
|
||||
|
@ -23,7 +23,6 @@ import com.alibaba.fastjson.serializer.JSONSerializer;
|
||||
import com.alibaba.fastjson.serializer.ObjectSerializer;
|
||||
import com.alibaba.fastjson.serializer.SerializeWriter;
|
||||
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -17,7 +17,6 @@ package com.alibaba.nacos.naming.healthcheck;
|
||||
|
||||
import com.alibaba.nacos.naming.core.Cluster;
|
||||
import com.alibaba.nacos.naming.core.Instance;
|
||||
import com.alibaba.nacos.naming.core.Service;
|
||||
import com.alibaba.nacos.naming.misc.Loggers;
|
||||
import com.alibaba.nacos.naming.misc.SwitchDomain;
|
||||
import com.alibaba.nacos.naming.monitor.MetricsMonitor;
|
||||
|
@ -27,22 +27,19 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class GlobalConfig {
|
||||
|
||||
@Value("${nacos.naming.distro.taskDispatchPeriod}")
|
||||
@Value("${nacos.naming.distro.taskDispatchPeriod:200}")
|
||||
private int taskDispatchPeriod = 2000;
|
||||
|
||||
@Value("${nacos.naming.distro.batchSyncKeyCount}")
|
||||
@Value("${nacos.naming.distro.batchSyncKeyCount:1000}")
|
||||
private int batchSyncKeyCount = 1000;
|
||||
|
||||
@Value("${nacos.naming.distro.syncRetryDelay}")
|
||||
@Value("${nacos.naming.distro.syncRetryDelay:5000}")
|
||||
private long syncRetryDelay = 5000L;
|
||||
|
||||
@Value("${nacos.naming.distro.taskDispatchThreadCount}")
|
||||
private int taskDispatchThreadCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
@Value("${nacos.naming.data.warmup}")
|
||||
@Value("${nacos.naming.data.warmup:false}")
|
||||
private boolean dataWarmup = false;
|
||||
|
||||
@Value("${nacos.naming.expireInstance}")
|
||||
@Value("${nacos.naming.expireInstance:true}")
|
||||
private boolean expireInstance = true;
|
||||
|
||||
public int getTaskDispatchPeriod() {
|
||||
@ -57,10 +54,6 @@ public class GlobalConfig {
|
||||
return syncRetryDelay;
|
||||
}
|
||||
|
||||
public int getTaskDispatchThreadCount() {
|
||||
return taskDispatchThreadCount;
|
||||
}
|
||||
|
||||
public boolean isDataWarmup() {
|
||||
return dataWarmup;
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import com.alibaba.nacos.common.util.HttpMethod;
|
||||
import com.ning.http.client.AsyncCompletionHandler;
|
||||
import com.ning.http.client.AsyncHttpClient;
|
||||
import com.ning.http.client.AsyncHttpClientConfig;
|
||||
import com.ning.http.client.FluentStringsMap;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@ -28,7 +27,6 @@ import org.apache.http.*;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.entity.ContentType;
|
||||
@ -36,7 +34,6 @@ import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -16,7 +16,6 @@
|
||||
package com.alibaba.nacos.naming.misc;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.core.utils.SystemUtils;
|
||||
import com.alibaba.nacos.naming.boot.RunningConfig;
|
||||
import com.ning.http.client.AsyncCompletionHandler;
|
||||
import com.ning.http.client.Response;
|
||||
|
@ -118,6 +118,8 @@ public class UtilsAndCommons {
|
||||
|
||||
public static final String DATA_BASE_DIR = NACOS_HOME + File.separator + "data" + File.separator + "naming";
|
||||
|
||||
public static final String NUMBER_PATTERN = "^\\d+$";
|
||||
|
||||
public static final ScheduledExecutorService SERVICE_SYNCHRONIZATION_EXECUTOR;
|
||||
|
||||
public static final ScheduledExecutorService SERVICE_UPDATE_EXECUTOR;
|
||||
|
@ -144,7 +144,7 @@ public class ClientInfo {
|
||||
/**
|
||||
* Unknown client type
|
||||
*/
|
||||
UNKNOWN;
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
public static class ClientTypeDescription {
|
||||
|
@ -16,11 +16,9 @@
|
||||
package com.alibaba.nacos.naming.web;
|
||||
|
||||
import com.alibaba.nacos.naming.acl.AuthChecker;
|
||||
import com.alibaba.nacos.naming.controllers.*;
|
||||
import com.alibaba.nacos.naming.exception.NacosException;
|
||||
import com.alibaba.nacos.naming.misc.SwitchDomain;
|
||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.servlet.*;
|
||||
@ -30,8 +28,6 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.security.AccessControlException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* @author nkorange
|
||||
|
@ -17,7 +17,6 @@ package com.alibaba.nacos.naming.web;
|
||||
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.naming.CommonParams;
|
||||
import com.alibaba.nacos.naming.boot.SpringContext;
|
||||
import com.alibaba.nacos.naming.core.DistroMapper;
|
||||
import com.alibaba.nacos.naming.misc.HttpClient;
|
||||
import com.alibaba.nacos.naming.misc.Loggers;
|
||||
|
@ -16,7 +16,6 @@
|
||||
package com.alibaba.nacos.naming.web;
|
||||
|
||||
import com.alibaba.nacos.common.util.HttpMethod;
|
||||
import com.alibaba.nacos.naming.cluster.ServerMode;
|
||||
import com.alibaba.nacos.naming.cluster.ServerStatus;
|
||||
import com.alibaba.nacos.naming.cluster.ServerStatusManager;
|
||||
import com.alibaba.nacos.naming.misc.SwitchDomain;
|
||||
@ -28,8 +27,6 @@ import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -25,12 +25,3 @@ server.tomcat.accesslog.enabled=true
|
||||
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
||||
# default current work dir
|
||||
server.tomcat.basedir=
|
||||
|
||||
nacos.naming.distro.taskDispatchThreadCount=1
|
||||
nacos.naming.distro.taskDispatchPeriod=200
|
||||
nacos.naming.distro.batchSyncKeyCount=1000
|
||||
nacos.naming.distro.initDataRatio=0.9
|
||||
nacos.naming.distro.syncRetryDelay=5000
|
||||
|
||||
nacos.naming.data.warmup=true
|
||||
nacos.naming.expireInstance=true
|
||||
|
@ -16,7 +16,7 @@
|
||||
package com.alibaba.nacos.naming.consistency.ephemeral.distro;
|
||||
|
||||
import com.alibaba.nacos.naming.misc.GlobalConfig;
|
||||
import com.alibaba.nacos.naming.misc.Loggers;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
@ -16,8 +16,6 @@
|
||||
package com.alibaba.nacos.naming.core;
|
||||
|
||||
import com.alibaba.nacos.naming.boot.SpringContext;
|
||||
import com.alibaba.nacos.naming.healthcheck.HealthCheckProcessorDelegate;
|
||||
import com.alibaba.nacos.naming.misc.SwitchDomain;
|
||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||
import com.alibaba.nacos.naming.push.PushService;
|
||||
import org.junit.Assert;
|
||||
|
@ -0,0 +1,129 @@
|
||||
package com.alibaba.nacos.naming.healthcheck;
|
||||
|
||||
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
|
||||
import com.alibaba.nacos.core.utils.SystemUtils;
|
||||
import com.alibaba.nacos.naming.core.*;
|
||||
import com.alibaba.nacos.naming.misc.GlobalConfig;
|
||||
import com.alibaba.nacos.naming.push.PushService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caoyixiong
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class ClientBeatCheckTaskTest {
|
||||
|
||||
@InjectMocks
|
||||
@Spy
|
||||
private ClientBeatCheckTask clientBeatCheckTask;
|
||||
@Mock
|
||||
private DistroMapper distroMapperSpy;
|
||||
@Mock
|
||||
private Service serviceSpy;
|
||||
@Mock
|
||||
private GlobalConfig globalConfig;
|
||||
@Mock
|
||||
private PushService pushService;
|
||||
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
ReflectionTestUtils.setField(clientBeatCheckTask, "service", serviceSpy);
|
||||
Mockito.doReturn(distroMapperSpy).when(clientBeatCheckTask).getDistroMapper();
|
||||
Mockito.doReturn(globalConfig).when(clientBeatCheckTask).getGlobalConfig();
|
||||
Mockito.doReturn(pushService).when(clientBeatCheckTask).getPushService();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeartBeatNotTimeout() {
|
||||
List<Instance> instances = new ArrayList<>();
|
||||
Instance instance = new Instance();
|
||||
instance.setLastBeat(System.currentTimeMillis());
|
||||
instance.setMarked(false);
|
||||
instance.setHealthy(true);
|
||||
Map<String, String> metadata = new HashMap<>();
|
||||
metadata.put(PreservedMetadataKeys.HEART_BEAT_TIMEOUT, "1000000000");
|
||||
instance.setMetadata(metadata);
|
||||
instances.add(instance);
|
||||
Mockito.when(serviceSpy.allIPs(true)).thenReturn(instances);
|
||||
|
||||
Mockito.doReturn("test").when(serviceSpy).getName();
|
||||
Mockito.doReturn(true).when(distroMapperSpy).responsible(Mockito.anyString());
|
||||
clientBeatCheckTask.run();
|
||||
Assert.assertTrue(instance.isHealthy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeartBeatTimeout() {
|
||||
List<Instance> instances = new ArrayList<>();
|
||||
Instance instance = new Instance();
|
||||
instance.setLastBeat(System.currentTimeMillis() - 1000);
|
||||
instance.setMarked(false);
|
||||
instance.setHealthy(true);
|
||||
Map<String, String> metadata = new HashMap<>();
|
||||
metadata.put(PreservedMetadataKeys.HEART_BEAT_TIMEOUT, "10");
|
||||
instance.setMetadata(metadata);
|
||||
instances.add(instance);
|
||||
Mockito.doReturn("test").when(serviceSpy).getName();
|
||||
Mockito.doReturn(true).when(distroMapperSpy).responsible(Mockito.anyString());
|
||||
|
||||
Mockito.when(serviceSpy.allIPs(true)).thenReturn(instances);
|
||||
|
||||
clientBeatCheckTask.run();
|
||||
Assert.assertFalse(instance.isHealthy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIpDeleteTimeOut() {
|
||||
List<Instance> instances = new ArrayList<>();
|
||||
Instance instance = new Instance();
|
||||
instance.setLastBeat(System.currentTimeMillis());
|
||||
instance.setMarked(true);
|
||||
instance.setHealthy(true);
|
||||
Map<String, String> metadata = new HashMap<>();
|
||||
metadata.put(PreservedMetadataKeys.IP_DELETE_TIMEOUT, "10");
|
||||
instance.setMetadata(metadata);
|
||||
instances.add(instance);
|
||||
Mockito.doReturn(true).when(distroMapperSpy).responsible(null);
|
||||
Mockito.doReturn(true).when(globalConfig).isExpireInstance();
|
||||
Mockito.when(serviceSpy.allIPs(true)).thenReturn(instances);
|
||||
|
||||
clientBeatCheckTask.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIpDeleteNotTimeOut() {
|
||||
List<Instance> instances = new ArrayList<>();
|
||||
Instance instance = new Instance();
|
||||
instance.setLastBeat(System.currentTimeMillis());
|
||||
instance.setMarked(true);
|
||||
instance.setHealthy(true);
|
||||
Map<String, String> metadata = new HashMap<>();
|
||||
metadata.put(PreservedMetadataKeys.IP_DELETE_TIMEOUT, "10000");
|
||||
instance.setMetadata(metadata);
|
||||
instances.add(instance);
|
||||
|
||||
Mockito.doReturn(true).when(distroMapperSpy).responsible(null);
|
||||
Mockito.doReturn(true).when(globalConfig).isExpireInstance();
|
||||
Mockito.when(serviceSpy.allIPs(true)).thenReturn(instances);
|
||||
|
||||
clientBeatCheckTask.run();
|
||||
}
|
||||
}
|
@ -86,7 +86,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, result.code);
|
||||
Assert.assertEquals(true, JSON.parseObject(result.content).getBoolean("data"));
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(result);
|
||||
value = iconfig.getConfig(dataId, group, TIME_OUT);
|
||||
System.out.println(value);
|
||||
Assert.assertEquals(null, value);
|
||||
Assert.assertNull(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,7 +133,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(true);
|
||||
return;
|
||||
}
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,7 +218,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(true);
|
||||
return;
|
||||
}
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -251,7 +251,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(true);
|
||||
return;
|
||||
}
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -283,7 +283,7 @@ public class ConfigAPI_ITCase {
|
||||
Thread.sleep(TIME_OUT);
|
||||
Assert.assertTrue(result);
|
||||
String value = iconfig.getConfig(dataId, group, TIME_OUT);
|
||||
Assert.assertEquals(null, value);
|
||||
Assert.assertNull(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -310,7 +310,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(true);
|
||||
return;
|
||||
}
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -366,7 +366,7 @@ public class ConfigAPI_ITCase {
|
||||
public void nacos_addListener_2() {
|
||||
try {
|
||||
iconfig.addListener(dataId, group, null);
|
||||
Assert.assertFalse(true);
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
Assert.assertFalse(false);
|
||||
}
|
||||
@ -537,7 +537,7 @@ public class ConfigAPI_ITCase {
|
||||
iconfig.addListener(dataId, group, new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
});
|
||||
Thread.sleep(TIME_OUT);
|
||||
@ -571,7 +571,7 @@ public class ConfigAPI_ITCase {
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,7 +653,7 @@ public class ConfigAPI_ITCase {
|
||||
|
||||
Assert.assertEquals(content, JSON.parseObject(result.content).getString("content"));
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,7 +682,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertNotNull(JSON.parseObject(result.content).getString("data"));
|
||||
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -713,7 +713,7 @@ public class ConfigAPI_ITCase {
|
||||
result = agent.httpDelete(CONFIG_CONTROLLER_PATH + "/", null, params, agent.getEncode(), TIME_OUT);
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, result.code);
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -744,7 +744,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, result.code);
|
||||
Assert.assertEquals(true, JSON.parseObject(result.content).getBoolean("data"));
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -773,7 +773,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertTrue(JSON.parseObject(result.content).getIntValue("totalCount") >= 1);
|
||||
Assert.assertTrue(JSON.parseObject(result.content).getJSONArray("pageItems").getJSONObject(0).getString("content").startsWith(content));
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -803,7 +803,7 @@ public class ConfigAPI_ITCase {
|
||||
Assert.assertEquals(content, JSON.parseObject(result.content).getJSONArray("pageItems").getJSONObject(0).getString("content"));
|
||||
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -829,11 +829,11 @@ public class ConfigAPI_ITCase {
|
||||
result = agent.httpGet(CONFIG_CONTROLLER_PATH + "/", null, params, agent.getEncode(), TIME_OUT);
|
||||
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, result.code);
|
||||
Assert.assertTrue(JSON.parseObject(result.content).getIntValue("totalCount") == 1);
|
||||
Assert.assertEquals(1, JSON.parseObject(result.content).getIntValue("totalCount"));
|
||||
Assert.assertEquals(content, JSON.parseObject(result.content).getJSONArray("pageItems").getJSONObject(0).getString("content"));
|
||||
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@ -858,10 +858,10 @@ public class ConfigAPI_ITCase {
|
||||
List<String> params = Arrays.asList("dataId", dataId, "group", group, "pageNo","1", "pageSize","10", "search", "accurate");
|
||||
result = agent.httpGet(CONFIG_CONTROLLER_PATH + "/", null, params, "utf-8", TIME_OUT);
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, result.code);
|
||||
Assert.assertTrue(JSON.parseObject(result.content).getIntValue("totalCount") == 1);
|
||||
Assert.assertEquals(1, JSON.parseObject(result.content).getIntValue("totalCount"));
|
||||
Assert.assertEquals(content, JSON.parseObject(result.content).getJSONArray("pageItems").getJSONObject(0).getString("content"));
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,20 +20,14 @@ import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.swing.text.View;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.naming.CommonParams;
|
||||
import com.alibaba.nacos.api.naming.NamingFactory;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.api.naming.pojo.ListView;
|
||||
import com.alibaba.nacos.config.server.utils.TimeUtils;
|
||||
import com.alibaba.nacos.config.server.utils.TimeoutUtils;
|
||||
import com.alibaba.nacos.naming.NamingApp;
|
||||
|
||||
import org.junit.After;
|
||||
@ -54,8 +48,6 @@ import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
import static com.alibaba.nacos.test.naming.NamingBase.*;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author nkorange
|
||||
*/
|
||||
|
@ -46,9 +46,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import static com.alibaba.nacos.client.naming.net.HttpClient.request;
|
||||
import static com.alibaba.nacos.test.naming.NamingBase.*;
|
||||
import static com.alibaba.nacos.test.naming.NamingBase.randomDomainName;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = NamingApp.class, properties = {"server.servlet.context-path=/nacos",
|
||||
|
@ -25,7 +25,6 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.test.annotation.Repeat;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -16,7 +16,6 @@ import com.alibaba.nacos.api.naming.listener.NamingEvent;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.api.naming.pojo.ListView;
|
||||
import com.alibaba.nacos.naming.NamingApp;
|
||||
import com.alibaba.nacos.naming.selector.Selector;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.alibaba.nacos.test.naming;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@ -13,11 +12,7 @@ import com.alibaba.nacos.api.PropertyKeyConst;
|
||||
import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.naming.NamingFactory;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.listener.Event;
|
||||
import com.alibaba.nacos.api.naming.listener.EventListener;
|
||||
import com.alibaba.nacos.api.naming.listener.NamingEvent;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.api.naming.pojo.ListView;
|
||||
import com.alibaba.nacos.client.naming.NacosNamingService;
|
||||
import com.alibaba.nacos.naming.NamingApp;
|
||||
|
||||
|
@ -38,7 +38,6 @@ public class RandomUtils {
|
||||
public static long getLongMoreThanZero() {
|
||||
long res;
|
||||
for(res = rd.nextLong(); res <= 0L; res = rd.nextLong()) {
|
||||
;
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -52,7 +51,6 @@ public class RandomUtils {
|
||||
public static long getLongMoreThanZeroLessThan(long n) {
|
||||
long res;
|
||||
for(res = getLongLessThan(n); res <= 0L; res = getLongLessThan(n)) {
|
||||
;
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -74,7 +72,6 @@ public class RandomUtils {
|
||||
public static int getIntegerMoreThanZero() {
|
||||
int res;
|
||||
for(res = rd.nextInt(); res <= 0; res = rd.nextInt()) {
|
||||
;
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -88,7 +85,6 @@ public class RandomUtils {
|
||||
public static int getIntegerMoreThanZeroLessThan(int n) {
|
||||
int res;
|
||||
for(res = rd.nextInt(n); res == 0; res = rd.nextInt(n)) {
|
||||
;
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -273,7 +269,6 @@ public class RandomUtils {
|
||||
int[] source = new int[len];
|
||||
|
||||
for(int i = min; i < min + len; source[i - min] = i++) {
|
||||
;
|
||||
}
|
||||
|
||||
int[] result = new int[n];
|
||||
|
@ -19,7 +19,7 @@ import com.alibaba.nacos.api.naming.NamingFactory;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.naming.NamingApp;
|
||||
import org.junit.After;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -28,7 +28,6 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.net.ServerSocket;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -89,7 +88,7 @@ public class SelectOneHealthyInstance_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,7 +107,7 @@ public class SelectOneHealthyInstance_ITCase {
|
||||
TimeUnit.SECONDS.sleep(2);
|
||||
Instance instance = naming.selectOneHealthyInstance(serviceName, Arrays.asList("c1"));
|
||||
|
||||
Assert.assertTrue(instance.getIp() != "1.1.1.1");
|
||||
Assert.assertNotSame("1.1.1.1", instance.getIp());
|
||||
Assert.assertTrue(instance.getPort() != 60002);
|
||||
|
||||
List<Instance> instancesGet = naming.getAllInstances(serviceName);
|
||||
@ -122,7 +121,7 @@ public class SelectOneHealthyInstance_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,7 +138,7 @@ public class SelectOneHealthyInstance_ITCase {
|
||||
|
||||
TimeUnit.SECONDS.sleep(2);
|
||||
Instance instance = naming.selectOneHealthyInstance(serviceName, Arrays.asList("c1", "c2"));
|
||||
Assert.assertTrue(instance.getIp() != "1.1.1.1");
|
||||
Assert.assertNotSame("1.1.1.1", instance.getIp());
|
||||
|
||||
List<Instance> instancesGet = naming.getAllInstances(serviceName);
|
||||
|
||||
@ -152,6 +151,6 @@ public class SelectOneHealthyInstance_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +196,6 @@ public class SubscribeCluster_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.alibaba.nacos.test.naming.NamingBase.*;
|
||||
|
||||
@ -111,7 +110,7 @@ public class Unsubscribe_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,7 +153,7 @@ public class Unsubscribe_ITCase {
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertTrue(false);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,11 +18,3 @@ server.tomcat.accesslog.enabled=false
|
||||
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
||||
# default current work dir
|
||||
server.tomcat.basedir=
|
||||
|
||||
nacos.naming.distro.taskDispatchThreadCount=1
|
||||
nacos.naming.distro.taskDispatchPeriod=200
|
||||
nacos.naming.distro.batchSyncKeyCount=1000
|
||||
nacos.naming.distro.initDataRatio=0.9
|
||||
nacos.naming.distro.syncRetryDelay=5000
|
||||
nacos.naming.data.warmup=false
|
||||
nacos.naming.expireInstance=true
|
||||
|
Loading…
Reference in New Issue
Block a user