parent
51a3cf9fe7
commit
9bcb901174
@ -158,7 +158,7 @@ public class Constants {
|
||||
|
||||
public static final int NAMING_INSTANCE_ID_SEG_COUNT = 4;
|
||||
|
||||
public static final String NAMING_HTTP_HEADER_SPILIER = "\\|";
|
||||
public static final String NAMING_HTTP_HEADER_SPLITTER = "\\|";
|
||||
|
||||
public static final String DEFAULT_CLUSTER_NAME = "DEFAULT";
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class Http extends AbstractHealthChecker {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
final Map<String, String> headerMap = new HashMap<String, String>(16);
|
||||
for (final String s : headers.split(Constants.NAMING_HTTP_HEADER_SPILIER)) {
|
||||
for (final String s : headers.split(Constants.NAMING_HTTP_HEADER_SPLITTER)) {
|
||||
final String[] splits = s.split(":");
|
||||
if (splits.length != 2) {
|
||||
continue;
|
||||
|
@ -288,7 +288,7 @@ public class ClientWorker implements Closeable {
|
||||
* Check config info.
|
||||
*/
|
||||
public void checkConfigInfo() {
|
||||
// Dispatch taskes.
|
||||
// Dispatch tasks.
|
||||
int listenerSize = cacheMap.size();
|
||||
// Round up the longingTaskCount.
|
||||
int longingTaskCount = (int) Math.ceil(listenerSize / ParamUtil.getPerTaskConfigSize());
|
||||
@ -304,7 +304,7 @@ public class ClientWorker implements Closeable {
|
||||
/**
|
||||
* Fetch the dataId list from server.
|
||||
*
|
||||
* @param cacheDatas CacheDatas for config infomations.
|
||||
* @param cacheDatas CacheDatas for config information.
|
||||
* @param inInitializingCacheList initial cache lists.
|
||||
* @return String include dataId and group (ps: it maybe null).
|
||||
* @throws Exception Exception.
|
||||
@ -322,7 +322,7 @@ public class ClientWorker implements Closeable {
|
||||
sb.append(cacheData.getTenant()).append(LINE_SEPARATOR);
|
||||
}
|
||||
if (cacheData.isInitializing()) {
|
||||
// It updates when cacheData occours in cacheMap by first time.
|
||||
// It updates when cacheData occurs in cacheMap by first time.
|
||||
inInitializingCacheList
|
||||
.add(GroupKey.getKeyTenant(cacheData.dataId, cacheData.group, cacheData.tenant));
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class Chooser<K, T> {
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
"Cumulative Weight caculate wrong , the sum of probabilities does not equals 1.");
|
||||
"Cumulative Weight calculate wrong , the sum of probabilities does not equals 1.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,7 +52,7 @@ public interface CmdbReader {
|
||||
*
|
||||
* @param labelName name of label
|
||||
* @param labelValue value of label
|
||||
* @return list of entiy
|
||||
* @return list of entity
|
||||
*/
|
||||
List<Entity> queryEntitiesByLabel(String labelName, String labelValue);
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public final class CollectionUtils {
|
||||
*
|
||||
* @param coll collection
|
||||
* @param target target value
|
||||
* @param <T> Genreal Type
|
||||
* @param <T> General Type
|
||||
* @return true if contain, otherwise false
|
||||
*/
|
||||
public static <T> boolean contains(Collection<T> coll, T target) {
|
||||
@ -236,7 +236,7 @@ public final class CollectionUtils {
|
||||
* @param defaultValue default value
|
||||
* @param <T> General Type
|
||||
* @return the value to which the specified index , or {@code defaultValue} if this collection contains no value for
|
||||
* the index.
|
||||
* the index.
|
||||
*/
|
||||
public static <T> T getOrDefault(Collection<T> coll, int index, T defaultValue) {
|
||||
try {
|
||||
|
@ -61,7 +61,7 @@ public class CapacityManagementAspect {
|
||||
private PersistService persistService;
|
||||
|
||||
/**
|
||||
* Need to judge the size of content whether to exceed the limination.
|
||||
* Need to judge the size of content whether to exceed the limitation.
|
||||
*/
|
||||
@Around(SYNC_UPDATE_CONFIG_ALL)
|
||||
public Object aroundSyncUpdateConfigAll(ProceedingJoinPoint pjp, HttpServletRequest request,
|
||||
@ -74,7 +74,7 @@ public class CapacityManagementAspect {
|
||||
String betaIps = request.getHeader("betaIps");
|
||||
if (StringUtils.isBlank(betaIps)) {
|
||||
if (StringUtils.isBlank(tag)) {
|
||||
// do capacity management limination check for writting or updating config_info table.
|
||||
// do capacity management limitation check for writing or updating config_info table.
|
||||
if (persistService.findConfigInfo(dataId, group, tenant) == null) {
|
||||
// Write operation.
|
||||
return do4Insert(pjp, request, response, group, tenant, content);
|
||||
@ -87,7 +87,7 @@ public class CapacityManagementAspect {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update operation: open the limination of capacity management and it will check the size of content.
|
||||
* Update operation: open the limitation of capacity management and it will check the size of content.
|
||||
*
|
||||
* @throws Throwable Throws Exception when actually operate.
|
||||
*/
|
||||
@ -109,11 +109,10 @@ public class CapacityManagementAspect {
|
||||
}
|
||||
|
||||
/**
|
||||
* Write operation.
|
||||
* Step 1: count whether to open the limination checking funtion for capacity management;
|
||||
* Step 2: open limination checking capacity management and check size of content and quota;
|
||||
* Write operation. Step 1: count whether to open the limitation checking function for capacity management; Step 2:
|
||||
* open limitation checking capacity management and check size of content and quota;
|
||||
*
|
||||
* @throws Throwable Expcetion.
|
||||
* @throws Throwable Exception.
|
||||
*/
|
||||
private Object do4Insert(ProceedingJoinPoint pjp, HttpServletRequest request, HttpServletResponse response,
|
||||
String group, String tenant, String content) throws Throwable {
|
||||
@ -143,7 +142,8 @@ public class CapacityManagementAspect {
|
||||
}
|
||||
|
||||
/**
|
||||
* The usage of capacity table for counting module will subtracte one whether open the limination check of capacity management.
|
||||
* The usage of capacity table for counting module will subtracte one whether open the limitation check of capacity
|
||||
* management.
|
||||
*/
|
||||
@Around(DELETE_CONFIG)
|
||||
public Object aroundDeleteConfig(ProceedingJoinPoint pjp, HttpServletRequest request, HttpServletResponse response,
|
||||
@ -162,7 +162,7 @@ public class CapacityManagementAspect {
|
||||
/**
|
||||
* Delete Operation.
|
||||
*
|
||||
* @throws Throwable Expcetion.
|
||||
* @throws Throwable Exception.
|
||||
*/
|
||||
private Object do4Delete(ProceedingJoinPoint pjp, HttpServletResponse response, String group, String tenant,
|
||||
ConfigInfo configInfo) throws Throwable {
|
||||
@ -221,7 +221,7 @@ public class CapacityManagementAspect {
|
||||
}
|
||||
|
||||
/**
|
||||
* Usage counting service: it will count whether the limination check funtion will be open.
|
||||
* Usage counting service: it will count whether the limitation check function will be open.
|
||||
*/
|
||||
private void insertOrUpdateUsage(String group, String tenant, CounterMode counterMode, boolean hasTenant) {
|
||||
try {
|
||||
@ -333,13 +333,13 @@ public class CapacityManagementAspect {
|
||||
if (capacity != null) {
|
||||
Integer maxSize = getMaxSize(isAggr, capacity);
|
||||
if (maxSize == 0) {
|
||||
// If there exists capacity info and maxSize = 0, then it uses maxSize limination default value to compare.
|
||||
// If there exists capacity info and maxSize = 0, then it uses maxSize limitation default value to compare.
|
||||
return isOverSize(group, tenant, currentSize, defaultMaxSize, hasTenant);
|
||||
}
|
||||
// If there exists capacity info, then maxSize!=0.
|
||||
return isOverSize(group, tenant, currentSize, maxSize, hasTenant);
|
||||
}
|
||||
// If there no exists capacity info, then it uses maxSize limination default value to compare.
|
||||
// If there no exists capacity info, then it uses maxSize limitation default value to compare.
|
||||
return isOverSize(group, tenant, currentSize, defaultMaxSize, hasTenant);
|
||||
}
|
||||
|
||||
@ -420,7 +420,7 @@ public class CapacityManagementAspect {
|
||||
}
|
||||
|
||||
/**
|
||||
* limit tyep.
|
||||
* limit type.
|
||||
*
|
||||
* @author Nacos.
|
||||
*/
|
||||
|
@ -90,7 +90,7 @@ public class CapacityController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify group or capacity of tenant, and init record when capacity informations are still initial.
|
||||
* Modify group or capacity of tenant, and init record when capacity information are still initial.
|
||||
*/
|
||||
@PostMapping
|
||||
public RestResult<Boolean> updateCapacity(HttpServletResponse response,
|
||||
|
@ -153,7 +153,7 @@ public class ConfigController {
|
||||
ParamUtils.checkParam(configAdvanceInfo);
|
||||
|
||||
if (AggrWhitelist.isAggrDataId(dataId)) {
|
||||
LOGGER.warn("[aggr-conflict] {} attemp to publish single data, {}, {}", RequestUtil.getRemoteIp(request),
|
||||
LOGGER.warn("[aggr-conflict] {} attempt to publish single data, {}, {}", RequestUtil.getRemoteIp(request),
|
||||
dataId, group);
|
||||
throw new NacosException(NacosException.NO_RIGHT, "dataId:" + dataId + " is aggr");
|
||||
}
|
||||
@ -185,7 +185,7 @@ public class ConfigController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get configure board infomation fail.
|
||||
* Get configure board information fail.
|
||||
*
|
||||
* @throws ServletException ServletException.
|
||||
* @throws IOException IOException.
|
||||
@ -666,14 +666,14 @@ public class ConfigController {
|
||||
List<ConfigAllInfo> configInfoList4Clone = new ArrayList<>(queryedDataList.size());
|
||||
|
||||
for (ConfigAllInfo ci : queryedDataList) {
|
||||
SameNamespaceCloneConfigBean prarmBean = configBeansMap.get(ci.getId());
|
||||
SameNamespaceCloneConfigBean paramBean = configBeansMap.get(ci.getId());
|
||||
ConfigAllInfo ci4save = new ConfigAllInfo();
|
||||
ci4save.setTenant(namespace);
|
||||
ci4save.setType(ci.getType());
|
||||
ci4save.setGroup((prarmBean != null && StringUtils.isNotBlank(prarmBean.getGroup())) ? prarmBean.getGroup()
|
||||
ci4save.setGroup((paramBean != null && StringUtils.isNotBlank(paramBean.getGroup())) ? paramBean.getGroup()
|
||||
: ci.getGroup());
|
||||
ci4save.setDataId(
|
||||
(prarmBean != null && StringUtils.isNotBlank(prarmBean.getDataId())) ? prarmBean.getDataId()
|
||||
(paramBean != null && StringUtils.isNotBlank(paramBean.getDataId())) ? paramBean.getDataId()
|
||||
: ci.getDataId());
|
||||
ci4save.setContent(ci.getContent());
|
||||
if (StringUtils.isNotBlank(ci.getAppName())) {
|
||||
|
@ -97,7 +97,7 @@ public class ConfigServletInner {
|
||||
}
|
||||
int versionNum = Protocol.getVersionNumber(version);
|
||||
|
||||
// Befor 2.0.4 version, return value is put into header.
|
||||
// Before 2.0.4 version, return value is put into header.
|
||||
if (versionNum < START_LONG_POLLING_VERSION_NUM) {
|
||||
response.addHeader(Constants.PROBE_MODIFY_RESPONSE, oldResult);
|
||||
response.addHeader(Constants.PROBE_MODIFY_RESPONSE_NEW, newResult);
|
||||
@ -298,6 +298,7 @@ public class ConfigServletInner {
|
||||
|
||||
/**
|
||||
* Try to add read lock.
|
||||
*
|
||||
* @param groupKey groupKey string value.
|
||||
* @return 0 - No data and failed. Positive number - lock succeeded. Negative number - lock failed。
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* ConfigInfoBase.
|
||||
* And can't add field, to compatible with old interface(If adding a field, then it will occour compatibility problems).
|
||||
* And can't add field, to compatible with old interface(If adding a field, then it will occur compatibility problems).
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
|
@ -18,7 +18,7 @@ package com.alibaba.nacos.config.server.model;
|
||||
|
||||
/**
|
||||
* ConfigInfoBaseEx.
|
||||
* And can't add field, to compatible with old interface(If adding a field, then it will occour compatibility problems).
|
||||
* And can't add field, to compatible with old interface(If adding a field, then it will occur compatibility problems).
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
|
@ -42,8 +42,8 @@ public class ClientTrackService {
|
||||
/**
|
||||
* TrackClientMd5.
|
||||
*
|
||||
* @param ip ip string value.
|
||||
* @param clientMd5Map clientMd5Map.
|
||||
* @param ip ip string value.
|
||||
* @param clientMd5Map clientMd5Map.
|
||||
* @param clientLastPollingTsMap clientLastPollingTsMap.
|
||||
*/
|
||||
public static void trackClientMd5(String ip, Map<String, String> clientMd5Map,
|
||||
@ -57,8 +57,8 @@ public class ClientTrackService {
|
||||
/**
|
||||
* Put the specified value(ip/groupKey/clientMd5) into clientRecords Map.
|
||||
*
|
||||
* @param ip ip string value.
|
||||
* @param groupKey groupKey string value.
|
||||
* @param ip ip string value.
|
||||
* @param groupKey groupKey string value.
|
||||
* @param clientMd5 clientMd5 string value.
|
||||
*/
|
||||
public static void trackClientMd5(String ip, String groupKey, String clientMd5) {
|
||||
@ -78,9 +78,9 @@ public class ClientTrackService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of subsciber count.
|
||||
* Get all of subscriber count.
|
||||
*
|
||||
* @return all of subsciber count.
|
||||
* @return all of subscriber count.
|
||||
*/
|
||||
public static long subscriberCount() {
|
||||
long count = 0;
|
||||
@ -92,7 +92,6 @@ public class ClientTrackService {
|
||||
|
||||
/**
|
||||
* Groupkey -> SubscriberStatus.
|
||||
*
|
||||
*/
|
||||
public static Map<String, SubscriberStatus> listSubStatus(String ip) {
|
||||
Map<String, SubscriberStatus> status = new HashMap<String, SubscriberStatus>(100);
|
||||
@ -134,9 +133,8 @@ public class ClientTrackService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify subscriber's ip and look up whether data is lastest.
|
||||
* Specify subscriber's ip and look up whether data is latest.
|
||||
* groupKey -> isUptodate.
|
||||
*
|
||||
*/
|
||||
public static Map<String, Boolean> isClientUptodate(String ip) {
|
||||
Map<String, Boolean> result = new HashMap<String, Boolean>(100);
|
||||
@ -150,7 +148,7 @@ public class ClientTrackService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify groupKey and look up whether subsciber and data is lastest.
|
||||
* Specify groupKey and look up whether subscriber and data is latest.
|
||||
* IP -> isUptodate.
|
||||
*/
|
||||
public static Map<String, Boolean> listSubscriberByGroup(String groupKey) {
|
||||
|
@ -231,8 +231,8 @@ public class ConfigCacheService {
|
||||
try {
|
||||
final String md5 = MD5Utils.md5Hex(content, Constants.ENCODE);
|
||||
if (!PropertyUtil.isDirectRead()) {
|
||||
String loacalMd5 = DiskUtil.getLocalConfigMd5(dataId, group, tenant);
|
||||
if (md5.equals(loacalMd5)) {
|
||||
String localMd5 = DiskUtil.getLocalConfigMd5(dataId, group, tenant);
|
||||
if (md5.equals(localMd5)) {
|
||||
DUMP_LOG.warn("[dump-ignore] ignore to save cache file. groupKey={}, md5={}, lastModifiedOld={}, "
|
||||
+ "lastModifiedNew={}", groupKey, md5, ConfigCacheService.getLastModifiedTs(groupKey),
|
||||
lastModifiedTs);
|
||||
|
@ -129,26 +129,26 @@ public class ConfigSubService {
|
||||
*/
|
||||
public SampleResult mergeSampleResult(SampleResult sampleCollectResult, List<SampleResult> sampleResults) {
|
||||
SampleResult mergeResult = new SampleResult();
|
||||
Map<String, String> lisentersGroupkeyStatus = null;
|
||||
Map<String, String> listenersGroupkeyStatus = null;
|
||||
if (sampleCollectResult.getLisentersGroupkeyStatus() == null || sampleCollectResult.getLisentersGroupkeyStatus()
|
||||
.isEmpty()) {
|
||||
lisentersGroupkeyStatus = new HashMap<String, String>(10);
|
||||
listenersGroupkeyStatus = new HashMap<String, String>(10);
|
||||
} else {
|
||||
lisentersGroupkeyStatus = sampleCollectResult.getLisentersGroupkeyStatus();
|
||||
listenersGroupkeyStatus = sampleCollectResult.getLisentersGroupkeyStatus();
|
||||
}
|
||||
|
||||
for (SampleResult sampleResult : sampleResults) {
|
||||
Map<String, String> lisentersGroupkeyStatusTmp = sampleResult.getLisentersGroupkeyStatus();
|
||||
for (Map.Entry<String, String> entry : lisentersGroupkeyStatusTmp.entrySet()) {
|
||||
lisentersGroupkeyStatus.put(entry.getKey(), entry.getValue());
|
||||
Map<String, String> listenersGroupkeyStatusTmp = sampleResult.getLisentersGroupkeyStatus();
|
||||
for (Map.Entry<String, String> entry : listenersGroupkeyStatusTmp.entrySet()) {
|
||||
listenersGroupkeyStatus.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
mergeResult.setLisentersGroupkeyStatus(lisentersGroupkeyStatus);
|
||||
mergeResult.setLisentersGroupkeyStatus(listenersGroupkeyStatus);
|
||||
return mergeResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query subsrciber's task from every nacos server nodes.
|
||||
* Query subscriber's task from every nacos server nodes.
|
||||
*
|
||||
* @author Nacos
|
||||
*/
|
||||
@ -177,8 +177,7 @@ public class ConfigSubService {
|
||||
}
|
||||
|
||||
String urlAll = getUrl(ip, url) + "?" + paramUrl;
|
||||
RestResult<String> result = NotifyService
|
||||
.invokeURL(urlAll, null, Constants.ENCODE);
|
||||
RestResult<String> result = NotifyService.invokeURL(urlAll, null, Constants.ENCODE);
|
||||
|
||||
// Http code 200
|
||||
if (result.ok()) {
|
||||
|
@ -126,7 +126,7 @@ public class ApiController extends InstanceController {
|
||||
* Get service ips.
|
||||
*
|
||||
* @param request http request
|
||||
* @return service detail infomation
|
||||
* @return service detail information
|
||||
* @throws Exception exception
|
||||
*/
|
||||
@RequestMapping("/srvIPXT")
|
||||
|
@ -116,7 +116,7 @@ public class CatalogController {
|
||||
|
||||
Service service = serviceManager.getService(namespaceId, serviceName);
|
||||
if (service == null) {
|
||||
throw new NacosException(NacosException.NOT_FOUND, "serivce " + serviceName + " is not found!");
|
||||
throw new NacosException(NacosException.NOT_FOUND, "service " + serviceName + " is not found!");
|
||||
}
|
||||
|
||||
if (!service.getClusterMap().containsKey(clusterName)) {
|
||||
|
@ -93,7 +93,7 @@ public class UtilsAndCommons {
|
||||
|
||||
public static final String SELF_SERVICE_CLUSTER_ENV = "naming_self_service_cluster_ips";
|
||||
|
||||
public static final String CACHE_KEY_SPLITER = "@@@@";
|
||||
public static final String CACHE_KEY_SPLITTER = "@@@@";
|
||||
|
||||
public static final int MAX_PUBLISH_WAIT_TIME_MILLIS = 5000;
|
||||
|
||||
|
@ -362,7 +362,7 @@ public class PushService implements ApplicationContextAware, ApplicationListener
|
||||
}
|
||||
|
||||
public static String getPushCacheKey(String serviceName, String clientIP, String agent) {
|
||||
return serviceName + UtilsAndCommons.CACHE_KEY_SPLITER + agent;
|
||||
return serviceName + UtilsAndCommons.CACHE_KEY_SPLITTER + agent;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -366,7 +366,7 @@ public class ConfigAPI_CITCase {
|
||||
Listener ml = new Listener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
System.out.println("recieve23:" + configInfo);
|
||||
System.out.println("receive23:" + configInfo);
|
||||
count.incrementAndGet();
|
||||
Assert.assertEquals(content, configInfo);
|
||||
}
|
||||
@ -582,7 +582,7 @@ public class ConfigAPI_CITCase {
|
||||
iconfig.removeListener(dataId, group, new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
System.out.println("remove recieve:" + configInfo);
|
||||
System.out.println("remove receive:" + configInfo);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
@ -633,7 +633,7 @@ public class ConfigAPI_CITCase {
|
||||
Listener ml1 = new AbstractListener() {
|
||||
@Override
|
||||
public void receiveConfigInfo(String configInfo) {
|
||||
//System.out.println("ml1 remove listener recieve:" + configInfo);
|
||||
//System.out.println("ml1 remove listener receive:" + configInfo);
|
||||
count.incrementAndGet();
|
||||
Assert.assertEquals(contentRemove, configInfo);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user