libcouchbase 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libcouchbase/.gitignore +2 -0
  3. data/ext/libcouchbase/CMakeLists.txt +5 -7
  4. data/ext/libcouchbase/README.markdown +2 -2
  5. data/ext/libcouchbase/RELEASE_NOTES.markdown +49 -0
  6. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +11 -0
  7. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -0
  8. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +2 -1
  9. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  10. data/ext/libcouchbase/cmake/config-cmake.h.in +2 -0
  11. data/ext/libcouchbase/cmake/defs.mk.in +0 -2
  12. data/ext/libcouchbase/cmake/source_files.cmake +34 -14
  13. data/ext/libcouchbase/configure.pl +1 -1
  14. data/ext/libcouchbase/contrib/genhash/genhash.h +6 -0
  15. data/ext/libcouchbase/include/libcouchbase/auth.h +10 -0
  16. data/ext/libcouchbase/include/libcouchbase/couchbase.h +10 -0
  17. data/ext/libcouchbase/include/libcouchbase/error.h +7 -0
  18. data/ext/libcouchbase/include/libcouchbase/n1ql.h +13 -1
  19. data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +1 -1
  20. data/ext/libcouchbase/include/libcouchbase/subdoc.h +9 -0
  21. data/ext/libcouchbase/include/libcouchbase/views.h +7 -1
  22. data/ext/libcouchbase/include/libcouchbase/visibility.h +1 -0
  23. data/ext/libcouchbase/include/memcached/protocol_binary.h +21 -1132
  24. data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
  25. data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +3 -2
  26. data/ext/libcouchbase/src/README.md +0 -2
  27. data/ext/libcouchbase/src/auth-priv.h +1 -0
  28. data/ext/libcouchbase/src/auth.cc +10 -0
  29. data/ext/libcouchbase/src/bootstrap.cc +216 -0
  30. data/ext/libcouchbase/src/bootstrap.h +50 -39
  31. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +455 -0
  32. data/ext/libcouchbase/src/bucketconfig/bc_file.cc +281 -0
  33. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +528 -0
  34. data/ext/libcouchbase/src/bucketconfig/bc_http.h +50 -25
  35. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.cc +115 -0
  36. data/ext/libcouchbase/src/bucketconfig/clconfig.h +407 -386
  37. data/ext/libcouchbase/src/bucketconfig/confmon.cc +378 -0
  38. data/ext/libcouchbase/src/cbft.cc +22 -27
  39. data/ext/libcouchbase/src/cntl.cc +24 -24
  40. data/ext/libcouchbase/src/connspec.cc +30 -1
  41. data/ext/libcouchbase/src/connspec.h +17 -0
  42. data/ext/libcouchbase/src/dns-srv.cc +143 -0
  43. data/ext/libcouchbase/src/{dump.c → dump.cc} +8 -11
  44. data/ext/libcouchbase/src/getconfig.cc +73 -0
  45. data/ext/libcouchbase/src/handler.cc +84 -85
  46. data/ext/libcouchbase/src/hostlist.cc +0 -1
  47. data/ext/libcouchbase/src/hostlist.h +6 -1
  48. data/ext/libcouchbase/src/http/http-priv.h +125 -112
  49. data/ext/libcouchbase/src/http/http.cc +9 -29
  50. data/ext/libcouchbase/src/http/http.h +1 -34
  51. data/ext/libcouchbase/src/http/http_io.cc +22 -26
  52. data/ext/libcouchbase/src/instance.cc +102 -28
  53. data/ext/libcouchbase/src/internal.h +47 -29
  54. data/ext/libcouchbase/src/jsparse/parser.cc +146 -202
  55. data/ext/libcouchbase/src/jsparse/parser.h +91 -98
  56. data/ext/libcouchbase/src/lcbht/lcbht.cc +177 -0
  57. data/ext/libcouchbase/src/lcbht/lcbht.h +174 -163
  58. data/ext/libcouchbase/src/lcbio/connect.cc +562 -0
  59. data/ext/libcouchbase/src/lcbio/connect.h +9 -2
  60. data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
  61. data/ext/libcouchbase/src/lcbio/iotable.h +61 -16
  62. data/ext/libcouchbase/src/lcbio/ioutils.h +1 -1
  63. data/ext/libcouchbase/src/lcbio/manager.c +2 -2
  64. data/ext/libcouchbase/src/lcbio/timer-cxx.h +87 -0
  65. data/ext/libcouchbase/src/mc/mcreq.h +9 -2
  66. data/ext/libcouchbase/src/mcserver/mcserver.cc +723 -0
  67. data/ext/libcouchbase/src/mcserver/mcserver.h +160 -70
  68. data/ext/libcouchbase/src/mcserver/negotiate.cc +118 -152
  69. data/ext/libcouchbase/src/mcserver/negotiate.h +85 -74
  70. data/ext/libcouchbase/src/mctx-helper.h +51 -0
  71. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +1 -2
  72. data/ext/libcouchbase/src/n1ql/n1ql.cc +56 -32
  73. data/ext/libcouchbase/src/{newconfig.c → newconfig.cc} +42 -70
  74. data/ext/libcouchbase/src/nodeinfo.cc +4 -8
  75. data/ext/libcouchbase/src/operations/{cbflush.c → cbflush.cc} +7 -15
  76. data/ext/libcouchbase/src/operations/{counter.c → counter.cc} +0 -0
  77. data/ext/libcouchbase/src/operations/{durability-cas.c → durability-cas.cc} +92 -76
  78. data/ext/libcouchbase/src/operations/{durability-seqno.c → durability-seqno.cc} +55 -49
  79. data/ext/libcouchbase/src/operations/durability.cc +643 -0
  80. data/ext/libcouchbase/src/operations/durability_internal.h +212 -124
  81. data/ext/libcouchbase/src/operations/{get.c → get.cc} +24 -26
  82. data/ext/libcouchbase/src/operations/{observe-seqno.c → observe-seqno.cc} +5 -8
  83. data/ext/libcouchbase/src/operations/{observe.c → observe.cc} +69 -94
  84. data/ext/libcouchbase/src/operations/{pktfwd.c → pktfwd.cc} +0 -0
  85. data/ext/libcouchbase/src/operations/{remove.c → remove.cc} +0 -0
  86. data/ext/libcouchbase/src/operations/{stats.c → stats.cc} +66 -78
  87. data/ext/libcouchbase/src/operations/{store.c → store.cc} +27 -32
  88. data/ext/libcouchbase/src/operations/subdoc.cc +38 -18
  89. data/ext/libcouchbase/src/operations/{touch.c → touch.cc} +0 -0
  90. data/ext/libcouchbase/src/packetutils.h +200 -137
  91. data/ext/libcouchbase/src/probes.d +1 -1
  92. data/ext/libcouchbase/src/{retrychk.c → retrychk.cc} +3 -4
  93. data/ext/libcouchbase/src/retryq.cc +394 -0
  94. data/ext/libcouchbase/src/retryq.h +116 -104
  95. data/ext/libcouchbase/src/settings.h +2 -1
  96. data/ext/libcouchbase/src/ssl/ssl_c.c +1 -0
  97. data/ext/libcouchbase/src/ssl/ssl_e.c +0 -1
  98. data/ext/libcouchbase/src/trace.h +8 -8
  99. data/ext/libcouchbase/src/vbucket/vbucket.c +0 -1
  100. data/ext/libcouchbase/src/views/{docreq.c → docreq.cc} +48 -54
  101. data/ext/libcouchbase/src/views/docreq.h +24 -30
  102. data/ext/libcouchbase/src/views/viewreq.cc +318 -0
  103. data/ext/libcouchbase/src/views/viewreq.h +43 -13
  104. data/ext/libcouchbase/src/{wait.c → wait.cc} +12 -17
  105. data/ext/libcouchbase/tests/basic/t_connstr.cc +89 -50
  106. data/ext/libcouchbase/tests/basic/t_jsparse.cc +27 -78
  107. data/ext/libcouchbase/tests/basic/t_packet.cc +35 -42
  108. data/ext/libcouchbase/tests/htparse/t_basic.cc +58 -78
  109. data/ext/libcouchbase/tests/iotests/t_confmon.cc +94 -111
  110. data/ext/libcouchbase/tests/iotests/t_sched.cc +1 -2
  111. data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
  112. data/ext/libcouchbase/tools/cbc-pillowfight.cc +1 -1
  113. data/lib/libcouchbase/version.rb +1 -1
  114. metadata +36 -39
  115. data/ext/libcouchbase/include/memcached/vbucket.h +0 -42
  116. data/ext/libcouchbase/src/bootstrap.c +0 -269
  117. data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +0 -495
  118. data/ext/libcouchbase/src/bucketconfig/bc_file.c +0 -347
  119. data/ext/libcouchbase/src/bucketconfig/bc_http.c +0 -630
  120. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +0 -150
  121. data/ext/libcouchbase/src/bucketconfig/confmon.c +0 -474
  122. data/ext/libcouchbase/src/getconfig.c +0 -100
  123. data/ext/libcouchbase/src/lcbht/lcbht.c +0 -282
  124. data/ext/libcouchbase/src/lcbio/connect.c +0 -557
  125. data/ext/libcouchbase/src/mcserver/mcserver.c +0 -784
  126. data/ext/libcouchbase/src/operations/durability.c +0 -668
  127. data/ext/libcouchbase/src/packetutils.c +0 -60
  128. data/ext/libcouchbase/src/retryq.c +0 -424
  129. data/ext/libcouchbase/src/simplestring.c +0 -211
  130. data/ext/libcouchbase/src/simplestring.h +0 -228
  131. data/ext/libcouchbase/src/ssobuf.h +0 -82
  132. data/ext/libcouchbase/src/views/viewreq.c +0 -358
  133. data/ext/libcouchbase/tests/basic/t_string.cc +0 -112
@@ -0,0 +1,378 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2013 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include "internal.h"
19
+ #include "clconfig.h"
20
+ #include <list>
21
+ #include <algorithm>
22
+
23
+ #define LOGARGS(mon, lvlbase) mon->settings, "confmon", LCB_LOG_##lvlbase, __FILE__, __LINE__
24
+ #define LOG(mon, lvlbase, msg) lcb_log(mon->settings, "confmon", LCB_LOG_##lvlbase, __FILE__, __LINE__, msg)
25
+
26
+ using namespace lcb::clconfig;
27
+
28
+ Provider* Confmon::next_active(Provider *cur) {
29
+ ProviderList::iterator ii = std::find(
30
+ active_providers.begin(), active_providers.end(), cur);
31
+
32
+ if (ii == active_providers.end() || (++ii) == active_providers.end()) {
33
+ return NULL;
34
+ } else {
35
+ return *ii;
36
+ }
37
+ }
38
+
39
+ Provider* Confmon::first_active()
40
+ {
41
+ if (active_providers.empty()) {
42
+ return NULL;
43
+ } else {
44
+ return active_providers.front();
45
+ }
46
+ }
47
+
48
+ static const char *
49
+ provider_string(Method type) {
50
+ if (type == CLCONFIG_HTTP) { return "HTTP"; }
51
+ if (type == CLCONFIG_CCCP) { return "CCCP"; }
52
+ if (type == CLCONFIG_FILE) { return "FILE"; }
53
+ if (type == CLCONFIG_MCRAW) { return "MCRAW"; }
54
+ return "";
55
+ }
56
+
57
+ Confmon::Confmon(lcb_settings *settings_, lcbio_pTABLE iot_)
58
+ : cur_provider(NULL),
59
+ config(NULL),
60
+ settings(settings_),
61
+ last_error(LCB_SUCCESS),
62
+ iot(iot_),
63
+ as_start(iot_, this),
64
+ as_stop(iot_, this),
65
+ state(0),
66
+ last_stop_us(0) {
67
+
68
+ lcbio_table_ref(iot);
69
+ lcb_settings_ref(settings);
70
+
71
+ all_providers[CLCONFIG_FILE] = new_file_provider(this);
72
+ all_providers[CLCONFIG_CCCP] = new_cccp_provider(this);
73
+ all_providers[CLCONFIG_HTTP] = new_http_provider(this);
74
+ all_providers[CLCONFIG_MCRAW] = new_mcraw_provider(this);
75
+
76
+ for (size_t ii = 0; ii < CLCONFIG_MAX; ii++) {
77
+ all_providers[ii]->parent = this;
78
+ }
79
+ }
80
+
81
+ void Confmon::prepare() {
82
+ active_providers.clear();
83
+ lcb_log(LOGARGS(this, DEBUG), "Preparing providers (this may be called multiple times)");
84
+
85
+ for (size_t ii = 0; ii < CLCONFIG_MAX; ii++) {
86
+ Provider *cur = all_providers[ii];
87
+ if (cur) {
88
+ if (cur->enabled) {
89
+ active_providers.push_back(cur);
90
+ lcb_log(LOGARGS(this, DEBUG), "Provider %s is ENABLED", provider_string(cur->type));
91
+ } else if (cur->pause()) {
92
+ lcb_log(LOGARGS(this, DEBUG), "Provider %s is DISABLED", provider_string(cur->type));
93
+ }
94
+ }
95
+ }
96
+
97
+ lcb_assert(!active_providers.empty());
98
+ cur_provider = first_active();
99
+ }
100
+
101
+ Confmon::~Confmon() {
102
+ as_start.release();
103
+ as_stop.release();
104
+
105
+ if (config) {
106
+ config->decref();
107
+ config = NULL;
108
+ }
109
+
110
+ for (size_t ii = 0; ii < CLCONFIG_MAX; ii++) {
111
+ Provider *provider = all_providers[ii];
112
+ if (provider == NULL) {
113
+ continue;
114
+ }
115
+ delete provider;
116
+ all_providers[ii] = NULL;
117
+ }
118
+
119
+ lcbio_table_unref(iot);
120
+ lcb_settings_unref(settings);
121
+ }
122
+
123
+ int Confmon::do_set_next(ConfigInfo *new_config, bool notify_miss)
124
+ {
125
+ unsigned ii;
126
+
127
+ if (config) {
128
+ lcbvb_CHANGETYPE chstatus = LCBVB_NO_CHANGES;
129
+ lcbvb_CONFIGDIFF *diff = lcbvb_compare(config->vbc, new_config->vbc);
130
+
131
+ if (!diff) {
132
+ lcb_log(LOGARGS(this, DEBUG), "Couldn't create vbucket diff");
133
+ return 0;
134
+ }
135
+
136
+ chstatus = lcbvb_get_changetype(diff);
137
+ lcbvb_free_diff(diff);
138
+
139
+ if (chstatus == 0 || config->compare(*new_config) >= 0) {
140
+ const lcbvb_CONFIG *ca, *cb;
141
+
142
+ ca = config->vbc;
143
+ cb = new_config->vbc;
144
+
145
+ lcb_log(LOGARGS(this, INFO), "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);
146
+ if (notify_miss) {
147
+ invoke_listeners(CLCONFIG_EVENT_GOT_ANY_CONFIG, new_config);
148
+ }
149
+ return 0;
150
+ }
151
+ }
152
+
153
+ lcb_log(LOGARGS(this, INFO), "Setting new configuration. Received via %s", provider_string(new_config->get_origin()));
154
+
155
+ if (config) {
156
+ /** DECREF the old one */
157
+ config->decref();
158
+ }
159
+
160
+ for (ii = 0; ii < CLCONFIG_MAX; ii++) {
161
+ Provider *cur = all_providers[ii];
162
+ if (cur && cur->enabled) {
163
+ cur->config_updated(new_config->vbc);
164
+ }
165
+ }
166
+
167
+ new_config->incref();
168
+ config = new_config;
169
+ stop();
170
+
171
+ invoke_listeners(CLCONFIG_EVENT_GOT_NEW_CONFIG, new_config);
172
+
173
+ return 1;
174
+ }
175
+
176
+ void Confmon::provider_failed(Provider *provider, lcb_error_t reason) {
177
+ lcb_log(LOGARGS(this, INFO), "Provider '%s' failed", provider_string(provider->type));
178
+
179
+ if (provider != cur_provider) {
180
+ lcb_log(LOGARGS(this, TRACE), "Ignoring failure. Current=%p (%s)", (void*)cur_provider, provider_string(cur_provider->type));
181
+ return;
182
+ }
183
+ if (!is_refreshing()) {
184
+ lcb_log(LOGARGS(this, DEBUG), "Ignoring failure. Refresh not active");
185
+ }
186
+
187
+ if (reason != LCB_SUCCESS) {
188
+ if (settings->detailed_neterr && last_error != LCB_SUCCESS) {
189
+ /* Filter out any artificial 'connect error' or 'network error' codes */
190
+ if (reason != LCB_CONNECT_ERROR && reason != LCB_NETWORK_ERROR) {
191
+ last_error = reason;
192
+ }
193
+ } else {
194
+ last_error = reason;
195
+ }
196
+ }
197
+
198
+ cur_provider = next_active(cur_provider);
199
+
200
+ if (!cur_provider) {
201
+ LOG(this, TRACE, "Maximum provider reached. Resetting index");
202
+ invoke_listeners(CLCONFIG_EVENT_PROVIDERS_CYCLED, NULL);
203
+ cur_provider = first_active();
204
+ stop();
205
+ } else {
206
+ uint32_t interval = 0;
207
+ if (config) {
208
+ /* Not first */
209
+ interval = settings->grace_next_provider;
210
+ }
211
+ lcb_log(LOGARGS(this, DEBUG), "Will try next provider in %uus", interval);
212
+ state |= CONFMON_S_ITERGRACE;
213
+ as_start.rearm(interval);
214
+ }
215
+ }
216
+
217
+ void Confmon::provider_got_config(Provider *, ConfigInfo *config_) {
218
+ do_set_next(config_, true);
219
+ stop();
220
+ }
221
+
222
+ void Confmon::do_next_provider()
223
+ {
224
+ state &= ~CONFMON_S_ITERGRACE;
225
+ for (ProviderList::const_iterator ii = active_providers.begin();
226
+ ii != active_providers.end(); ++ii) {
227
+ ConfigInfo *info;
228
+ Provider* cached_provider = *ii;
229
+ info = cached_provider->get_cached();
230
+ if (!info) {
231
+ continue;
232
+ }
233
+
234
+ if (do_set_next(info, false)) {
235
+ LOG(this, DEBUG, "Using cached configuration");
236
+ }
237
+ }
238
+
239
+ lcb_log(LOGARGS(this, TRACE), "Attempting to retrieve cluster map via %s", provider_string(cur_provider->type));
240
+
241
+ cur_provider->refresh();
242
+ }
243
+
244
+ void Confmon::start() {
245
+ lcb_U32 tmonext = 0;
246
+ as_stop.cancel();
247
+ if (is_refreshing()) {
248
+ LOG(this, DEBUG, "Cluster map refresh already in progress");
249
+ return;
250
+ }
251
+
252
+ LOG(this, TRACE, "Refreshing current cluster map");
253
+ lcb_assert(cur_provider);
254
+ state = CONFMON_S_ACTIVE|CONFMON_S_ITERGRACE;
255
+
256
+ if (last_stop_us > 0) {
257
+ lcb_U32 diff = LCB_NS2US(gethrtime()) - last_stop_us;
258
+ if (diff <= settings->grace_next_cycle) {
259
+ tmonext = settings->grace_next_cycle - diff;
260
+ }
261
+ }
262
+
263
+ as_start.rearm(tmonext);
264
+ }
265
+
266
+ void Confmon::stop_real() {
267
+ ProviderList::const_iterator ii;
268
+ for (ii = active_providers.begin(); ii != active_providers.end(); ++ii) {
269
+ (*ii)->pause();
270
+ }
271
+
272
+ last_stop_us = LCB_NS2US(gethrtime());
273
+ invoke_listeners(CLCONFIG_EVENT_MONITOR_STOPPED, NULL);
274
+ }
275
+
276
+ void Confmon::stop() {
277
+ if (!is_refreshing()) {
278
+ return;
279
+ }
280
+ as_start.cancel();
281
+ as_stop.cancel();
282
+ state = CONFMON_S_INACTIVE;
283
+ }
284
+
285
+ Provider::Provider(Confmon *parent_, Method type_)
286
+ : type(type_), enabled(false), parent(parent_) {
287
+ }
288
+
289
+ Provider::~Provider() {
290
+ parent = NULL;
291
+ }
292
+
293
+ ConfigInfo::~ConfigInfo() {
294
+ if (vbc) {
295
+ lcbvb_destroy(vbc);
296
+ }
297
+ }
298
+
299
+ int ConfigInfo::compare(const ConfigInfo& other) {
300
+ /** First check if both have revisions */
301
+ int rev_a, rev_b;
302
+ rev_a = lcbvb_get_revision(this->vbc);
303
+ rev_b = lcbvb_get_revision(other.vbc);
304
+ if (rev_a >= 0 && rev_b >= 0) {
305
+ return rev_a - rev_b;
306
+ }
307
+
308
+ if (this->cmpclock == other.cmpclock) {
309
+ return 0;
310
+
311
+ } else if (this->cmpclock < other.cmpclock) {
312
+ return -1;
313
+ }
314
+
315
+ return 1;
316
+ }
317
+
318
+ ConfigInfo::ConfigInfo(lcbvb_CONFIG *config_, Method origin_)
319
+ : vbc(config_), cmpclock(gethrtime()), refcount(1), origin(origin_) {
320
+ }
321
+
322
+ void Confmon::add_listener(Listener *lsn) {
323
+ listeners.push_back(lsn);
324
+ }
325
+
326
+ void Confmon::remove_listener(Listener *lsn) {
327
+ listeners.remove(lsn);
328
+ }
329
+
330
+ void Confmon::invoke_listeners(EventType event, ConfigInfo *info) {
331
+ ListenerList::iterator ii = listeners.begin();
332
+ while (ii != listeners.end()) {
333
+ ListenerList::iterator cur = ii++;
334
+ (*cur)->clconfig_lsn(event, info);
335
+ }
336
+ }
337
+
338
+
339
+ void Confmon::set_active(Method type, bool enabled)
340
+ {
341
+ Provider *provider = all_providers[type];
342
+ if (provider->enabled == enabled) {
343
+ return;
344
+ } else {
345
+ provider->enabled = enabled;
346
+ }
347
+ prepare();
348
+ }
349
+
350
+ void Confmon::dump(FILE *fp) {
351
+ fprintf(fp, "CONFMON=%p\n", (void*)this);
352
+ fprintf(fp, "STATE= (0x%x)", state);
353
+ if (state & CONFMON_S_ACTIVE) {
354
+ fprintf(fp, "ACTIVE|");
355
+ }
356
+ if (state == CONFMON_S_INACTIVE) {
357
+ fprintf(fp, "INACTIVE/IDLE");
358
+ }
359
+ if (state & CONFMON_S_ITERGRACE) {
360
+ fprintf(fp, "ITERGRACE");
361
+ }
362
+ fprintf(fp, "\n");
363
+ fprintf(fp, "LAST ERROR: 0x%x\n", last_error);
364
+
365
+
366
+ for (size_t ii = 0; ii < CLCONFIG_MAX; ii++) {
367
+ Provider *cur = all_providers[ii];
368
+ if (!cur) {
369
+ continue;
370
+ }
371
+
372
+ fprintf(fp, "** PROVIDER: 0x%x (%s) %p\n", cur->type, provider_string(cur->type), (void*)cur);
373
+ fprintf(fp, "** ENABLED: %s\n", cur->enabled ? "YES" : "NO");
374
+ fprintf(fp, "** CURRENT: %s\n", cur == cur_provider ? "YES" : "NO");
375
+ cur->dump(fp);
376
+ fprintf(fp, "\n");
377
+ }
378
+ }
@@ -27,10 +27,10 @@
27
27
  #define LOGID(req) static_cast<const void*>(req)
28
28
  #define LOGARGS(req, lvl) req->instance->settings, "n1ql", LCB_LOG_##lvl, __FILE__, __LINE__
29
29
 
30
- struct lcb_FTSREQ {
30
+ struct lcb_FTSREQ : lcb::jsparse::Parser::Actions {
31
31
  const lcb_RESPHTTP *cur_htresp;
32
32
  lcb_http_request_t htreq;
33
- lcbjsp_PARSER *parser;
33
+ lcb::jsparse::Parser *parser;
34
34
  const void *cookie;
35
35
  lcb_FTSCALLBACK callback;
36
36
  lcb_t instance;
@@ -41,25 +41,20 @@ struct lcb_FTSREQ {
41
41
 
42
42
  lcb_FTSREQ(lcb_t, const void *, const lcb_CMDFTS *);
43
43
  ~lcb_FTSREQ();
44
- };
45
-
46
- static void
47
- row_callback(lcbjsp_PARSER *parser, const lcbjsp_ROW *datum)
48
- {
49
- lcb_FTSREQ *req = static_cast<lcb_FTSREQ*>(parser->data);
50
- lcb_RESPFTS resp = { 0 };
51
-
52
- if (datum->type == LCBJSP_TYPE_ROW) {
53
- resp.row = static_cast<const char*>(datum->row.iov_base);
54
- resp.nrow = datum->row.iov_len;
55
- req->nrows++;
56
- req->invoke_row(&resp);
57
- } else if (datum->type == LCBJSP_TYPE_ERROR) {
58
- req->lasterr = resp.rc = LCB_PROTOCOL_ERROR;
59
- } else if (datum->type == LCBJSP_TYPE_COMPLETE) {
60
- /* Nothing */
44
+ void JSPARSE_on_row(const lcb::jsparse::Row& datum) {
45
+ lcb_RESPFTS resp = { 0 };
46
+ resp.row = static_cast<const char*>(datum.row.iov_base);
47
+ resp.nrow = datum.row.iov_len;
48
+ nrows++;
49
+ invoke_row(&resp);
61
50
  }
62
- }
51
+ void JSPARSE_on_error(const std::string&) {
52
+ lasterr = LCB_PROTOCOL_ERROR;
53
+ }
54
+ void JSPARSE_on_complete(const std::string&) {
55
+ // Nothing
56
+ }
57
+ };
63
58
 
64
59
  static void
65
60
  chunk_callback(lcb_t, int, const lcb_RESPBASE *rb)
@@ -83,7 +78,7 @@ chunk_callback(lcb_t, int, const lcb_RESPBASE *rb)
83
78
  * should remain alive (so we can cancel it later on) */
84
79
  delete req;
85
80
  } else {
86
- lcbjsp_feed(req->parser, static_cast<const char*>(rh->body), rh->nbody);
81
+ req->parser->feed(static_cast<const char*>(rh->body), rh->nbody);
87
82
  }
88
83
  }
89
84
 
@@ -107,7 +102,7 @@ lcb_FTSREQ::invoke_last()
107
102
 
108
103
  if (parser) {
109
104
  lcb_IOV meta;
110
- lcbjsp_get_postmortem(parser, &meta);
105
+ parser->get_postmortem(meta);
111
106
  resp.row = static_cast<const char*>(meta.iov_base);
112
107
  resp.nrow = meta.iov_len;
113
108
  }
@@ -116,7 +111,9 @@ lcb_FTSREQ::invoke_last()
116
111
  }
117
112
 
118
113
  lcb_FTSREQ::lcb_FTSREQ(lcb_t instance_, const void *cookie_, const lcb_CMDFTS *cmd)
119
- : cur_htresp(NULL), htreq(NULL), parser(lcbjsp_create(LCBJSP_MODE_FTS)),
114
+ : lcb::jsparse::Parser::Actions(),
115
+ cur_htresp(NULL), htreq(NULL),
116
+ parser(new lcb::jsparse::Parser(lcb::jsparse::Parser::MODE_FTS, this)),
120
117
  cookie(cookie_), callback(cmd->callback), instance(instance_), nrows(0),
121
118
  lasterr(LCB_SUCCESS)
122
119
  {
@@ -165,12 +162,10 @@ lcb_FTSREQ::lcb_FTSREQ(lcb_t instance_, const void *cookie_, const lcb_CMDFTS *c
165
162
  std::string qbody(Json::FastWriter().write(root));
166
163
  htcmd.body = qbody.c_str();
167
164
  htcmd.nbody = qbody.size();
168
- parser->data = this;
169
- parser->callback = row_callback;
170
165
 
171
166
  lasterr = lcb_http3(instance, this, &htcmd);
172
167
  if (lasterr == LCB_SUCCESS) {
173
- lcb_htreq_setcb(htreq, chunk_callback);
168
+ htreq->set_callback(chunk_callback);
174
169
  if (cmd->handle) {
175
170
  *cmd->handle = reinterpret_cast<lcb_FTSREQ*>(this);
176
171
  }
@@ -184,7 +179,7 @@ lcb_FTSREQ::~lcb_FTSREQ()
184
179
  htreq = NULL;
185
180
  }
186
181
  if (parser) {
187
- lcbjsp_free(parser);
182
+ delete parser;
188
183
  parser = NULL;
189
184
  }
190
185
  }