use of com.alibaba.nacos.naming.core.v2.metadata.InstanceMetadata in project nacos by alibaba.
the class ServiceStorage method parseInstance.
private Instance parseInstance(Service service, InstancePublishInfo instanceInfo) {
Instance result = InstanceUtil.parseToApiInstance(service, instanceInfo);
Optional<InstanceMetadata> metadata = metadataManager.getInstanceMetadata(service, instanceInfo.getMetadataId());
metadata.ifPresent(instanceMetadata -> InstanceUtil.updateInstanceMetadata(result, instanceMetadata));
return result;
}
use of com.alibaba.nacos.naming.core.v2.metadata.InstanceMetadata in project nacos by alibaba.
the class InstanceMetadataProcessor method updateInstanceMetadata.
private void updateInstanceMetadata(MetadataOperation<InstanceMetadata> op) {
Service service = Service.newService(op.getNamespace(), op.getGroup(), op.getServiceName());
namingMetadataManager.updateInstanceMetadata(service, op.getTag(), op.getMetadata());
NotifyCenter.publishEvent(new ServiceEvent.ServiceChangedEvent(service, true));
}
use of com.alibaba.nacos.naming.core.v2.metadata.InstanceMetadata in project nacos by alibaba.
the class InstanceMetadataProcessor method deleteInstanceMetadata.
private void deleteInstanceMetadata(MetadataOperation<InstanceMetadata> op) {
Service service = Service.newService(op.getNamespace(), op.getGroup(), op.getServiceName());
namingMetadataManager.removeInstanceMetadata(service, op.getTag());
}
use of com.alibaba.nacos.naming.core.v2.metadata.InstanceMetadata in project nacos by alibaba.
the class InstanceEnableBeatCheckInterceptor method intercept.
@Override
public boolean intercept(InstanceBeatCheckTask object) {
NamingMetadataManager metadataManager = ApplicationUtils.getBean(NamingMetadataManager.class);
HealthCheckInstancePublishInfo instance = object.getInstancePublishInfo();
Optional<InstanceMetadata> metadata = metadataManager.getInstanceMetadata(object.getService(), instance.getMetadataId());
if (metadata.isPresent() && metadata.get().getExtendData().containsKey(UtilsAndCommons.ENABLE_CLIENT_BEAT)) {
return ConvertUtils.toBoolean(metadata.get().getExtendData().get(UtilsAndCommons.ENABLE_CLIENT_BEAT).toString());
}
if (instance.getExtendDatum().containsKey(UtilsAndCommons.ENABLE_CLIENT_BEAT)) {
return ConvertUtils.toBoolean(instance.getExtendDatum().get(UtilsAndCommons.ENABLE_CLIENT_BEAT).toString());
}
return false;
}
use of com.alibaba.nacos.naming.core.v2.metadata.InstanceMetadata in project nacos by alibaba.
the class InstanceOperatorClientImpl method patchInstance.
@Override
public void patchInstance(String namespaceId, String serviceName, InstancePatchObject patchObject) throws NacosException {
Service service = getService(namespaceId, serviceName, true);
Instance instance = getInstance(namespaceId, serviceName, patchObject.getCluster(), patchObject.getIp(), patchObject.getPort());
String metadataId = InstancePublishInfo.genMetadataId(instance.getIp(), instance.getPort(), instance.getClusterName());
Optional<InstanceMetadata> instanceMetadata = metadataManager.getInstanceMetadata(service, metadataId);
InstanceMetadata newMetadata = instanceMetadata.map(this::cloneMetadata).orElseGet(InstanceMetadata::new);
mergeMetadata(newMetadata, patchObject);
metadataOperateService.updateInstanceMetadata(service, metadataId, newMetadata);
}
Aggregations