Search in sources :

Example 1 with MetadataService

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;
}
Also used : MetadataInfo(org.apache.dubbo.metadata.MetadataInfo) RemoteMetadataServiceImpl(org.apache.dubbo.registry.client.metadata.store.RemoteMetadataServiceImpl) MetadataService(org.apache.dubbo.metadata.MetadataService)

Aggregations

MetadataInfo (org.apache.dubbo.metadata.MetadataInfo)1 MetadataService (org.apache.dubbo.metadata.MetadataService)1 RemoteMetadataServiceImpl (org.apache.dubbo.registry.client.metadata.store.RemoteMetadataServiceImpl)1