Search in sources :

Example 1 with Response

use of io.etcd.jetcd.Response in project jetcd by coreos.

the class LoadBalancerTest method testPickFirstBalancerFactory.

@Test
public void testPickFirstBalancerFactory() throws Exception {
    final List<URI> endpoints = cluster.clientEndpoints();
    final ClientBuilder builder = Client.builder().endpoints(endpoints).loadBalancerPolicy("pick_first");
    try (Client client = builder.build();
        KV kv = client.getKVClient()) {
        long lastMemberId = 0;
        final String allEndpoints = endpoints.stream().map(URI::toString).collect(Collectors.joining(","));
        for (int i = 0; i < allEndpoints.length() * 2; i++) {
            Response response = kv.put(TestUtil.randomByteSequence(), TestUtil.randomByteSequence()).get();
            if (i == 0) {
                lastMemberId = response.getHeader().getMemberId();
            }
            assertThat(response.getHeader().getMemberId()).isEqualTo(lastMemberId);
        }
    }
}
Also used : Response(io.etcd.jetcd.Response) PutResponse(io.etcd.jetcd.kv.PutResponse) KV(io.etcd.jetcd.KV) Client(io.etcd.jetcd.Client) URI(java.net.URI) ClientBuilder(io.etcd.jetcd.ClientBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

Client (io.etcd.jetcd.Client)1 ClientBuilder (io.etcd.jetcd.ClientBuilder)1 KV (io.etcd.jetcd.KV)1 Response (io.etcd.jetcd.Response)1 PutResponse (io.etcd.jetcd.kv.PutResponse)1 URI (java.net.URI)1 Test (org.junit.jupiter.api.Test)1