Merge pull request #8227 from Chaos-coder/ClientOperationService_result_getExtendDatum_multiple_calls
ClientOperationService result.getExtendDatum multiple calls
This commit is contained in:
commit
a272a7137e
@ -24,6 +24,8 @@ import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||
import com.alibaba.nacos.naming.pojo.Subscriber;
|
||||
import com.alibaba.nacos.naming.constants.Constants;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Client operation service.
|
||||
*
|
||||
@ -79,17 +81,18 @@ public interface ClientOperationService {
|
||||
*/
|
||||
default InstancePublishInfo getPublishInfo(Instance instance) {
|
||||
InstancePublishInfo result = new InstancePublishInfo(instance.getIp(), instance.getPort());
|
||||
Map<String, Object> extendDatum = result.getExtendDatum();
|
||||
if (null != instance.getMetadata() && !instance.getMetadata().isEmpty()) {
|
||||
result.getExtendDatum().putAll(instance.getMetadata());
|
||||
extendDatum.putAll(instance.getMetadata());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(instance.getInstanceId())) {
|
||||
result.getExtendDatum().put(Constants.CUSTOM_INSTANCE_ID, instance.getInstanceId());
|
||||
extendDatum.put(Constants.CUSTOM_INSTANCE_ID, instance.getInstanceId());
|
||||
}
|
||||
if (Constants.DEFAULT_INSTANCE_WEIGHT != instance.getWeight()) {
|
||||
result.getExtendDatum().put(Constants.PUBLISH_INSTANCE_WEIGHT, instance.getWeight());
|
||||
extendDatum.put(Constants.PUBLISH_INSTANCE_WEIGHT, instance.getWeight());
|
||||
}
|
||||
if (!instance.isEnabled()) {
|
||||
result.getExtendDatum().put(Constants.PUBLISH_INSTANCE_ENABLE, instance.isEnabled());
|
||||
extendDatum.put(Constants.PUBLISH_INSTANCE_ENABLE, instance.isEnabled());
|
||||
}
|
||||
String clusterName = StringUtils.isBlank(instance.getClusterName()) ? UtilsAndCommons.DEFAULT_CLUSTER_NAME
|
||||
: instance.getClusterName();
|
||||
|
Loading…
Reference in New Issue
Block a user