mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-21 22:26:07 +00:00
perf[registry]: remoteProviderRegisterSet use lsit as return value
This commit is contained in:
@@ -17,7 +17,6 @@ import org.apache.zookeeper.CreateMode;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -40,7 +39,10 @@ public interface IRegistry {
|
||||
|
||||
List<String> children(String path);
|
||||
|
||||
Set<Register> remoteProviderRegisterSet();
|
||||
/**
|
||||
* 获取所有服务提供者的注册信息
|
||||
*/
|
||||
List<Register> remoteProviderRegisters();
|
||||
|
||||
/**
|
||||
* 监听path路径下的更新
|
||||
|
||||
@@ -91,7 +91,7 @@ public class Register {
|
||||
|
||||
return register;
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionUtils.getMessage(e));
|
||||
logger.error("parse register error", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,14 +601,15 @@ public class ZookeeperRegistry implements IRegistry {
|
||||
@Override
|
||||
public List<String> children(String path) {
|
||||
try {
|
||||
var children = curator.getChildren().forPath(path).stream()
|
||||
var children = curator.getChildren().forPath(path)
|
||||
.stream()
|
||||
.filter(it -> StringUtils.isNotBlank(it) && !"null".equals(it))
|
||||
.toList();
|
||||
return children;
|
||||
} catch (Exception e) {
|
||||
logger.error("unknown exception", e);
|
||||
logger.error("query children unknown exception", e);
|
||||
} catch (Throwable t) {
|
||||
logger.error("unknown error", t);
|
||||
logger.error("query children unknown error", t);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -619,20 +620,20 @@ public class ZookeeperRegistry implements IRegistry {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Set<Register> remoteProviderRegisterSet() {
|
||||
public List<Register> remoteProviderRegisters() {
|
||||
try {
|
||||
var remoteProviderSet = curator.getChildren().forPath(PROVIDER_ROOT_PATH).stream()
|
||||
.filter(it -> StringUtils.isNotBlank(it) && !"null".equals(it))
|
||||
.map(it -> Register.parseString(it))
|
||||
.filter(it -> Objects.nonNull(it))
|
||||
.collect(Collectors.toSet());
|
||||
return remoteProviderSet;
|
||||
var remoteProviders = children(PROVIDER_ROOT_PATH)
|
||||
.stream()
|
||||
.map(Register::parseString)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
return remoteProviders;
|
||||
} catch (Exception e) {
|
||||
logger.error("unknown exception", e);
|
||||
logger.error("remoteProviderRegisters unknown exception", e);
|
||||
} catch (Throwable t) {
|
||||
logger.error("unknown error", t);
|
||||
logger.error("remoteProviderRegisters unknown error", t);
|
||||
}
|
||||
return Collections.emptySet();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user