Skip to content

Commit 6290f8e

Browse files
authored
Merge pull request #6 from alibaba/develop
pull latest code
2 parents b8aaa5a + 80c260e commit 6290f8e

File tree

154 files changed

+2614
-8124
lines changed

Some content is hidden

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

154 files changed

+2614
-8124
lines changed

Diff for: .github/ISSUE_TEMPLATE.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!-- Here is for bug reports and feature requests ONLY!
2+
3+
If you're looking for help, please check our mail list、WeChat group and the Gitter room.
4+
5+
Please try to use English to describe your issue, or at least provide a snippet of English translation.
6+
我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。
7+
-->
8+
9+
## Issue Description
10+
11+
Type: *bug report* or *feature request*
12+
13+
### Describe what happened (or what feature you want)
14+
15+
16+
### Describe what you expected to happen
17+
18+
19+
### How to reproduce it (as minimally and precisely as possible)
20+
21+
1.
22+
2.
23+
3.
24+
25+
### Tell us your environment
26+
27+
28+
### Anything else we need to know?

Diff for: .github/ISSUE_TEMPLATE/bug_report.md

-43
This file was deleted.

Diff for: .github/ISSUE_TEMPLATE/feature_request.md

-17
This file was deleted.

Diff for: CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## 0.9.0(Feb 28, 2019)
2+
3+
* [#840] Nacos server adds startup mode to distinguish between config and naming.
4+
* [#762] Register instance returns failed when the health check mode is 'server' in standalone mode.
5+
* [#473] Nacos Cluster Mode kubernate Startup nacos.log error Log.
6+
* [#240] Log strong dependence problem.
7+
* [#824] getServicesOfServer throws exception if service list is empty.
8+
* [#802] Nacos server multi-boot mode support.
9+
* [#800] Nacos's client-to-server addressing mode document introduction.
10+
* [#768] The interval at which the heartbeat is sent in BeatReactor is not controlled by the server return value.
11+
* [#759] why instance can't auto-delete.
12+
* [#756] Format of instance and service should be validated.
13+
* [#720] Memory leak in PushService.
14+
* [#653] IoUtils under nacos-common-0.2.1-RC1.jar lacks "" judgment on encoding.
15+
* [#588] Client compatible to jdk1.6.
16+
117
## 0.8.0(Jan 22, 2019) PRE-GA
218

319
* [#162] Support open metrics and prometheus

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ It is super easy to get started with your first project.
4040

4141
You can download the package from the [latest stable release](https://github.com/alibaba/nacos/releases).
4242

43-
Take release nacos-server-0.8.0.zip for example.
43+
Take release nacos-server-0.9.0.zip for example.
4444
```
45-
unzip nacos-server-0.8.0.zip
45+
unzip nacos-server-0.9.0.zip
4646
cd nacos/bin
4747
```
4848

Diff for: api/pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<parent>
1717
<groupId>com.alibaba.nacos</groupId>
1818
<artifactId>nacos-all</artifactId>
19-
<version>0.8.0</version>
19+
<version>0.9.0</version>
2020
</parent>
2121

2222
<modelVersion>4.0.0</modelVersion>
@@ -32,8 +32,8 @@
3232
<groupId>org.apache.maven.plugins</groupId>
3333
<artifactId>maven-compiler-plugin</artifactId>
3434
<configuration>
35-
<source>7</source>
36-
<target>7</target>
35+
<source>6</source>
36+
<target>6</target>
3737
</configuration>
3838
</plugin>
3939
</plugins>

Diff for: client/pom.xml

+16-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<parent>
1717
<groupId>com.alibaba.nacos</groupId>
1818
<artifactId>nacos-all</artifactId>
19-
<version>0.8.0</version>
19+
<version>0.9.0</version>
2020
<relativePath>../pom.xml</relativePath>
2121
</parent>
2222

@@ -43,7 +43,6 @@
4343
<dependency>
4444
<groupId>org.apache.logging.log4j</groupId>
4545
<artifactId>log4j-core</artifactId>
46-
<version>2.8.2</version>
4746
<optional>true</optional>
4847
</dependency>
4948

@@ -108,9 +107,22 @@
108107
</dependency>
109108

110109
<dependency>
111-
<groupId>io.micrometer</groupId>
112-
<artifactId>micrometer-core</artifactId>
110+
<groupId>io.prometheus</groupId>
111+
<artifactId>simpleclient</artifactId>
112+
<version>0.5.0</version>
113113
</dependency>
114114

115115
</dependencies>
116+
<build>
117+
<plugins>
118+
<plugin>
119+
<groupId>org.apache.maven.plugins</groupId>
120+
<artifactId>maven-compiler-plugin</artifactId>
121+
<configuration>
122+
<source>6</source>
123+
<target>6</target>
124+
</configuration>
125+
</plugin>
126+
</plugins>
127+
</build>
116128
</project>

Diff for: client/src/main/java/com/alibaba/nacos/client/config/NacosConfigService.java

+25-29
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@
3030
import com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult;
3131
import com.alibaba.nacos.client.config.impl.LocalConfigInfoProcessor;
3232
import com.alibaba.nacos.client.config.utils.ContentUtils;
33-
import com.alibaba.nacos.client.config.utils.LogUtils;
3433
import com.alibaba.nacos.client.config.utils.ParamUtils;
3534
import com.alibaba.nacos.client.config.utils.TenantUtil;
36-
import com.alibaba.nacos.client.logger.Logger;
37-
import com.alibaba.nacos.client.logger.support.LoggerHelper;
35+
import com.alibaba.nacos.client.utils.LogUtils;
3836
import com.alibaba.nacos.client.utils.StringUtils;
37+
import org.slf4j.Logger;
3938

4039
import java.io.IOException;
4140
import java.net.HttpURLConnection;
@@ -52,8 +51,9 @@
5251
@SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule")
5352
public class NacosConfigService implements ConfigService {
5453

55-
final static public Logger log = LogUtils.logger(NacosConfigService.class);
56-
public final long POST_TIMEOUT = 3000L;
54+
private static final Logger LOGGER = LogUtils.logger(NacosConfigService.class);
55+
56+
private final long POST_TIMEOUT = 3000L;
5757
/**
5858
* http agent
5959
*/
@@ -123,8 +123,8 @@ private String getConfigInner(String tenant, String dataId, String group, long t
123123
// 优先使用本地配置
124124
String content = LocalConfigInfoProcessor.getFailover(agent.getName(), dataId, group, tenant);
125125
if (content != null) {
126-
log.warn(agent.getName(), "[get-config] get failover ok, dataId={}, group={}, tenant={}, config={}", dataId,
127-
group, tenant, ContentUtils.truncateContent(content));
126+
LOGGER.warn("[{}] [get-config] get failover ok, dataId={}, group={}, tenant={}, config={}", agent.getName(),
127+
dataId, group, tenant, ContentUtils.truncateContent(content));
128128
cr.setContent(content);
129129
configFilterChainManager.doFilter(null, cr);
130130
content = cr.getContent();
@@ -143,14 +143,12 @@ private String getConfigInner(String tenant, String dataId, String group, long t
143143
if (NacosException.NO_RIGHT == ioe.getErrCode()) {
144144
throw ioe;
145145
}
146-
log.warn("NACOS-0003",
147-
LoggerHelper.getErrorCodeStr("NACOS", "NACOS-0003", "环境问题", "get from server error"));
148-
log.warn(agent.getName(), "[get-config] get from server error, dataId={}, group={}, tenant={}, msg={}",
149-
dataId, group, tenant, ioe.toString());
146+
LOGGER.warn("[{}] [get-config] get from server error, dataId={}, group={}, tenant={}, msg={}",
147+
agent.getName(), dataId, group, tenant, ioe.toString());
150148
}
151149

152-
log.warn(agent.getName(), "[get-config] get snapshot ok, dataId={}, group={}, tenant={}, config={}", dataId,
153-
group, tenant, ContentUtils.truncateContent(content));
150+
LOGGER.warn("[{}] [get-config] get snapshot ok, dataId={}, group={}, tenant={}, config={}", agent.getName(),
151+
dataId, group, tenant, ContentUtils.truncateContent(content));
154152
content = LocalConfigInfoProcessor.getSnapshot(agent.getName(), dataId, group, tenant);
155153
cr.setContent(content);
156154
configFilterChainManager.doFilter(null, cr);
@@ -183,20 +181,20 @@ private boolean removeConfigInner(String tenant, String dataId, String group, St
183181
try {
184182
result = agent.httpDelete(url, null, params, encode, POST_TIMEOUT);
185183
} catch (IOException ioe) {
186-
log.warn("[remove] error, " + dataId + ", " + group + ", " + tenant + ", msg: " + ioe.toString());
184+
LOGGER.warn("[remove] error, " + dataId + ", " + group + ", " + tenant + ", msg: " + ioe.toString());
187185
return false;
188186
}
189187

190188
if (HttpURLConnection.HTTP_OK == result.code) {
191-
log.info(agent.getName(), "[remove] ok, dataId={}, group={}, tenant={}", dataId, group, tenant);
189+
LOGGER.info("[{}] [remove] ok, dataId={}, group={}, tenant={}", agent.getName(), dataId, group, tenant);
192190
return true;
193191
} else if (HttpURLConnection.HTTP_FORBIDDEN == result.code) {
194-
log.warn(agent.getName(), "[remove] error, dataId={}, group={}, tenant={}, code={}, msg={}", dataId, group,
195-
tenant, result.code, result.content);
192+
LOGGER.warn("[{}] [remove] error, dataId={}, group={}, tenant={}, code={}, msg={}", agent.getName(), dataId,
193+
group, tenant, result.code, result.content);
196194
throw new NacosException(result.code, result.content);
197195
} else {
198-
log.warn(agent.getName(), "[remove] error, dataId={}, group={}, tenant={}, code={}, msg={}", dataId, group,
199-
tenant, result.code, result.content);
196+
LOGGER.warn("[{}] [remove] error, dataId={}, group={}, tenant={}, code={}, msg={}", agent.getName(), dataId,
197+
group, tenant, result.code, result.content);
200198
return false;
201199
}
202200
}
@@ -245,24 +243,22 @@ private boolean publishConfigInner(String tenant, String dataId, String group, S
245243
try {
246244
result = agent.httpPost(url, headers, params, encode, POST_TIMEOUT);
247245
} catch (IOException ioe) {
248-
log.warn("NACOS-0006",
249-
LoggerHelper.getErrorCodeStr("NACOS", "NACOS-0006", "环境问题", "[publish-single] exception"));
250-
log.warn(agent.getName(), "[publish-single] exception, dataId={}, group={}, msg={}", dataId, group,
251-
ioe.toString());
246+
LOGGER.warn("[{}] [publish-single] exception, dataId={}, group={}, msg={}", agent.getName(), dataId,
247+
group, ioe.toString());
252248
return false;
253249
}
254250

255251
if (HttpURLConnection.HTTP_OK == result.code) {
256-
log.info(agent.getName(), "[publish-single] ok, dataId={}, group={}, tenant={}, config={}", dataId, group,
257-
tenant, ContentUtils.truncateContent(content));
252+
LOGGER.info("[{}] [publish-single] ok, dataId={}, group={}, tenant={}, config={}", agent.getName(), dataId,
253+
group, tenant, ContentUtils.truncateContent(content));
258254
return true;
259255
} else if (HttpURLConnection.HTTP_FORBIDDEN == result.code) {
260-
log.warn(agent.getName(), "[publish-single] error, dataId={}, group={}, tenant={}, code={}, msg={}", dataId,
261-
group, tenant, result.code, result.content);
256+
LOGGER.warn("[{}] [publish-single] error, dataId={}, group={}, tenant={}, code={}, msg={}", agent.getName(),
257+
dataId, group, tenant, result.code, result.content);
262258
throw new NacosException(result.code, result.content);
263259
} else {
264-
log.warn(agent.getName(), "[publish-single] error, dataId={}, group={}, tenant={}, code={}, msg={}", dataId,
265-
group, tenant, result.code, result.content);
260+
LOGGER.warn("[{}] [publish-single] error, dataId={}, group={}, tenant={}, code={}, msg={}", agent.getName(),
261+
dataId, group, tenant, result.code, result.content);
266262
return false;
267263
}
268264

Diff for: client/src/main/java/com/alibaba/nacos/client/config/http/MetricsHttpAgent.java

+15-22
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
import com.alibaba.nacos.api.exception.NacosException;
1919
import com.alibaba.nacos.client.config.impl.HttpSimpleClient.HttpResult;
2020
import com.alibaba.nacos.client.monitor.MetricsMonitor;
21+
import io.prometheus.client.Histogram;
2122

2223
import java.io.IOException;
2324
import java.util.List;
24-
import java.util.concurrent.TimeUnit;
2525

2626
/**
2727
* MetricsHttpAgent
@@ -42,58 +42,50 @@ public void start() throws NacosException {
4242

4343
@Override
4444
public HttpResult httpGet(String path, List<String> headers, List<String> paramValues, String encoding, long readTimeoutMs) throws IOException {
45-
long start = System.currentTimeMillis();
46-
long end = 0;
45+
Histogram.Timer timer = MetricsMonitor.getConfigRequestMonitor("GET", path, "NA");
4746
HttpResult result = null;
4847
try {
4948
result = httpAgent.httpGet(path, headers, paramValues, encoding, readTimeoutMs);
5049
} catch (IOException e) {
51-
end = System.currentTimeMillis();
52-
MetricsMonitor.getConfigRequestMonitor("GET", path, "NA").record(end - start, TimeUnit.MILLISECONDS);
5350
throw e;
51+
} finally {
52+
timer.observeDuration();
53+
timer.close();
5454
}
5555

56-
end = System.currentTimeMillis();
57-
MetricsMonitor.getConfigRequestMonitor("GET", path, String.valueOf(result.code)).record(end - start, TimeUnit.MILLISECONDS);
58-
5956
return result;
6057
}
6158

6259
@Override
6360
public HttpResult httpPost(String path, List<String> headers, List<String> paramValues, String encoding, long readTimeoutMs) throws IOException {
64-
long start = System.currentTimeMillis();
65-
long end = 0;
61+
Histogram.Timer timer = MetricsMonitor.getConfigRequestMonitor("POST", path, "NA");
6662
HttpResult result = null;
6763
try {
6864
result = httpAgent.httpPost(path, headers, paramValues, encoding, readTimeoutMs);
6965
} catch (IOException e) {
70-
end = System.currentTimeMillis();
71-
MetricsMonitor.getConfigRequestMonitor("POST", path, "NA").record(end - start, TimeUnit.MILLISECONDS);
7266
throw e;
67+
} finally {
68+
timer.observeDuration();
69+
timer.close();
7370
}
7471

75-
end = System.currentTimeMillis();
76-
MetricsMonitor.getConfigRequestMonitor("POST", path, String.valueOf(result.code)).record(end - start, TimeUnit.MILLISECONDS);
77-
7872
return result;
7973
}
8074

8175
@Override
8276
public HttpResult httpDelete(String path, List<String> headers, List<String> paramValues, String encoding, long readTimeoutMs) throws IOException {
83-
long start = System.currentTimeMillis();
84-
long end = 0;
77+
Histogram.Timer timer = MetricsMonitor.getConfigRequestMonitor("DELETE", path, "NA");
8578
HttpResult result = null;
8679
try {
8780
result = httpAgent.httpDelete(path, headers, paramValues, encoding, readTimeoutMs);
8881
} catch (IOException e) {
89-
end = System.currentTimeMillis();
90-
MetricsMonitor.getConfigRequestMonitor("DELETE", path, "NA").record(end - start, TimeUnit.MILLISECONDS);
82+
9183
throw e;
84+
} finally {
85+
timer.observeDuration();
86+
timer.close();
9287
}
9388

94-
end = System.currentTimeMillis();
95-
MetricsMonitor.getConfigRequestMonitor("DELETE", path, String.valueOf(result.code)).record(end - start, TimeUnit.MILLISECONDS);
96-
9789
return result;
9890
}
9991

@@ -117,3 +109,4 @@ public String getEncode() {
117109
return httpAgent.getEncode();
118110
}
119111
}
112+

0 commit comments

Comments
 (0)