libcouchbase 1.2.8 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -4
  3. data/README.md +16 -8
  4. data/ext/libcouchbase/CMakeLists.txt +34 -32
  5. data/ext/libcouchbase/RELEASE_NOTES.markdown +277 -6
  6. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +14 -0
  7. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +2 -0
  8. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +2 -1
  9. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -0
  10. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +8 -1
  11. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  12. data/ext/libcouchbase/cmake/config-cmake.h.in +14 -0
  13. data/ext/libcouchbase/cmake/configure +8 -26
  14. data/ext/libcouchbase/cmake/defs.mk.in +2 -2
  15. data/ext/libcouchbase/cmake/libcouchbase.stp.in +829 -0
  16. data/ext/libcouchbase/cmake/source_files.cmake +11 -2
  17. data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +18 -2
  18. data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +44 -2
  19. data/ext/libcouchbase/contrib/cbsasl/src/client.c +285 -73
  20. data/ext/libcouchbase/contrib/cbsasl/src/common.c +4 -0
  21. data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.c +500 -0
  22. data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.h +99 -0
  23. data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +1 -1
  24. data/ext/libcouchbase/contrib/cliopts/cliopts.h +14 -1
  25. data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +2 -3
  26. data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +4 -0
  27. data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +7 -5
  28. data/ext/libcouchbase/contrib/snappy/snappy.cc +7 -2
  29. data/ext/libcouchbase/example/crypto/.gitignore +2 -0
  30. data/ext/libcouchbase/example/crypto/Makefile +13 -0
  31. data/ext/libcouchbase/example/crypto/common_provider.c +24 -0
  32. data/ext/libcouchbase/example/crypto/common_provider.h +31 -0
  33. data/ext/libcouchbase/example/crypto/openssl_symmetric_decrypt.c +139 -0
  34. data/ext/libcouchbase/example/crypto/openssl_symmetric_encrypt.c +147 -0
  35. data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.c +281 -0
  36. data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.h +29 -0
  37. data/ext/libcouchbase/example/tracing/.gitignore +2 -0
  38. data/ext/libcouchbase/example/tracing/Makefile +8 -0
  39. data/ext/libcouchbase/example/tracing/cJSON.c +1 -0
  40. data/ext/libcouchbase/example/tracing/cJSON.h +1 -0
  41. data/ext/libcouchbase/example/tracing/tracing.c +439 -0
  42. data/ext/libcouchbase/example/tracing/views.c +444 -0
  43. data/ext/libcouchbase/include/libcouchbase/auth.h +56 -4
  44. data/ext/libcouchbase/include/libcouchbase/cbft.h +8 -0
  45. data/ext/libcouchbase/include/libcouchbase/cntl-private.h +55 -1
  46. data/ext/libcouchbase/include/libcouchbase/cntl.h +101 -1
  47. data/ext/libcouchbase/include/libcouchbase/configuration.h.in +6 -0
  48. data/ext/libcouchbase/include/libcouchbase/couchbase.h +109 -6
  49. data/ext/libcouchbase/include/libcouchbase/crypto.h +140 -0
  50. data/ext/libcouchbase/include/libcouchbase/error.h +38 -2
  51. data/ext/libcouchbase/include/libcouchbase/kvbuf.h +6 -1
  52. data/ext/libcouchbase/include/libcouchbase/metrics.h +79 -0
  53. data/ext/libcouchbase/include/libcouchbase/n1ql.h +9 -0
  54. data/ext/libcouchbase/include/libcouchbase/tracing.h +319 -0
  55. data/ext/libcouchbase/include/libcouchbase/vbucket.h +1 -1
  56. data/ext/libcouchbase/include/libcouchbase/views.h +8 -0
  57. data/ext/libcouchbase/include/memcached/protocol_binary.h +40 -10
  58. data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +6 -14
  59. data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +3 -0
  60. data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +1 -0
  61. data/ext/libcouchbase/plugins/io/select/plugin-select.c +4 -1
  62. data/ext/libcouchbase/src/auth-priv.h +36 -4
  63. data/ext/libcouchbase/src/auth.cc +66 -27
  64. data/ext/libcouchbase/src/bootstrap.cc +1 -1
  65. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +12 -7
  66. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +26 -17
  67. data/ext/libcouchbase/src/bucketconfig/bc_http.h +1 -1
  68. data/ext/libcouchbase/src/bucketconfig/clconfig.h +4 -2
  69. data/ext/libcouchbase/src/bucketconfig/confmon.cc +6 -3
  70. data/ext/libcouchbase/src/cbft.cc +48 -0
  71. data/ext/libcouchbase/src/cntl.cc +138 -2
  72. data/ext/libcouchbase/src/config_static.h +17 -0
  73. data/ext/libcouchbase/src/connspec.cc +54 -6
  74. data/ext/libcouchbase/src/connspec.h +9 -1
  75. data/ext/libcouchbase/src/crypto.cc +386 -0
  76. data/ext/libcouchbase/src/ctx-log-inl.h +23 -6
  77. data/ext/libcouchbase/src/dump.cc +4 -0
  78. data/ext/libcouchbase/src/getconfig.cc +1 -2
  79. data/ext/libcouchbase/src/handler.cc +65 -27
  80. data/ext/libcouchbase/src/hostlist.cc +35 -7
  81. data/ext/libcouchbase/src/hostlist.h +7 -0
  82. data/ext/libcouchbase/src/http/http-priv.h +2 -0
  83. data/ext/libcouchbase/src/http/http.cc +77 -37
  84. data/ext/libcouchbase/src/http/http_io.cc +19 -2
  85. data/ext/libcouchbase/src/instance.cc +90 -17
  86. data/ext/libcouchbase/src/internal.h +5 -0
  87. data/ext/libcouchbase/src/lcbio/connect.cc +39 -4
  88. data/ext/libcouchbase/src/lcbio/connect.h +27 -0
  89. data/ext/libcouchbase/src/lcbio/ctx.c +49 -23
  90. data/ext/libcouchbase/src/lcbio/ioutils.cc +30 -3
  91. data/ext/libcouchbase/src/lcbio/ioutils.h +2 -0
  92. data/ext/libcouchbase/src/lcbio/manager.cc +44 -8
  93. data/ext/libcouchbase/src/lcbio/manager.h +2 -0
  94. data/ext/libcouchbase/src/lcbio/rw-inl.h +1 -0
  95. data/ext/libcouchbase/src/lcbio/ssl.h +3 -5
  96. data/ext/libcouchbase/src/logging.c +1 -1
  97. data/ext/libcouchbase/src/logging.h +2 -0
  98. data/ext/libcouchbase/src/mc/compress.cc +164 -0
  99. data/ext/libcouchbase/src/mc/compress.h +7 -12
  100. data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +5 -1
  101. data/ext/libcouchbase/src/mc/mcreq.c +11 -1
  102. data/ext/libcouchbase/src/mc/mcreq.h +35 -4
  103. data/ext/libcouchbase/src/mcserver/mcserver.cc +30 -7
  104. data/ext/libcouchbase/src/mcserver/mcserver.h +7 -0
  105. data/ext/libcouchbase/src/mcserver/negotiate.cc +103 -57
  106. data/ext/libcouchbase/src/mcserver/negotiate.h +2 -2
  107. data/ext/libcouchbase/src/mctx-helper.h +11 -0
  108. data/ext/libcouchbase/src/metrics.cc +132 -0
  109. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +2 -1
  110. data/ext/libcouchbase/src/n1ql/n1ql.cc +66 -0
  111. data/ext/libcouchbase/src/newconfig.cc +9 -2
  112. data/ext/libcouchbase/src/operations/counter.cc +2 -1
  113. data/ext/libcouchbase/src/operations/durability-cas.cc +11 -0
  114. data/ext/libcouchbase/src/operations/durability-seqno.cc +3 -0
  115. data/ext/libcouchbase/src/operations/durability.cc +24 -2
  116. data/ext/libcouchbase/src/operations/durability_internal.h +19 -0
  117. data/ext/libcouchbase/src/operations/get.cc +4 -2
  118. data/ext/libcouchbase/src/operations/observe-seqno.cc +1 -0
  119. data/ext/libcouchbase/src/operations/observe.cc +113 -62
  120. data/ext/libcouchbase/src/operations/ping.cc +246 -67
  121. data/ext/libcouchbase/src/operations/remove.cc +2 -1
  122. data/ext/libcouchbase/src/operations/store.cc +17 -14
  123. data/ext/libcouchbase/src/operations/touch.cc +3 -0
  124. data/ext/libcouchbase/src/packetutils.h +68 -4
  125. data/ext/libcouchbase/src/probes.d +132 -161
  126. data/ext/libcouchbase/src/rdb/bigalloc.c +1 -1
  127. data/ext/libcouchbase/src/retryq.cc +6 -2
  128. data/ext/libcouchbase/src/rnd.cc +68 -0
  129. data/ext/libcouchbase/src/rnd.h +39 -0
  130. data/ext/libcouchbase/src/settings.c +27 -0
  131. data/ext/libcouchbase/src/settings.h +67 -3
  132. data/ext/libcouchbase/src/ssl/CMakeLists.txt +0 -12
  133. data/ext/libcouchbase/src/ssl/ssl_common.c +23 -4
  134. data/ext/libcouchbase/src/strcodecs/base64.c +141 -16
  135. data/ext/libcouchbase/src/strcodecs/strcodecs.h +16 -1
  136. data/ext/libcouchbase/src/trace.h +68 -61
  137. data/ext/libcouchbase/src/tracing/span.cc +289 -0
  138. data/ext/libcouchbase/src/tracing/threshold_logging_tracer.cc +171 -0
  139. data/ext/libcouchbase/src/tracing/tracer.cc +53 -0
  140. data/ext/libcouchbase/src/tracing/tracing-internal.h +213 -0
  141. data/ext/libcouchbase/src/utilities.c +5 -0
  142. data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -2
  143. data/ext/libcouchbase/src/vbucket/vbucket.c +50 -18
  144. data/ext/libcouchbase/src/views/docreq.cc +26 -1
  145. data/ext/libcouchbase/src/views/docreq.h +17 -0
  146. data/ext/libcouchbase/src/views/viewreq.cc +64 -1
  147. data/ext/libcouchbase/src/views/viewreq.h +21 -0
  148. data/ext/libcouchbase/tests/CMakeLists.txt +6 -6
  149. data/ext/libcouchbase/tests/basic/t_base64.cc +34 -6
  150. data/ext/libcouchbase/tests/basic/t_connstr.cc +14 -0
  151. data/ext/libcouchbase/tests/basic/t_creds.cc +10 -10
  152. data/ext/libcouchbase/tests/basic/t_host.cc +22 -2
  153. data/ext/libcouchbase/tests/basic/t_scram.cc +514 -0
  154. data/ext/libcouchbase/tests/check-all.cc +6 -2
  155. data/ext/libcouchbase/tests/iotests/mock-environment.cc +64 -0
  156. data/ext/libcouchbase/tests/iotests/mock-environment.h +27 -1
  157. data/ext/libcouchbase/tests/iotests/t_confmon.cc +2 -2
  158. data/ext/libcouchbase/tests/iotests/t_forward.cc +8 -0
  159. data/ext/libcouchbase/tests/iotests/t_netfail.cc +124 -0
  160. data/ext/libcouchbase/tests/iotests/t_smoke.cc +1 -1
  161. data/ext/libcouchbase/tests/iotests/t_snappy.cc +316 -0
  162. data/ext/libcouchbase/tests/socktests/socktest.cc +2 -2
  163. data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
  164. data/ext/libcouchbase/tests/socktests/t_manager.cc +1 -1
  165. data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
  166. data/ext/libcouchbase/tools/CMakeLists.txt +1 -1
  167. data/ext/libcouchbase/tools/cbc-handlers.h +17 -0
  168. data/ext/libcouchbase/tools/cbc-n1qlback.cc +7 -4
  169. data/ext/libcouchbase/tools/cbc-pillowfight.cc +408 -100
  170. data/ext/libcouchbase/tools/cbc-proxy.cc +134 -3
  171. data/ext/libcouchbase/tools/cbc-subdoc.cc +1 -2
  172. data/ext/libcouchbase/tools/cbc.cc +113 -8
  173. data/ext/libcouchbase/tools/common/histogram.cc +1 -0
  174. data/ext/libcouchbase/tools/common/options.cc +28 -1
  175. data/ext/libcouchbase/tools/common/options.h +5 -0
  176. data/ext/libcouchbase/tools/docgen/docgen.h +36 -10
  177. data/ext/libcouchbase/tools/docgen/loc.h +5 -4
  178. data/ext/libcouchbase/tools/docgen/seqgen.h +28 -0
  179. data/lib/libcouchbase/ext/libcouchbase/enums.rb +10 -0
  180. data/lib/libcouchbase/n1ql.rb +6 -1
  181. data/lib/libcouchbase/version.rb +1 -1
  182. data/spec/connection_spec.rb +6 -6
  183. metadata +38 -5
  184. data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +0 -11
  185. data/ext/libcouchbase/src/mc/compress.c +0 -90
  186. data/ext/libcouchbase/tools/common/my_inttypes.h +0 -22
@@ -22,8 +22,9 @@
22
22
  #include <lcbio/ssl.h>
23
23
  #include "ctx-log-inl.h"
24
24
  #define LOGARGS(ht, lvlbase) ht->parent->settings, "htconfig", LCB_LOG_##lvlbase, __FILE__, __LINE__
25
- #define LOGFMT "<%s:%s> "
26
- #define LOGID(h) get_ctx_host(h->ioctx), get_ctx_port(h->ioctx)
25
+
26
+ #define LOGFMT CTX_LOGFMT
27
+ #define LOGID(p) CTX_LOGID(p->ioctx)
27
28
 
28
29
  using namespace lcb::clconfig;
29
30
 
@@ -243,24 +244,31 @@ lcb_error_t HttpProvider::setup_request_header(const lcb_host_t &host) {
243
244
  }
244
245
 
245
246
  request_buf.append(" HTTP/1.1\r\n");
246
- const std::string& password = (settings().conntype == LCB_TYPE_BUCKET)
247
- ? settings().auth->password_for(settings().bucket)
248
- : settings().auth->password();
249
- if (!password.empty()) {
250
- const std::string& username = (settings().conntype == LCB_TYPE_BUCKET)
251
- ? settings().auth->username_for(settings().bucket)
252
- : settings().auth->username();
253
- std::string cred;
254
- cred.append(username).append(":").append(password);
255
- char b64[256] = { 0 };
256
- if (lcb_base64_encode(cred.c_str(), b64, sizeof(b64)) == -1) {
257
- return LCB_EINTERNAL;
247
+ if (!settings().keypath) {
248
+ // not using SSL client certificate to authenticate
249
+ const std::string password = (settings().conntype == LCB_TYPE_BUCKET)
250
+ ? settings().auth->password_for(host.host, host.port, settings().bucket)
251
+ : settings().auth->password();
252
+ if (!password.empty()) {
253
+ const std::string username = (settings().conntype == LCB_TYPE_BUCKET)
254
+ ? settings().auth->username_for(host.host, host.port, settings().bucket)
255
+ : settings().auth->username();
256
+ std::string cred;
257
+ cred.append(username).append(":").append(password);
258
+ char b64[256] = { 0 };
259
+ if (lcb_base64_encode(cred.c_str(), cred.size(), b64, sizeof(b64)) == -1) {
260
+ return LCB_EINTERNAL;
261
+ }
262
+ request_buf.append("Authorization: Basic ").append(b64).append("\r\n");
258
263
  }
259
- request_buf.append("Authorization: Basic ").append(b64).append("\r\n");
260
264
  }
261
265
 
262
266
  request_buf.append("Host: ").append(host.host).append(":").append(host.port).append("\r\n");
263
- request_buf.append("User-Agent: libcouchbase/").append(LCB_VERSION_STRING).append("\r\n");
267
+ request_buf.append("User-Agent: ").append(LCB_CLIENT_ID);
268
+ if (settings().client_string) {
269
+ request_buf.append(" ").append(settings().client_string);
270
+ }
271
+ request_buf.append("\r\n");
264
272
  request_buf.append("\r\n");
265
273
  return LCB_SUCCESS;
266
274
  }
@@ -294,7 +302,7 @@ on_connected(lcbio_SOCKET *sock, void *arg, lcb_error_t err, lcbio_OSERR syserr)
294
302
  return;
295
303
  }
296
304
  host = lcbio_get_host(sock);
297
- lcb_log(LOGARGS(http, DEBUG), "Successfuly connected to REST API %s:%s", host->host, host->port);
305
+ lcb_log(LOGARGS(http, DEBUG), "Successfuly connected to REST API " LCB_HOST_FMT, LCB_HOST_ARG(http->parent->settings, host));
298
306
 
299
307
  lcbio_sslify_if_needed(sock, http->parent->settings);
300
308
  http->reset_stream_state();
@@ -310,6 +318,7 @@ on_connected(lcbio_SOCKET *sock, void *arg, lcb_error_t err, lcbio_OSERR syserr)
310
318
  procs.cb_read = read_common;
311
319
  http->ioctx = lcbio_ctx_new(sock, http, &procs);
312
320
  http->ioctx->subsys = "bc_http";
321
+ sock->service = LCBIO_SERVICE_CFG;
313
322
 
314
323
  lcbio_ctx_put(http->ioctx, http->request_buf.c_str(), http->request_buf.size());
315
324
  lcbio_ctx_rwant(http->ioctx, 1);
@@ -34,7 +34,7 @@
34
34
 
35
35
  #define REQPOOLS_URI "/pools/"
36
36
  #define HOSTHDR_FMT "Host: %s:%s\r\n"
37
- #define LAST_HTTP_HEADER "X-Libcouchbase: " LCB_VERSION_STRING "\r\n"
37
+ #define LAST_HTTP_HEADER "X-Libcouchbase: " LCB_CLIENT_ID "\r\n"
38
38
  #define CONFIG_DELIMITER "\n\n\n\n"
39
39
 
40
40
  namespace lcb {
@@ -164,7 +164,7 @@ struct Confmon {
164
164
  * remain to be activated you should call lcb_confmon_prepare() once. Then
165
165
  * call the rest of the functions.
166
166
  */
167
- Confmon(lcb_settings*, lcbio_pTABLE iot);
167
+ Confmon(lcb_settings*, lcbio_pTABLE iot, lcb_t instance);
168
168
  void destroy() { delete this; }
169
169
  ~Confmon();
170
170
 
@@ -383,10 +383,12 @@ struct Confmon {
383
383
  int state;
384
384
 
385
385
  /** Last time the provider was stopped. As a microsecond timestamp */
386
- lcb_uint32_t last_stop_us;
386
+ lcb_uint64_t last_stop_us;
387
387
 
388
388
  typedef std::list<Provider*> ProviderList;
389
389
  ProviderList active_providers;
390
+
391
+ lcb_t instance;
390
392
  };
391
393
 
392
394
  /**
@@ -19,6 +19,7 @@
19
19
  #include "clconfig.h"
20
20
  #include <list>
21
21
  #include <algorithm>
22
+ #include "trace.h"
22
23
 
23
24
  #define LOGARGS(mon, lvlbase) mon->settings, "confmon", LCB_LOG_##lvlbase, __FILE__, __LINE__
24
25
  #define LOG(mon, lvlbase, msg) lcb_log(mon->settings, "confmon", LCB_LOG_##lvlbase, __FILE__, __LINE__, msg)
@@ -55,7 +56,7 @@ provider_string(Method type) {
55
56
  return "";
56
57
  }
57
58
 
58
- Confmon::Confmon(lcb_settings *settings_, lcbio_pTABLE iot_)
59
+ Confmon::Confmon(lcb_settings *settings_, lcbio_pTABLE iot_, lcb_t instance_)
59
60
  : cur_provider(NULL),
60
61
  config(NULL),
61
62
  settings(settings_),
@@ -64,7 +65,8 @@ Confmon::Confmon(lcb_settings *settings_, lcbio_pTABLE iot_)
64
65
  as_start(iot_, this),
65
66
  as_stop(iot_, this),
66
67
  state(0),
67
- last_stop_us(0) {
68
+ last_stop_us(0),
69
+ instance(instance_) {
68
70
 
69
71
  lcbio_table_ref(iot);
70
72
  lcb_settings_ref(settings);
@@ -147,7 +149,7 @@ int Confmon::do_set_next(ConfigInfo *new_config, bool notify_miss)
147
149
  ca = config->vbc;
148
150
  cb = new_config->vbc;
149
151
 
150
- lcb_log(LOGARGS(this, DEBUG), "Not applying configuration received via %s. No changes detected. A.rev=%d, B.rev=%d", provider_string(new_config->get_origin()), ca->revid, cb->revid);
152
+ lcb_log(LOGARGS(this, TRACE), "Not applying configuration received via %s. No changes detected. A.rev=%d, B.rev=%d", provider_string(new_config->get_origin()), ca->revid, cb->revid);
151
153
  if (notify_miss) {
152
154
  invoke_listeners(CLCONFIG_EVENT_GOT_ANY_CONFIG, new_config);
153
155
  }
@@ -156,6 +158,7 @@ int Confmon::do_set_next(ConfigInfo *new_config, bool notify_miss)
156
158
  }
157
159
 
158
160
  lcb_log(LOGARGS(this, INFO), "Setting new configuration. Received via %s", provider_string(new_config->get_origin()));
161
+ TRACE_NEW_CONFIG(instance, new_config);
159
162
 
160
163
  if (config) {
161
164
  /** DECREF the old one */
@@ -36,6 +36,10 @@ struct lcb_FTSREQ : lcb::jsparse::Parser::Actions {
36
36
  lcb_t instance;
37
37
  size_t nrows;
38
38
  lcb_error_t lasterr;
39
+ #ifdef LCB_TRACING
40
+ lcbtrace_SPAN *span;
41
+ #endif
42
+
39
43
  void invoke_row(lcb_RESPFTS *resp);
40
44
  void invoke_last();
41
45
 
@@ -116,6 +120,9 @@ lcb_FTSREQ::lcb_FTSREQ(lcb_t instance_, const void *cookie_, const lcb_CMDFTS *c
116
120
  parser(new lcb::jsparse::Parser(lcb::jsparse::Parser::MODE_FTS, this)),
117
121
  cookie(cookie_), callback(cmd->callback), instance(instance_), nrows(0),
118
122
  lasterr(LCB_SUCCESS)
123
+ #ifdef LCB_TRACING
124
+ , span(NULL)
125
+ #endif
119
126
  {
120
127
  lcb_CMDHTTP htcmd = { 0 };
121
128
  htcmd.type = LCB_HTTP_TYPE_FTS;
@@ -169,6 +176,15 @@ lcb_FTSREQ::lcb_FTSREQ(lcb_t instance_, const void *cookie_, const lcb_CMDFTS *c
169
176
  if (cmd->handle) {
170
177
  *cmd->handle = reinterpret_cast<lcb_FTSREQ*>(this);
171
178
  }
179
+ #ifdef LCB_TRACING
180
+ if (instance->settings->tracer) {
181
+ char id[20] = {0};
182
+ snprintf(id, sizeof(id), "%p", (void *)this);
183
+ span = lcbtrace_span_start(instance->settings->tracer, LCBTRACE_OP_DISPATCH_TO_SERVER, LCBTRACE_NOW, NULL);
184
+ lcbtrace_span_add_tag_str(span, LCBTRACE_TAG_OPERATION_ID, id);
185
+ lcbtrace_span_add_system_tags(span, instance->settings, LCBTRACE_TAG_SERVICE_SEARCH);
186
+ }
187
+ #endif
172
188
  }
173
189
  }
174
190
 
@@ -178,6 +194,26 @@ lcb_FTSREQ::~lcb_FTSREQ()
178
194
  lcb_cancel_http_request(instance, htreq);
179
195
  htreq = NULL;
180
196
  }
197
+ #ifdef LCB_TRACING
198
+ if (span) {
199
+ if (htreq) {
200
+ lcbio_CTX *ctx = htreq->ioctx;
201
+ if (ctx) {
202
+ std::string remote;
203
+ if (htreq->ipv6) {
204
+ remote = "[" + std::string(htreq->host) + "]:" + std::string(htreq->port);
205
+ } else {
206
+ remote = std::string(htreq->host) + ":" + std::string(htreq->port);
207
+ }
208
+ lcbtrace_span_add_tag_str(span, LCBTRACE_TAG_PEER_ADDRESS, remote.c_str());
209
+ lcbtrace_span_add_tag_str(span, LCBTRACE_TAG_LOCAL_ADDRESS,
210
+ lcbio__inet_ntop(&ctx->sock->info->sa_local).c_str());
211
+ }
212
+ }
213
+ lcbtrace_span_finish(span, LCBTRACE_NOW);
214
+ span = NULL;
215
+ }
216
+ #endif
181
217
  if (parser) {
182
218
  delete parser;
183
219
  parser = NULL;
@@ -203,3 +239,15 @@ lcb_fts_cancel(lcb_t, lcb_FTSHANDLE handle)
203
239
  {
204
240
  handle->callback = NULL;
205
241
  }
242
+
243
+ #ifdef LCB_TRACING
244
+
245
+ LIBCOUCHBASE_API
246
+ void lcb_fts_set_parent_span(lcb_t, lcb_FTSHANDLE handle, lcbtrace_SPAN *span)
247
+ {
248
+ if (handle) {
249
+ lcbtrace_span_set_parent(handle->span, span);
250
+ }
251
+ }
252
+
253
+ #endif
@@ -82,6 +82,15 @@ static lcb_uint32_t *get_timeout_field(lcb_t instance, int cmd)
82
82
  case LCB_CNTL_RETRY_INTERVAL: return &settings->retry_interval;
83
83
  case LCB_CNTL_RETRY_NMV_INTERVAL: return &settings->retry_nmv_interval;
84
84
  case LCB_CNTL_CONFIG_POLL_INTERVAL: return &settings->config_poll_interval;
85
+ #ifdef LCB_TRACING
86
+ case LCB_CNTL_TRACING_ORPHANED_QUEUE_FLUSH_INTERVAL: return &settings->tracer_orphaned_queue_flush_interval;
87
+ case LCB_CNTL_TRACING_THRESHOLD_QUEUE_FLUSH_INTERVAL: return &settings->tracer_threshold_queue_flush_interval;
88
+ case LCB_CNTL_TRACING_THRESHOLD_KV: return &settings->tracer_threshold[LCBTRACE_THRESHOLD_KV];
89
+ case LCB_CNTL_TRACING_THRESHOLD_N1QL: return &settings->tracer_threshold[LCBTRACE_THRESHOLD_N1QL];
90
+ case LCB_CNTL_TRACING_THRESHOLD_VIEW: return &settings->tracer_threshold[LCBTRACE_THRESHOLD_VIEW];
91
+ case LCB_CNTL_TRACING_THRESHOLD_FTS: return &settings->tracer_threshold[LCBTRACE_THRESHOLD_FTS];
92
+ case LCB_CNTL_TRACING_THRESHOLD_ANALYTICS: return &settings->tracer_threshold[LCBTRACE_THRESHOLD_ANALYTICS];
93
+ #endif
85
94
  default: return NULL;
86
95
  }
87
96
  }
@@ -132,9 +141,15 @@ HANDLER(get_changeset) {
132
141
  HANDLER(ssl_mode_handler) {
133
142
  RETURN_GET_ONLY(int, LCBT_SETTING(instance, sslopts))
134
143
  }
144
+ HANDLER(ssl_truststorepath_handler) {
145
+ RETURN_GET_ONLY(char*, LCBT_SETTING(instance, truststorepath))
146
+ }
135
147
  HANDLER(ssl_certpath_handler) {
136
148
  RETURN_GET_ONLY(char*, LCBT_SETTING(instance, certpath))
137
149
  }
150
+ HANDLER(ssl_keypath_handler) {
151
+ RETURN_GET_ONLY(char*, LCBT_SETTING(instance, keypath))
152
+ }
138
153
  HANDLER(htconfig_urltype_handler) {
139
154
  RETURN_GET_SET(int, LCBT_SETTING(instance, bc_http_urltype));
140
155
  }
@@ -168,6 +183,9 @@ HANDLER(schedflush_handler) {
168
183
  HANDLER(vbguess_handler) {
169
184
  RETURN_GET_SET(int, LCBT_SETTING(instance, keep_guess_vbs))
170
185
  }
186
+ HANDLER(vb_noremap_handler) {
187
+ RETURN_GET_SET(int, LCBT_SETTING(instance, vb_noremap))
188
+ }
171
189
  HANDLER(fetch_mutation_tokens_handler) {
172
190
  RETURN_GET_SET(int, LCBT_SETTING(instance, fetch_mutation_tokens))
173
191
  }
@@ -201,6 +219,35 @@ HANDLER(select_bucket_handler) {
201
219
  HANDLER(send_hello_handler) {
202
220
  RETURN_GET_SET(int, LCBT_SETTING(instance, send_hello));
203
221
  }
222
+ HANDLER(log_redaction_handler) {
223
+ RETURN_GET_SET(int, LCBT_SETTING(instance, log_redaction));
224
+ }
225
+ HANDLER(enable_tracing_handler) {
226
+ RETURN_GET_SET(int, LCBT_SETTING(instance, use_tracing));
227
+ }
228
+ HANDLER(tracing_orphaned_queue_size_handler) {
229
+ #ifdef LCB_TRACING
230
+ RETURN_GET_SET(lcb_U32, LCBT_SETTING(instance, tracer_orphaned_queue_size));
231
+ #else
232
+ (void)mode;
233
+ (void)instance;
234
+ (void)cmd;
235
+ (void)arg;
236
+ return LCB_ECTL_BADARG;
237
+ #endif
238
+ }
239
+ HANDLER(tracing_threshold_queue_size_handler) {
240
+ #ifdef LCB_TRACING
241
+ RETURN_GET_SET(lcb_U32, LCBT_SETTING(instance, tracer_threshold_queue_size));
242
+ #else
243
+ (void)mode;
244
+ (void)instance;
245
+ (void)cmd;
246
+ (void)arg;
247
+ return LCB_ECTL_BADARG;
248
+ #endif
249
+ }
250
+
204
251
  HANDLER(config_poll_interval_handler) {
205
252
  lcb_U32 *user = reinterpret_cast<lcb_U32*>(arg);
206
253
  if (mode == LCB_CNTL_SET && *user > 0 && *user < LCB_CONFIG_POLL_INTERVAL_FLOOR) {
@@ -528,6 +575,9 @@ HANDLER(n1ql_cache_clear_handler) {
528
575
  HANDLER(bucket_auth_handler) {
529
576
  const lcb_BUCKETCRED *cred;
530
577
  if (mode == LCB_CNTL_SET) {
578
+ if (LCBT_SETTING(instance, keypath)) {
579
+ return LCB_ECTL_UNSUPPMODE;
580
+ }
531
581
  /* Parse the bucket string... */
532
582
  cred = (const lcb_BUCKETCRED *)arg;
533
583
  return lcbauth_add_pass(instance->settings->auth, (*cred)[0], (*cred)[1], LCBAUTH_F_BUCKET);
@@ -551,6 +601,45 @@ HANDLER(bucket_auth_handler) {
551
601
  return LCB_SUCCESS;
552
602
  }
553
603
 
604
+ HANDLER(metrics_handler) {
605
+ if (mode == LCB_CNTL_SET) {
606
+ int val = *(int *)arg;
607
+ if (!val) {
608
+ return LCB_ECTL_BADARG;
609
+ }
610
+ if (!instance->settings->metrics) {
611
+ instance->settings->metrics = lcb_metrics_new();
612
+ }
613
+ return LCB_SUCCESS;
614
+ } else if (mode == LCB_CNTL_GET) {
615
+ *(lcb_METRICS**)arg = instance->settings->metrics;
616
+ return LCB_SUCCESS;
617
+ } else {
618
+ return LCB_ECTL_UNSUPPMODE;
619
+ }
620
+ (void)cmd;
621
+ }
622
+
623
+ HANDLER(collections_handler) {
624
+ RETURN_GET_SET(int, LCBT_SETTING(instance, use_collections));
625
+ }
626
+
627
+ HANDLER(comp_min_size_handler) {
628
+ if (mode == LCB_CNTL_SET && *reinterpret_cast<lcb_U32*>(arg) < LCB_DEFAULT_COMPRESS_MIN_SIZE) {
629
+ return LCB_ECTL_BADARG;
630
+ }
631
+ RETURN_GET_SET(lcb_U32, LCBT_SETTING(instance, compress_min_size))
632
+ }
633
+
634
+ HANDLER(comp_min_ratio_handler) {
635
+ if (mode == LCB_CNTL_SET) {
636
+ float val = *reinterpret_cast<float*>(arg);
637
+ if (val > 1 || val < 0) {
638
+ return LCB_ECTL_BADARG;
639
+ }
640
+ }
641
+ RETURN_GET_SET(float, LCBT_SETTING(instance, compress_min_ratio))
642
+ }
554
643
 
555
644
  static ctl_handler handlers[] = {
556
645
  timeout_common, /* LCB_CNTL_OP_TIMEOUT */
@@ -588,7 +677,7 @@ static ctl_handler handlers[] = {
588
677
  init_providers, /* LCB_CNTL_CONFIG_ALL_NODES */
589
678
  config_cache_handler, /* LCB_CNTL_CONFIGCACHE */
590
679
  ssl_mode_handler, /* LCB_CNTL_SSL_MODE */
591
- ssl_certpath_handler, /* LCB_CNTL_SSL_CAPATH */
680
+ ssl_certpath_handler, /* LCB_CNTL_SSL_CERT */
592
681
  retrymode_handler, /* LCB_CNTL_RETRYMODE */
593
682
  htconfig_urltype_handler, /* LCB_CNTL_HTCONFIG_URLTYPE */
594
683
  compmode_handler, /* LCB_CNTL_COMPRESSION_OPTS */
@@ -625,7 +714,25 @@ static ctl_handler handlers[] = {
625
714
  tcp_keepalive_handler, /* LCB_CNTL_TCP_KEEPALIVE */
626
715
  config_poll_interval_handler, /* LCB_CNTL_CONFIG_POLL_INTERVAL */
627
716
  send_hello_handler, /* LCB_CNTL_SEND_HELLO */
628
- buckettype_handler /* LCB_CNTL_BUCKETTYPE */
717
+ buckettype_handler, /* LCB_CNTL_BUCKETTYPE */
718
+ metrics_handler, /* LCB_CNTL_METRICS */
719
+ collections_handler, /* LCB_CNTL_USE_COLLECTIONS */
720
+ ssl_keypath_handler, /* LCB_CNTL_SSL_KEY */
721
+ log_redaction_handler, /* LCB_CNTL_LOG_REDACTION */
722
+ ssl_truststorepath_handler, /* LCB_CNTL_SSL_TRUSTSTORE */
723
+ enable_tracing_handler, /* LCB_CNTL_ENABLE_TRACING */
724
+ timeout_common, /* LCB_CNTL_TRACING_ORPHANED_QUEUE_FLUSH_INTERVAL */
725
+ tracing_orphaned_queue_size_handler, /* LCB_CNTL_TRACING_ORPHANED_QUEUE_SIZE */
726
+ timeout_common, /* LCB_CNTL_TRACING_THRESHOLD_QUEUE_FLUSH_INTERVAL */
727
+ tracing_threshold_queue_size_handler, /* LCB_CNTL_TRACING_THRESHOLD_QUEUE_SIZE */
728
+ timeout_common, /* LCB_CNTL_TRACING_THRESHOLD_KV */
729
+ timeout_common, /* LCB_CNTL_TRACING_THRESHOLD_N1QL */
730
+ timeout_common, /* LCB_CNTL_TRACING_THRESHOLD_VIEW */
731
+ timeout_common, /* LCB_CNTL_TRACING_THRESHOLD_FTS */
732
+ timeout_common, /* LCB_CNTL_TRACING_THRESHOLD_ANALYTICS */
733
+ comp_min_size_handler, /* LCB_CNTL_COMPRESSION_MIN_SIZE */
734
+ comp_min_ratio_handler, /* LCB_CNTL_COMPRESSION_MIN_RATIO */
735
+ vb_noremap_handler, /* LCB_CNTL_VB_NOREMAP */
629
736
  };
630
737
 
631
738
  /* Union used for conversion to/from string functions */
@@ -708,6 +815,7 @@ static lcb_error_t convert_compression(const char *arg, u_STRCONVERT *u) {
708
815
  { "on", LCB_COMPRESS_INOUT },
709
816
  { "off", LCB_COMPRESS_NONE },
710
817
  { "inflate_only", LCB_COMPRESS_IN },
818
+ { "deflate_only", LCB_COMPRESS_OUT },
711
819
  { "force", LCB_COMPRESS_INOUT|LCB_COMPRESS_FORCE },
712
820
  { NULL }
713
821
  };
@@ -739,6 +847,18 @@ static lcb_error_t convert_retrymode(const char *arg, u_STRCONVERT *u) {
739
847
  return LCB_SUCCESS;
740
848
  }
741
849
 
850
+ static lcb_error_t convert_ipv6(const char *arg, u_STRCONVERT *u)
851
+ {
852
+ static const STR_u32MAP optmap[] = {
853
+ {"disabled", LCB_IPV6_DISABLED},
854
+ {"only", LCB_IPV6_ONLY},
855
+ {"allow", LCB_IPV6_ALLOW},
856
+ {NULL}
857
+ };
858
+ DO_CONVERT_STR2NUM(arg, optmap, u->i);
859
+ return LCB_SUCCESS;
860
+ }
861
+
742
862
  static cntl_OPCODESTRS stropcode_map[] = {
743
863
  {"operation_timeout", LCB_CNTL_OP_TIMEOUT, convert_timevalue},
744
864
  {"timeout", LCB_CNTL_OP_TIMEOUT, convert_timevalue},
@@ -782,6 +902,22 @@ static cntl_OPCODESTRS stropcode_map[] = {
782
902
  {"tcp_keepalive", LCB_CNTL_TCP_KEEPALIVE, convert_intbool},
783
903
  {"config_poll_interval", LCB_CNTL_CONFIG_POLL_INTERVAL, convert_timevalue},
784
904
  {"send_hello", LCB_CNTL_SEND_HELLO, convert_intbool},
905
+ {"ipv6", LCB_CNTL_IP6POLICY, convert_ipv6},
906
+ {"metrics", LCB_CNTL_METRICS, convert_intbool },
907
+ {"log_redaction", LCB_CNTL_LOG_REDACTION, convert_intbool},
908
+ {"enable_tracing", LCB_CNTL_ENABLE_TRACING, convert_intbool},
909
+ {"tracing_orphaned_queue_flush_interval", LCB_CNTL_TRACING_ORPHANED_QUEUE_FLUSH_INTERVAL, convert_timevalue},
910
+ {"tracing_orphaned_queue_size", LCB_CNTL_TRACING_ORPHANED_QUEUE_SIZE, convert_u32},
911
+ {"tracing_threshold_queue_flush_interval", LCB_CNTL_TRACING_THRESHOLD_QUEUE_FLUSH_INTERVAL, convert_timevalue},
912
+ {"tracing_threshold_queue_size", LCB_CNTL_TRACING_THRESHOLD_QUEUE_SIZE, convert_u32},
913
+ {"tracing_threshold_kv", LCB_CNTL_TRACING_THRESHOLD_KV, convert_timevalue},
914
+ {"tracing_threshold_n1ql", LCB_CNTL_TRACING_THRESHOLD_N1QL, convert_timevalue},
915
+ {"tracing_threshold_view", LCB_CNTL_TRACING_THRESHOLD_VIEW, convert_timevalue},
916
+ {"tracing_threshold_fts", LCB_CNTL_TRACING_THRESHOLD_FTS, convert_timevalue},
917
+ {"tracing_threshold_analytics", LCB_CNTL_TRACING_THRESHOLD_ANALYTICS, convert_timevalue},
918
+ {"compression_min_size", LCB_CNTL_COMPRESSION_MIN_SIZE, convert_u32},
919
+ {"compression_min_ratio", LCB_CNTL_COMPRESSION_MIN_RATIO, convert_float},
920
+ {"vb_noremap", LCB_CNTL_VB_NOREMAP, convert_intbool },
785
921
  {NULL, -1}
786
922
  };
787
923
 
@@ -43,7 +43,20 @@
43
43
  #endif
44
44
 
45
45
  #ifdef HAVE_INTTYPES_H
46
+ #ifdef __cplusplus
47
+ #define __STDC_FORMAT_MACROS 1
48
+ #endif
46
49
  #include <inttypes.h>
50
+ #elif defined(_MSC_VER)
51
+ #ifndef PRIx64
52
+ #define PRIx64 "I64x"
53
+ #endif
54
+ #ifndef PRId64
55
+ #define PRId64 "I64d"
56
+ #endif
57
+ #ifndef PRIu64
58
+ #define PRIu64 "I64u"
59
+ #endif
47
60
  #endif
48
61
 
49
62
  #ifdef HAVE_NETDB_H
@@ -130,10 +143,14 @@
130
143
  extern "C" {
131
144
  #endif
132
145
  extern uint64_t lcb_byteswap64(uint64_t val);
146
+ extern uint16_t lcb_byteswap16(uint16_t val);
133
147
  #ifdef __cplusplus
134
148
  }
135
149
  #endif
136
150
 
151
+ #define lcb_ntohs(a) lcb_byteswap16(a)
152
+ #define lcb_htons(a) lcb_byteswap16(a)
153
+
137
154
  #ifdef linux
138
155
  #undef ntohs
139
156
  #undef ntohl