use of io.etcd.jetcd.common.exception.EtcdException in project dubbo by alibaba.
the class JEtcdClientWrapper method keepAlive.
@SuppressWarnings("unchecked")
private <T> void keepAlive(long lease, Consumer<T> onFailed) {
final StreamObserver<LeaseKeepAliveResponse> observer = new Observers.Builder().onError((e) -> {
if (e instanceof EtcdException) {
EtcdException error = (EtcdException) e;
/**
* ttl has expired
*/
if (error.getErrorCode() == ErrorCode.NOT_FOUND) {
keepAlive0(onFailed);
}
}
}).onCompleted(() -> {
/**
* deadline reached.
*/
keepAlive0(onFailed);
}).build();
/**
* If there is already a keepalive, cancel first
*/
cancelKeepAlive();
/**
* create and set new keepAlive to globalKeepAliveRef
*/
this.keepAlive = client.getLeaseClient().keepAlive(lease, observer);
}
Aggregations