use of org.apache.dubbo.metadata.MetadataService in project dubbo by alibaba.
the class ServiceInstancesChangedListener method getMetadataInfo.
private MetadataInfo getMetadataInfo(ServiceInstance instance) {
String metadataType = ServiceInstanceMetadataUtils.getMetadataStorageType(instance);
// FIXME, check "REGISTRY_CLUSTER_KEY" must be set by every registry implementation.
instance.getExtendParams().putIfAbsent(REGISTRY_CLUSTER_KEY, RegistryClusterIdentifier.getExtension(url).consumerKey(url));
MetadataInfo metadataInfo = null;
try {
if (logger.isDebugEnabled()) {
logger.debug("Instance " + instance.getAddress() + " is using metadata type " + metadataType);
}
if (REMOTE_METADATA_STORAGE_TYPE.equals(metadataType)) {
RemoteMetadataServiceImpl remoteMetadataService = MetadataUtils.getRemoteMetadataService();
metadataInfo = remoteMetadataService.getMetadata(instance);
} else {
MetadataService metadataServiceProxy = MetadataUtils.getMetadataServiceProxy(instance, serviceDiscovery);
metadataInfo = metadataServiceProxy.getMetadataInfo(ServiceInstanceMetadataUtils.getExportedServicesRevision(instance));
}
if (logger.isDebugEnabled()) {
logger.debug("Metadata " + metadataInfo.toString());
}
} catch (Exception e) {
logger.error("Failed to load service metadata, metadata type is " + metadataType, e);
// TODO, load metadata backup. Stop getting metadata after x times of failure for one revision?
}
return metadataInfo;
}
Aggregations