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.
- checksums.yaml +4 -4
- data/ext/libcouchbase/CMakeLists.txt +6 -8
- data/ext/libcouchbase/README.markdown +2 -2
- data/ext/libcouchbase/RELEASE_NOTES.markdown +229 -2
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +18 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +3 -2
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
- data/ext/libcouchbase/cmake/config-cmake.h.in +4 -0
- data/ext/libcouchbase/cmake/defs.mk.in +0 -2
- data/ext/libcouchbase/cmake/source_files.cmake +21 -5
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +1 -1
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +2 -0
- data/ext/libcouchbase/example/users/README +48 -0
- data/ext/libcouchbase/example/users/users.c +147 -0
- data/ext/libcouchbase/include/libcouchbase/auth.h +175 -31
- data/ext/libcouchbase/include/libcouchbase/cntl.h +82 -1
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +45 -3
- data/ext/libcouchbase/include/libcouchbase/error.h +19 -1
- data/ext/libcouchbase/include/libcouchbase/iops.h +3 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +31 -1
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +4 -1
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +36 -2
- data/ext/libcouchbase/include/libcouchbase/views.h +7 -1
- data/ext/libcouchbase/include/libcouchbase/visibility.h +1 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +24 -1146
- data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +3 -2
- data/ext/libcouchbase/src/README.md +0 -2
- data/ext/libcouchbase/src/auth-priv.h +23 -4
- data/ext/libcouchbase/src/auth.cc +51 -43
- data/ext/libcouchbase/src/bootstrap.cc +244 -0
- data/ext/libcouchbase/src/bootstrap.h +58 -38
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +120 -158
- data/ext/libcouchbase/src/bucketconfig/bc_file.cc +281 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.cc +526 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +50 -25
- data/ext/libcouchbase/src/bucketconfig/bc_static.cc +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +410 -386
- data/ext/libcouchbase/src/bucketconfig/confmon.cc +393 -0
- data/ext/libcouchbase/src/cbft.cc +22 -27
- data/ext/libcouchbase/src/cntl.cc +56 -22
- data/ext/libcouchbase/src/connspec.cc +47 -6
- data/ext/libcouchbase/src/connspec.h +27 -0
- data/ext/libcouchbase/src/dns-srv.cc +147 -0
- data/ext/libcouchbase/src/dump.cc +3 -3
- data/ext/libcouchbase/src/errmap.cc +173 -0
- data/ext/libcouchbase/src/errmap.h +198 -0
- data/ext/libcouchbase/src/getconfig.cc +7 -33
- data/ext/libcouchbase/src/handler.cc +118 -7
- data/ext/libcouchbase/src/hostlist.cc +0 -36
- data/ext/libcouchbase/src/hostlist.h +44 -62
- data/ext/libcouchbase/src/http/http-priv.h +125 -112
- data/ext/libcouchbase/src/http/http.cc +27 -35
- data/ext/libcouchbase/src/http/http.h +1 -34
- data/ext/libcouchbase/src/http/http_io.cc +28 -36
- data/ext/libcouchbase/src/instance.cc +131 -34
- data/ext/libcouchbase/src/internal.h +58 -26
- data/ext/libcouchbase/src/jsparse/parser.cc +136 -210
- data/ext/libcouchbase/src/jsparse/parser.h +84 -98
- data/ext/libcouchbase/src/lcbht/lcbht.cc +177 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +174 -163
- data/ext/libcouchbase/src/lcbio/connect.cc +569 -0
- data/ext/libcouchbase/src/lcbio/connect.h +16 -7
- data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
- data/ext/libcouchbase/src/lcbio/iotable.h +101 -16
- data/ext/libcouchbase/src/lcbio/{ioutils.c → ioutils.cc} +30 -51
- data/ext/libcouchbase/src/lcbio/ioutils.h +29 -90
- data/ext/libcouchbase/src/lcbio/manager.cc +543 -0
- data/ext/libcouchbase/src/lcbio/manager.h +133 -96
- data/ext/libcouchbase/src/lcbio/protoctx.c +2 -2
- data/ext/libcouchbase/src/lcbio/timer-cxx.h +87 -0
- data/ext/libcouchbase/src/mc/mcreq.c +11 -2
- data/ext/libcouchbase/src/mc/mcreq.h +9 -2
- data/ext/libcouchbase/src/mcserver/mcserver.cc +175 -43
- data/ext/libcouchbase/src/mcserver/mcserver.h +9 -13
- data/ext/libcouchbase/src/mcserver/negotiate.cc +181 -62
- data/ext/libcouchbase/src/mcserver/negotiate.h +1 -3
- data/ext/libcouchbase/src/mctx-helper.h +51 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +1 -2
- data/ext/libcouchbase/src/n1ql/n1ql.cc +74 -42
- data/ext/libcouchbase/src/netbuf/netbuf.c +4 -4
- data/ext/libcouchbase/src/newconfig.cc +6 -6
- data/ext/libcouchbase/src/nodeinfo.cc +2 -2
- data/ext/libcouchbase/src/operations/{cbflush.c → cbflush.cc} +7 -15
- data/ext/libcouchbase/src/operations/{counter.c → counter.cc} +0 -0
- data/ext/libcouchbase/src/operations/durability.cc +6 -26
- data/ext/libcouchbase/src/operations/durability_internal.h +6 -3
- data/ext/libcouchbase/src/operations/{get.c → get.cc} +24 -26
- data/ext/libcouchbase/src/operations/{observe.c → observe.cc} +68 -93
- data/ext/libcouchbase/src/operations/{pktfwd.c → pktfwd.cc} +0 -0
- data/ext/libcouchbase/src/operations/{remove.c → remove.cc} +0 -0
- data/ext/libcouchbase/src/operations/stats.cc +3 -8
- data/ext/libcouchbase/src/operations/{store.c → store.cc} +27 -32
- data/ext/libcouchbase/src/operations/subdoc.cc +129 -42
- data/ext/libcouchbase/src/operations/{touch.c → touch.cc} +0 -0
- data/ext/libcouchbase/src/packetutils.h +30 -2
- data/ext/libcouchbase/src/probes.d +1 -1
- data/ext/libcouchbase/src/rdb/rope.c +1 -1
- data/ext/libcouchbase/src/{retrychk.c → retrychk.cc} +2 -3
- data/ext/libcouchbase/src/retryq.cc +52 -14
- data/ext/libcouchbase/src/retryq.h +3 -3
- data/ext/libcouchbase/src/settings.c +5 -0
- data/ext/libcouchbase/src/settings.h +11 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +1 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +2 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +0 -1
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +1 -1
- data/ext/libcouchbase/src/trace.h +4 -4
- data/ext/libcouchbase/src/vbucket/vbucket.c +6 -10
- data/ext/libcouchbase/src/views/{docreq.c → docreq.cc} +48 -54
- data/ext/libcouchbase/src/views/docreq.h +24 -30
- data/ext/libcouchbase/src/views/viewreq.cc +318 -0
- data/ext/libcouchbase/src/views/viewreq.h +43 -13
- data/ext/libcouchbase/tests/basic/t_connstr.cc +88 -50
- data/ext/libcouchbase/tests/basic/t_creds.cc +47 -5
- data/ext/libcouchbase/tests/basic/t_host.cc +67 -75
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +27 -82
- data/ext/libcouchbase/tests/basic/t_misc.cc +1 -1
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +0 -1
- data/ext/libcouchbase/tests/htparse/t_basic.cc +58 -78
- data/ext/libcouchbase/tests/ioserver/connection.cc +1 -1
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +19 -6
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +28 -2
- data/ext/libcouchbase/tests/iotests/mock-environment.h +51 -1
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +1 -7
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +97 -115
- data/ext/libcouchbase/tests/iotests/t_durability.cc +0 -1
- data/ext/libcouchbase/tests/iotests/t_eerrs.cc +119 -0
- data/ext/libcouchbase/tests/iotests/t_errmap.cc +178 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +3 -3
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +1 -1
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +0 -1
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +18 -11
- data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
- data/ext/libcouchbase/tests/socktests/socktest.cc +7 -10
- data/ext/libcouchbase/tests/socktests/socktest.h +2 -3
- data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
- data/ext/libcouchbase/tests/socktests/t_manager.cc +5 -6
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
- data/ext/libcouchbase/tests/vbucket/confdata/ketama_expected.json +2562 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_ketama_config.json +31 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +35 -5
- data/ext/libcouchbase/tools/CMakeLists.txt +2 -2
- data/ext/libcouchbase/tools/cbc-handlers.h +128 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +64 -10
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +2 -2
- data/ext/libcouchbase/tools/cbc.cc +143 -10
- data/ext/libcouchbase/tools/docgen/loc.h +1 -1
- data/lib/libcouchbase/connection.rb +4 -3
- data/lib/libcouchbase/version.rb +1 -1
- metadata +37 -28
- data/ext/libcouchbase/include/memcached/vbucket.h +0 -42
- data/ext/libcouchbase/src/bootstrap.c +0 -269
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +0 -347
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +0 -630
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +0 -150
- data/ext/libcouchbase/src/bucketconfig/confmon.c +0 -474
- data/ext/libcouchbase/src/lcbht/lcbht.c +0 -282
- data/ext/libcouchbase/src/lcbio/connect.c +0 -557
- data/ext/libcouchbase/src/lcbio/manager.c +0 -584
- data/ext/libcouchbase/src/packetutils.c +0 -37
- data/ext/libcouchbase/src/simplestring.c +0 -211
- data/ext/libcouchbase/src/simplestring.h +0 -228
- data/ext/libcouchbase/src/ssobuf.h +0 -82
- data/ext/libcouchbase/src/views/viewreq.c +0 -358
- 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
|
-
|
|
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
|
-
|
|
273
|
-
|
|
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()
|
|
300
|
-
|
|
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
|
-
|
|
378
|
+
if ((lasterr = request_plan()) == LCB_SUCCESS) {
|
|
353
379
|
// We'll be parsing more rows later on..
|
|
354
|
-
|
|
380
|
+
delete parser;
|
|
381
|
+
parser = new lcb::jsparse::Parser(lcb::jsparse::Parser::MODE_N1QL, this);
|
|
382
|
+
return true;
|
|
355
383
|
}
|
|
356
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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),
|
|
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,
|
|
308
|
+
void lcb_update_vbconfig(lcb_t instance, lcb_pCONFIGINFO config)
|
|
309
309
|
{
|
|
310
310
|
lcb_configuration_t change_status;
|
|
311
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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
|
|
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 *
|
|
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
|
-
(
|
|
51
|
-
|
|
52
|
-
|
|
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.
|
|
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
|
-
|
|
61
|
+
htr->set_callback(flush_cb);
|
|
70
62
|
return LCB_SUCCESS;
|
|
71
63
|
}
|