Search in sources :

Example 6 with LeaseKeepAliveResponse

use of io.etcd.jetcd.lease.LeaseKeepAliveResponse in project dubbo by alibaba.

the class LeaseTest method testKeepAliveOnce.

@Test
public void testKeepAliveOnce() throws ExecutionException, InterruptedException {
    long leaseID = leaseClient.grant(2).get().getID();
    kvClient.put(KEY, VALUE, PutOption.newBuilder().withLeaseId(leaseID).build()).get();
    assertThat(kvClient.get(KEY).get().getCount()).isEqualTo(1);
    LeaseKeepAliveResponse rp = leaseClient.keepAliveOnce(leaseID).get();
    assertThat(rp.getTTL()).isGreaterThan(0);
}
Also used : LeaseKeepAliveResponse(io.etcd.jetcd.lease.LeaseKeepAliveResponse) Test(org.junit.jupiter.api.Test)

Aggregations

LeaseKeepAliveResponse (io.etcd.jetcd.lease.LeaseKeepAliveResponse)6 Test (org.junit.jupiter.api.Test)4 CloseableClient (io.etcd.jetcd.support.CloseableClient)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 EtcdException (io.etcd.jetcd.common.exception.EtcdException)1 Observers (io.etcd.jetcd.support.Observers)1 CompletableFuture (java.util.concurrent.CompletableFuture)1