From b6664c5e2ca36d77812e7c09cbbed4185d3757a9 Mon Sep 17 00:00:00 2001 From: xuliguo Date: Thu, 4 Feb 2021 17:16:10 +0800 Subject: [PATCH] Optimize and update some code --- .../java/com/baidu/hugegraph/rpc/RpcClientProvider.java | 2 +- .../java/com/baidu/hugegraph/rpc/RpcConsumerConfig.java | 6 +++--- .../java/com/baidu/hugegraph/rpc/RpcProviderConfig.java | 4 ++-- .../main/java/com/baidu/hugegraph/rpc/SofaRpcServer.java | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcClientProvider.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcClientProvider.java index ce6516ef7f..d028ce8104 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcClientProvider.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcClientProvider.java @@ -38,7 +38,7 @@ public UserManager userManager() { } public Object serviceProxy(String serviceName) { - ConsumerConfig config = rpcConsumerConfig.consumerConfig(serviceName); + ConsumerConfig config = this.rpcConsumerConfig.consumerConfig(serviceName); return config.refer(); } } diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcConsumerConfig.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcConsumerConfig.java index fc6da41627..b32c38d8f8 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcConsumerConfig.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcConsumerConfig.java @@ -41,13 +41,13 @@ public void addConsumerConfig(Class clazz, HugeConfig conf) { .setRetries(conf.get(ServerOptions.RPC_CLIENT_RETRIES)) .setLoadBalancer(conf.get( ServerOptions.RPC_CLIENT_LOAD_BALANCER)); - configs.put(clazz.getName(), consumerConfig); + this.configs.put(clazz.getName(), consumerConfig); } public ConsumerConfig consumerConfig(String serverName) { - if (!configs.containsKey(serverName)) { + if (!this.configs.containsKey(serverName)) { throw new RpcException("Invalid server name '%s'", serverName); } - return configs.get(serverName); + return this.configs.get(serverName); } } diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcProviderConfig.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcProviderConfig.java index 73ad91adc3..ca8c336e95 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcProviderConfig.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcProviderConfig.java @@ -33,10 +33,10 @@ public void addProviderConfig(Class clazz, ProviderConfig providerConfig = new ProviderConfig() .setInterfaceId(clazz.getName()) .setRef(serviceImpl); - configs.put(clazz.getName(), providerConfig); + this.configs.put(clazz.getName(), providerConfig); } public Map providerConfigs() { - return configs; + return this.configs; } } diff --git a/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/SofaRpcServer.java b/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/SofaRpcServer.java index 7fa5712708..56ec856b63 100644 --- a/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/SofaRpcServer.java +++ b/hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/SofaRpcServer.java @@ -58,7 +58,8 @@ public SofaRpcServer(HugeConfig conf, RpcProviderConfig providerConfig) { public void exportAll() { if (MapUtils.isEmpty(this.providerConfigs)) { - throw new RpcException("Server provider config map is empty"); + throw new RpcException("The server provider config map can't be " + + "empty"); } for (ProviderConfig providerConfig : this.providerConfigs.values()) { providerConfig.setServer(this.serverConfig); @@ -68,7 +69,7 @@ public void exportAll() { public void unExport(String serviceName) { if (!this.providerConfigs.containsKey(serviceName)) { - throw new RpcException("Service name '%s' is not exist, please " + + throw new RpcException("The service name '%s' doesn't exist, please " + "change others", serviceName); } this.providerConfigs.get(serviceName).unExport();