Search in sources :

Example 11 with MetadataIdentifier

use of org.apache.dubbo.metadata.report.identifier.MetadataIdentifier in project dubbo by alibaba.

the class EtcdMetadataReportTest method testStoreConsumer.

@Test
public void testStoreConsumer() throws Exception {
    String version = "1.0.0";
    String group = null;
    String application = "etc-metadata-report-consumer-test";
    MetadataIdentifier consumerIdentifier = storeConsumer(etcdMetadataReport, TEST_SERVICE, version, group, application);
    CompletableFuture<GetResponse> response = etcdClientForTest.getKVClient().get(ByteSequence.from(etcdMetadataReport.getNodeKey(consumerIdentifier), StandardCharsets.UTF_8));
    String fileContent = response.get().getKvs().get(0).getValue().toString(StandardCharsets.UTF_8);
    Assertions.assertNotNull(fileContent);
    Assertions.assertEquals(fileContent, "{\"paramConsumerTest\":\"etcdConsumer\"}");
}
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) GetResponse(io.etcd.jetcd.kv.GetResponse) Test(org.junit.jupiter.api.Test)

Example 12 with MetadataIdentifier

use of org.apache.dubbo.metadata.report.identifier.MetadataIdentifier in project dubbo by alibaba.

the class RemoteMetadataServiceImpl method publishConsumer.

private void publishConsumer(URL consumerURL) throws RpcException {
    final URL url = consumerURL.removeParameters(PID_KEY, TIMESTAMP_KEY, Constants.BIND_IP_KEY, Constants.BIND_PORT_KEY, TIMESTAMP_KEY);
    getMetadataReports().forEach((registryKey, config) -> {
        config.storeConsumerMetadata(new MetadataIdentifier(url.getServiceInterface(), url.getParameter(VERSION_KEY), url.getParameter(GROUP_KEY), CONSUMER_SIDE, url.getParameter(APPLICATION_KEY)), url.getParameters());
    });
}
Also used : MetadataIdentifier(org.apache.dubbo.metadata.report.identifier.MetadataIdentifier) SubscriberMetadataIdentifier(org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier) URL(org.apache.dubbo.common.URL)

Example 13 with MetadataIdentifier

use of org.apache.dubbo.metadata.report.identifier.MetadataIdentifier 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)

Example 14 with MetadataIdentifier

use of org.apache.dubbo.metadata.report.identifier.MetadataIdentifier in project dubbo by alibaba.

the class RedisMetadataReportTest method storeConsumer.

private MetadataIdentifier storeConsumer(RedisMetadataReport redisMetadataReport, String interfaceName, String version, String group, String application) throws ClassNotFoundException {
    URL url = URL.valueOf("xxx://" + NetUtils.getLocalAddress().getHostName() + ":4444/" + interfaceName + "?version=" + version + "&application=" + application + (group == null ? "" : "&group=" + group));
    MetadataIdentifier consumerMetadataIdentifier = new MetadataIdentifier(interfaceName, version, group, CONSUMER_SIDE, application);
    Class interfaceClass = Class.forName(interfaceName);
    Map<String, String> tmp = new HashMap<>();
    tmp.put("paramConsumerTest", "redisCm");
    redisMetadataReport.storeConsumerMetadata(consumerMetadataIdentifier, tmp);
    try {
        Thread.sleep(300);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    return consumerMetadataIdentifier;
}
Also used : MetadataIdentifier(org.apache.dubbo.metadata.report.identifier.MetadataIdentifier) HashMap(java.util.HashMap) URL(org.apache.dubbo.common.URL)

Example 15 with MetadataIdentifier

use of org.apache.dubbo.metadata.report.identifier.MetadataIdentifier in project dubbo by alibaba.

the class ZookeeperMetadataReportTest method testConsumer.

@Test
public void testConsumer() throws ClassNotFoundException, InterruptedException {
    String interfaceName = "org.apache.dubbo.metadata.store.zookeeper.ZookeeperMetadataReport4TstService";
    String version = "1.0.0.zk.md";
    String group = null;
    String application = "vic.zk.md";
    MetadataIdentifier consumerMetadataIdentifier = storeConsumer(zookeeperMetadataReport, interfaceName, version, group, application);
    String fileContent = zookeeperMetadataReport.zkClient.getContent(zookeeperMetadataReport.getNodePath(consumerMetadataIdentifier));
    fileContent = waitSeconds(fileContent, 3500, zookeeperMetadataReport.getNodePath(consumerMetadataIdentifier));
    Assertions.assertNotNull(fileContent);
    deletePath(consumerMetadataIdentifier, zookeeperMetadataReport);
    fileContent = zookeeperMetadataReport.zkClient.getContent(zookeeperMetadataReport.getNodePath(consumerMetadataIdentifier));
    fileContent = waitSeconds(fileContent, 1000, zookeeperMetadataReport.getNodePath(consumerMetadataIdentifier));
    Assertions.assertNull(fileContent);
    consumerMetadataIdentifier = storeConsumer(zookeeperMetadataReport, interfaceName, version, group, application);
    fileContent = zookeeperMetadataReport.zkClient.getContent(zookeeperMetadataReport.getNodePath(consumerMetadataIdentifier));
    fileContent = waitSeconds(fileContent, 3000, zookeeperMetadataReport.getNodePath(consumerMetadataIdentifier));
    Assertions.assertNotNull(fileContent);
    Assertions.assertEquals(fileContent, "{\"paramConsumerTest\":\"zkCm\"}");
}
Also used : ServiceMetadataIdentifier(org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier) SubscriberMetadataIdentifier(org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier) MetadataIdentifier(org.apache.dubbo.metadata.report.identifier.MetadataIdentifier) Test(org.junit.jupiter.api.Test)

Aggregations

MetadataIdentifier (org.apache.dubbo.metadata.report.identifier.MetadataIdentifier)22 SubscriberMetadataIdentifier (org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier)12 FullServiceDefinition (org.apache.dubbo.metadata.definition.model.FullServiceDefinition)11 ServiceMetadataIdentifier (org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier)10 URL (org.apache.dubbo.common.URL)8 HashMap (java.util.HashMap)7 Test (org.junit.jupiter.api.Test)6 Gson (com.google.gson.Gson)5 GetResponse (io.etcd.jetcd.kv.GetResponse)2 Consumer (org.apache.dubbo.admin.model.domain.Consumer)2 Provider (org.apache.dubbo.admin.model.domain.Provider)2 MetadataInfo (org.apache.dubbo.metadata.MetadataInfo)2 MethodDefinition (org.apache.dubbo.metadata.definition.model.MethodDefinition)2 ServiceDefinition (org.apache.dubbo.metadata.definition.model.ServiceDefinition)2 MetadataReport (org.apache.dubbo.metadata.report.MetadataReport)2 RpcException (org.apache.dubbo.rpc.RpcException)2 Test (org.junit.Test)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Jedis (redis.clients.jedis.Jedis)2 JsonParseException (com.google.gson.JsonParseException)1