use of com.alipay.sofa.registry.client.api.registration.PublisherRegistration in project sofa-rpc by sofastack.
the class SofaRegistry method doRegister.
/**
* 注册单条服务信息
*
* @param appName 应用
* @param serviceName 服务关键字
* @param serviceData 服务提供者数据
* @param group 服务分组
*/
protected void doRegister(String appName, String serviceName, String serviceData, String group) {
// 生成注册对象,并添加额外属性
PublisherRegistration publisherRegistration = new PublisherRegistration(serviceName);
publisherRegistration.setGroup(group);
// 去注册
SofaRegistryClient.getRegistryClient(appName, registryConfig).register(publisherRegistration, serviceData);
}
use of com.alipay.sofa.registry.client.api.registration.PublisherRegistration in project dubbo by apache.
the class SofaRegistryServiceDiscovery method doRegister.
@Override
public void doRegister(ServiceInstance serviceInstance) {
SofaRegistryInstance sofaRegistryInstance = new SofaRegistryInstance(serviceInstance.getId(), serviceInstance.getHost(), serviceInstance.getPort(), serviceInstance.getServiceName(), serviceInstance.getMetadata());
Publisher publisher = publishers.get(serviceInstance.getServiceName());
this.serviceInstance = serviceInstance;
if (null == publisher) {
PublisherRegistration registration = new PublisherRegistration(serviceInstance.getServiceName());
registration.setGroup(DEFAULT_GROUP);
publisher = registryClient.register(registration, gson.toJson(sofaRegistryInstance));
publishers.put(serviceInstance.getServiceName(), publisher);
} else {
publisher.republish(gson.toJson(sofaRegistryInstance));
}
}
use of com.alipay.sofa.registry.client.api.registration.PublisherRegistration in project seata by seata.
the class SofaRegistryServiceImpl method register.
@Override
public void register(InetSocketAddress address) throws Exception {
NetUtil.validAddress(address);
String clusterName = registryProps.getProperty(PRO_CLUSTER_KEY);
PublisherRegistration publisherRegistration = new PublisherRegistration(clusterName);
publisherRegistration.setGroup(registryProps.getProperty(PRO_GROUP_KEY));
String serviceData = address.getAddress().getHostAddress() + HOST_SEPERATOR + address.getPort();
getRegistryInstance().register(publisherRegistration, serviceData);
}
use of com.alipay.sofa.registry.client.api.registration.PublisherRegistration in project dubbo by alibaba.
the class SofaRegistry method doRegister.
@Override
public void doRegister(URL url) {
if (!url.getParameter(REGISTER_KEY, true) || CONSUMER_PROTOCOL.equals(url.getProtocol())) {
return;
}
String serviceName = buildServiceName(url);
String serviceData = url.toFullString();
PublisherRegistration registration = new PublisherRegistration(serviceName);
addAttributesForPub(registration);
registryClient.register(registration, serviceData);
}
use of com.alipay.sofa.registry.client.api.registration.PublisherRegistration in project dubbo by alibaba.
the class SofaRegistryServiceDiscovery method doRegister.
@Override
public void doRegister(ServiceInstance serviceInstance) {
SofaRegistryInstance sofaRegistryInstance = new SofaRegistryInstance(serviceInstance.getId(), serviceInstance.getHost(), serviceInstance.getPort(), serviceInstance.getServiceName(), serviceInstance.getMetadata());
Publisher publisher = publishers.get(serviceInstance.getServiceName());
this.serviceInstance = serviceInstance;
if (null == publisher) {
PublisherRegistration registration = new PublisherRegistration(serviceInstance.getServiceName());
registration.setGroup(DEFAULT_GROUP);
publisher = registryClient.register(registration, gson.toJson(sofaRegistryInstance));
publishers.put(serviceInstance.getServiceName(), publisher);
} else {
publisher.republish(gson.toJson(sofaRegistryInstance));
}
}
Aggregations