Search in sources :

Example 1 with Registration

use of com.orbitz.consul.model.agent.Registration in project camel by apache.

the class ConsulRibbonServiceCallRouteTest method doPreSetup.

// *************************************************************************
// Setup / tear down
// *************************************************************************
@Override
protected void doPreSetup() throws Exception {
    client = getConsul().agentClient();
    registrations = new ArrayList<>(SERVICE_COUNT);
    expectedBodies = new ArrayList<>(SERVICE_COUNT);
    for (int i = 0; i < SERVICE_COUNT; i++) {
        Registration r = ImmutableRegistration.builder().id("service-" + i).name(SERVICE_NAME).address("127.0.0.1").port(SERVICE_PORT_BASE + i).build();
        client.register(r);
        registrations.add(r);
        expectedBodies.add("ping on " + r.getPort().get());
    }
}
Also used : ImmutableRegistration(com.orbitz.consul.model.agent.ImmutableRegistration) Registration(com.orbitz.consul.model.agent.Registration)

Example 2 with Registration

use of com.orbitz.consul.model.agent.Registration in project microservices by pwillhan.

the class ConsulRegistrator method register.

public void register() {
    try {
        URL healthUrl = new URL("http", host, port, "/health");
        Registration registration = new Registration();
        registration.setAddress(host);
        registration.setPort(port);
        registration.setId(id);
        registration.setName(name);
        Registration.Check check = new Registration.Check();
        check.setHttp(healthUrl.toExternalForm());
        check.setInterval("5s");
        registration.setCheck(check);
        agentClient.register(registration);
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Registration(com.orbitz.consul.model.agent.Registration) URL(java.net.URL)

Example 3 with Registration

use of com.orbitz.consul.model.agent.Registration in project microservices by pwillhan.

the class ConsulRegistrator method register.

public void register() {
    try {
        URL healthUrl = new URL("http", host, port, "/health");
        Registration registration = new Registration();
        registration.setAddress(host);
        registration.setPort(port);
        registration.setId(id);
        registration.setName(name);
        Registration.Check check = new Registration.Check();
        check.setHttp(healthUrl.toExternalForm());
        check.setInterval("5s");
        registration.setCheck(check);
        agentClient.register(registration);
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Registration(com.orbitz.consul.model.agent.Registration) URL(java.net.URL)

Example 4 with Registration

use of com.orbitz.consul.model.agent.Registration in project camel by apache.

the class ConsulDefaultServiceCallRouteTest method doPreSetup.

// *************************************************************************
// Setup / tear down
// *************************************************************************
@Override
protected void doPreSetup() throws Exception {
    client = getConsul().agentClient();
    registrations = new ArrayList<>(SERVICE_COUNT);
    expectedBodies = new ArrayList<>(SERVICE_COUNT);
    for (int i = 0; i < SERVICE_COUNT; i++) {
        Registration r = ImmutableRegistration.builder().id("service-" + i).name(SERVICE_NAME).address("127.0.0.1").port(SERVICE_PORT_BASE + i).build();
        client.register(r);
        registrations.add(r);
        expectedBodies.add("ping on " + r.getPort().get());
    }
}
Also used : ImmutableRegistration(com.orbitz.consul.model.agent.ImmutableRegistration) Registration(com.orbitz.consul.model.agent.Registration)

Example 5 with Registration

use of com.orbitz.consul.model.agent.Registration in project camel by apache.

the class ConsulServiceDiscoveryTest method setUp.

@Before
public void setUp() throws Exception {
    client = Consul.builder().build().agentClient();
    registrations = new ArrayList<>(3);
    for (int i = 0; i < 3; i++) {
        Registration r = ImmutableRegistration.builder().id("service-" + i).name("my-service").address("127.0.0.1").addTags("a-tag").addTags("key1=value1").addTags("key2=value2").port(9000 + i).build();
        client.register(r);
        registrations.add(r);
    }
}
Also used : ImmutableRegistration(com.orbitz.consul.model.agent.ImmutableRegistration) Registration(com.orbitz.consul.model.agent.Registration) Before(org.junit.Before)

Aggregations

Registration (com.orbitz.consul.model.agent.Registration)6 ImmutableRegistration (com.orbitz.consul.model.agent.ImmutableRegistration)4 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 AgentClient (com.orbitz.consul.AgentClient)1 ServiceDefinition (org.apache.camel.cloud.ServiceDefinition)1 ServiceDiscovery (org.apache.camel.cloud.ServiceDiscovery)1 ConsulConfiguration (org.apache.camel.component.consul.ConsulConfiguration)1 ConsulServiceDiscovery (org.apache.camel.component.consul.cloud.ConsulServiceDiscovery)1 Before (org.junit.Before)1 Test (org.junit.Test)1