libcouchbase 0.3.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libcouchbase/CMakeLists.txt +6 -8
  3. data/ext/libcouchbase/README.markdown +2 -2
  4. data/ext/libcouchbase/RELEASE_NOTES.markdown +229 -2
  5. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +11 -0
  6. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +18 -0
  7. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +3 -2
  8. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  9. data/ext/libcouchbase/cmake/config-cmake.h.in +4 -0
  10. data/ext/libcouchbase/cmake/defs.mk.in +0 -2
  11. data/ext/libcouchbase/cmake/source_files.cmake +21 -5
  12. data/ext/libcouchbase/contrib/cJSON/cJSON.c +1 -1
  13. data/ext/libcouchbase/contrib/cbsasl/src/client.c +2 -0
  14. data/ext/libcouchbase/example/users/README +48 -0
  15. data/ext/libcouchbase/example/users/users.c +147 -0
  16. data/ext/libcouchbase/include/libcouchbase/auth.h +175 -31
  17. data/ext/libcouchbase/include/libcouchbase/cntl.h +82 -1
  18. data/ext/libcouchbase/include/libcouchbase/couchbase.h +45 -3
  19. data/ext/libcouchbase/include/libcouchbase/error.h +19 -1
  20. data/ext/libcouchbase/include/libcouchbase/iops.h +3 -0
  21. data/ext/libcouchbase/include/libcouchbase/n1ql.h +31 -1
  22. data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +4 -1
  23. data/ext/libcouchbase/include/libcouchbase/subdoc.h +36 -2
  24. data/ext/libcouchbase/include/libcouchbase/views.h +7 -1
  25. data/ext/libcouchbase/include/libcouchbase/visibility.h +1 -0
  26. data/ext/libcouchbase/include/memcached/protocol_binary.h +24 -1146
  27. data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
  28. data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +3 -2
  29. data/ext/libcouchbase/src/README.md +0 -2
  30. data/ext/libcouchbase/src/auth-priv.h +23 -4
  31. data/ext/libcouchbase/src/auth.cc +51 -43
  32. data/ext/libcouchbase/src/bootstrap.cc +244 -0
  33. data/ext/libcouchbase/src/bootstrap.h +58 -38
  34. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +120 -158
  35. data/ext/libcouchbase/src/bucketconfig/bc_file.cc +281 -0
  36. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +526 -0
  37. data/ext/libcouchbase/src/bucketconfig/bc_http.h +50 -25
  38. data/ext/libcouchbase/src/bucketconfig/bc_static.cc +150 -0
  39. data/ext/libcouchbase/src/bucketconfig/clconfig.h +410 -386
  40. data/ext/libcouchbase/src/bucketconfig/confmon.cc +393 -0
  41. data/ext/libcouchbase/src/cbft.cc +22 -27
  42. data/ext/libcouchbase/src/cntl.cc +56 -22
  43. data/ext/libcouchbase/src/connspec.cc +47 -6
  44. data/ext/libcouchbase/src/connspec.h +27 -0
  45. data/ext/libcouchbase/src/dns-srv.cc +147 -0
  46. data/ext/libcouchbase/src/dump.cc +3 -3
  47. data/ext/libcouchbase/src/errmap.cc +173 -0
  48. data/ext/libcouchbase/src/errmap.h +198 -0
  49. data/ext/libcouchbase/src/getconfig.cc +7 -33
  50. data/ext/libcouchbase/src/handler.cc +118 -7
  51. data/ext/libcouchbase/src/hostlist.cc +0 -36
  52. data/ext/libcouchbase/src/hostlist.h +44 -62
  53. data/ext/libcouchbase/src/http/http-priv.h +125 -112
  54. data/ext/libcouchbase/src/http/http.cc +27 -35
  55. data/ext/libcouchbase/src/http/http.h +1 -34
  56. data/ext/libcouchbase/src/http/http_io.cc +28 -36
  57. data/ext/libcouchbase/src/instance.cc +131 -34
  58. data/ext/libcouchbase/src/internal.h +58 -26
  59. data/ext/libcouchbase/src/jsparse/parser.cc +136 -210
  60. data/ext/libcouchbase/src/jsparse/parser.h +84 -98
  61. data/ext/libcouchbase/src/lcbht/lcbht.cc +177 -0
  62. data/ext/libcouchbase/src/lcbht/lcbht.h +174 -163
  63. data/ext/libcouchbase/src/lcbio/connect.cc +569 -0
  64. data/ext/libcouchbase/src/lcbio/connect.h +16 -7
  65. data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
  66. data/ext/libcouchbase/src/lcbio/iotable.h +101 -16
  67. data/ext/libcouchbase/src/lcbio/{ioutils.c → ioutils.cc} +30 -51
  68. data/ext/libcouchbase/src/lcbio/ioutils.h +29 -90
  69. data/ext/libcouchbase/src/lcbio/manager.cc +543 -0
  70. data/ext/libcouchbase/src/lcbio/manager.h +133 -96
  71. data/ext/libcouchbase/src/lcbio/protoctx.c +2 -2
  72. data/ext/libcouchbase/src/lcbio/timer-cxx.h +87 -0
  73. data/ext/libcouchbase/src/mc/mcreq.c +11 -2
  74. data/ext/libcouchbase/src/mc/mcreq.h +9 -2
  75. data/ext/libcouchbase/src/mcserver/mcserver.cc +175 -43
  76. data/ext/libcouchbase/src/mcserver/mcserver.h +9 -13
  77. data/ext/libcouchbase/src/mcserver/negotiate.cc +181 -62
  78. data/ext/libcouchbase/src/mcserver/negotiate.h +1 -3
  79. data/ext/libcouchbase/src/mctx-helper.h +51 -0
  80. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +1 -2
  81. data/ext/libcouchbase/src/n1ql/n1ql.cc +74 -42
  82. data/ext/libcouchbase/src/netbuf/netbuf.c +4 -4
  83. data/ext/libcouchbase/src/newconfig.cc +6 -6
  84. data/ext/libcouchbase/src/nodeinfo.cc +2 -2
  85. data/ext/libcouchbase/src/operations/{cbflush.c → cbflush.cc} +7 -15
  86. data/ext/libcouchbase/src/operations/{counter.c → counter.cc} +0 -0
  87. data/ext/libcouchbase/src/operations/durability.cc +6 -26
  88. data/ext/libcouchbase/src/operations/durability_internal.h +6 -3
  89. data/ext/libcouchbase/src/operations/{get.c → get.cc} +24 -26
  90. data/ext/libcouchbase/src/operations/{observe.c → observe.cc} +68 -93
  91. data/ext/libcouchbase/src/operations/{pktfwd.c → pktfwd.cc} +0 -0
  92. data/ext/libcouchbase/src/operations/{remove.c → remove.cc} +0 -0
  93. data/ext/libcouchbase/src/operations/stats.cc +3 -8
  94. data/ext/libcouchbase/src/operations/{store.c → store.cc} +27 -32
  95. data/ext/libcouchbase/src/operations/subdoc.cc +129 -42
  96. data/ext/libcouchbase/src/operations/{touch.c → touch.cc} +0 -0
  97. data/ext/libcouchbase/src/packetutils.h +30 -2
  98. data/ext/libcouchbase/src/probes.d +1 -1
  99. data/ext/libcouchbase/src/rdb/rope.c +1 -1
  100. data/ext/libcouchbase/src/{retrychk.c → retrychk.cc} +2 -3
  101. data/ext/libcouchbase/src/retryq.cc +52 -14
  102. data/ext/libcouchbase/src/retryq.h +3 -3
  103. data/ext/libcouchbase/src/settings.c +5 -0
  104. data/ext/libcouchbase/src/settings.h +11 -0
  105. data/ext/libcouchbase/src/ssl/ssl_c.c +1 -0
  106. data/ext/libcouchbase/src/ssl/ssl_common.c +2 -0
  107. data/ext/libcouchbase/src/ssl/ssl_e.c +0 -1
  108. data/ext/libcouchbase/src/strcodecs/strcodecs.h +1 -1
  109. data/ext/libcouchbase/src/trace.h +4 -4
  110. data/ext/libcouchbase/src/vbucket/vbucket.c +6 -10
  111. data/ext/libcouchbase/src/views/{docreq.c → docreq.cc} +48 -54
  112. data/ext/libcouchbase/src/views/docreq.h +24 -30
  113. data/ext/libcouchbase/src/views/viewreq.cc +318 -0
  114. data/ext/libcouchbase/src/views/viewreq.h +43 -13
  115. data/ext/libcouchbase/tests/basic/t_connstr.cc +88 -50
  116. data/ext/libcouchbase/tests/basic/t_creds.cc +47 -5
  117. data/ext/libcouchbase/tests/basic/t_host.cc +67 -75
  118. data/ext/libcouchbase/tests/basic/t_jsparse.cc +27 -82
  119. data/ext/libcouchbase/tests/basic/t_misc.cc +1 -1
  120. data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +0 -1
  121. data/ext/libcouchbase/tests/htparse/t_basic.cc +58 -78
  122. data/ext/libcouchbase/tests/ioserver/connection.cc +1 -1
  123. data/ext/libcouchbase/tests/ioserver/ioserver.cc +19 -6
  124. data/ext/libcouchbase/tests/iotests/mock-environment.cc +28 -2
  125. data/ext/libcouchbase/tests/iotests/mock-environment.h +51 -1
  126. data/ext/libcouchbase/tests/iotests/t_behavior.cc +1 -7
  127. data/ext/libcouchbase/tests/iotests/t_confmon.cc +97 -115
  128. data/ext/libcouchbase/tests/iotests/t_durability.cc +0 -1
  129. data/ext/libcouchbase/tests/iotests/t_eerrs.cc +119 -0
  130. data/ext/libcouchbase/tests/iotests/t_errmap.cc +178 -0
  131. data/ext/libcouchbase/tests/iotests/t_misc.cc +3 -3
  132. data/ext/libcouchbase/tests/iotests/t_netfail.cc +1 -1
  133. data/ext/libcouchbase/tests/iotests/t_obseqno.cc +0 -1
  134. data/ext/libcouchbase/tests/iotests/t_subdoc.cc +18 -11
  135. data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
  136. data/ext/libcouchbase/tests/socktests/socktest.cc +7 -10
  137. data/ext/libcouchbase/tests/socktests/socktest.h +2 -3
  138. data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
  139. data/ext/libcouchbase/tests/socktests/t_manager.cc +5 -6
  140. data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
  141. data/ext/libcouchbase/tests/vbucket/confdata/ketama_expected.json +2562 -0
  142. data/ext/libcouchbase/tests/vbucket/confdata/memd_ketama_config.json +31 -0
  143. data/ext/libcouchbase/tests/vbucket/t_config.cc +35 -5
  144. data/ext/libcouchbase/tools/CMakeLists.txt +2 -2
  145. data/ext/libcouchbase/tools/cbc-handlers.h +128 -0
  146. data/ext/libcouchbase/tools/cbc-n1qlback.cc +64 -10
  147. data/ext/libcouchbase/tools/cbc-pillowfight.cc +2 -2
  148. data/ext/libcouchbase/tools/cbc.cc +143 -10
  149. data/ext/libcouchbase/tools/docgen/loc.h +1 -1
  150. data/lib/libcouchbase/connection.rb +4 -3
  151. data/lib/libcouchbase/version.rb +1 -1
  152. metadata +37 -28
  153. data/ext/libcouchbase/include/memcached/vbucket.h +0 -42
  154. data/ext/libcouchbase/src/bootstrap.c +0 -269
  155. data/ext/libcouchbase/src/bucketconfig/bc_file.c +0 -347
  156. data/ext/libcouchbase/src/bucketconfig/bc_http.c +0 -630
  157. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +0 -150
  158. data/ext/libcouchbase/src/bucketconfig/confmon.c +0 -474
  159. data/ext/libcouchbase/src/lcbht/lcbht.c +0 -282
  160. data/ext/libcouchbase/src/lcbio/connect.c +0 -557
  161. data/ext/libcouchbase/src/lcbio/manager.c +0 -584
  162. data/ext/libcouchbase/src/packetutils.c +0 -37
  163. data/ext/libcouchbase/src/simplestring.c +0 -211
  164. data/ext/libcouchbase/src/simplestring.h +0 -228
  165. data/ext/libcouchbase/src/ssobuf.h +0 -82
  166. data/ext/libcouchbase/src/views/viewreq.c +0 -358
  167. data/ext/libcouchbase/tests/basic/t_string.cc +0 -112
@@ -38,7 +38,7 @@
38
38
  struct lcb_settings_st;
39
39
 
40
40
  namespace lcb {
41
- class SessionRequest {
41
+ class SessionRequest : public lcb::io::ConnectionRequest {
42
42
  public:
43
43
  /**
44
44
  * @brief Start negotiation on a connected socket
@@ -82,8 +82,6 @@ public:
82
82
  };
83
83
  class SessionRequestImpl;
84
84
 
85
- extern "C" { void sessreq_cancel(SessionRequest *); }
86
-
87
85
  class SessionInfo : public lcbio_PROTOCTX {
88
86
  public:
89
87
  /**
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Copyright 2016 Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #ifndef LCB_MCTX_HELPER_H
18
+ #define LCB_MCTX_HELPER_H
19
+ #include <libcouchbase/couchbase.h>
20
+
21
+ namespace lcb {
22
+
23
+ class MultiCmdContext : public lcb_MULTICMD_CTX {
24
+ protected:
25
+ virtual lcb_error_t MCTX_addcmd(const lcb_CMDBASE* cmd) = 0;
26
+ virtual lcb_error_t MCTX_done(const void *cookie) = 0;
27
+ virtual void MCTX_fail() = 0;
28
+
29
+ MultiCmdContext() {
30
+ lcb_MULTICMD_CTX::addcmd = dispatch_mctx_addcmd;
31
+ lcb_MULTICMD_CTX::done = dispatch_mctx_done;
32
+ lcb_MULTICMD_CTX::fail = dispatch_mctx_fail;
33
+ }
34
+
35
+ virtual ~MultiCmdContext() {}
36
+
37
+ private:
38
+ static lcb_error_t dispatch_mctx_addcmd(lcb_MULTICMD_CTX* ctx, const lcb_CMDBASE * cmd) {
39
+ return static_cast<MultiCmdContext*>(ctx)->MCTX_addcmd(cmd);
40
+ }
41
+ static lcb_error_t dispatch_mctx_done(lcb_MULTICMD_CTX* ctx, const void *cookie) {
42
+ return static_cast<MultiCmdContext*>(ctx)->MCTX_done(cookie);
43
+ }
44
+ static void dispatch_mctx_fail(lcb_MULTICMD_CTX* ctx) {
45
+ static_cast<MultiCmdContext*>(ctx)->MCTX_fail();
46
+ }
47
+ };
48
+
49
+ }
50
+
51
+ #endif
@@ -210,8 +210,7 @@ dispatch_common(lcb_t instance,
210
210
  // mind-numbing buffer copies. Maybe this can be done via a macro instead?
211
211
  class IndexSpec : public lcb_N1XSPEC {
212
212
  public:
213
- IndexSpec(const char *s, size_t n) {
214
- memset(static_cast<lcb_N1XSPEC*>(this), 0, sizeof (lcb_N1XSPEC));
213
+ IndexSpec(const char *s, size_t n) : lcb_N1XSPEC() {
215
214
  load_json(s, n);
216
215
  }
217
216
  inline IndexSpec(const lcb_N1XSPEC *spec);
@@ -142,10 +142,10 @@ struct lcb_N1QLCACHE_st {
142
142
  }
143
143
  };
144
144
 
145
- typedef struct lcb_N1QLREQ {
145
+ typedef struct lcb_N1QLREQ : lcb::jsparse::Parser::Actions {
146
146
  const lcb_RESPHTTP *cur_htresp;
147
147
  struct lcb_http_request_st *htreq;
148
- lcbjsp_PARSER *parser;
148
+ lcb::jsparse::Parser *parser;
149
149
  const void *cookie;
150
150
  lcb_N1QLCALLBACK callback;
151
151
  lcb_t instance;
@@ -155,6 +155,9 @@ typedef struct lcb_N1QLREQ {
155
155
  // How many rows were received. Used to avoid parsing the meta
156
156
  size_t nrows;
157
157
 
158
+ // Host for CBAS/Analytics query
159
+ std::string cbashost;
160
+
158
161
  /** The PREPARE query itself */
159
162
  struct lcb_N1QLREQ *prepare_req;
160
163
 
@@ -227,9 +230,28 @@ typedef struct lcb_N1QLREQ {
227
230
  */
228
231
  inline void fail_prepared(const lcb_RESPN1QL *orig, lcb_error_t err);
229
232
 
233
+ bool is_cbas() const {
234
+ return !cbashost.empty();
235
+ }
236
+
230
237
  inline lcb_N1QLREQ(lcb_t obj, const void *user_cookie, const lcb_CMDN1QL *cmd);
231
238
  inline ~lcb_N1QLREQ();
232
239
 
240
+ // Parser overrides:
241
+ void JSPARSE_on_row(const lcb::jsparse::Row& row) {
242
+ lcb_RESPN1QL resp = { 0 };
243
+ resp.row = static_cast<const char *>(row.row.iov_base);
244
+ resp.nrow = row.row.iov_len;
245
+ nrows++;
246
+ invoke_row(&resp, false);
247
+ }
248
+ void JSPARSE_on_error(const std::string&) {
249
+ lasterr = LCB_PROTOCOL_ERROR;
250
+ }
251
+ void JSPARSE_on_complete(const std::string&) {
252
+ // Nothing
253
+ }
254
+
233
255
  } N1QLREQ;
234
256
 
235
257
  static bool
@@ -269,8 +291,12 @@ lcb_n1qlcache_getplan(lcb_N1QLCACHE *cache,
269
291
  }
270
292
  }
271
293
 
272
- #define WTF_MAGIC_STRING \
273
- "index deleted or node hosting the index is down - cause: queryport.indexNotFound"
294
+
295
+ static const char *wtf_magic_strings[] = {
296
+ "index deleted or node hosting the index is down - cause: queryport.indexNotFound",
297
+ "Index Not Found - cause: queryport.indexNotFound",
298
+ NULL
299
+ };
274
300
 
275
301
  static bool
276
302
  has_retriable_error(const Json::Value& root)
@@ -296,8 +322,13 @@ has_retriable_error(const Json::Value& root)
296
322
  return true;
297
323
  }
298
324
  }
299
- if (jmsg.isString() && strstr(jmsg.asCString(), WTF_MAGIC_STRING) != NULL) {
300
- return true;
325
+ if (jmsg.isString()) {
326
+ const char *jmstr = jmsg.asCString();
327
+ for (const char **curs = wtf_magic_strings; *curs; curs++) {
328
+ if (!strstr(jmstr, *curs)) {
329
+ return true;
330
+ }
331
+ }
301
332
  }
302
333
  }
303
334
  return false;
@@ -330,8 +361,7 @@ N1QLREQ::maybe_retry()
330
361
  }
331
362
 
332
363
  was_retried = true;
333
-
334
- lcbjsp_get_postmortem(parser, &meta);
364
+ parser->get_postmortem(meta);
335
365
  if (!parse_json(static_cast<const char*>(meta.iov_base), meta.iov_len, root)) {
336
366
  return false; // Not JSON
337
367
  }
@@ -344,16 +374,15 @@ N1QLREQ::maybe_retry()
344
374
  // Let's see if we can actually retry. First remove the existing prepared
345
375
  // entry:
346
376
  cache().remove_entry(statement);
347
- lcb_error_t rc = request_plan();
348
- if (rc != LCB_SUCCESS) {
349
- lasterr = rc;
350
- return false;
351
377
 
352
- } else {
378
+ if ((lasterr = request_plan()) == LCB_SUCCESS) {
353
379
  // We'll be parsing more rows later on..
354
- lcbjsp_reset(parser);
380
+ delete parser;
381
+ parser = new lcb::jsparse::Parser(lcb::jsparse::Parser::MODE_N1QL, this);
382
+ return true;
355
383
  }
356
- return true;
384
+
385
+ return false;
357
386
  }
358
387
 
359
388
  void
@@ -366,7 +395,7 @@ N1QLREQ::invoke_row(lcb_RESPN1QL *resp, bool is_last)
366
395
  lcb_IOV meta;
367
396
  resp->rflags |= LCB_RESP_F_FINAL;
368
397
  resp->rc = lasterr;
369
- lcbjsp_get_postmortem(parser, &meta);
398
+ parser->get_postmortem(meta);
370
399
  resp->row = static_cast<const char*>(meta.iov_base);
371
400
  resp->nrow = meta.iov_len;
372
401
  }
@@ -392,31 +421,13 @@ lcb_N1QLREQ::~lcb_N1QLREQ()
392
421
  }
393
422
 
394
423
  if (parser) {
395
- lcbjsp_free(parser);
424
+ delete parser;
396
425
  }
397
426
  if (prepare_req) {
398
427
  lcb_n1ql_cancel(instance, prepare_req);
399
428
  }
400
429
  }
401
430
 
402
- static void
403
- row_callback(lcbjsp_PARSER *parser, const lcbjsp_ROW *datum)
404
- {
405
- N1QLREQ *req = static_cast<N1QLREQ*>(parser->data);
406
- lcb_RESPN1QL resp = { 0 };
407
-
408
- if (datum->type == LCBJSP_TYPE_ROW) {
409
- resp.row = static_cast<const char*>(datum->row.iov_base);
410
- resp.nrow = datum->row.iov_len;
411
- req->nrows++;
412
- req->invoke_row(&resp, 0);
413
- } else if (datum->type == LCBJSP_TYPE_ERROR) {
414
- req->lasterr = resp.rc = LCB_PROTOCOL_ERROR;
415
- } else if (datum->type == LCBJSP_TYPE_COMPLETE) {
416
- /* Nothing */
417
- }
418
- }
419
-
420
431
  static void
421
432
  chunk_callback(lcb_t instance, int ign, const lcb_RESPBASE *rb)
422
433
  {
@@ -444,8 +455,7 @@ chunk_callback(lcb_t instance, int ign, const lcb_RESPBASE *rb)
444
455
  delete req;
445
456
  return;
446
457
  }
447
-
448
- lcbjsp_feed(req->parser, static_cast<const char*>(rh->body), rh->nbody);
458
+ req->parser->feed(static_cast<const char*>(rh->body), rh->nbody);
449
459
  }
450
460
 
451
461
  #define QUERY_PATH "/query/service"
@@ -512,7 +522,14 @@ N1QLREQ::issue_htreq(const std::string& body)
512
522
 
513
523
  htcmd.content_type = "application/json";
514
524
  htcmd.method = LCB_HTTP_METHOD_POST;
515
- htcmd.type = LCB_HTTP_TYPE_N1QL;
525
+
526
+ if (is_cbas()) {
527
+ htcmd.type = LCB_HTTP_TYPE_RAW;
528
+ htcmd.host = cbashost.c_str();
529
+ } else {
530
+ htcmd.type = LCB_HTTP_TYPE_N1QL;
531
+ }
532
+
516
533
  htcmd.cmdflags = LCB_CMDHTTP_F_STREAM|LCB_CMDHTTP_F_CASTMO;
517
534
  if (flags & F_CMDN1QL_CREDSAUTH) {
518
535
  htcmd.cmdflags |= LCB_CMDHTTP_F_NOUPASS;
@@ -522,7 +539,7 @@ N1QLREQ::issue_htreq(const std::string& body)
522
539
 
523
540
  lcb_error_t rc = lcb_http3(instance, this, &htcmd);
524
541
  if (rc == LCB_SUCCESS) {
525
- lcb_htreq_setcb(htreq, chunk_callback);
542
+ htreq->set_callback(chunk_callback);
526
543
  }
527
544
  return rc;
528
545
  }
@@ -586,13 +603,12 @@ lcb_n1qlreq_parsetmo(const std::string& s)
586
603
 
587
604
  lcb_N1QLREQ::lcb_N1QLREQ(lcb_t obj,
588
605
  const void *user_cookie, const lcb_CMDN1QL *cmd)
589
- : cur_htresp(NULL), htreq(NULL), parser(lcbjsp_create(LCBJSP_MODE_N1QL)),
606
+ : cur_htresp(NULL), htreq(NULL),
607
+ parser(new lcb::jsparse::Parser(lcb::jsparse::Parser::MODE_N1QL, this)),
590
608
  cookie(user_cookie), callback(cmd->callback), instance(obj),
591
609
  lasterr(LCB_SUCCESS), flags(cmd->cmdflags), timeout(0),
592
610
  nrows(0), prepare_req(NULL), was_retried(false)
593
611
  {
594
- parser->data = this;
595
- parser->callback = row_callback;
596
612
  if (cmd->handle) {
597
613
  *cmd->handle = this;
598
614
  }
@@ -604,6 +620,22 @@ lcb_N1QLREQ::lcb_N1QLREQ(lcb_t obj,
604
620
  return;
605
621
  }
606
622
 
623
+ if (flags & LCB_CMDN1QL_F_CBASQUERY) {
624
+ if (!cmd->host) {
625
+ lasterr = LCB_EINVAL;
626
+ return;
627
+ }
628
+ cbashost.assign(cmd->host);
629
+ if (cbashost.empty()) {
630
+ lasterr = LCB_EINVAL;
631
+ return;
632
+ }
633
+ if (flags & LCB_CMDN1QL_F_PREPCACHE) {
634
+ lasterr = LCB_OPTIONS_CONFLICT;
635
+ return;
636
+ }
637
+ }
638
+
607
639
  const Json::Value& j_statement = json_const()["statement"];
608
640
  if (j_statement.isString()) {
609
641
  statement = j_statement.asString();
@@ -405,7 +405,7 @@ mblock_release_ptr(nb_MBPOOL *pool, char * ptr, nb_SIZE size)
405
405
  return;
406
406
  }
407
407
 
408
- fprintf(stderr, "NETBUF: Requested to release pointer %p which was not allocated\n", ptr);
408
+ fprintf(stderr, "NETBUF: Requested to release pointer %p which was not allocated\n", (void *)ptr);
409
409
  assert(0);
410
410
  }
411
411
 
@@ -785,7 +785,7 @@ dump_managed_block(nb_MBLOCK *block, FILE *fp)
785
785
  {
786
786
  const char *indent = " ";
787
787
  fprintf(fp, "%sBLOCK(MANAGED)=%p; BUF=%p, %uB\n", indent,
788
- (void *)block, block->root, block->nalloc);
788
+ (void *)block, (void *)block->root, block->nalloc);
789
789
  indent = " ";
790
790
 
791
791
  fprintf(fp, "%sUSAGE:\n", indent);
@@ -828,7 +828,7 @@ dump_sendq(nb_SENDQ *q, FILE *fp)
828
828
  fprintf(fp, "Send Queue\n");
829
829
  SLLIST_FOREACH(&q->pending, ll) {
830
830
  nb_SNDQELEM *e = SLLIST_ITEM(ll, nb_SNDQELEM, slnode);
831
- fprintf(fp, "%s[Base=%p, Len=%u]\n", indent, e->base, e->len);
831
+ fprintf(fp, "%s[Base=%p, Len=%u]\n", indent, (void *)e->base, e->len);
832
832
  if (q->last_requested == e) {
833
833
  fprintf(fp, "%s<Current Flush Limit @%u^^^>\n", indent, q->last_offset);
834
834
  }
@@ -851,7 +851,7 @@ netbuf_dump_status(nb_MGR *mgr, FILE *fp)
851
851
  nb_MBLOCK *block = SLLIST_ITEM(ll, nb_MBLOCK, slnode);
852
852
  const char *indent = " ";
853
853
  fprintf(fp, "%sBLOCK(AVAIL)=%p; BUF=%p, %uB\n", indent,
854
- (void*)block, block->root, block->nalloc);
854
+ (void*)block, (void *)block->root, block->nalloc);
855
855
  }
856
856
  dump_sendq(&mgr->sendq, fp);
857
857
  }
@@ -221,7 +221,7 @@ iterwipe_cb(mc_CMDQUEUE *cq, mc_PIPELINE *oldpl, mc_PACKET *oldpkt, void *)
221
221
  return MCREQ_KEEP_PACKET;
222
222
  }
223
223
 
224
- lcb_log(LOGARGS((lcb_t)cq->cqdata, DEBUG), "Remapped packet %p (SEQ=%u) from "SERVER_FMT " to " SERVER_FMT,
224
+ lcb_log(LOGARGS((lcb_t)cq->cqdata, DEBUG), "Remapped packet %p (SEQ=%u) from " SERVER_FMT " to " SERVER_FMT,
225
225
  (void*)oldpkt, oldpkt->opaque, SERVER_ARGS((lcb::Server*)oldpl), SERVER_ARGS((lcb::Server*)newpl));
226
226
 
227
227
  /** Otherwise, copy over the packet and find the new vBucket to map to */
@@ -256,7 +256,7 @@ replace_config(lcb_t instance, lcbvb_CONFIG *oldconfig, lcbvb_CONFIG *newconfig)
256
256
  cur->set_new_index(newix);
257
257
  ppnew[newix] = cur;
258
258
  ppold[ii] = NULL;
259
- lcb_log(LOGARGS(instance, INFO), "Reusing server "SERVER_FMT". OldIndex=%d. NewIndex=%d", SERVER_ARGS(cur), ii, newix);
259
+ lcb_log(LOGARGS(instance, INFO), "Reusing server " SERVER_FMT ". OldIndex=%d. NewIndex=%d", SERVER_ARGS(cur), ii, newix);
260
260
  }
261
261
  }
262
262
 
@@ -305,14 +305,14 @@ replace_config(lcb_t instance, lcbvb_CONFIG *oldconfig, lcbvb_CONFIG *newconfig)
305
305
  free(ppold);
306
306
  }
307
307
 
308
- void lcb_update_vbconfig(lcb_t instance, clconfig_info *config)
308
+ void lcb_update_vbconfig(lcb_t instance, lcb_pCONFIGINFO config)
309
309
  {
310
310
  lcb_configuration_t change_status;
311
- clconfig_info *old_config = instance->cur_configinfo;
311
+ lcb::clconfig::ConfigInfo *old_config = instance->cur_configinfo;
312
312
  mc_CMDQUEUE *q = &instance->cmdq;
313
313
 
314
314
  instance->cur_configinfo = config;
315
- lcb_clconfig_incref(config);
315
+ config->incref();
316
316
  q->config = instance->cur_configinfo->vbc;
317
317
  q->cqdata = instance;
318
318
 
@@ -328,7 +328,7 @@ void lcb_update_vbconfig(lcb_t instance, clconfig_info *config)
328
328
  lcb_vbguess_newconfig(instance, config->vbc, instance->vbguess);
329
329
 
330
330
  replace_config(instance, old_config->vbc, config->vbc);
331
- lcb_clconfig_decref(old_config);
331
+ old_config->decref();
332
332
  change_status = LCB_CONFIGURATION_CHANGED;
333
333
  } else {
334
334
  size_t nservers = VB_NSERVERS(config->vbc);
@@ -70,7 +70,7 @@ lcb_get_node(lcb_t instance, lcb_GETNODETYPE type, unsigned ix)
70
70
 
71
71
  if (type & LCB_NODE_HTCONFIG) {
72
72
  if (type & LCB_NODE_CONNECTED) {
73
- const lcb_host_t *host = lcb_confmon_get_rest_host(instance->confmon);
73
+ const lcb_host_t *host = lcb::clconfig::http_get_host(instance->confmon);
74
74
  if (host) {
75
75
  return mk_scratch_host(instance, host);
76
76
  } else {
@@ -167,7 +167,7 @@ lcb_int32_t lcb_get_num_nodes(lcb_t instance)
167
167
  LIBCOUCHBASE_API
168
168
  const char *const *lcb_get_server_list(lcb_t instance)
169
169
  {
170
- return hostlist_strents(instance->ht_nodes);
170
+ return instance->ht_nodes->get_strlist();
171
171
  }
172
172
 
173
173
  LIBCOUCHBASE_API
@@ -15,11 +15,10 @@
15
15
  */
16
16
 
17
17
  #include "internal.h"
18
- #include "simplestring.h"
19
18
  #include <http/http.h>
20
19
 
21
20
  static void
22
- flush_cb(lcb_t instance, int cbtype, const lcb_RESPBASE *rb)
21
+ flush_cb(lcb_t instance, int, const lcb_RESPBASE *rb)
23
22
  {
24
23
  const lcb_RESPHTTP *resp = (const lcb_RESPHTTP *)rb;
25
24
  lcb_RESPCBFLUSH fresp = { 0 };
@@ -35,37 +34,30 @@ flush_cb(lcb_t instance, int cbtype, const lcb_RESPBASE *rb)
35
34
  if (callback) {
36
35
  callback(instance, LCB_CALLBACK_CBFLUSH, (lcb_RESPBASE*)&fresp);
37
36
  }
38
- (void)cbtype;
39
37
  }
40
38
 
41
39
  LIBCOUCHBASE_API
42
40
  lcb_error_t
43
- lcb_cbflush3(lcb_t instance, const void *cookie, const lcb_CMDBASE *cmd)
41
+ lcb_cbflush3(lcb_t instance, const void *cookie, const lcb_CMDBASE *)
44
42
  {
45
43
  lcb_http_request_t htr;
46
44
  lcb_CMDHTTP htcmd = { 0 };
47
- lcb_string urlpath;
48
45
  lcb_error_t rc;
49
46
 
50
- (void)cmd;
51
-
52
- lcb_string_init(&urlpath);
53
- lcb_string_appendz(&urlpath, "/pools/default/buckets/");
54
- lcb_string_appendz(&urlpath, LCBT_SETTING(instance, bucket));
55
- lcb_string_appendz(&urlpath, "/controller/doFlush");
56
-
47
+ std::string urlpath("/pools/default/buckets/");
48
+ urlpath.append(LCBT_SETTING(instance, bucket));
49
+ urlpath.append("/controller/doFlush");
57
50
 
58
51
  htcmd.type = LCB_HTTP_TYPE_MANAGEMENT;
59
52
  htcmd.method = LCB_HTTP_METHOD_POST;
60
53
  htcmd.reqhandle = &htr;
61
- LCB_CMD_SET_KEY(&htcmd, urlpath.base, urlpath.nused);
54
+ LCB_CMD_SET_KEY(&htcmd, urlpath.c_str(), urlpath.size());
62
55
 
63
56
  rc = lcb_http3(instance, cookie, &htcmd);
64
- lcb_string_release(&urlpath);
65
57
 
66
58
  if (rc != LCB_SUCCESS) {
67
59
  return rc;
68
60
  }
69
- lcb_htreq_setcb(htr, flush_cb);
61
+ htr->set_callback(flush_cb);
70
62
  return LCB_SUCCESS;
71
63
  }