Skip to content

Commit

Permalink
optimize: consul supports custom port (apache#2652)
Browse files Browse the repository at this point in the history
  • Loading branch information
helloworlde authored May 5, 2020
1 parent 748e97a commit 9c9212d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.seata.config.consul;

import java.net.InetSocketAddress;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
Expand All @@ -30,6 +31,7 @@
import com.ecwid.consul.v1.kv.model.PutParams;
import io.netty.util.internal.ConcurrentSet;
import io.seata.common.thread.NamedThreadFactory;
import io.seata.common.util.NetUtil;
import io.seata.config.AbstractConfiguration;
import io.seata.config.ConfigFuture;
import io.seata.config.Configuration;
Expand Down Expand Up @@ -174,7 +176,9 @@ private static ConsulClient getConsulClient() {
if (null == client) {
synchronized (ConsulConfiguration.class) {
if (null == client) {
client = new ConsulClient(FILE_CONFIG.getConfig(FILE_CONFIG_KEY_PREFIX + SERVER_ADDR_KEY));
String serverAddr = FILE_CONFIG.getConfig(FILE_CONFIG_KEY_PREFIX + SERVER_ADDR_KEY);
InetSocketAddress inetSocketAddress = NetUtil.toInetSocketAddress(serverAddr);
client = new ConsulClient(inetSocketAddress.getHostName(), inetSocketAddress.getPort());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ private ConsulClient getConsulClient() {
if (null == client) {
synchronized (ConsulRegistryServiceImpl.class) {
if (null == client) {
client = new ConsulClient(FILE_CONFIG.getConfig(FILE_CONFIG_KEY_PREFIX + SERVER_ADDR_KEY));
String serverAddr = FILE_CONFIG.getConfig(FILE_CONFIG_KEY_PREFIX + SERVER_ADDR_KEY);
InetSocketAddress inetSocketAddress = NetUtil.toInetSocketAddress(serverAddr);
client = new ConsulClient(inetSocketAddress.getHostName(), inetSocketAddress.getPort());
}
}
}
Expand Down

0 comments on commit 9c9212d

Please sign in to comment.