in dubbo-remoting-extensions/dubbo-remoting-etcd3/src/main/java/org/apache/dubbo/remoting/etcd/jetcd/JEtcdClientWrapper.java [182:211]
public List<String> getChildren(String path) {
try {
return RetryLoops.invokeWithRetry(
() -> {
requiredNotNull(client, failed);
int len = path.length();
return client.getKVClient()
.get(ByteSequence.from(path, UTF_8),
GetOption.newBuilder().withPrefix(ByteSequence.from(path, UTF_8)).build())
.get(DEFAULT_REQUEST_TIMEOUT, TimeUnit.MILLISECONDS)
.getKvs().stream().parallel()
.filter(pair -> {
String key = pair.getKey().toString(UTF_8);
int index = len, count = 0;
if (key.length() > len) {
for (; (index = key.indexOf(PATH_SEPARATOR, index)) != -1; ++index) {
if (count++ > 1) {
break;
}
}
}
return count == 1;
})
.map(pair -> pair.getKey().toString(UTF_8))
.collect(toList());
}, retryPolicy);
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}