From 951955ad51c602a51b4ac6ada7344eef9ee1c195 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Wed, 10 Jun 2020 14:59:01 +0800 Subject: [PATCH] Polish apache/dubbo#6296 : Adding the new methods into MetadataReport to manipulate the exported URLs for service introspection (#6299) --- .../dubbo/metadata/report/MetadataReport.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/MetadataReport.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/MetadataReport.java index 90ca45acb76..35fa40111da 100644 --- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/MetadataReport.java +++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/MetadataReport.java @@ -18,15 +18,20 @@ import org.apache.dubbo.common.URL; +import org.apache.dubbo.metadata.URLRevisionResolver; import org.apache.dubbo.metadata.definition.model.ServiceDefinition; import org.apache.dubbo.metadata.report.identifier.MetadataIdentifier; import org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier; import org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier; +import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; +import static org.apache.dubbo.rpc.model.ApplicationModel.getName; + /** * */ @@ -47,4 +52,52 @@ public interface MetadataReport { List getSubscribedURLs(SubscriberMetadataIdentifier subscriberMetadataIdentifier); String getServiceDefinition(MetadataIdentifier metadataIdentifier); + + /** + * Save the exported {@link URL urls} in bulk. + * + * @param exportedURLs the exported {@link URL urls} + * @return If successful, return true, or false + * @since 2.7.8 + */ + default boolean saveExportedURLs(Collection exportedURLs) { + return saveExportedURLs(getName(), exportedURLs); + } + + /** + * Save the exported {@link URL urls} in bulk. + * + * @param serviceName the specified Dubbo service name + * @param exportedURLs the exported {@link URL urls} + * @return If successful, return true, or false + * @since 2.7.8 + */ + default boolean saveExportedURLs(String serviceName, Collection exportedURLs) { + return saveExportedURLs(serviceName, new URLRevisionResolver().resolve(exportedURLs), exportedURLs); + } + + /** + * Save the exported {@link URL urls} in bulk. + * + * @param serviceName the specified Dubbo service name + * @param exportedServicesRevision the revision of the exported Services + * @param exportedURLs the exported {@link URL urls} + * @return If successful, return true, or false + * @since 2.7.8 + */ + default boolean saveExportedURLs(String serviceName, String exportedServicesRevision, Collection exportedURLs) { + return true; + } + + /** + * Get the {@link URL#toFullString() strings} presenting the {@link URL URLs} that were exported by the provider + * + * @param serviceName the specified Dubbo service name + * @param exportedServicesRevision the revision of the exported Services + * @return non-null + * @since 2.7.8 + */ + default List getExportedURLs(String serviceName, String exportedServicesRevision) { + return Collections.emptyList(); + } }