com.ecwid.consul.LocalTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of consul-api Show documentation
Show all versions of consul-api Show documentation
Java client for Consul HTTP API (http://consul.io)
The newest version!
package com.ecwid.consul;
import com.ecwid.consul.v1.ConsulClient;
import com.ecwid.consul.v1.QueryParams;
import com.ecwid.consul.v1.Response;
import com.ecwid.consul.v1.agent.model.*;
import com.ecwid.consul.v1.catalog.CatalogNodesRequest;
import com.ecwid.consul.v1.catalog.model.CatalogRegistration;
import com.ecwid.consul.v1.session.model.NewSession;
import java.util.*;
public class LocalTest {
public static void main(String[] args) {
ConsulClient client = new ConsulClient("localhost", 8500);
NewService newService = new NewService();
newService.setId("vgv-test-" + System.currentTimeMillis());
newService.setName("vgv-test");
newService.setAddress("test.example.com");
newService.setPort(null);
NewService.Check check = new NewService.Check();
check.setTtl("100s");
check.setDeregisterCriticalServiceAfter("1000s");
check.setStatus("passing");
newService.setCheck(check);
client.agentServiceRegister(newService, "d5923adf-6831-61af-ffe6-9b1cac3fe3c4");
client.deleteKVValue("asd", "d5923adf-6831-61af-ffe6-9b1cac3fe3c4");
client.getDatacenters();
}
}