Skip to content

Commit 7dfc813

Browse files
author
fishtailfu
committed
feat: support config event and monitor address list.
1 parent 04539c0 commit 7dfc813

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

polaris-plugins/polaris-plugins-observability/event-pushgateway/src/main/java/com/tencent/polaris/plugins/event/pushgateway/PushGatewayEventReporter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void postContextInit(Extensions ctx) throws PolarisException {
152152

153153
eventQueue = new LinkedBlockingQueue<>(config.getEventQueueSize());
154154

155-
serviceAddressRepository = new ServiceAddressRepository(Collections.singletonList(this.config.getAddress()),
155+
serviceAddressRepository = new ServiceAddressRepository(this.config.getAddress(),
156156
ctx.getValueContext().getClientId(), ctx, new ServiceKey(config.getNamespace(), config.getService()));
157157

158158
eventExecutors.scheduleWithFixedDelay(new PushGatewayEventTask(), 1000, 1000, TimeUnit.MILLISECONDS);

polaris-plugins/polaris-plugins-observability/event-pushgateway/src/main/java/com/tencent/polaris/plugins/event/pushgateway/PushGatewayEventReporterConfig.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
import com.fasterxml.jackson.annotation.JsonProperty;
2121
import com.tencent.polaris.api.config.verify.Verifier;
22+
import com.tencent.polaris.api.utils.CollectionUtils;
2223
import com.tencent.polaris.api.utils.StringUtils;
2324
import com.tencent.polaris.factory.util.ConfigUtils;
25+
import java.util.List;
2426

2527
/**
2628
* Polaris push gateway event reporter config.
@@ -32,8 +34,9 @@ public class PushGatewayEventReporterConfig implements Verifier {
3234
@JsonProperty
3335
private Boolean enable;
3436

37+
3538
@JsonProperty
36-
private String address;
39+
private List<String> address;
3740

3841
@JsonProperty
3942
private Integer eventQueueSize;
@@ -53,7 +56,6 @@ public void verify() {
5356
if (!enable) {
5457
return;
5558
}
56-
ConfigUtils.validateString(address, "global.eventReporter.plugin.pushgateway.address");
5759
ConfigUtils.validatePositive(eventQueueSize, "global.eventReporter.plugin.pushgateway.eventQueueSize");
5860
ConfigUtils.validatePositive(maxBatchSize, "global.eventReporter.plugin.pushgateway.maxBatchSize");
5961
ConfigUtils.validateString(namespace, "global.eventReporter.plugin.pushgateway.namespace");
@@ -67,7 +69,7 @@ public void setDefault(Object defaultObject) {
6769
if (null == enable) {
6870
setEnable(pushGatewayEventReporterConfig.isEnable());
6971
}
70-
if (StringUtils.isBlank(address)) {
72+
if (CollectionUtils.isEmpty(address)) {
7173
setAddress(pushGatewayEventReporterConfig.getAddress());
7274
}
7375
if (null == eventQueueSize) {
@@ -96,11 +98,11 @@ public void setEnable(boolean enable) {
9698
this.enable = enable;
9799
}
98100

99-
public String getAddress() {
101+
public List<String> getAddress() {
100102
return address;
101103
}
102104

103-
public void setAddress(String address) {
105+
public void setAddress(List<String> address) {
104106
this.address = address;
105107
}
106108

polaris-plugins/polaris-plugins-observability/stat-prometheus/src/main/java/com/tencent/polaris/plugins/stat/prometheus/handler/PrometheusHandlerConfig.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
import com.fasterxml.jackson.annotation.JsonProperty;
2121
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
2222
import com.tencent.polaris.api.config.verify.Verifier;
23+
import com.tencent.polaris.api.utils.CollectionUtils;
2324
import com.tencent.polaris.api.utils.StringUtils;
2425
import com.tencent.polaris.factory.util.TimeStrJsonDeserializer;
2526

2627
import java.util.ArrayList;
28+
import java.util.Collections;
2729
import java.util.List;
2830

2931
/**
@@ -38,8 +40,7 @@ public class PrometheusHandlerConfig implements Verifier {
3840
private String type;
3941

4042
@JsonProperty
41-
private String address;
42-
43+
private List<String> address;
4344
@JsonProperty
4445
private String namespace;
4546

@@ -82,7 +83,7 @@ public void setDefault(Object defaultObject) {
8283
if (StringUtils.isBlank(path)) {
8384
setPath(config.getPath());
8485
}
85-
if (StringUtils.isBlank(address)) {
86+
if (CollectionUtils.isEmpty(address)) {
8687
setAddress(config.getAddress());
8788
}
8889
if (null == pushInterval) {
@@ -116,11 +117,11 @@ public void setPath(String path) {
116117
this.path = path;
117118
}
118119

119-
public String getAddress() {
120+
public List<String> getAddress() {
120121
return address;
121122
}
122123

123-
public void setAddress(String address) {
124+
public void setAddress(List<String> address) {
124125
this.address = address;
125126
}
126127

polaris-plugins/polaris-plugins-observability/stat-prometheus/src/main/java/com/tencent/polaris/plugins/stat/prometheus/plugin/PrometheusReporter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void postContextInit(Extensions extensions) throws PolarisException {
129129
this.executorService = Executors.newScheduledThreadPool(4, new NamedThreadFactory(getName()));
130130
this.port = extensions.getConfiguration().getGlobal().getAdmin().getPort();
131131

132-
this.serviceAddressRepository = new ServiceAddressRepository(Collections.singletonList(this.config.getAddress()),
132+
this.serviceAddressRepository = new ServiceAddressRepository(this.config.getAddress(),
133133
extensions.getValueContext().getClientId(), extensions, new ServiceKey(config.getNamespace(), config.getService()));
134134

135135
if (CollectionUtils.isNotEmpty(config.getPathRegexList())) {

0 commit comments

Comments
 (0)