Search in sources :

Example 1 with ReducedViewErrorContext

use of com.couchbase.client.core.error.context.ReducedViewErrorContext in project couchbase-jvm-clients by couchbase.

the class AsyncViewIndexManager method upsertDesignDocument.

/**
 * Stores the design document on the server under the specified namespace, replacing any existing document
 * with the same name.
 *
 * @param doc document to store
 * @param namespace namespace to store it in
 * @param options additional optional arguments (timeout, retry, etc.)
 */
public CompletableFuture<Void> upsertDesignDocument(final DesignDocument doc, final DesignDocumentNamespace namespace, final UpsertDesignDocumentOptions options) {
    notNull(doc, "DesignDocument", () -> new ReducedViewErrorContext(null, null, bucket));
    notNull(namespace, "DesignDocumentNamespace", () -> new ReducedViewErrorContext(doc.name(), null, bucket));
    notNull(options, "UpsertDesignDocumentOptions", () -> new ReducedViewErrorContext(doc.name(), null, bucket));
    byte[] docBytes = Mapper.encodeAsBytes(toJson(doc));
    return coreManager.upsertDesignDocument(doc.name(), docBytes, namespace == PRODUCTION, options.build());
}
Also used : ReducedViewErrorContext(com.couchbase.client.core.error.context.ReducedViewErrorContext)

Example 2 with ReducedViewErrorContext

use of com.couchbase.client.core.error.context.ReducedViewErrorContext in project couchbase-jvm-clients by couchbase.

the class AsyncViewIndexManager method dropDesignDocument.

/**
 * Removes a design document from the server.
 *
 * @param name name of the document to remove
 * @param namespace namespace to remove it from
 * @param options additional optional arguments (timeout, retry, etc.)
 * @throws DesignDocumentNotFoundException if the namespace does not contain a document with the given name
 */
public CompletableFuture<Void> dropDesignDocument(final String name, final DesignDocumentNamespace namespace, final DropDesignDocumentOptions options) {
    notNullOrEmpty(name, "Name", () -> new ReducedViewErrorContext(null, null, bucket));
    notNull(namespace, "DesignDocumentNamespace", () -> new ReducedViewErrorContext(name, null, bucket));
    notNull(options, "DropDesignDocumentOptions", () -> new ReducedViewErrorContext(name, null, bucket));
    return coreManager.dropDesignDocument(name, namespace == PRODUCTION, options.build());
}
Also used : ReducedViewErrorContext(com.couchbase.client.core.error.context.ReducedViewErrorContext)

Example 3 with ReducedViewErrorContext

use of com.couchbase.client.core.error.context.ReducedViewErrorContext in project couchbase-jvm-clients by couchbase.

the class ReactiveBucket method viewQuery.

public Mono<ReactiveViewResult> viewQuery(final String designDoc, final String viewName, final ViewOptions options) {
    return Mono.defer(() -> {
        notNull(options, "ViewOptions", () -> new ReducedViewErrorContext(designDoc, viewName, name()));
        ViewOptions.Built opts = options.build();
        JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
        return ViewAccessor.viewQueryReactive(asyncBucket.core(), asyncBucket.viewRequest(designDoc, viewName, opts), serializer);
    });
}
Also used : ViewOptions(com.couchbase.client.java.view.ViewOptions) ReducedViewErrorContext(com.couchbase.client.core.error.context.ReducedViewErrorContext) JsonSerializer(com.couchbase.client.java.codec.JsonSerializer)

Example 4 with ReducedViewErrorContext

use of com.couchbase.client.core.error.context.ReducedViewErrorContext in project couchbase-jvm-clients by couchbase.

the class AsyncBucket method viewRequest.

ViewRequest viewRequest(final String designDoc, final String viewName, final ViewOptions.Built opts) {
    notNullOrEmpty(designDoc, "DesignDoc", () -> new ReducedViewErrorContext(designDoc, viewName, name));
    notNullOrEmpty(viewName, "ViewName", () -> new ReducedViewErrorContext(designDoc, viewName, name));
    String query = opts.query();
    Optional<byte[]> keysJson = Optional.ofNullable(opts.keys()).map(s -> s.getBytes(StandardCharsets.UTF_8));
    boolean development = opts.development();
    Duration timeout = opts.timeout().orElse(environment.timeoutConfig().viewTimeout());
    RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
    final RequestSpan span = environment().requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_VIEWS, opts.parentSpan().orElse(null));
    ViewRequest request = new ViewRequest(timeout, core.context(), retryStrategy, authenticator, name, designDoc, viewName, query, keysJson, development, span);
    request.context().clientContext(opts.clientContext());
    return request;
}
Also used : ReducedViewErrorContext(com.couchbase.client.core.error.context.ReducedViewErrorContext) Duration(java.time.Duration) ViewRequest(com.couchbase.client.core.msg.view.ViewRequest) RetryStrategy(com.couchbase.client.core.retry.RetryStrategy) RequestSpan(com.couchbase.client.core.cnc.RequestSpan)

Example 5 with ReducedViewErrorContext

use of com.couchbase.client.core.error.context.ReducedViewErrorContext in project couchbase-jvm-clients by couchbase.

the class CoreViewIndexManager method publishDesignDocument.

/**
 * Convenience method that gets a the document from the development namespace
 * and upserts it to the production namespace.
 *
 * @param name name of the development design document
 * @throws DesignDocumentNotFoundException if the development namespace does not contain a document with the given name
 */
public CompletableFuture<Void> publishDesignDocument(String name, CoreCommonOptions options) {
    notNullOrEmpty(name, "Name", () -> new ReducedViewErrorContext(null, null, bucket));
    RequestSpan span = buildSpan(TracingIdentifiers.SPAN_REQUEST_MV_PUBLISH_DD, options.parentSpan());
    CoreCommonOptions childOptions = options.withParentSpan(span);
    return getDesignDocument(name, false, childOptions).thenCompose(doc -> upsertDesignDocument(name, doc, true, childOptions)).whenComplete((r, t) -> span.end());
}
Also used : DesignDocumentNotFoundException(com.couchbase.client.core.error.DesignDocumentNotFoundException) HttpStatusCodeException(com.couchbase.client.core.error.HttpStatusCodeException) Validators.notNull(com.couchbase.client.core.util.Validators.notNull) CouchbaseException(com.couchbase.client.core.error.CouchbaseException) RequestTarget(com.couchbase.client.core.msg.RequestTarget) CompletableFuture(java.util.concurrent.CompletableFuture) CoreHttpPath(com.couchbase.client.core.endpoint.http.CoreHttpPath) CoreCommonOptions(com.couchbase.client.core.endpoint.http.CoreCommonOptions) JsonNode(com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNode) LinkedHashMap(java.util.LinkedHashMap) CbCollections.mapOf(com.couchbase.client.core.util.CbCollections.mapOf) TracingIdentifiers(com.couchbase.client.core.cnc.TracingIdentifiers) Map(java.util.Map) CoreHttpPath.path(com.couchbase.client.core.endpoint.http.CoreHttpPath.path) Objects.requireNonNull(java.util.Objects.requireNonNull) Stability(com.couchbase.client.core.annotation.Stability) RequestSpan(com.couchbase.client.core.cnc.RequestSpan) ObjectNode(com.couchbase.client.core.deps.com.fasterxml.jackson.databind.node.ObjectNode) CbStrings.removeStart(com.couchbase.client.core.util.CbStrings.removeStart) CbTracing(com.couchbase.client.core.cnc.CbTracing) ReducedViewErrorContext(com.couchbase.client.core.error.context.ReducedViewErrorContext) Mapper(com.couchbase.client.core.json.Mapper) CoreHttpClient(com.couchbase.client.core.endpoint.http.CoreHttpClient) UrlQueryStringBuilder.urlEncode(com.couchbase.client.core.util.UrlQueryStringBuilder.urlEncode) InvalidArgumentException(com.couchbase.client.core.error.InvalidArgumentException) Validators.notNullOrEmpty(com.couchbase.client.core.util.Validators.notNullOrEmpty) ResponseStatus(com.couchbase.client.core.msg.ResponseStatus) RedactableArgument.redactMeta(com.couchbase.client.core.logging.RedactableArgument.redactMeta) CoreHttpResponse(com.couchbase.client.core.endpoint.http.CoreHttpResponse) Optional(java.util.Optional) Core(com.couchbase.client.core.Core) CoreCommonOptions(com.couchbase.client.core.endpoint.http.CoreCommonOptions) ReducedViewErrorContext(com.couchbase.client.core.error.context.ReducedViewErrorContext) RequestSpan(com.couchbase.client.core.cnc.RequestSpan)

Aggregations

ReducedViewErrorContext (com.couchbase.client.core.error.context.ReducedViewErrorContext)9 RequestSpan (com.couchbase.client.core.cnc.RequestSpan)2 JsonSerializer (com.couchbase.client.java.codec.JsonSerializer)2 ViewOptions (com.couchbase.client.java.view.ViewOptions)2 Core (com.couchbase.client.core.Core)1 Stability (com.couchbase.client.core.annotation.Stability)1 CbTracing (com.couchbase.client.core.cnc.CbTracing)1 TracingIdentifiers (com.couchbase.client.core.cnc.TracingIdentifiers)1 JsonNode (com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.couchbase.client.core.deps.com.fasterxml.jackson.databind.node.ObjectNode)1 CoreCommonOptions (com.couchbase.client.core.endpoint.http.CoreCommonOptions)1 CoreHttpClient (com.couchbase.client.core.endpoint.http.CoreHttpClient)1 CoreHttpPath (com.couchbase.client.core.endpoint.http.CoreHttpPath)1 CoreHttpPath.path (com.couchbase.client.core.endpoint.http.CoreHttpPath.path)1 CoreHttpResponse (com.couchbase.client.core.endpoint.http.CoreHttpResponse)1 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)1 DesignDocumentNotFoundException (com.couchbase.client.core.error.DesignDocumentNotFoundException)1 HttpStatusCodeException (com.couchbase.client.core.error.HttpStatusCodeException)1 InvalidArgumentException (com.couchbase.client.core.error.InvalidArgumentException)1 Mapper (com.couchbase.client.core.json.Mapper)1