Skip to content

Commit

Permalink
[#1721] fix(coordinator): classCastExpection of boolean->String with …
Browse files Browse the repository at this point in the history
…yaml style remote client conf (#1722)

### What changes were proposed in this pull request?

fix classCastExpection of boolean->String with yaml style remote client conf

### Why are the changes needed?

Fix: #1721 

### Does this PR introduce _any_ user-facing change?


No.

### How was this patch tested?

Unit tests
  • Loading branch information
zuston authored May 21, 2024
1 parent c3cbdec commit d9b1d9f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -58,7 +59,11 @@ public ClientConf tryParse(InputStream fileInputStream) throws Exception {

private Map<String, String> parseKVItems(Object confRaw) throws Exception {
if (confRaw instanceof Map) {
return (Map<String, String>) confRaw;
return ((Map<?, ?>) confRaw)
.entrySet().stream()
.collect(
Collectors.toMap(
x -> String.valueOf(x.getKey()), x -> String.valueOf(x.getValue())));
}

// todo: currently only xml format is supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public void testFromFile() throws Exception {
getClass().getClassLoader().getResource("dynamicClientConf.yaml").openStream());
assertEquals("v1", conf.getRssClientConf().get("k1"));
assertEquals("v2", conf.getRssClientConf().get("k2"));
assertEquals("true", conf.getRssClientConf().get("k3"));
assertEquals("false", conf.getRssClientConf().get("k4"));
assertEquals("1", conf.getRssClientConf().get("k5"));
assertEquals("2", conf.getRssClientConf().get("k6"));

assertEquals(
"v1,v2,v3", conf.getRemoteStorageInfos().get("hdfs://a-ns01").getConfItems().get("k1"));
assertEquals("v1", conf.getRemoteStorageInfos().get("hdfs://x-ns01").getConfItems().get("k1"));
Expand Down
4 changes: 4 additions & 0 deletions coordinator/src/test/resources/dynamicClientConf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
rssClientConf:
k1: v1
k2: v2
k3: true
k4: false
k5: 1
k6: 2

remoteStorageInfos:
hdfs://a-ns01: |+
Expand Down

0 comments on commit d9b1d9f

Please sign in to comment.