Search in sources :

Example 1 with DefaultRegistryClient

use of com.alipay.sofa.registry.client.provider.DefaultRegistryClient 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 DefaultRegistryClient

use of com.alipay.sofa.registry.client.provider.DefaultRegistryClient 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 DefaultRegistryClient

use of com.alipay.sofa.registry.client.provider.DefaultRegistryClient 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 DefaultRegistryClient

use of com.alipay.sofa.registry.client.provider.DefaultRegistryClient in project dubbo by apache.

the class SofaRegistryServiceDiscovery method initialize.

@Override
public void initialize(URL registryURL) throws Exception {
    this.registryURL = registryURL;
    this.registryClientConfig = DefaultRegistryClientConfigBuilder.start().setDataCenter(LOCAL_DATA_CENTER).setZone(LOCAL_REGION).setRegistryEndpoint(registryURL.getHost()).setRegistryEndpointPort(registryURL.getPort()).build();
    registryClient = new DefaultRegistryClient(this.registryClientConfig);
    registryClient.init();
    this.waitAddressTimeout = Integer.parseInt(ConfigUtils.getProperty(ADDRESS_WAIT_TIME_KEY, "5000"));
}
Also used : DefaultRegistryClient(com.alipay.sofa.registry.client.provider.DefaultRegistryClient)

Example 5 with DefaultRegistryClient

use of com.alipay.sofa.registry.client.provider.DefaultRegistryClient in project dubbo by alibaba.

the class SofaRegistryServiceDiscovery method initialize.

@Override
public void initialize(URL registryURL) throws Exception {
    this.registryURL = registryURL;
    this.registryClientConfig = DefaultRegistryClientConfigBuilder.start().setDataCenter(LOCAL_DATA_CENTER).setZone(LOCAL_REGION).setRegistryEndpoint(registryURL.getHost()).setRegistryEndpointPort(registryURL.getPort()).build();
    registryClient = new DefaultRegistryClient(this.registryClientConfig);
    registryClient.init();
    this.waitAddressTimeout = Integer.parseInt(ConfigUtils.getProperty(ADDRESS_WAIT_TIME_KEY, "5000"));
}
Also used : DefaultRegistryClient(com.alipay.sofa.registry.client.provider.DefaultRegistryClient)

Aggregations

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