Sent by the consumer side to the producer specifying that the consumer wants to create a vbucket stream. The command can optionally accept a value, which encodes a JSON object to configure the stream.
The following keys can be included in the JSON object.
uid- for resuming collection aware DCP streams, manifest-UIDsid- for specifying an ID the client would like to associated with the streamcollections- for specifying the set of collection IDs the stream must includescope- for specifying the scope-ID the stream must includepurge_seqno- for telling the server the most recently observed purge-seqnocts- for configuring the CacheTransfer phase of the stream (only meaningful when the stream-request extras has theCacheTransferflag set)
uid can be set by the client when they are resuming a stream, the value should
be the uid they last observed from a collection's DCP System event.
For example if the client observed a create-collection event with uid 0xb4 at
seqno 2091, then any subsequent stream-request for a stream starting at seqno 2091 or
higher must include a JSON object that encodes at least the manifest uid.
The value of the "uid" parameter matches the JSON manifest data used to manage each key-value node's collection configuration:
- A JSON string containing the manifest-UID as a string representation of the value in base16 with no leading 0x.
For example:
{
"uid" : "b4"
}
This value is optional and is only used to assist debugging (it is included in log messages).
The sid must be set for any stream-requested from a DCP producer which has the
DCP stream-ID feature enabled. The sid is an unsigned 16-bit integer
(1 to 65536) chosen by the client. All DCP mutations, deletions, expirations,
snapshot markers and end stream messages will be transmitted from server to
client with the chosen value encoded in the message (using flexible framing.)
A client can create many DCP streams on the same vbucket using different values of sid.
{
"sid" : 71
}
The collections key can be specified to request the stream only includes items
relating to the specified collection or collections.
The key specifies an array of collection-IDs which folled the JSON collections manifest format, JSON strings representing the ID as a base-16 string without a 0x prefix.
{
"collections" : ["0", "8a"]
}
The scope key can be specified to request the stream only includes items
relating to the collections of the specified scope.
The value is a JSON string representing the ID as a base-16 string without a 0x prefix.
{
"scope" : "9"
}
A DCP client can give to the server the most recent purge-seqno the client has observed which can reduce rollbacks. Only servers which support transmitting the purge-seqno will utilise this input parameter. To discover if the server supports this feature a client can test if "max_marker_version=2.2" can be enabled, see control.md max_marker_version.
The value is a JSON string with the purge-seqno as a base-10 representation.
{
"purge_seqno" : "81021"
}
The cts (cache-transfer-stream) key is a JSON object used to configure the
CacheTransfer phase of a stream. The key is only
meaningful when the stream-request extras has the CacheTransfer flag
(0x100) set; the stream is otherwise unaffected by it.
The object supports the following keys (all optional):
free_memory- a non-negative JSON integer (unsigned) describing the amount of memory in bytes that the consumer has available for the items it is about to receive. The producer treats this as a soft budget and decrements it as it queues items.- If
free_memoryreaches0andall_keysisfalse, the cache transfer is stopped. - If
free_memoryreaches0andall_keysistrue, the producer switches to shipping key + metadata only for the remaining items.
- If
all_keys- a JSON boolean. Whentruethe producer attempts to ship every eligible item from the hash-table, downgrading the value to "key + metadata only" whenever it is forced to (consumer budget exhausted or producer above its high-water-mark). Whenfalse(the default) the producer only ships items whose value is currently resident, and stops when the consumer'sfree_memorybudget is exhausted.
If free_memory is omitted the producer assumes free_memory:0
If all_keys is omitted the producer assumes all_keys:false
For example:
{
"cts" : {
"free_memory" : 1073741824,
"all_keys" : true
}
}
The semantics of these options (including which items are eligible for transfer and how memory pressure is handled) are described in detail in cache_transfer.md.
- The stream-request code does not error for unknown keys.
- The stream-request will fail with
Invalidifcollectionsandscopeare defined.
- The stream-request will fail if
uidis not a JSON string
- The stream-request will fail if
sidis included and the client has not enabled multiple streams. - The stream-request will fail if
sidis not a JSON integer - The stream-request will fail if
sidis 0 - The stream-request will fail if
sidis in use by a stream - No more streams can be created, there will be a limit on how many streams can be created per vbucket.
- The stream-request will fail if
collectionsis not a JSON array
- The stream-request will fail if
scopeis not a JSON string
- The stream-request will fail if
purge_seqnois not a JSON string. - The stream-request will fail if
purge_seqnovalue cannot be converted using std::strtoull
- The stream-request will fail if
ctsis not a JSON object. - The stream-request will fail if
cts.free_memoryis present and is not a JSON unsigned integer. - The stream-request will fail if
cts.all_keysis present and is not a JSON boolean.
Request a DCP stream to include collections with id 0xa and 0x1e and last
seen purge-seqno of 1000.
{
"collections" : ["a", "1e"],
"purge_seqno" : "1000"
}