Search in sources :

Example 1 with GetValue

use of com.ecwid.consul.v1.kv.model.GetValue in project spring-cloud-consul by spring-cloud.

the class ConfigWatchTests method watchPublishesEvent.

@Test
public void watchPublishesEvent() {
    ApplicationEventPublisher eventPublisher = mock(ApplicationEventPublisher.class);
    setupWatch(eventPublisher, new GetValue(), "/app/");
    verify(eventPublisher, times(1)).publishEvent(any(RefreshEvent.class));
}
Also used : RefreshEvent(org.springframework.cloud.endpoint.event.RefreshEvent) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) GetValue(com.ecwid.consul.v1.kv.model.GetValue) Test(org.junit.Test)

Example 2 with GetValue

use of com.ecwid.consul.v1.kv.model.GetValue in project spring-cloud-consul by spring-cloud.

the class ConfigWatchTests method watchPublishesEventWithAcl.

@Test
public void watchPublishesEventWithAcl() {
    ApplicationEventPublisher eventPublisher = mock(ApplicationEventPublisher.class);
    setupWatch(eventPublisher, new GetValue(), "/app/", "2ee647bd-bd69-4118-9f34-b9a6e9e60746");
    verify(eventPublisher, times(1)).publishEvent(any(RefreshEvent.class));
}
Also used : RefreshEvent(org.springframework.cloud.endpoint.event.RefreshEvent) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) GetValue(com.ecwid.consul.v1.kv.model.GetValue) Test(org.junit.Test)

Example 3 with GetValue

use of com.ecwid.consul.v1.kv.model.GetValue in project spring-cloud-consul by spring-cloud.

the class ConfigWatchTests method watchForFileFormatPublishesEvent.

@Test
public void watchForFileFormatPublishesEvent() {
    ApplicationEventPublisher eventPublisher = mock(ApplicationEventPublisher.class);
    configProperties.setFormat(FILES);
    setupWatch(eventPublisher, new GetValue(), "/config/app.yml");
    verify(eventPublisher, times(1)).publishEvent(any(RefreshEvent.class));
}
Also used : RefreshEvent(org.springframework.cloud.endpoint.event.RefreshEvent) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) GetValue(com.ecwid.consul.v1.kv.model.GetValue) Test(org.junit.Test)

Example 4 with GetValue

use of com.ecwid.consul.v1.kv.model.GetValue in project motan by weibocom.

the class ConsulRegistryService method getNodes.

@Override
public List<JSONObject> getNodes(String dcGroup, String service, String nodeType) {
    List<JSONObject> results = new ArrayList<JSONObject>();
    List<Check> checks = consulClient.getHealthChecksForService(getGroupName(dcGroup), new QueryParams(getDcName(dcGroup))).getValue();
    for (Check check : checks) {
        String serviceId = check.getServiceId();
        String[] strings = serviceId.split("-");
        if (strings[1].equals(service)) {
            Check.CheckStatus status = check.getStatus();
            JSONObject node = new JSONObject();
            if (nodeType.equals(status.toString())) {
                node.put("host", strings[0]);
                node.put("info", null);
                results.add(node);
            }
        }
    }
    return results;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Check(com.ecwid.consul.v1.health.model.Check) QueryParams(com.ecwid.consul.v1.QueryParams)

Example 5 with GetValue

use of com.ecwid.consul.v1.kv.model.GetValue in project motan by weibocom.

the class ConsulEcwidClient method lookupCommand.

@Override
public String lookupCommand(String group) {
    Response<GetValue> response = client.getKVValue(ConsulConstants.CONSUL_MOTAN_COMMAND + ConsulUtils.convertGroupToServiceName(group));
    GetValue value = response.getValue();
    String command = "";
    if (value == null) {
        LoggerUtil.info("no command in group: " + group);
    } else if (value.getValue() != null) {
        command = value.getDecodedValue();
    }
    return command;
}
Also used : GetValue(com.ecwid.consul.v1.kv.model.GetValue)

Aggregations

GetValue (com.ecwid.consul.v1.kv.model.GetValue)10 QueryParams (com.ecwid.consul.v1.QueryParams)5 RefreshEvent (org.springframework.cloud.endpoint.event.RefreshEvent)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Test (org.junit.Test)4 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)4 JSONObject (com.alibaba.fastjson.JSONObject)2 ConsulClient (com.ecwid.consul.v1.ConsulClient)2 Response (com.ecwid.consul.v1.Response)2 Check (com.ecwid.consul.v1.health.model.Check)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Member (com.ecwid.consul.v1.agent.model.Member)1 Server (com.netflix.loadbalancer.Server)1 Timed (io.micrometer.core.annotation.Timed)1 LinkedHashMap (java.util.LinkedHashMap)1 CompositePropertySource (org.springframework.core.env.CompositePropertySource)1 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)1 Retryable (org.springframework.retry.annotation.Retryable)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1