use of com.alipay.sofa.registry.client.api.RegistryClientConfig in project sofa-rpc by sofastack.
the class SofaRegistryClient method getRegistryClient.
public static synchronized RegistryClient getRegistryClient(String appName, RegistryConfig registryConfig) {
if (registryClient == null) {
String address = registryConfig.getAddress();
final String portStr = StringUtils.substringAfter(address, ":");
RegistryClientConfig config = DefaultRegistryClientConfigBuilder.start().setAppName(appName).setDataCenter(LOCAL_DATACENTER).setZone(LOCAL_REGION).setRegistryEndpoint(StringUtils.substringBefore(address, ":")).setRegistryEndpointPort(Integer.parseInt(portStr)).build();
registryClient = new DefaultRegistryClient(config);
((DefaultRegistryClient) registryClient).init();
}
return registryClient;
}
use of com.alipay.sofa.registry.client.api.RegistryClientConfig in project dubbo by alibaba.
the class SofaRegistry method buildClient.
/**
* Build client registry client.
*
* @param url the url
* @return the registry client
*/
protected RegistryClient buildClient(URL url) {
RegistryClientConfig config = DefaultRegistryClientConfigBuilder.start().setDataCenter(LOCAL_DATA_CENTER).setZone(LOCAL_REGION).setRegistryEndpoint(url.getHost()).setRegistryEndpointPort(url.getPort()).build();
DefaultRegistryClient registryClient = new DefaultRegistryClient(config);
registryClient.init();
return registryClient;
}
use of com.alipay.sofa.registry.client.api.RegistryClientConfig in project seata by seata.
the class SofaRegistryServiceImpl method getRegistryInstance.
private RegistryClient getRegistryInstance() {
if (registryClient == null) {
synchronized (SofaRegistryServiceImpl.class) {
if (registryClient == null) {
String address = registryProps.getProperty(PRO_SERVER_ADDR_KEY);
final String portStr = StringUtils.substringAfter(address, HOST_SEPERATOR);
RegistryClientConfig config = DefaultRegistryClientConfigBuilder.start().setAppName(getApplicationName()).setDataCenter(registryProps.getProperty(PRO_DATACENTER_KEY)).setZone(registryProps.getProperty(PRO_REGION_KEY)).setRegistryEndpoint(StringUtils.substringBefore(address, HOST_SEPERATOR)).setRegistryEndpointPort(Integer.parseInt(portStr)).build();
DefaultRegistryClient result = new DefaultRegistryClient(config);
result.init();
registryClient = result;
}
}
}
return registryClient;
}
use of com.alipay.sofa.registry.client.api.RegistryClientConfig in project dubbo by apache.
the class SofaRegistry method buildClient.
/**
* Build client registry client.
*
* @param url the url
* @return the registry client
*/
protected RegistryClient buildClient(URL url) {
RegistryClientConfig config = DefaultRegistryClientConfigBuilder.start().setDataCenter(LOCAL_DATA_CENTER).setZone(LOCAL_REGION).setRegistryEndpoint(url.getHost()).setRegistryEndpointPort(url.getPort()).build();
DefaultRegistryClient registryClient = new DefaultRegistryClient(config);
registryClient.init();
return registryClient;
}
Aggregations