Fix error getting client address

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

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

@ -31,6 +31,12 @@ public class CloudCommonIdUtil {
private static final String SEPARATOR = ":"; 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 @SneakyThrows
public static String getDefaultInstanceId(PropertyResolver resolver, InetUtils inetUtils) { public static String getDefaultInstanceId(PropertyResolver resolver, InetUtils inetUtils) {
String namePart = getIpApplicationName(resolver, inetUtils); String namePart = getIpApplicationName(resolver, inetUtils);

Loading…
Cancel
Save