Search in sources :

Example 16 with ConsulClient

use of com.ecwid.consul.v1.ConsulClient in project motan by weibocom.

the class ConsulClientWrapper method init.

@PostConstruct
void init() {
    try {
        String[] arr = registryUrl.split(":");
        String host = arr[0];
        int port = Integer.parseInt(arr[1]);
        consulClient = new ConsulClient(host, port);
    } catch (Exception e) {
        throw new MotanFrameworkException("Fail to connect consul, cause: " + e.getMessage());
    }
}
Also used : MotanFrameworkException(com.weibo.api.motan.exception.MotanFrameworkException) ConsulClient(com.ecwid.consul.v1.ConsulClient) MotanFrameworkException(com.weibo.api.motan.exception.MotanFrameworkException) PostConstruct(javax.annotation.PostConstruct)

Example 17 with ConsulClient

use of com.ecwid.consul.v1.ConsulClient in project dubbo by alibaba.

the class ConsulServiceDiscovery method initialize.

@Override
public void initialize(URL registryURL) throws Exception {
    this.url = registryURL;
    String host = url.getHost();
    int port = INVALID_PORT != url.getPort() ? url.getPort() : DEFAULT_PORT;
    checkPassInterval = url.getParameter(CHECK_PASS_INTERVAL, DEFAULT_CHECK_PASS_INTERVAL);
    client = new ConsulClient(host, port);
    ttlScheduler = new TtlScheduler(checkPassInterval, client);
    this.tag = registryURL.getParameter(QUERY_TAG);
    this.registeringTags.addAll(getRegisteringTags(url));
    this.aclToken = ACL_TOKEN.getValue(registryURL);
    this.tags = getTags(registryURL);
    this.consistencyMode = getConsistencyMode(registryURL);
    this.defaultZoneMetadataName = DEFAULT_ZONE_METADATA_NAME.getValue(registryURL);
    this.instanceZone = INSTANCE_ZONE.getValue(registryURL);
    this.instanceGroup = INSTANCE_GROUP.getValue(registryURL);
}
Also used : ConsulClient(com.ecwid.consul.v1.ConsulClient)

Aggregations

ConsulClient (com.ecwid.consul.v1.ConsulClient)17 Before (org.junit.Before)5 ConsulProperties (org.springframework.cloud.consul.ConsulProperties)5 Test (org.junit.Test)4 ConsulRawClient (com.ecwid.consul.v1.ConsulRawClient)3 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)3 QueryParams (com.ecwid.consul.v1.QueryParams)2 Response (com.ecwid.consul.v1.Response)2 GetValue (com.ecwid.consul.v1.kv.model.GetValue)2 Ambari (com.sequenceiq.periscope.domain.Ambari)2 TlsConfiguration (com.sequenceiq.periscope.model.TlsConfiguration)2 List (java.util.List)2 Matchers.anyString (org.mockito.Matchers.anyString)2 RawResponse (com.ecwid.consul.transport.RawResponse)1 NewService (com.ecwid.consul.v1.agent.model.NewService)1 CatalogService (com.ecwid.consul.v1.catalog.model.CatalogService)1 DefaultClientConfigImpl (com.netflix.client.config.DefaultClientConfigImpl)1 PluginFailureException (com.sequenceiq.cloudbreak.service.cluster.PluginFailureException)1 MotanFrameworkException (com.weibo.api.motan.exception.MotanFrameworkException)1 Field (java.lang.reflect.Field)1