Merge pull request #628 from alibaba/feature_multi_tenant
Feature multi tenant
This commit is contained in:
commit
07d92f6174
@ -83,6 +83,7 @@ class NameSpaceList extends React.Component {
|
|||||||
切换namespace
|
切换namespace
|
||||||
* */
|
* */
|
||||||
changeNameSpace(ns, nsName) {
|
changeNameSpace(ns, nsName) {
|
||||||
|
localStorage.setItem('namespace', ns);
|
||||||
this.setnamespace(ns || '');
|
this.setnamespace(ns || '');
|
||||||
setParams({
|
setParams({
|
||||||
namespace: ns || '',
|
namespace: ns || '',
|
||||||
@ -140,6 +141,7 @@ class NameSpaceList extends React.Component {
|
|||||||
}
|
}
|
||||||
window.namespaceShowName = namespaceShowName;
|
window.namespaceShowName = namespaceShowName;
|
||||||
setParams('namespace', nownamespace || '');
|
setParams('namespace', nownamespace || '');
|
||||||
|
localStorage.setItem('namespace', nownamespace);
|
||||||
// setParams('namespaceShowName', namespaceShowName);
|
// setParams('namespaceShowName', namespaceShowName);
|
||||||
this.props.setNowNameSpace && this.props.setNowNameSpace(namespaceShowName, nownamespace);
|
this.props.setNowNameSpace && this.props.setNowNameSpace(namespaceShowName, nownamespace);
|
||||||
this.setState({
|
this.setState({
|
||||||
@ -191,8 +193,8 @@ class NameSpaceList extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={namespaceList.length > 0 ? 'namespacewrapper' : ''}
|
className={namespaceList.length ? 'namespacewrapper' : ''}
|
||||||
style={namespaceList.length > 0 ? namespacestyle : {}}
|
style={namespaceList.length ? namespacestyle : {}}
|
||||||
>
|
>
|
||||||
{}
|
{}
|
||||||
{title ? (
|
{title ? (
|
||||||
|
@ -217,6 +217,7 @@ const aliwareIntl = (function(_global) {
|
|||||||
this.nowData = nowData;
|
this.nowData = nowData;
|
||||||
this.setMomentLocale(this.currentLanguageCode);
|
this.setMomentLocale(this.currentLanguageCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
let aliwareLocal = aliwareGetCookieByKeyName('aliyun_lang') || 'zh';
|
let aliwareLocal = aliwareGetCookieByKeyName('aliyun_lang') || 'zh';
|
||||||
let aliwareLocalSite = aliwareGetCookieByKeyName('aliyun_country') || 'cn';
|
let aliwareLocalSite = aliwareGetCookieByKeyName('aliyun_country') || 'cn';
|
||||||
aliwareLocal = aliwareLocal.toLowerCase();
|
aliwareLocal = aliwareLocal.toLowerCase();
|
||||||
@ -473,6 +474,7 @@ const request = (function(_global) {
|
|||||||
return serviceObj;
|
return serviceObj;
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加中间件函数
|
* 添加中间件函数
|
||||||
* @param {*function} callback 回调函数
|
* @param {*function} callback 回调函数
|
||||||
@ -485,6 +487,7 @@ const request = (function(_global) {
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理中间件
|
* 处理中间件
|
||||||
* @param {*Object} config ajax请求配置信息
|
* @param {*Object} config ajax请求配置信息
|
||||||
@ -504,6 +507,7 @@ const request = (function(_global) {
|
|||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理自定义url
|
* 处理自定义url
|
||||||
* @param {*Object} config ajax请求配置信息
|
* @param {*Object} config ajax请求配置信息
|
||||||
@ -594,6 +598,10 @@ const request = (function(_global) {
|
|||||||
// 处理后置中间件
|
// 处理后置中间件
|
||||||
config = handleMiddleWare.apply(this, [config, ...args, middlewareBackList]);
|
config = handleMiddleWare.apply(this, [config, ...args, middlewareBackList]);
|
||||||
|
|
||||||
|
const namespace = localStorage.getItem('namespace') ? localStorage.getItem('namespace') : '';
|
||||||
|
const namespaceConf = { namespaceId: namespace };
|
||||||
|
config.data = config.data ? Object.assign({}, config.data, namespaceConf) : namespaceConf;
|
||||||
|
|
||||||
return $.ajax(
|
return $.ajax(
|
||||||
Object.assign({}, config, {
|
Object.assign({}, config, {
|
||||||
type: config.type,
|
type: config.type,
|
||||||
@ -621,6 +629,7 @@ const request = (function(_global) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暴露方法
|
// 暴露方法
|
||||||
Request.handleCustomService = handleCustomService;
|
Request.handleCustomService = handleCustomService;
|
||||||
Request.handleMiddleWare = handleMiddleWare;
|
Request.handleMiddleWare = handleMiddleWare;
|
||||||
|
@ -64,8 +64,8 @@ class EditClusterDialog extends React.Component {
|
|||||||
healthChecker,
|
healthChecker,
|
||||||
} = this.state.editCluster;
|
} = this.state.editCluster;
|
||||||
request({
|
request({
|
||||||
method: 'POST',
|
method: 'PUT',
|
||||||
url: 'v1/ns/cluster/update',
|
url: 'v1/ns/cluster',
|
||||||
data: {
|
data: {
|
||||||
serviceName,
|
serviceName,
|
||||||
clusterName: name,
|
clusterName: name,
|
||||||
|
@ -58,8 +58,8 @@ class EditInstanceDialog extends React.Component {
|
|||||||
const { serviceName, clusterName, getInstanceList, openLoading, closeLoading } = this.props;
|
const { serviceName, clusterName, getInstanceList, openLoading, closeLoading } = this.props;
|
||||||
const { ip, port, weight, enabled, metadataText } = this.state.editInstance;
|
const { ip, port, weight, enabled, metadataText } = this.state.editInstance;
|
||||||
request({
|
request({
|
||||||
method: 'POST',
|
method: 'PUT',
|
||||||
url: 'v1/ns/instance/update',
|
url: 'v1/ns/instance',
|
||||||
data: { serviceName, clusterName, ip, port, weight, enable: enabled, metadata: metadataText },
|
data: { serviceName, clusterName, ip, port, weight, enable: enabled, metadata: metadataText },
|
||||||
dataType: 'text',
|
dataType: 'text',
|
||||||
beforeSend: () => openLoading(),
|
beforeSend: () => openLoading(),
|
||||||
|
@ -57,7 +57,7 @@ class EditServiceDialog extends React.Component {
|
|||||||
const editService = Object.assign({}, this.state.editService);
|
const editService = Object.assign({}, this.state.editService);
|
||||||
const { name, protectThreshold, healthCheckMode, metadataText, selector } = editService;
|
const { name, protectThreshold, healthCheckMode, metadataText, selector } = editService;
|
||||||
request({
|
request({
|
||||||
method: isCreate ? 'PUT' : 'POST',
|
method: isCreate ? 'POST' : 'PUT',
|
||||||
url: 'v1/ns/service',
|
url: 'v1/ns/service',
|
||||||
data: {
|
data: {
|
||||||
serviceName: name,
|
serviceName: name,
|
||||||
|
@ -80,8 +80,8 @@ class InstanceTable extends React.Component {
|
|||||||
const newVal = Object.assign({}, instance);
|
const newVal = Object.assign({}, instance);
|
||||||
newVal.list[index].enabled = !enabled;
|
newVal.list[index].enabled = !enabled;
|
||||||
request({
|
request({
|
||||||
method: 'POST',
|
method: 'PUT',
|
||||||
url: 'v1/ns/instance/update',
|
url: 'v1/ns/instance',
|
||||||
data: {
|
data: {
|
||||||
serviceName,
|
serviceName,
|
||||||
clusterName,
|
clusterName,
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -50,6 +50,10 @@ public class WebUtils {
|
|||||||
|
|
||||||
String value = req.getParameter(key);
|
String value = req.getParameter(key);
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(value)) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
String encoding = req.getParameter("encoding");
|
String encoding = req.getParameter("encoding");
|
||||||
if (!StringUtils.isEmpty(encoding)) {
|
if (!StringUtils.isEmpty(encoding)) {
|
||||||
try {
|
try {
|
||||||
|
@ -27,7 +27,6 @@ import com.alibaba.nacos.naming.exception.NacosException;
|
|||||||
import com.alibaba.nacos.naming.healthcheck.HealthCheckMode;
|
import com.alibaba.nacos.naming.healthcheck.HealthCheckMode;
|
||||||
import com.alibaba.nacos.naming.misc.Switch;
|
import com.alibaba.nacos.naming.misc.Switch;
|
||||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||||
import com.alibaba.nacos.naming.raft.RaftCore;
|
|
||||||
import com.alibaba.nacos.naming.selector.LabelSelector;
|
import com.alibaba.nacos.naming.selector.LabelSelector;
|
||||||
import com.alibaba.nacos.naming.selector.NoneSelector;
|
import com.alibaba.nacos.naming.selector.NoneSelector;
|
||||||
import com.alibaba.nacos.naming.selector.Selector;
|
import com.alibaba.nacos.naming.selector.Selector;
|
||||||
@ -144,9 +143,6 @@ public class ServiceController {
|
|||||||
|
|
||||||
res.put("selector", domain.getSelector());
|
res.put("selector", domain.getSelector());
|
||||||
|
|
||||||
res.put("instanceTimestamp", RaftCore.getDatum(UtilsAndCommons.getIPListStoreKey(domain)).timestamp.get());
|
|
||||||
res.put("serviceTimestamp", RaftCore.getDatum(UtilsAndCommons.getDomStoreKey(domain)).timestamp.get());
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,12 +606,12 @@ public class DomainsManager {
|
|||||||
final RaftListener raftListener = new RaftListener() {
|
final RaftListener raftListener = new RaftListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean interests(String key) {
|
public boolean interests(String key) {
|
||||||
return StringUtils.startsWith(key, UtilsAndCommons.DOMAINS_DATA_ID);
|
return StringUtils.startsWith(key, UtilsAndCommons.DOMAINS_DATA_ID_PRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchUnlistenKey(String key) {
|
public boolean matchUnlistenKey(String key) {
|
||||||
return StringUtils.equals(key, UtilsAndCommons.DOMAINS_DATA_ID + ".*");
|
return StringUtils.equals(key, UtilsAndCommons.DOMAINS_DATA_ID_PRE + "*");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressFBWarnings("JLM_JSR166_LOCK_MONITORENTER")
|
@SuppressFBWarnings("JLM_JSR166_LOCK_MONITORENTER")
|
||||||
@ -656,7 +656,7 @@ public class DomainsManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDelete(String key, String value) throws Exception {
|
public void onDelete(String key, String value) throws Exception {
|
||||||
String domKey = StringUtils.removeStart(key, UtilsAndCommons.DOMAINS_DATA_ID + ".");
|
String domKey = StringUtils.removeStart(key, UtilsAndCommons.DOMAINS_DATA_ID_PRE);
|
||||||
String namespace = domKey.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[0];
|
String namespace = domKey.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[0];
|
||||||
String name = domKey.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[1];
|
String name = domKey.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[1];
|
||||||
Domain dom = chooseDomMap(namespace).remove(name);
|
Domain dom = chooseDomMap(namespace).remove(name);
|
||||||
|
@ -18,7 +18,6 @@ package com.alibaba.nacos.naming.core;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.TypeReference;
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
|
||||||
import com.alibaba.nacos.naming.healthcheck.ClientBeatCheckTask;
|
import com.alibaba.nacos.naming.healthcheck.ClientBeatCheckTask;
|
||||||
import com.alibaba.nacos.naming.healthcheck.ClientBeatProcessor;
|
import com.alibaba.nacos.naming.healthcheck.ClientBeatProcessor;
|
||||||
import com.alibaba.nacos.naming.healthcheck.HealthCheckReactor;
|
import com.alibaba.nacos.naming.healthcheck.HealthCheckReactor;
|
||||||
@ -29,8 +28,8 @@ import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
|||||||
import com.alibaba.nacos.naming.push.PushService;
|
import com.alibaba.nacos.naming.push.PushService;
|
||||||
import com.alibaba.nacos.naming.raft.RaftCore;
|
import com.alibaba.nacos.naming.raft.RaftCore;
|
||||||
import com.alibaba.nacos.naming.raft.RaftListener;
|
import com.alibaba.nacos.naming.raft.RaftListener;
|
||||||
import com.alibaba.nacos.naming.selector.Selector;
|
|
||||||
import com.alibaba.nacos.naming.selector.NoneSelector;
|
import com.alibaba.nacos.naming.selector.NoneSelector;
|
||||||
|
import com.alibaba.nacos.naming.selector.Selector;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.ListUtils;
|
import org.apache.commons.collections.ListUtils;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
@ -24,11 +24,9 @@ import org.apache.commons.collections.MapUtils;
|
|||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.*;
|
import org.apache.http.*;
|
||||||
import org.apache.http.client.RedirectStrategy;
|
|
||||||
import org.apache.http.client.config.RequestConfig;
|
import org.apache.http.client.config.RequestConfig;
|
||||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.client.methods.HttpUriRequest;
|
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
@ -36,7 +34,6 @@ import org.apache.http.impl.client.HttpClientBuilder;
|
|||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
import org.apache.http.protocol.HttpContext;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -48,12 +48,12 @@ public class Switch {
|
|||||||
RaftCore.listen(new RaftListener() {
|
RaftCore.listen(new RaftListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean interests(String key) {
|
public boolean interests(String key) {
|
||||||
return StringUtils.equals(key, UtilsAndCommons.DOMAINS_DATA_ID + ".00-00---000-VIPSRV_SWITCH_DOMAIN-000---00-00");
|
return StringUtils.equals(key, UtilsAndCommons.DOMAINS_DATA_ID_PRE + UtilsAndCommons.SWITCH_DOMAIN_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchUnlistenKey(String key) {
|
public boolean matchUnlistenKey(String key) {
|
||||||
return StringUtils.equals(key, UtilsAndCommons.DOMAINS_DATA_ID + ".00-00---000-VIPSRV_SWITCH_DOMAIN-000---00-00");
|
return StringUtils.equals(key, UtilsAndCommons.DOMAINS_DATA_ID_PRE + UtilsAndCommons.SWITCH_DOMAIN_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,7 +31,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @author nacos
|
* @author nacos
|
||||||
*/
|
*/
|
||||||
public class SwitchDomain implements Domain, RaftListener {
|
public class SwitchDomain implements Domain, RaftListener {
|
||||||
public String name = "00-00---000-VIPSRV_SWITCH_DOMAIN-000---00-00";
|
|
||||||
|
public String name = UtilsAndCommons.SWITCH_DOMAIN_NAME;
|
||||||
|
|
||||||
public List<String> masters;
|
public List<String> masters;
|
||||||
|
|
||||||
@ -236,12 +237,12 @@ public class SwitchDomain implements Domain, RaftListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean interests(String key) {
|
public boolean interests(String key) {
|
||||||
return StringUtils.equals(key, UtilsAndCommons.DOMAINS_DATA_ID + "." + name);
|
return StringUtils.equals(key, UtilsAndCommons.DOMAINS_DATA_ID_PRE + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchUnlistenKey(String key) {
|
public boolean matchUnlistenKey(String key) {
|
||||||
return StringUtils.equals(key, UtilsAndCommons.DOMAINS_DATA_ID + "." + name);
|
return StringUtils.equals(key, UtilsAndCommons.DOMAINS_DATA_ID_PRE + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,7 +20,6 @@ import com.alibaba.fastjson.TypeReference;
|
|||||||
import com.alibaba.fastjson.parser.ParserConfig;
|
import com.alibaba.fastjson.parser.ParserConfig;
|
||||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
|
||||||
import com.alibaba.nacos.naming.core.Domain;
|
import com.alibaba.nacos.naming.core.Domain;
|
||||||
import com.alibaba.nacos.naming.core.VirtualClusterDomain;
|
import com.alibaba.nacos.naming.core.VirtualClusterDomain;
|
||||||
@ -61,7 +60,7 @@ public class UtilsAndCommons {
|
|||||||
|
|
||||||
public static final String SUPER_TOKEN = "xy";
|
public static final String SUPER_TOKEN = "xy";
|
||||||
|
|
||||||
public static final String DOMAINS_DATA_ID = "com.alibaba.nacos.naming.domains.meta";
|
public static final String DOMAINS_DATA_ID_PRE = "com.alibaba.nacos.naming.domains.meta.";
|
||||||
|
|
||||||
public static final String IPADDRESS_DATA_ID_PRE = "com.alibaba.nacos.naming.iplist.";
|
public static final String IPADDRESS_DATA_ID_PRE = "com.alibaba.nacos.naming.iplist.";
|
||||||
|
|
||||||
@ -69,6 +68,8 @@ public class UtilsAndCommons {
|
|||||||
|
|
||||||
public static final String TAG_DOMAINS_DATA_ID = "com.alibaba.nacos.naming.domains.tag.meta";
|
public static final String TAG_DOMAINS_DATA_ID = "com.alibaba.nacos.naming.domains.tag.meta";
|
||||||
|
|
||||||
|
public static final String SWITCH_DOMAIN_NAME = "00-00---000-VIPSRV_SWITCH_DOMAIN-000---00-00";
|
||||||
|
|
||||||
static public final String CIDR_REGEX = "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/[0-9]+";
|
static public final String CIDR_REGEX = "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}/[0-9]+";
|
||||||
|
|
||||||
static public final String UNKNOWN_SITE = "unknown";
|
static public final String UNKNOWN_SITE = "unknown";
|
||||||
@ -79,7 +80,7 @@ public class UtilsAndCommons {
|
|||||||
|
|
||||||
public static final int RAFT_PUBLISH_TIMEOUT = 5000;
|
public static final int RAFT_PUBLISH_TIMEOUT = 5000;
|
||||||
|
|
||||||
static public final String RAFT_DOM_PRE = "meta";
|
static public final String RAFT_DOM_PRE = "meta.";
|
||||||
static public final String RAFT_IPLIST_PRE = "iplist.";
|
static public final String RAFT_IPLIST_PRE = "iplist.";
|
||||||
static public final String RAFT_TAG_DOM_PRE = "tag.meta";
|
static public final String RAFT_TAG_DOM_PRE = "tag.meta";
|
||||||
static public final String RAFT_TAG_IPLIST_PRE = "tag.iplist.";
|
static public final String RAFT_TAG_IPLIST_PRE = "tag.iplist.";
|
||||||
@ -225,10 +226,10 @@ public class UtilsAndCommons {
|
|||||||
|
|
||||||
public static String getDomStoreKey(Domain dom) {
|
public static String getDomStoreKey(Domain dom) {
|
||||||
if (dom instanceof VirtualClusterDomain) {
|
if (dom instanceof VirtualClusterDomain) {
|
||||||
return UtilsAndCommons.DOMAINS_DATA_ID + "." + ((VirtualClusterDomain) dom).getNamespaceId() +
|
return UtilsAndCommons.DOMAINS_DATA_ID_PRE + ((VirtualClusterDomain) dom).getNamespaceId() +
|
||||||
UtilsAndCommons.SERVICE_GROUP_CONNECTOR + dom.getName();
|
UtilsAndCommons.SERVICE_GROUP_CONNECTOR + dom.getName();
|
||||||
}
|
}
|
||||||
return UtilsAndCommons.DOMAINS_DATA_ID + "." + dom.getName();
|
return UtilsAndCommons.DOMAINS_DATA_ID_PRE + dom.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> parseMetadata(String metadata) throws NacosException {
|
public static Map<String, String> parseMetadata(String metadata) throws NacosException {
|
||||||
|
@ -25,7 +25,6 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
|
@ -15,7 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.alibaba.nacos.naming.raft;
|
package com.alibaba.nacos.naming.raft;
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nacos
|
* @author nacos
|
||||||
|
@ -354,7 +354,7 @@ public class RaftCore {
|
|||||||
local.resetLeaderDue();
|
local.resetLeaderDue();
|
||||||
|
|
||||||
// do apply
|
// do apply
|
||||||
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID) || UtilsAndCommons.INSTANCE_LIST_PERSISTED) {
|
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID_PRE) || UtilsAndCommons.INSTANCE_LIST_PERSISTED) {
|
||||||
RaftStore.write(datum);
|
RaftStore.write(datum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ public class RaftCore {
|
|||||||
String key = params.getString("key");
|
String key = params.getString("key");
|
||||||
deleteDatum(key);
|
deleteDatum(key);
|
||||||
|
|
||||||
if (key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID)) {
|
if (key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID_PRE)) {
|
||||||
|
|
||||||
if (local.term.get() + PUBLISH_TERM_INCREASE_COUNT > source.term.get()) {
|
if (local.term.get() + PUBLISH_TERM_INCREASE_COUNT > source.term.get()) {
|
||||||
//set leader term:
|
//set leader term:
|
||||||
@ -570,8 +570,8 @@ public class RaftCore {
|
|||||||
JSONObject element = new JSONObject();
|
JSONObject element = new JSONObject();
|
||||||
String key;
|
String key;
|
||||||
|
|
||||||
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID)) {
|
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID_PRE)) {
|
||||||
key = (datum.key).split(UtilsAndCommons.DOMAINS_DATA_ID)[1];
|
key = (datum.key).split(UtilsAndCommons.DOMAINS_DATA_ID_PRE)[1];
|
||||||
element.put("key", UtilsAndCommons.RAFT_DOM_PRE + key);
|
element.put("key", UtilsAndCommons.RAFT_DOM_PRE + key);
|
||||||
} else if (datum.key.startsWith(UtilsAndCommons.IPADDRESS_DATA_ID_PRE)) {
|
} else if (datum.key.startsWith(UtilsAndCommons.IPADDRESS_DATA_ID_PRE)) {
|
||||||
key = (datum.key).split(UtilsAndCommons.IPADDRESS_DATA_ID_PRE)[1];
|
key = (datum.key).split(UtilsAndCommons.IPADDRESS_DATA_ID_PRE)[1];
|
||||||
@ -699,7 +699,7 @@ public class RaftCore {
|
|||||||
|
|
||||||
if (key.startsWith(UtilsAndCommons.RAFT_DOM_PRE)) {
|
if (key.startsWith(UtilsAndCommons.RAFT_DOM_PRE)) {
|
||||||
int index = key.indexOf(UtilsAndCommons.RAFT_DOM_PRE);
|
int index = key.indexOf(UtilsAndCommons.RAFT_DOM_PRE);
|
||||||
datumKey = UtilsAndCommons.DOMAINS_DATA_ID + key.substring(index + UtilsAndCommons.RAFT_DOM_PRE.length());
|
datumKey = UtilsAndCommons.DOMAINS_DATA_ID_PRE + key.substring(index + UtilsAndCommons.RAFT_DOM_PRE.length());
|
||||||
} else if (key.startsWith(UtilsAndCommons.RAFT_IPLIST_PRE)) {
|
} else if (key.startsWith(UtilsAndCommons.RAFT_IPLIST_PRE)) {
|
||||||
int index = key.indexOf(UtilsAndCommons.RAFT_IPLIST_PRE);
|
int index = key.indexOf(UtilsAndCommons.RAFT_IPLIST_PRE);
|
||||||
datumKey = UtilsAndCommons.IPADDRESS_DATA_ID_PRE + key.substring(index + UtilsAndCommons.RAFT_IPLIST_PRE.length());
|
datumKey = UtilsAndCommons.IPADDRESS_DATA_ID_PRE + key.substring(index + UtilsAndCommons.RAFT_IPLIST_PRE.length());
|
||||||
@ -761,7 +761,7 @@ public class RaftCore {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID) ||
|
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID_PRE) ||
|
||||||
UtilsAndCommons.INSTANCE_LIST_PERSISTED) {
|
UtilsAndCommons.INSTANCE_LIST_PERSISTED) {
|
||||||
RaftStore.write(datum);
|
RaftStore.write(datum);
|
||||||
}
|
}
|
||||||
@ -769,7 +769,7 @@ public class RaftCore {
|
|||||||
RaftCore.datums.put(datum.key, datum);
|
RaftCore.datums.put(datum.key, datum);
|
||||||
local.resetLeaderDue();
|
local.resetLeaderDue();
|
||||||
|
|
||||||
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID)) {
|
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID_PRE)) {
|
||||||
if (local.term.get() + 100 > remote.term.get()) {
|
if (local.term.get() + 100 > remote.term.get()) {
|
||||||
getLeader().term.set(remote.term.get());
|
getLeader().term.set(remote.term.get());
|
||||||
local.term.set(getLeader().term.get());
|
local.term.set(getLeader().term.get());
|
||||||
@ -962,9 +962,7 @@ public class RaftCore {
|
|||||||
private static void deleteDatum(String key) {
|
private static void deleteDatum(String key) {
|
||||||
Datum deleted = datums.remove(key);
|
Datum deleted = datums.remove(key);
|
||||||
if (deleted != null) {
|
if (deleted != null) {
|
||||||
if (key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID)) {
|
RaftStore.delete(deleted);
|
||||||
RaftStore.delete(deleted);
|
|
||||||
}
|
|
||||||
notifier.addTask(deleted, Notifier.ApplyAction.DELETE);
|
notifier.addTask(deleted, Notifier.ApplyAction.DELETE);
|
||||||
Loggers.RAFT.info("datum deleted, key: {}", key);
|
Loggers.RAFT.info("datum deleted, key: {}", key);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package com.alibaba.nacos.naming.raft;
|
package com.alibaba.nacos.naming.raft;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.nacos.api.common.Constants;
|
||||||
import com.alibaba.nacos.naming.misc.Loggers;
|
import com.alibaba.nacos.naming.misc.Loggers;
|
||||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||||
import com.alibaba.nacos.naming.monitor.MetricsMonitor;
|
import com.alibaba.nacos.naming.monitor.MetricsMonitor;
|
||||||
@ -61,11 +62,11 @@ public class RaftStore {
|
|||||||
for (File cache : listCaches()) {
|
for (File cache : listCaches()) {
|
||||||
if (cache.isDirectory() && cache.listFiles() != null) {
|
if (cache.isDirectory() && cache.listFiles() != null) {
|
||||||
for (File datumFile : cache.listFiles()) {
|
for (File datumFile : cache.listFiles()) {
|
||||||
readDatum(datumFile);
|
readDatum(datumFile, cache.getName());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
readDatum(cache);
|
readDatum(cache, StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load meta
|
// load meta
|
||||||
@ -93,14 +94,14 @@ public class RaftStore {
|
|||||||
if (!StringUtils.equals(decodeFileName(cache.getName()), key)) {
|
if (!StringUtils.equals(decodeFileName(cache.getName()), key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
readDatum(cache);
|
readDatum(cache, StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
Loggers.RAFT.info("finish loading datum, key: {} cost {} ms.",
|
Loggers.RAFT.info("finish loading datum, key: {} cost {} ms.",
|
||||||
key, (System.currentTimeMillis() - start));
|
key, (System.currentTimeMillis() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static void readDatum(File file) throws IOException {
|
public synchronized static void readDatum(File file, String namespaceId) throws IOException {
|
||||||
|
|
||||||
ByteBuffer buffer;
|
ByteBuffer buffer;
|
||||||
FileChannel fc = null;
|
FileChannel fc = null;
|
||||||
@ -115,6 +116,26 @@ public class RaftStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Datum datum = JSON.parseObject(json, Datum.class);
|
Datum datum = JSON.parseObject(json, Datum.class);
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(namespaceId)) {
|
||||||
|
namespaceId = Constants.REQUEST_PARAM_DEFAULT_NAMESPACE_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!datum.key.contains(UtilsAndCommons.SWITCH_DOMAIN_NAME) && !datum.key.contains(namespaceId)) {
|
||||||
|
|
||||||
|
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID_PRE)) {
|
||||||
|
datum.key = UtilsAndCommons.DOMAINS_DATA_ID_PRE + namespaceId +
|
||||||
|
UtilsAndCommons.SERVICE_GROUP_CONNECTOR +
|
||||||
|
datum.key.substring(UtilsAndCommons.DOMAINS_DATA_ID_PRE.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (datum.key.startsWith(UtilsAndCommons.IPADDRESS_DATA_ID_PRE)) {
|
||||||
|
datum.key = UtilsAndCommons.IPADDRESS_DATA_ID_PRE + namespaceId +
|
||||||
|
UtilsAndCommons.SERVICE_GROUP_CONNECTOR +
|
||||||
|
datum.key.substring(UtilsAndCommons.IPADDRESS_DATA_ID_PRE.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RaftCore.addDatum(datum);
|
RaftCore.addDatum(datum);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Loggers.RAFT.warn("waning: failed to deserialize key: {}", file.getName());
|
Loggers.RAFT.warn("waning: failed to deserialize key: {}", file.getName());
|
||||||
@ -130,28 +151,35 @@ public class RaftStore {
|
|||||||
|
|
||||||
String namespaceId = null;
|
String namespaceId = null;
|
||||||
|
|
||||||
Datum writeDatum = new Datum();
|
if (datum.key.contains(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)) {
|
||||||
writeDatum.key = datum.key;
|
String[] segments = datum.key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[0].split("\\.");
|
||||||
writeDatum.value = datum.value;
|
|
||||||
writeDatum.timestamp.set(datum.timestamp.get());
|
|
||||||
|
|
||||||
if (writeDatum.key.contains(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)) {
|
|
||||||
String[] segments = writeDatum.key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[0].split("\\.");
|
|
||||||
namespaceId = segments[segments.length - 1];
|
namespaceId = segments[segments.length - 1];
|
||||||
String newKey;
|
|
||||||
segments = writeDatum.key.split(namespaceId + UtilsAndCommons.SERVICE_GROUP_CONNECTOR);
|
|
||||||
newKey = segments[0] + segments[1];
|
|
||||||
writeDatum.key = newKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File cacheFile;
|
File cacheFile;
|
||||||
File oldCacheFile = null;
|
File oldCacheFile = null;
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(namespaceId)) {
|
if (StringUtils.isNotBlank(namespaceId)) {
|
||||||
cacheFile = new File(CACHE_DIR + File.separator + namespaceId + File.separator + encodeFileName(writeDatum.key));
|
cacheFile = new File(CACHE_DIR + File.separator + namespaceId + File.separator + encodeFileName(datum.key));
|
||||||
} else {
|
} else {
|
||||||
oldCacheFile = new File(CACHE_DIR + File.separator + encodeFileName(writeDatum.key));
|
cacheFile = new File(CACHE_DIR + File.separator + encodeFileName(datum.key));
|
||||||
cacheFile = new File(CACHE_DIR + File.separator + UtilsAndCommons.getDefaultNamespaceId() + File.separator + encodeFileName(writeDatum.key));
|
}
|
||||||
|
|
||||||
|
if (Constants.REQUEST_PARAM_DEFAULT_NAMESPACE_ID.equals(namespaceId)) {
|
||||||
|
// remove old format file:
|
||||||
|
String originDatumKey = null;
|
||||||
|
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID_PRE)) {
|
||||||
|
originDatumKey = UtilsAndCommons.DOMAINS_DATA_ID_PRE +
|
||||||
|
datum.key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[1];
|
||||||
|
} else if (datum.key.startsWith(UtilsAndCommons.IPADDRESS_DATA_ID_PRE)) {
|
||||||
|
originDatumKey = UtilsAndCommons.IPADDRESS_DATA_ID_PRE +
|
||||||
|
datum.key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
oldCacheFile = new File(CACHE_DIR + File.separator + encodeFileName(originDatumKey));
|
||||||
|
if (oldCacheFile.exists() && !oldCacheFile.delete()) {
|
||||||
|
throw new IllegalStateException("remove old format file failed, key:" + originDatumKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cacheFile.exists() && !cacheFile.getParentFile().mkdirs() && !cacheFile.createNewFile()) {
|
if (!cacheFile.exists() && !cacheFile.getParentFile().mkdirs() && !cacheFile.createNewFile()) {
|
||||||
@ -161,7 +189,7 @@ public class RaftStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileChannel fc = null;
|
FileChannel fc = null;
|
||||||
ByteBuffer data = ByteBuffer.wrap(JSON.toJSONString(writeDatum).getBytes("UTF-8"));
|
ByteBuffer data = ByteBuffer.wrap(JSON.toJSONString(datum).getBytes("UTF-8"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fc = new FileOutputStream(cacheFile, false).getChannel();
|
fc = new FileOutputStream(cacheFile, false).getChannel();
|
||||||
@ -192,10 +220,46 @@ public class RaftStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void delete(Datum datum) {
|
public static void delete(Datum datum) {
|
||||||
File cacheFile = new File(CACHE_DIR + File.separator + encodeFileName(datum.key));
|
|
||||||
if (!cacheFile.delete()) {
|
if (datum.key.contains(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)) {
|
||||||
Loggers.RAFT.error("[RAFT-DELETE] failed to delete datum: {}, value: {}", datum.key, datum.value);
|
// datum key contains namespace info:
|
||||||
throw new IllegalStateException("failed to delete datum: " + datum.key);
|
String namspaceId = null;
|
||||||
|
String originDatumKey = null;
|
||||||
|
if (datum.key.startsWith(UtilsAndCommons.DOMAINS_DATA_ID_PRE)) {
|
||||||
|
namspaceId = datum.key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[0]
|
||||||
|
.substring(UtilsAndCommons.DOMAINS_DATA_ID_PRE.length());
|
||||||
|
originDatumKey = UtilsAndCommons.DOMAINS_DATA_ID_PRE +
|
||||||
|
datum.key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[1];
|
||||||
|
} else if (datum.key.startsWith(UtilsAndCommons.IPADDRESS_DATA_ID_PRE)) {
|
||||||
|
namspaceId = datum.key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[0]
|
||||||
|
.substring(UtilsAndCommons.IPADDRESS_DATA_ID_PRE.length());
|
||||||
|
originDatumKey = UtilsAndCommons.IPADDRESS_DATA_ID_PRE +
|
||||||
|
datum.key.split(UtilsAndCommons.SERVICE_GROUP_CONNECTOR)[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(namspaceId)) {
|
||||||
|
|
||||||
|
if (namspaceId.equals(Constants.REQUEST_PARAM_DEFAULT_NAMESPACE_ID)) {
|
||||||
|
|
||||||
|
File cacheFile = new File(CACHE_DIR + File.separator + encodeFileName(originDatumKey));
|
||||||
|
if (cacheFile.exists() && !cacheFile.delete()) {
|
||||||
|
Loggers.RAFT.error("[RAFT-DELETE] failed to delete datum: {}, value: {}", datum.key, datum.value);
|
||||||
|
throw new IllegalStateException("failed to delete datum: " + datum.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File cacheFile = new File(CACHE_DIR + File.separator + namspaceId + File.separator + encodeFileName(datum.key));
|
||||||
|
if (cacheFile.exists() && !cacheFile.delete()) {
|
||||||
|
Loggers.RAFT.error("[RAFT-DELETE] failed to delete datum: {}, value: {}", datum.key, datum.value);
|
||||||
|
throw new IllegalStateException("failed to delete datum: " + datum.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
File cacheFile = new File(CACHE_DIR + File.separator + encodeFileName(datum.key));
|
||||||
|
if (cacheFile.exists() && !cacheFile.delete()) {
|
||||||
|
Loggers.RAFT.error("[RAFT-DELETE] failed to delete datum: {}, value: {}", datum.key, datum.value);
|
||||||
|
throw new IllegalStateException("failed to delete datum: " + datum.key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ package com.alibaba.nacos.naming.selector;
|
|||||||
|
|
||||||
|
|
||||||
import com.alibaba.nacos.api.cmdb.pojo.PreservedEntityTypes;
|
import com.alibaba.nacos.api.cmdb.pojo.PreservedEntityTypes;
|
||||||
import com.alibaba.nacos.api.selector.SelectorType;
|
|
||||||
import com.alibaba.nacos.api.selector.ExpressionSelector;
|
import com.alibaba.nacos.api.selector.ExpressionSelector;
|
||||||
|
import com.alibaba.nacos.api.selector.SelectorType;
|
||||||
import com.alibaba.nacos.cmdb.service.CmdbReader;
|
import com.alibaba.nacos.cmdb.service.CmdbReader;
|
||||||
import com.alibaba.nacos.naming.boot.SpringContext;
|
import com.alibaba.nacos.naming.boot.SpringContext;
|
||||||
import com.alibaba.nacos.naming.core.IpAddress;
|
import com.alibaba.nacos.naming.core.IpAddress;
|
||||||
@ -26,7 +26,10 @@ import com.alibaba.nacos.naming.exception.NacosException;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A selector to implement a so called same-label-prior rule for service discovery.
|
* A selector to implement a so called same-label-prior rule for service discovery.
|
||||||
|
@ -22,7 +22,6 @@ import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
|
|||||||
import com.alibaba.fastjson.serializer.JSONSerializer;
|
import com.alibaba.fastjson.serializer.JSONSerializer;
|
||||||
import com.alibaba.fastjson.serializer.ObjectSerializer;
|
import com.alibaba.fastjson.serializer.ObjectSerializer;
|
||||||
import com.alibaba.fastjson.serializer.SerializeWriter;
|
import com.alibaba.fastjson.serializer.SerializeWriter;
|
||||||
import com.alibaba.nacos.api.selector.AbstractSelector;
|
|
||||||
import com.alibaba.nacos.api.selector.SelectorType;
|
import com.alibaba.nacos.api.selector.SelectorType;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
@ -17,11 +17,9 @@ package com.alibaba.nacos.naming.view;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.nacos.api.naming.pojo.Cluster;
|
import com.alibaba.nacos.api.naming.pojo.Cluster;
|
||||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.Service;
|
import com.alibaba.nacos.api.naming.pojo.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
|
* @author <a href="mailto:zpf.073@gmail.com">nkorange</a>
|
||||||
|
@ -1463,13 +1463,13 @@ public class ApiCommands {
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
String entry = WebUtils.required(request, "entry");
|
String entry = WebUtils.required(request, "entry");
|
||||||
|
|
||||||
Datum datum = RaftCore.getDatum(UtilsAndCommons.DOMAINS_DATA_ID + ".00-00---000-VIPSRV_SWITCH_DOMAIN-000---00-00");
|
Datum datum = RaftCore.getDatum(UtilsAndCommons.DOMAINS_DATA_ID_PRE + UtilsAndCommons.SWITCH_DOMAIN_NAME);
|
||||||
SwitchDomain switchDomain = null;
|
SwitchDomain switchDomain = null;
|
||||||
|
|
||||||
if (datum != null) {
|
if (datum != null) {
|
||||||
switchDomain = JSON.parseObject(datum.value, SwitchDomain.class);
|
switchDomain = JSON.parseObject(datum.value, SwitchDomain.class);
|
||||||
} else {
|
} else {
|
||||||
Loggers.SRV_LOG.warn("datum: {}.00-00---000-VIPSRV_SWITCH_DOMAIN-000---00-00 is null", UtilsAndCommons.DOMAINS_DATA_ID);
|
Loggers.SRV_LOG.warn("datum: {}{} is null", UtilsAndCommons.DOMAINS_DATA_ID_PRE, UtilsAndCommons.SWITCH_DOMAIN_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SwitchEntry.BATCH.equals(entry)) {
|
if (SwitchEntry.BATCH.equals(entry)) {
|
||||||
|
@ -18,7 +18,6 @@ package com.alibaba.nacos.naming.controllers;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.nacos.api.common.Constants;
|
|
||||||
import com.alibaba.nacos.naming.BaseTest;
|
import com.alibaba.nacos.naming.BaseTest;
|
||||||
import com.alibaba.nacos.naming.core.Cluster;
|
import com.alibaba.nacos.naming.core.Cluster;
|
||||||
import com.alibaba.nacos.naming.core.IpAddress;
|
import com.alibaba.nacos.naming.core.IpAddress;
|
||||||
|
@ -22,7 +22,9 @@ package com.alibaba.nacos.naming.web;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.nacos.naming.core.Cluster;
|
import com.alibaba.nacos.naming.core.Cluster;
|
||||||
|
import com.alibaba.nacos.naming.core.DomainsManager;
|
||||||
import com.alibaba.nacos.naming.core.IpAddress;
|
import com.alibaba.nacos.naming.core.IpAddress;
|
||||||
import com.alibaba.nacos.naming.core.VirtualClusterDomain;
|
import com.alibaba.nacos.naming.core.VirtualClusterDomain;
|
||||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||||
@ -42,8 +44,6 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.alibaba.nacos.naming.core.DomainsManager;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
Loading…
Reference in New Issue
Block a user