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\"}");
}
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());
});
}
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;
}
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;
}
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\"}");
}
Aggregations