Skip to content

Commit 3302af0

Browse files
authored
Merge pull request #70 from reactivegroup/feature/metrics
Fix Configuration data type casting.
2 parents f5f3481 + 45b8576 commit 3302af0

File tree

10 files changed

+27
-19
lines changed

10 files changed

+27
-19
lines changed

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>capa-parent</artifactId>
2525
<groupId>group.rxcloud</groupId>
26-
<version>1.0.8.RELEASE</version>
26+
<version>1.0.9.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>capa-examples</artifactId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<groupId>group.rxcloud</groupId>
2424
<artifactId>capa-parent</artifactId>
2525
<packaging>pom</packaging>
26-
<version>1.0.8.RELEASE</version>
26+
<version>1.0.9.RELEASE</version>
2727
<name>capa-sdk-parent</name>
2828
<description>SDK for Capa.</description>
2929
<url>https://github.com/reactivegroup</url>

sdk-component/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<groupId>group.rxcloud</groupId>
2525
<artifactId>capa-parent</artifactId>
26-
<version>1.0.8.RELEASE</version>
26+
<version>1.0.9.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>capa-sdk-component</artifactId>

sdk-component/src/test/java/group/rxcloud/capa/component/telemetry/TestMixerProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
import group.rxcloud.cloudruntimes.utils.TypeRef;
2626
import reactor.core.publisher.Flux;
2727

28+
import java.util.HashMap;
2829
import java.util.List;
2930
import java.util.Map;
30-
import java.util.Properties;
3131

3232
/**
3333
* @author: chenyijiang
3434
* @date: 2021/12/2 12:39
3535
*/
3636
public class TestMixerProvider implements Mixer.MixerProvider {
3737

38-
Properties app = new Properties() {{put("metricsEnable", false);}};
39-
Properties global = new Properties() {{put("traceEnable", false); put("metricsEnable", true);}};
38+
Map<String, String> app = new HashMap() {{put("metricsEnable", false);}};
39+
Map<String, String> global = new HashMap() {{put("traceEnable", false); put("metricsEnable", true);}};
4040

4141

4242
private ConfigurationHooks configurationHooks = new ConfigurationHooks() {
@@ -53,7 +53,7 @@ public String defaultConfigurationAppId() {
5353
@Override
5454
public <T> Flux<SubConfigurationResp<T>> subscribeConfiguration(String storeName, String appId, List<String> keys, Map<String, String> metadata, String group, String label, TypeRef<T> type) {
5555

56-
if (type.getType() == Properties.class) {
56+
if (type.getType() == Map.class) {
5757
if ("123".equals(appId)) {
5858
return Flux.just(getSubscribeResponse(global));
5959
}
@@ -66,7 +66,7 @@ public <T> Flux<SubConfigurationResp<T>> subscribeConfiguration(String storeName
6666
}
6767
};
6868

69-
private <T> SubConfigurationResp<T> getSubscribeResponse(Properties samplerConfig) {
69+
private <T> SubConfigurationResp<T> getSubscribeResponse(Map samplerConfig) {
7070
SubConfigurationResp<T> subConfigurationResp = new SubConfigurationResp<>();
7171
ConfigurationItem item = new ConfigurationItem();
7272
item.setContent(samplerConfig);

sdk-infrastructure/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>capa-parent</artifactId>
2525
<groupId>group.rxcloud</groupId>
26-
<version>1.0.8.RELEASE</version>
26+
<version>1.0.9.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>capa-sdk-infrastructure</artifactId>

sdk-infrastructure/src/main/java/group/rxcloud/capa/infrastructure/hook/MergedPropertiesConfig.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818

1919
import group.rxcloud.cloudruntimes.domain.core.configuration.SubConfigurationResp;
2020
import group.rxcloud.cloudruntimes.utils.TypeRef;
21+
import org.slf4j.Logger;
22+
import org.slf4j.LoggerFactory;
2123
import reactor.core.publisher.Flux;
2224

2325
import java.util.Collections;
2426
import java.util.HashMap;
2527
import java.util.Map;
26-
import java.util.Properties;
2728
import java.util.concurrent.atomic.AtomicReferenceArray;
2829

2930
/**
@@ -36,9 +37,11 @@
3637
@Deprecated
3738
public class MergedPropertiesConfig {
3839

40+
private static final Logger log = LoggerFactory.getLogger(MergedPropertiesConfig.class);
41+
3942
private final String fileName;
4043

41-
private final AtomicReferenceArray<Properties> properties;
44+
private final AtomicReferenceArray<Map> properties;
4245

4346
private final Object lock = new Object();
4447

@@ -50,7 +53,12 @@ public MergedPropertiesConfig(String fileName, String... appIds) {
5053
merged = new HashMap<>();
5154
Mixer.configurationHooksNullable().ifPresent(hooks -> {
5255
for (int i = 0; i < appIds.length; i++) {
53-
subscribeConfigurationByAppId(hooks, appIds[i], i);
56+
try {
57+
subscribeConfigurationByAppId(hooks, appIds[i], i);
58+
} catch (Throwable throwable) {
59+
log.warn("Fail to subscribe config for app id " + appIds[i] + ", index " + i, throwable);
60+
}
61+
5462
}
5563
});
5664
}
@@ -70,14 +78,14 @@ public Map<String, String> getMerged() {
7078
private void subscribeConfigurationByAppId(ConfigurationHooks configurationHooks, String appId, int index) {
7179
String storeName = configurationHooks.registryStoreNames().get(0);
7280

73-
Flux<SubConfigurationResp<Properties>> configFlux = configurationHooks.subscribeConfiguration(
81+
Flux<SubConfigurationResp<Map>> configFlux = configurationHooks.subscribeConfiguration(
7482
storeName,
7583
appId,
7684
Collections.singletonList(fileName),
7785
null,
7886
"",
7987
"",
80-
TypeRef.get(Properties.class));
88+
TypeRef.get(Map.class));
8189

8290
// FIXME: 2021/12/3 random callback?
8391
configFlux.subscribe(resp -> {
@@ -90,7 +98,7 @@ private void subscribeConfigurationByAppId(ConfigurationHooks configurationHooks
9098

9199
Map<String, String> merged = new HashMap<>();
92100
for (int i = 0; i < properties.length(); i++) {
93-
Properties item = properties.get(i);
101+
Map item = properties.get(i);
94102
if (item != null) {
95103
item.forEach((k, v) -> merged.putIfAbsent(String.valueOf(k), String.valueOf(v)));
96104
}

sdk-spi-demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>capa-parent</artifactId>
2525
<groupId>group.rxcloud</groupId>
26-
<version>1.0.8.RELEASE</version>
26+
<version>1.0.9.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>capa-sdk-spi-demo</artifactId>

sdk-spi/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>capa-parent</artifactId>
2525
<groupId>group.rxcloud</groupId>
26-
<version>1.0.8.RELEASE</version>
26+
<version>1.0.9.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>capa-sdk-spi</artifactId>

sdk-springboot/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>capa-parent</artifactId>
2525
<groupId>group.rxcloud</groupId>
26-
<version>1.0.8.RELEASE</version>
26+
<version>1.0.9.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>sdk-springboot</artifactId>

sdk/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<groupId>group.rxcloud</groupId>
2525
<artifactId>capa-parent</artifactId>
26-
<version>1.0.8.RELEASE</version>
26+
<version>1.0.9.RELEASE</version>
2727
</parent>
2828

2929
<artifactId>capa-sdk</artifactId>

0 commit comments

Comments
 (0)