Skip to content

Commit

Permalink
Optimize and update some code
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliguov5 committed Feb 8, 2021
1 parent d3bf39c commit b6664c5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public <T> void addConsumerConfig(Class<T> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public <T, E extends T> void addProviderConfig(Class<T> clazz,
ProviderConfig<T> providerConfig = new ProviderConfig<T>()
.setInterfaceId(clazz.getName())
.setRef(serviceImpl);
configs.put(clazz.getName(), providerConfig);
this.configs.put(clazz.getName(), providerConfig);
}

public Map<String, ProviderConfig> providerConfigs() {
return configs;
return this.configs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit b6664c5

Please sign in to comment.