Skip to content

Commit f5e0b13

Browse files
authored
Merge pull request #13017 from KomachiSion/v3.0-develop-sync-develop
V3.0 develop sync develop
2 parents 0ff32de + ef2fd20 commit f5e0b13

File tree

89 files changed

+2621
-941
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2621
-941
lines changed

client/src/main/java/com/alibaba/nacos/client/config/impl/ConfigHttpClientManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ public static ConfigHttpClientManager getInstance() {
7171

7272
@Override
7373
public void shutdown() throws NacosException {
74-
NAMING_LOGGER.warn("[ConfigHttpClientManager] Start destroying NacosRestTemplate");
74+
NAMING_LOGGER.info("[ConfigHttpClientManager] Start destroying NacosRestTemplate");
7575
try {
7676
HttpClientBeanHolder.shutdownNacosSyncRest(HTTP_CLIENT_FACTORY.getClass().getName());
7777
} catch (Exception ex) {
7878
NAMING_LOGGER.error("[ConfigHttpClientManager] An exception occurred when the HTTP client was closed : {}",
7979
ExceptionUtil.getStackTrace(ex));
8080
}
81-
NAMING_LOGGER.warn("[ConfigHttpClientManager] Destruction of the end");
81+
NAMING_LOGGER.info("[ConfigHttpClientManager] Completed destruction of NacosRestTemplate");
8282
}
8383

8484
/**

client/src/main/java/com/alibaba/nacos/client/naming/remote/http/NamingHttpClientManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ public NacosRestTemplate getNacosRestTemplate() {
6868

6969
@Override
7070
public void shutdown() throws NacosException {
71-
NAMING_LOGGER.warn("[NamingHttpClientManager] Start destroying NacosRestTemplate");
71+
NAMING_LOGGER.info("[NamingHttpClientManager] Start destroying NacosRestTemplate");
7272
try {
7373
HttpClientBeanHolder.shutdownNacosSyncRest(HTTP_CLIENT_FACTORY.getClass().getName());
7474
} catch (Exception ex) {
7575
NAMING_LOGGER.error("[NamingHttpClientManager] An exception occurred when the HTTP client was closed : {}",
7676
ExceptionUtil.getStackTrace(ex));
7777
}
78-
NAMING_LOGGER.warn("[NamingHttpClientManager] Destruction of the end");
78+
NAMING_LOGGER.info("[NamingHttpClientManager] Completed destruction of NacosRestTemplate");
7979
}
8080

8181
private static class NamingHttpClientFactory extends AbstractHttpClientFactory {

common/src/main/java/com/alibaba/nacos/common/executor/ThreadPoolManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public final class ThreadPoolManager {
5151
static {
5252
INSTANCE.init();
5353
ThreadUtils.addShutdownHook(new Thread(() -> {
54-
LOGGER.warn("[ThreadPoolManager] Start destroying ThreadPool");
54+
LOGGER.info("[ThreadPoolManager] Start destroying ThreadPool");
5555
shutdown();
56-
LOGGER.warn("[ThreadPoolManager] Destruction of the end");
56+
LOGGER.info("[ThreadPoolManager] Completed destruction of ThreadPool");
5757
}));
5858
}
5959

common/src/main/java/com/alibaba/nacos/common/http/HttpClientBeanHolder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private static void shutdown() {
9999
if (!ALREADY_SHUTDOWN.compareAndSet(false, true)) {
100100
return;
101101
}
102-
LOGGER.warn("[HttpClientBeanHolder] Start destroying common HttpClient");
102+
LOGGER.info("[HttpClientBeanHolder] Start destroying common HttpClient");
103103

104104
try {
105105
shutdown(DefaultHttpClientFactory.class.getName());
@@ -108,7 +108,7 @@ private static void shutdown() {
108108
ExceptionUtil.getStackTrace(ex));
109109
}
110110

111-
LOGGER.warn("[HttpClientBeanHolder] Destruction of the end");
111+
LOGGER.info("[HttpClientBeanHolder] Completed destruction of HttpClient");
112112
}
113113

114114
/**

common/src/main/java/com/alibaba/nacos/common/notify/NotifyCenter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public static void shutdown() {
131131
if (!CLOSED.compareAndSet(false, true)) {
132132
return;
133133
}
134-
LOGGER.warn("[NotifyCenter] Start destroying Publisher");
134+
LOGGER.info("[NotifyCenter] Start destroying Publisher");
135135

136136
for (Map.Entry<String, EventPublisher> entry : INSTANCE.publisherMap.entrySet()) {
137137
try {
@@ -148,7 +148,7 @@ public static void shutdown() {
148148
LOGGER.error("[SharePublisher] shutdown has error : ", e);
149149
}
150150

151-
LOGGER.warn("[NotifyCenter] Destruction of the end");
151+
LOGGER.info("[NotifyCenter] Completed destruction of Publisher");
152152
}
153153

154154
/**

common/src/test/java/com/alibaba/nacos/common/notify/DefaultSharePublisherTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void testIgnoreExpiredEvent() throws InterruptedException {
106106
defaultSharePublisher.addSubscriber(smartSubscriber2, MockSlowEvent2.class);
107107
defaultSharePublisher.publish(mockSlowEvent1);
108108
defaultSharePublisher.publish(mockSlowEvent2);
109-
TimeUnit.MILLISECONDS.sleep(1100);
109+
TimeUnit.MILLISECONDS.sleep(1500);
110110
verify(smartSubscriber1).onEvent(mockSlowEvent1);
111111
verify(smartSubscriber2).onEvent(mockSlowEvent2);
112112
reset(smartSubscriber1);

config/src/main/java/com/alibaba/nacos/config/server/configuration/NacosConfigConfiguration.java

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.alibaba.nacos.core.code.ControllerMethodsCache;
2222
import com.alibaba.nacos.core.web.NacosWebBean;
2323
import com.alibaba.nacos.persistence.configuration.condition.ConditionDistributedEmbedStorage;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2425
import org.springframework.boot.web.servlet.FilterRegistrationBean;
2526
import org.springframework.context.annotation.Bean;
2627
import org.springframework.context.annotation.Conditional;
@@ -50,6 +51,7 @@ public void init() {
5051
}
5152

5253
@Bean
54+
@ConditionalOnProperty(name = "nacos.web.charset.filter", havingValue = "nacos", matchIfMissing = true)
5355
public FilterRegistrationBean<NacosWebFilter> nacosWebFilterRegistration() {
5456
FilterRegistrationBean<NacosWebFilter> registration = new FilterRegistrationBean<>();
5557
registration.setFilter(nacosWebFilter());

config/src/main/java/com/alibaba/nacos/config/server/controller/HistoryController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public ConfigHistoryInfo getConfigHistoryInfo(@RequestParam("dataId") String dat
106106
tenant = NamespaceUtil.processNamespaceParameter(tenant);
107107
return historyService.getConfigHistoryInfo(dataId, group, tenant, nid);
108108
}
109-
109+
110110
/**
111111
* Query previous config history information. notes:
112112
*

config/src/main/java/com/alibaba/nacos/config/server/controller/v2/HistoryControllerV2.java

+22
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.alibaba.nacos.common.utils.StringUtils;
2626
import com.alibaba.nacos.config.server.constant.Constants;
2727
import com.alibaba.nacos.config.server.model.ConfigHistoryInfo;
28+
import com.alibaba.nacos.config.server.model.ConfigHistoryInfoDetail;
2829
import com.alibaba.nacos.config.server.model.ConfigInfoWrapper;
2930
import com.alibaba.nacos.config.server.paramcheck.ConfigDefaultHttpParamExtractor;
3031
import com.alibaba.nacos.core.controller.compatibility.Compatibility;
@@ -116,6 +117,27 @@ public Result<ConfigHistoryInfo> getConfigHistoryInfo(@RequestParam("dataId") St
116117
return Result.success(configHistoryInfo);
117118
}
118119

120+
121+
/**
122+
* Query the detailed configuration history information pair, including the original version and the updated version. notes:
123+
*
124+
* @param nid history_config_info nid
125+
* @param dataId dataId @since 2.0.3
126+
* @param group groupId @since 2.0.3
127+
* @param namespaceId namespaceId @since 2.0.3
128+
* @return history config info
129+
* @since 2.0.3 add {@link Secured}, dataId, groupId and tenant for history config permission check.
130+
*/
131+
@GetMapping(value = "/detail")
132+
@Secured(action = ActionTypes.READ, signType = SignType.CONFIG)
133+
public Result<ConfigHistoryInfoDetail> getConfigHistoryInfoDetail(@RequestParam("dataId") String dataId,
134+
@RequestParam("group") String group,
135+
@RequestParam(value = "namespaceId", required = false, defaultValue = StringUtils.EMPTY) String namespaceId,
136+
@RequestParam(value = "nid") Long nid) throws AccessException {
137+
return Result.success(historyService.getConfigHistoryInfoDetail(dataId, group, namespaceId, nid));
138+
}
139+
140+
119141
/**
120142
* Query previous config history information. notes:
121143
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 1999-2018 Alibaba Group Holding Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.alibaba.nacos.config.server.enums;
18+
19+
/**
20+
* Operation type enum.
21+
*
22+
* @author dirtybit
23+
*/
24+
public enum OperationType {
25+
26+
/**
27+
* Insert.
28+
*/
29+
INSERT("I"),
30+
31+
/**
32+
* Update.
33+
*/
34+
UPDATE("U"),
35+
36+
/**
37+
* Delete.
38+
*/
39+
DELETE("D");
40+
41+
/**
42+
* operation type value.
43+
*/
44+
private String value;
45+
46+
OperationType(String value) {
47+
this.value = value;
48+
}
49+
50+
public void setValue(String value) {
51+
this.value = value;
52+
}
53+
54+
public String getValue() {
55+
return this.value;
56+
}
57+
58+
}

config/src/main/java/com/alibaba/nacos/config/server/model/CacheItem.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class CacheItem {
3535

3636
public String type;
3737

38-
ConfigCache configCache = new ConfigCache();
38+
ConfigCache configCache = ConfigCacheFactoryDelegate.getInstance().createConfigCache();
3939

4040
/**
4141
* Use for gray.
@@ -92,7 +92,7 @@ public void initConfigGrayIfEmpty() {
9292
public void initConfigGrayIfEmpty(String grayName) {
9393
initConfigGrayIfEmpty();
9494
if (!this.configCacheGray.containsKey(grayName)) {
95-
this.configCacheGray.put(grayName, new ConfigCacheGray(grayName));
95+
this.configCacheGray.put(grayName, ConfigCacheFactoryDelegate.getInstance().createConfigCacheGray(grayName));
9696
}
9797
}
9898

config/src/main/java/com/alibaba/nacos/config/server/model/ConfigCache.java

+11-33
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@
2121

2222
import java.io.Serializable;
2323

24-
import static java.nio.charset.StandardCharsets.UTF_8;
25-
2624
/**
2725
* config cache .
2826
*
2927
* @author shiyiyue1102
3028
*/
3129
public class ConfigCache implements Serializable {
3230

33-
volatile String md5Gbk = Constants.NULL;
34-
35-
volatile String md5Utf8 = Constants.NULL;
31+
volatile String md5 = Constants.NULL;
3632

3733
volatile String encryptedDataKey;
3834

@@ -42,21 +38,21 @@ public class ConfigCache implements Serializable {
4238
* clear cache.
4339
*/
4440
public void clear() {
45-
this.md5Gbk = Constants.NULL;
46-
this.md5Utf8 = Constants.NULL;
41+
this.md5 = Constants.NULL;
4742
this.encryptedDataKey = null;
4843
this.lastModifiedTs = -1L;
4944
}
5045

5146
public ConfigCache() {
5247
}
5348

54-
public String getMd5(String encode) {
55-
if (UTF_8.name().equalsIgnoreCase(encode)) {
56-
return md5Utf8;
57-
} else {
58-
return md5Gbk;
59-
}
49+
public ConfigCache(String md5, long lastModifiedTs) {
50+
this.md5 = StringPool.get(md5);
51+
this.lastModifiedTs = lastModifiedTs;
52+
}
53+
54+
public String getMd5() {
55+
return md5;
6056
}
6157

6258
public String getEncryptedDataKey() {
@@ -67,26 +63,8 @@ public void setEncryptedDataKey(String encryptedDataKey) {
6763
this.encryptedDataKey = encryptedDataKey;
6864
}
6965

70-
public ConfigCache(String md5Gbk, String md5Utf8, long lastModifiedTs) {
71-
this.md5Gbk = StringPool.get(md5Gbk);
72-
this.md5Utf8 = StringPool.get(md5Utf8);
73-
this.lastModifiedTs = lastModifiedTs;
74-
}
75-
76-
public String getMd5Gbk() {
77-
return md5Gbk;
78-
}
79-
80-
public void setMd5Gbk(String md5Gbk) {
81-
this.md5Gbk = StringPool.get(md5Gbk);
82-
}
83-
84-
public String getMd5Utf8() {
85-
return md5Utf8;
86-
}
87-
88-
public void setMd5Utf8(String md5Utf8) {
89-
this.md5Utf8 = StringPool.get(md5Utf8);
66+
public void setMd5(String md5) {
67+
this.md5 = StringPool.get(md5);
9068
}
9169

9270
public long getLastModifiedTs() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 1999-2024 Alibaba Group Holding Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.alibaba.nacos.config.server.model;
18+
19+
/**
20+
* The interface Config cache factory.
21+
*
22+
* @author Sunrisea
23+
*/
24+
public interface ConfigCacheFactory {
25+
26+
/**
27+
* Create config cache config cache.
28+
*
29+
* @return the config cache
30+
*/
31+
public ConfigCache createConfigCache();
32+
33+
/**
34+
* Create config cache gray config cache gray.
35+
*
36+
* @return the config cache gray
37+
*/
38+
public ConfigCacheGray createConfigCacheGray();
39+
40+
/**
41+
* Gets config cache factroy name.
42+
*
43+
* @return the config cache factory name
44+
*/
45+
public String getName();
46+
}

0 commit comments

Comments
 (0)