Search in sources :

Example 1 with RegistryClientConfig

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;
}
Also used : DefaultRegistryClient(com.alipay.sofa.registry.client.provider.DefaultRegistryClient) RegistryClientConfig(com.alipay.sofa.registry.client.api.RegistryClientConfig)

Example 2 with RegistryClientConfig

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;
}
Also used : DefaultRegistryClient(com.alipay.sofa.registry.client.provider.DefaultRegistryClient) RegistryClientConfig(com.alipay.sofa.registry.client.api.RegistryClientConfig)

Example 3 with RegistryClientConfig

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;
}
Also used : DefaultRegistryClient(com.alipay.sofa.registry.client.provider.DefaultRegistryClient) RegistryClientConfig(com.alipay.sofa.registry.client.api.RegistryClientConfig)

Example 4 with RegistryClientConfig

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;
}
Also used : DefaultRegistryClient(com.alipay.sofa.registry.client.provider.DefaultRegistryClient) RegistryClientConfig(com.alipay.sofa.registry.client.api.RegistryClientConfig)

Aggregations

RegistryClientConfig (com.alipay.sofa.registry.client.api.RegistryClientConfig)4 DefaultRegistryClient (com.alipay.sofa.registry.client.provider.DefaultRegistryClient)4