Fix error getting client address

pull/233/head
chen.ma 2 years ago
parent f40ef77c79
commit 662b34a438

@ -74,7 +74,7 @@ public class ThreadPoolAdapterRegister implements ApplicationRunner {
String tenantItemKey = properties.getNamespace() + IDENTIFY_SLICER_SYMBOL + properties.getItemId();
cacheConfig.setTenantItemKey(tenantItemKey);
cacheConfig.setClientIdentify(IdentifyUtil.getIdentify());
String clientAddress = CloudCommonIdUtil.getDefaultInstanceId(environment, hippo4JInetUtils);
String clientAddress = CloudCommonIdUtil.getClientIpPort(environment, hippo4JInetUtils);
cacheConfig.setClientAddress(clientAddress);
cacheConfig.setThreadPoolAdapterStates(threadPoolStates);
cacheConfigList.add(cacheConfig);

@ -31,6 +31,12 @@ public class CloudCommonIdUtil {
private static final String SEPARATOR = ":";
public static String getClientIpPort(PropertyResolver resolver, InetUtils inetUtils) {
String hostname = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
String port = resolver.getProperty("server.port", "8080");
return combineParts(hostname, SEPARATOR, port);
}
@SneakyThrows
public static String getDefaultInstanceId(PropertyResolver resolver, InetUtils inetUtils) {
String namePart = getIpApplicationName(resolver, inetUtils);

Loading…
Cancel
Save