Search in sources :

Example 1 with EtcdExceptionFactory.toEtcdException

use of io.etcd.jetcd.common.exception.EtcdExceptionFactory.toEtcdException in project jetcd by coreos.

the class ElectionImpl method observe.

@Override
public void observe(ByteSequence electionName, Listener listener) {
    checkNotNull(electionName, "election name should not be null");
    checkNotNull(listener, "listener should not be null");
    LeaderRequest request = LeaderRequest.newBuilder().setName(ByteString.copyFrom(electionName.getBytes())).build();
    stub.observe(request).handler(value -> listener.onNext(new LeaderResponse(value, namespace))).endHandler(ignored -> listener.onCompleted()).exceptionHandler(error -> listener.onError(EtcdExceptionFactory.toEtcdException(error)));
}
Also used : ProclaimRequest(io.etcd.jetcd.api.ProclaimRequest) EtcdExceptionFactory.toEtcdException(io.etcd.jetcd.common.exception.EtcdExceptionFactory.toEtcdException) CampaignResponse(io.etcd.jetcd.election.CampaignResponse) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) VertxElectionGrpc(io.etcd.jetcd.api.VertxElectionGrpc) LeaderResponse(io.etcd.jetcd.election.LeaderResponse) CompletableFuture(java.util.concurrent.CompletableFuture) ProclaimResponse(io.etcd.jetcd.election.ProclaimResponse) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) ResignRequest(io.etcd.jetcd.api.ResignRequest) CampaignRequest(io.etcd.jetcd.api.CampaignRequest) LeaderKey(io.etcd.jetcd.election.LeaderKey) NoLeaderException(io.etcd.jetcd.election.NoLeaderException) Util(io.etcd.jetcd.support.Util) ByteSequence(io.etcd.jetcd.ByteSequence) Election(io.etcd.jetcd.Election) ResignResponse(io.etcd.jetcd.election.ResignResponse) NotLeaderException(io.etcd.jetcd.election.NotLeaderException) LeaderRequest(io.etcd.jetcd.api.LeaderRequest) EtcdExceptionFactory(io.etcd.jetcd.common.exception.EtcdExceptionFactory) LeaderRequest(io.etcd.jetcd.api.LeaderRequest) LeaderResponse(io.etcd.jetcd.election.LeaderResponse)

Aggregations

Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ByteString (com.google.protobuf.ByteString)1 ByteSequence (io.etcd.jetcd.ByteSequence)1 Election (io.etcd.jetcd.Election)1 CampaignRequest (io.etcd.jetcd.api.CampaignRequest)1 LeaderRequest (io.etcd.jetcd.api.LeaderRequest)1 ProclaimRequest (io.etcd.jetcd.api.ProclaimRequest)1 ResignRequest (io.etcd.jetcd.api.ResignRequest)1 VertxElectionGrpc (io.etcd.jetcd.api.VertxElectionGrpc)1 EtcdExceptionFactory (io.etcd.jetcd.common.exception.EtcdExceptionFactory)1 EtcdExceptionFactory.toEtcdException (io.etcd.jetcd.common.exception.EtcdExceptionFactory.toEtcdException)1 CampaignResponse (io.etcd.jetcd.election.CampaignResponse)1 LeaderKey (io.etcd.jetcd.election.LeaderKey)1 LeaderResponse (io.etcd.jetcd.election.LeaderResponse)1 NoLeaderException (io.etcd.jetcd.election.NoLeaderException)1 NotLeaderException (io.etcd.jetcd.election.NotLeaderException)1 ProclaimResponse (io.etcd.jetcd.election.ProclaimResponse)1 ResignResponse (io.etcd.jetcd.election.ResignResponse)1 Util (io.etcd.jetcd.support.Util)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1