Search in sources :

Example 1 with KvPingResponse

use of com.couchbase.client.core.msg.kv.KvPingResponse in project couchbase-jvm-clients by couchbase.

the class HealthPinger method pingKv.

private static Mono<EndpointPingReport> pingKv(final Core core, final RequestTarget target, final CoreCommonOptions options) {
    return Mono.defer(() -> {
        Duration timeout = options.timeout().orElse(core.context().environment().timeoutConfig().kvTimeout());
        CollectionIdentifier collectionIdentifier = CollectionIdentifier.fromDefault(target.bucketName());
        KvPingRequest request = new KvPingRequest(timeout, core.context(), options.retryStrategy().orElse(null), collectionIdentifier, target.nodeIdentifier());
        core.send(request);
        return Reactor.wrap(request, request.response(), true).map(response -> {
            request.context().logicallyComplete();
            return assembleSuccessReport(request.context(), ((KvPingResponse) response).channelId(), Optional.ofNullable(target.bucketName()));
        }).onErrorResume(throwable -> {
            request.context().logicallyComplete();
            return Mono.just(assembleFailureReport(throwable, request.context(), Optional.ofNullable(target.bucketName())));
        });
    });
}
Also used : ClusterConfig(com.couchbase.client.core.config.ClusterConfig) CbCollections.isNullOrEmpty(com.couchbase.client.core.util.CbCollections.isNullOrEmpty) CoreHttpRequest(com.couchbase.client.core.endpoint.http.CoreHttpRequest) TimeoutException(com.couchbase.client.core.error.TimeoutException) RequestTarget(com.couchbase.client.core.msg.RequestTarget) KvPingRequest(com.couchbase.client.core.msg.kv.KvPingRequest) CoreCommonOptions(com.couchbase.client.core.endpoint.http.CoreCommonOptions) HashSet(java.util.HashSet) ServiceType(com.couchbase.client.core.service.ServiceType) Duration(java.time.Duration) Map(java.util.Map) CoreHttpPath.path(com.couchbase.client.core.endpoint.http.CoreHttpPath.path) Stability(com.couchbase.client.core.annotation.Stability) RequestContext(com.couchbase.client.core.msg.RequestContext) BucketConfig(com.couchbase.client.core.config.BucketConfig) KvPingResponse(com.couchbase.client.core.msg.kv.KvPingResponse) Reactor(com.couchbase.client.core.Reactor) NodeInfo(com.couchbase.client.core.config.NodeInfo) Set(java.util.Set) Mono(reactor.core.publisher.Mono) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Flux(reactor.core.publisher.Flux) Optional(java.util.Optional) CollectionIdentifier(com.couchbase.client.core.io.CollectionIdentifier) RetryStrategy(com.couchbase.client.core.retry.RetryStrategy) Core(com.couchbase.client.core.Core) PortInfo(com.couchbase.client.core.config.PortInfo) KvPingRequest(com.couchbase.client.core.msg.kv.KvPingRequest) KvPingResponse(com.couchbase.client.core.msg.kv.KvPingResponse) Duration(java.time.Duration) CollectionIdentifier(com.couchbase.client.core.io.CollectionIdentifier)

Aggregations

Core (com.couchbase.client.core.Core)1 Reactor (com.couchbase.client.core.Reactor)1 Stability (com.couchbase.client.core.annotation.Stability)1 BucketConfig (com.couchbase.client.core.config.BucketConfig)1 ClusterConfig (com.couchbase.client.core.config.ClusterConfig)1 NodeInfo (com.couchbase.client.core.config.NodeInfo)1 PortInfo (com.couchbase.client.core.config.PortInfo)1 CoreCommonOptions (com.couchbase.client.core.endpoint.http.CoreCommonOptions)1 CoreHttpPath.path (com.couchbase.client.core.endpoint.http.CoreHttpPath.path)1 CoreHttpRequest (com.couchbase.client.core.endpoint.http.CoreHttpRequest)1 TimeoutException (com.couchbase.client.core.error.TimeoutException)1 CollectionIdentifier (com.couchbase.client.core.io.CollectionIdentifier)1 RequestContext (com.couchbase.client.core.msg.RequestContext)1 RequestTarget (com.couchbase.client.core.msg.RequestTarget)1 KvPingRequest (com.couchbase.client.core.msg.kv.KvPingRequest)1 KvPingResponse (com.couchbase.client.core.msg.kv.KvPingResponse)1 RetryStrategy (com.couchbase.client.core.retry.RetryStrategy)1 ServiceType (com.couchbase.client.core.service.ServiceType)1 CbCollections.isNullOrEmpty (com.couchbase.client.core.util.CbCollections.isNullOrEmpty)1 Duration (java.time.Duration)1