Search in sources :

Example 6 with FullServiceDefinition

use of org.apache.dubbo.metadata.definition.model.FullServiceDefinition in project dubbo by alibaba.

the class RemoteMetadataServiceImpl method publishProvider.

private void publishProvider(URL providerUrl) throws RpcException {
    // first add into the list
    // remove the individual param
    providerUrl = providerUrl.removeParameters(PID_KEY, TIMESTAMP_KEY, Constants.BIND_IP_KEY, Constants.BIND_PORT_KEY, TIMESTAMP_KEY);
    try {
        String interfaceName = providerUrl.getParameter(INTERFACE_KEY);
        if (StringUtils.isNotEmpty(interfaceName)) {
            Class interfaceClass = Class.forName(interfaceName);
            FullServiceDefinition fullServiceDefinition = ServiceDefinitionBuilder.buildFullDefinition(interfaceClass, providerUrl.getParameters());
            for (Map.Entry<String, MetadataReport> entry : getMetadataReports().entrySet()) {
                MetadataReport metadataReport = entry.getValue();
                metadataReport.storeProviderMetadata(new MetadataIdentifier(providerUrl.getServiceInterface(), providerUrl.getParameter(VERSION_KEY), providerUrl.getParameter(GROUP_KEY), PROVIDER_SIDE, providerUrl.getParameter(APPLICATION_KEY)), fullServiceDefinition);
            }
            return;
        }
        logger.error("publishProvider interfaceName is empty . providerUrl: " + providerUrl.toFullString());
    } catch (ClassNotFoundException e) {
        // ignore error
        logger.error("publishProvider getServiceDescriptor error. providerUrl: " + providerUrl.toFullString(), e);
    }
}
Also used : MetadataReport(org.apache.dubbo.metadata.report.MetadataReport) MetadataIdentifier(org.apache.dubbo.metadata.report.identifier.MetadataIdentifier) SubscriberMetadataIdentifier(org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier) FullServiceDefinition(org.apache.dubbo.metadata.definition.model.FullServiceDefinition) Map(java.util.Map)

Example 7 with FullServiceDefinition

use of org.apache.dubbo.metadata.definition.model.FullServiceDefinition in project dubbo by alibaba.

the class ServiceDefinitionBuilder method buildFullDefinition.

public static FullServiceDefinition buildFullDefinition(final Class<?> interfaceClass, Map<String, String> params) {
    FullServiceDefinition sd = new FullServiceDefinition();
    build(sd, interfaceClass);
    sd.setParameters(params);
    return sd;
}
Also used : FullServiceDefinition(org.apache.dubbo.metadata.definition.model.FullServiceDefinition)

Example 8 with FullServiceDefinition

use of org.apache.dubbo.metadata.definition.model.FullServiceDefinition in project dubbo by alibaba.

the class ServiceDefinitionBuilder method buildFullDefinition.

public static FullServiceDefinition buildFullDefinition(final Class<?> interfaceClass) {
    FullServiceDefinition sd = new FullServiceDefinition();
    build(sd, interfaceClass);
    return sd;
}
Also used : FullServiceDefinition(org.apache.dubbo.metadata.definition.model.FullServiceDefinition)

Example 9 with FullServiceDefinition

use of org.apache.dubbo.metadata.definition.model.FullServiceDefinition in project dubbo by alibaba.

the class EtcdMetadataReportTest method storeProvider.

private MetadataIdentifier storeProvider(EtcdMetadataReport etcdMetadataReport, String interfaceName, String version, String group, String application) throws ClassNotFoundException, InterruptedException {
    URL url = URL.valueOf("xxx://" + NetUtils.getLocalAddress().getHostName() + ":4444/" + interfaceName + "?paramTest=etcdTest&version=" + version + "&application=" + application + (group == null ? "" : "&group=" + group));
    MetadataIdentifier providerMetadataIdentifier = new MetadataIdentifier(interfaceName, version, group, PROVIDER_SIDE, application);
    Class interfaceClass = Class.forName(interfaceName);
    FullServiceDefinition fullServiceDefinition = ServiceDefinitionBuilder.buildFullDefinition(interfaceClass, url.getParameters());
    etcdMetadataReport.storeProviderMetadata(providerMetadataIdentifier, fullServiceDefinition);
    Thread.sleep(1000);
    return providerMetadataIdentifier;
}
Also used : MetadataIdentifier(org.apache.dubbo.metadata.report.identifier.MetadataIdentifier) ServiceMetadataIdentifier(org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier) SubscriberMetadataIdentifier(org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier) FullServiceDefinition(org.apache.dubbo.metadata.definition.model.FullServiceDefinition) URL(org.apache.dubbo.common.URL)

Example 10 with FullServiceDefinition

use of org.apache.dubbo.metadata.definition.model.FullServiceDefinition in project dubbo by alibaba.

the class RedisMetadataReportTest method storePrivider.

private MetadataIdentifier storePrivider(RedisMetadataReport redisMetadataReport, String interfaceName, String version, String group, String application) throws ClassNotFoundException {
    URL url = URL.valueOf("xxx://" + NetUtils.getLocalAddress().getHostName() + ":4444/" + interfaceName + "?paramTest=redisTest&version=" + version + "&application=" + application + (group == null ? "" : "&group=" + group));
    MetadataIdentifier providerMetadataIdentifier = new MetadataIdentifier(interfaceName, version, group, PROVIDER_SIDE, application);
    Class interfaceClass = Class.forName(interfaceName);
    FullServiceDefinition fullServiceDefinition = ServiceDefinitionBuilder.buildFullDefinition(interfaceClass, url.getParameters());
    redisMetadataReport.storeProviderMetadata(providerMetadataIdentifier, fullServiceDefinition);
    try {
        Thread.sleep(300);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    return providerMetadataIdentifier;
}
Also used : MetadataIdentifier(org.apache.dubbo.metadata.report.identifier.MetadataIdentifier) FullServiceDefinition(org.apache.dubbo.metadata.definition.model.FullServiceDefinition) URL(org.apache.dubbo.common.URL)

Aggregations

FullServiceDefinition (org.apache.dubbo.metadata.definition.model.FullServiceDefinition)16 MetadataIdentifier (org.apache.dubbo.metadata.report.identifier.MetadataIdentifier)11 Gson (com.google.gson.Gson)5 SubscriberMetadataIdentifier (org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier)5 Test (org.junit.jupiter.api.Test)5 URL (org.apache.dubbo.common.URL)4 MethodDefinition (org.apache.dubbo.metadata.definition.model.MethodDefinition)4 ServiceMetadataIdentifier (org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Consumer (org.apache.dubbo.admin.model.domain.Consumer)2 Provider (org.apache.dubbo.admin.model.domain.Provider)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 JsonParseException (com.google.gson.JsonParseException)1 GetResponse (io.etcd.jetcd.kv.GetResponse)1 VersionValidationException (org.apache.dubbo.admin.common.exception.VersionValidationException)1 MethodMetadata (org.apache.dubbo.admin.model.domain.MethodMetadata)1 ServiceDetailDTO (org.apache.dubbo.admin.model.dto.ServiceDetailDTO)1 TypeDefinition (org.apache.dubbo.metadata.definition.model.TypeDefinition)1 MetadataReport (org.apache.dubbo.metadata.report.MetadataReport)1