List of usage examples for io.netty.buffer Unpooled EMPTY_BUFFER
ByteBuf EMPTY_BUFFER
To view the source code for io.netty.buffer Unpooled EMPTY_BUFFER.
Click Source Link
From source file:com.couchbase.client.core.message.kv.AbstractKeyValueResponse.java
License:Apache License
protected AbstractKeyValueResponse(ResponseStatus status, short serverStatusCode, String bucket, ByteBuf content, CouchbaseRequest request) { super(status, request); this.content = content == null ? Unpooled.EMPTY_BUFFER : content; this.bucket = bucket; this.serverStatusCode = serverStatusCode; }
From source file:com.couchbase.client.core.message.kv.subdoc.multi.MultiLookupResponse.java
License:Apache License
public MultiLookupResponse(ResponseStatus status, short serverStatusCode, String bucket, List<MultiResult<Lookup>> responses, BinarySubdocMultiLookupRequest request, long cas) { super(status, serverStatusCode, bucket, Unpooled.EMPTY_BUFFER, request); this.responses = responses; this.cas = cas; }
From source file:com.couchbase.client.core.message.kv.subdoc.multi.MultiMutationResponse.java
License:Apache License
/** * Creates a {@link MultiMutationResponse} that failed at subdocument level. The status, expected to be * {@link ResponseStatus#SUBDOC_MULTI_PATH_FAILURE}, denotes that at least one {@link MutationCommand} failed. * * @param status the status of the request (SUBDOC_MULTI_PATH_FAILURE). * @param serverStatusCode the status code of the whole request. * @param bucket the bucket on which the request happened. * @param firstErrorIndex the zero-based index of the first {@link MutationCommand} that failed (in case failure is * due to one or more commands). * @param firstErrorStatusCode the status code for the first {@link MutationCommand} that failed (in case failure is * due to one or more commands). * @param request the original {@link BinarySubdocMultiMutationRequest}. * @param cas the CAS value of the document after mutations. * @param mutationToken the {@link MutationToken} of the document after mutations, if available. Null otherwise. *///from w ww . j a v a 2 s. c o m public MultiMutationResponse(ResponseStatus status, short serverStatusCode, String bucket, int firstErrorIndex, short firstErrorStatusCode, BinarySubdocMultiMutationRequest request, long cas, MutationToken mutationToken) { //do cas and muto make sense here? super(status, serverStatusCode, bucket, Unpooled.EMPTY_BUFFER, request); this.cas = cas; this.mutationToken = mutationToken; this.firstErrorIndex = firstErrorIndex; if (firstErrorIndex == -1) { this.firstErrorStatus = ResponseStatus.FAILURE; } else { this.firstErrorStatus = ResponseStatusConverter.fromBinary(firstErrorStatusCode); } this.responses = Collections.emptyList(); }
From source file:com.couchbase.client.core.message.kv.subdoc.multi.MultiMutationResponse.java
License:Apache License
/** * Creates a unsuccessful {@link MultiMutationResponse} that failed at document level. * * First error index is set to -1 and first error status is set to {@link ResponseStatus#FAILURE}. * * @param status the failed status of the request. * @param serverStatusCode the status code of the whole request. * @param bucket the bucket on which the request happened. * @param request the original {@link BinarySubdocMultiMutationRequest}. * @param cas the CAS value of the document after mutations. * @param mutationToken the {@link MutationToken} of the document after mutations, if available. Null otherwise. *///from w w w . ja v a2s .c o m public MultiMutationResponse(ResponseStatus status, short serverStatusCode, String bucket, BinarySubdocMultiMutationRequest request, long cas, MutationToken mutationToken) { //do cas and muto make sense here? super(status, serverStatusCode, bucket, Unpooled.EMPTY_BUFFER, request); this.cas = cas; this.mutationToken = mutationToken; this.firstErrorIndex = -1; this.firstErrorStatus = ResponseStatus.FAILURE; this.responses = Collections.emptyList(); }
From source file:com.couchbase.client.core.message.kv.subdoc.multi.MultiMutationResponse.java
License:Apache License
/** * Creates an successful {@link MultiMutationResponse}. * * @param bucket the bucket on which the request happened. * @param request the original {@link BinarySubdocMultiMutationRequest}. * @param cas the CAS value of the document after mutations. * @param token the {@link MutationToken} of the document after mutations, if available. Null otherwise. * @param responses the list of {@link MultiResult MultiResult<Mutation>} for each command. Some may include a value. *///from w w w. ja va 2 s . co m public MultiMutationResponse(String bucket, BinarySubdocMultiMutationRequest request, long cas, MutationToken token, List<MultiResult<Mutation>> responses) { super(ResponseStatus.SUCCESS, KeyValueStatus.SUCCESS.code(), bucket, Unpooled.EMPTY_BUFFER, request); this.cas = cas; this.mutationToken = token; this.firstErrorIndex = -1; this.firstErrorStatus = ResponseStatus.SUCCESS; this.responses = responses; }
From source file:com.couchbase.client.core.message.kv.subdoc.multi.MutationCommand.java
License:Apache License
/** * Create a multi-mutation command./* w w w . ja v a 2s.c o m*/ * * @param mutation the mutation type. * @param path the path to mutate inside the document. * @param fragment the target value for the mutation. This will be released when the request is sent. * @param createIntermediaryPath true if missing parts of the path should be created if possible, false otherwise. */ public MutationCommand(Mutation mutation, String path, ByteBuf fragment, boolean createIntermediaryPath) { this.mutation = mutation; this.path = path; this.fragment = (fragment == null) ? Unpooled.EMPTY_BUFFER : fragment; this.createIntermediaryPath = createIntermediaryPath; }
From source file:com.couchbase.client.core.message.kv.subdoc.multi.MutationCommand.java
License:Apache License
/** * Create a multi-mutation without a fragment (should be restricted to DELETE, not to be confused with * an empty string fragment where ByteBuf contains "<code>""</code>", or the null fragment where * ByteBuf contains "<code>NULL</code>"). * * @param path the path to delete inside the document. *//*w w w . j ava2s . com*/ public MutationCommand(Mutation mutation, String path) { this(mutation, path, Unpooled.EMPTY_BUFFER, false); }
From source file:com.couchbase.client.core.message.kv.subdoc.multi.MutationCommandBuilder.java
License:Apache License
/** * Create a multi-mutation command./* w w w .j av a 2 s. c o m*/ * * @param mutation the mutation type. * @param path the path to mutate inside the document. */ public MutationCommandBuilder(Mutation mutation, String path) { this.mutation = mutation; this.path = path; this.fragment = Unpooled.EMPTY_BUFFER; }
From source file:com.couchbase.client.core.message.kv.subdoc.multi.MutationCommandBuilder.java
License:Apache License
/** * Create a multi-mutation command./*from www . ja v a 2s. com*/ * * @param mutation the mutation type. * @param path the path to mutate inside the document. * @param fragment the target value for the mutation. This will be released when the request is sent. */ public MutationCommandBuilder(Mutation mutation, String path, ByteBuf fragment) { this.mutation = mutation; this.path = path; this.fragment = (fragment == null) ? Unpooled.EMPTY_BUFFER : fragment; }
From source file:com.couchbase.client.core.message.kv.subdoc.simple.AbstractSubdocRequest.java
License:Apache License
/** * Creates a new {@link AbstractSubdocRequest}. * * @param key the key of the document. * @param path the subdocument path to consider inside the document. * @param bucket the bucket of the document. * @param observable the observable which receives responses. * @param restOfContent the optional remainder of the {@link #content()} of the final protocol message, or null if not applicable * @throws NullPointerException if the path is null (see {@link #EXCEPTION_NULL_PATH}) *///from www . j av a2 s . co m public AbstractSubdocRequest(String key, String path, String bucket, Subject<CouchbaseResponse, CouchbaseResponse> observable, ByteBuf... restOfContent) { super(key, bucket, null, observable); this.path = path; ByteBuf pathByteBuf; if (path == null || path.isEmpty()) { pathByteBuf = Unpooled.EMPTY_BUFFER; } else { pathByteBuf = Unpooled.wrappedBuffer(path.getBytes(CharsetUtil.UTF_8)); } this.pathLength = pathByteBuf.readableBytes(); this.content = createContent(pathByteBuf, restOfContent); //checking nullity here allows to release all of restOfContent through cleanUpAndThrow releasing content() if (this.path == null) { cleanUpAndThrow(EXCEPTION_NULL_PATH); } }